Re: Complicated SQL queries

"Jurgen Doll" <[email protected]> Mon, 22 Jan 2024 09:18:36 +0200
Newsgroups gmane.comp.java.cayenne.user
Organization iVory EMR
Message-ID <op.2hxs9apiy9kazd@admin-pc>
Ahh, my bad again - I missed the whole point of using ObjectSelect  
somehow, probably because it's difficult to explain without having your  
model. Anyways here's a shot at it, conceptually the same as what you did  
in the modeller:

List<Object[]> results = ObjectSelect.query( ObjEntityA.class )
.columns( ObjEntityA.PROP_FOR_OBJ_E.dot( ObjEntityE.PROP_A ),
                    ObjEntityA.PROP_FOR_OBJ_E.dot( ObjEntityE.PROP_B ),
                    ObjEntityA.PROP_FOR_OBJ_E.dot( ObjEntityE.PROP_C ) )
.where(  ObjEntityA.PROP_FOR_OBJ_B.dot( ObjEntityB.PROP_FOR_OBJ_C ).dot(  
ObjEntityC.PROP_FOR_OBJ_D )
                  .dot( ObjEntityD.PROP_B )  // this is t3.varB
                  .eq( "somevalue" ) )
.select( context );



On Fri, 19 Jan 2024 22:45:24 +0200, Christian Gonzalez  
<[email protected]> wrote:

> Looks like it worked, thank you. It is definitely an interesting way of
> doing it although I'm not sure about how I feel about having to make a  
> new
> entity every time a query like this is used but hopefully it won't be too
> often.
>
> Thank you for your help.
>
>
> On Wed, Jan 17, 2024 at 11:08 AM Jurgen Doll <[email protected]>  
> wrote:
>
>> Ahh, sorry my bad I didn't see the t0 for tableE.
>>
>> There may be other ways to do it but I think adding t3.varB as an
>> attribute to the object entity might be the simplest.
>>
>> Regards
>> Jurgen