Cedric Beust wrote: >>From: A mailing list for Enterprise JavaBeans development >>[mailto:[EMAIL PROTECTED]]On Behalf Of Evan Ireland >> > >>I was just thinking about your point regarding EJB QL, and it struck >>me that if your entity has a composite primary key (primkey-field is >>not specified in deployment descriptor), then you can't write an >>EJB QL query for it. >> > > That would be very unfortunate :-) > > >>Say my primary key type has two fields (abc and xyz). I can't write: >> >> select object(o) from MyObject o where abc = ?1.abc and xyz = ?2.xyz >> > > select object(o) from MyObject o where o = ?1 > > should do the trick.
That won't work, as you then have to pass the object reference as a parameter to the finder (EJB QL does not permit a comparison between an object 'o' and a parameter '?1' if the parameter is a primary key type). And if one assumes '?1' is an object reference, if you already have the object reference, you don't need to call findByPrimaryKey in the first place. I think I will submit a comment on EJB QL in respect of the inability to write queries that need to use fields within composite primary key parameters. > That being said, there is indeed some cheating going on since this only works > for the primary key. If you need to write a query that needs to "really" select > on the object (as in SELECT in SQL), then you are stuck. > > Strangely enought, nobody seems to have complained about this, so I guess it's > not such a big deal. I don't supposed EJB QL is being 'stressed' by many folks yet. > -- > Cedric > > > > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
