Re: Complicated SQL queries

"Jurgen Doll" <[email protected]> Wed, 07 Feb 2024 20:22:05 +0200
Newsgroups gmane.comp.java.cayenne.user
Organization iVory EMR
Message-ID <op.2isam3ydy9kazd@admin-pc>
Try the following version and see if it works for you:

ObjectSelect.query( ObjectEntityA.class )
     .columns(
          ObjEntityA.PROP_FOR_OBJECT_B
          .dot( ObjEntityB.PROP_FOR_OBJECT_C )
          .dot( ObjEntityC.PROP_FOR_OBJECT_D )
          .count()
     )
     .where(
          ObjEntityA.PROP_FOR_OBJECT_E
          .dot( ObjEntityE.PROP )
          .eq( someValue )
     )
     .select( context )




On Wed, 07 Feb 2024 19:25:34 +0200, Christian Gonzalez  
<[email protected]> wrote:

> One last question, I was trying to update another query using the same
> method of identifying the wanted columns when trying to fetch from a
> different ObjectEntity than the one from the ObjectSelect. The issue  
> seems
> to be that the column I'm selecting is the pk column of another
> ObjectEntity? The query I'm doing looks something like this.
> ObjectSelect.query(ObjectEntityA.class).columns(ObjEntityA.PROP_FOR_OBJECT_B.dot(ObjEntityB.PROP_FOR_OBJECT_C.dot(ObjEntityC.PROP_FOR_OBJECT_D.dot(ObjEntityD.ENTITY_D_PK_PROP).count()))).where(ObjEntityA.PROP_FOR_OBJECT_E.dot(ObjEntityE.PROP).eq(someValue)).select(context).
> However this returns an error that says "Can't translate dbid path
> 'dbEntityB.dbEntityDPKAttribute', no such pk ''. I know cayenne
> usually doesn't include pk property's however we use cgen to generate the
> java classes and have the flag createPKProperties set to true so the
> properties get generated. Could this be a part of the issue or am I doing
> the query wrong?


-- 
Using Opera's mail client: http://www.opera.com/mail/