You have a good point there. Thanks for the advice. I guess I would just
have run into that problem later. Maybe it would be a good idea to add
this advice to the user guide, where flattened relationships are
discussed. It took me, as a cayenne beginner, some time to figure out
how it is working. One emerging problem was solved in this conversation.
Maybe others will experience the same problems.
Michael Gentry schrieb:
> Daniel,
>
> I just re-ran your app after unchecking personID in your join table
> (only bookID was set as the primary key). That causes SQL like this
> to be produced:
>
> INFO: DELETE FROM Person_is_author_of_book WHERE bookID = ?
> May 12, 2008 2:45:31 PM org.apache.cayenne.access.QueryLogger logQueryParameters
> INFO: [bind: 1->bookID:3]
>
> That is incorrect for what you want. You need to make both a primary
> key. If not, it will delete too many records (potentially) since it
> is not qualifying the personID.
>
> /dev/mrg
>
>
>
>> Hi
>>
>> Thanks again. Setting at least one of the attributes as primary key solved
>> the problem. As far as I tested, it is not important which of the attributes
>> is assigned the primary key, but there has to be at least one PK. The PK
>> generation strategy is set to default by the modeller. Any changes to that
>> setting do not seem to affect the generated code, so everything seems to
>> work just as it should by now.
>>
>>
>> Michael Gentry schrieb:
>>
>>
>>
>>
>>> [followup back to the user list]
>>>
>>> Hi Daniel,
>>>
>>> The first time I ran your test application it did indeed crash with
>>> the missing WHERE clause (this is on Cayenne 3.x, too). I went into
>>> your Cayenne Model, though, and on your Person_is_author_of_book table
>>> (you didn't map it as a class, which is cool since you are flattening
>>> it), I checked the PK/Mandatory checkboxes under the Attributes tab
>>> for the DbEntity. Then I re-ran the application and it worked:
>>>
>>> INFO: DELETE FROM Person_is_author_of_book WHERE bookID = ? AND personID =
>>>
>> ?
>>
>>> May 12, 2008 12:17:06 PM org.apache.cayenne.access.QueryLogger
>>> logQueryParameters
>>> INFO: [bind: 1->bookID:2, 2->personID:2]
>>>
>>> Try updating your model and see if it fixes your issue.
>>>
>>> Thanks,
>>>
>>> /dev/mrg
>>>
>>>
>>>
>>>
>
>
This archive was generated by hypermail 2.0.0 : Mon May 12 2008 - 18:07:24 EDT