cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gentry" <blackn...@gmail.com>
Subject Re: many-to-many mapping resulting in incomplete SQL queries
Date Mon, 12 May 2008 18:48:08 GMT
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

On Mon, May 12, 2008 at 12:52 PM, Daniel Doppmeier
<ddoppmei@cebitec.uni-bielefeld.de> wrote:
> 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
> >
> >
> >
>

Mime
View raw message