tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <d...@iq80.com>
Subject Re: Multiple LEFT JOIN FETCH clauses in EJBQL
Date Wed, 16 Jan 2008 23:41:46 GMT
On Jan 16, 2008, at 3:03 PM, Alexander Saint Croix wrote:

> Thank you, Dain.
>
> This is helpful in that it reinforces my intuition to avoid eager  
> loading
> for anything that can be replaced by well-written queries.  I'd  
> rather the
> extra data were optionally retrieved than enforced across all  
> applications
> regardless of circumstance.
>
> I asked one of the University's former EJBQL experts, Rogers George,  
> and his
> recommendation regarding using multiple join fetches is "don't."

Rogers and I went to school together... tell him I said hi next time  
you see him.

> He continues:
>
> "You can only fetch one multi-valued association at a time in EJBQL.
> Hibername 3 QL will let you, but it's almost always a bad idea; the
> resultset becomes a cartesian product of the contents of the  
> collections.
> Just running the two queries instead is almost certainly faster.
>
> If the two collections are nested, you can usually rearrange your  
> query so
> that it selects the "leaves" of your entity graph, and all the join  
> fetch
> clauses follow many-to-one relations back towards the root.  Then  
> you can
> iterate over the results directly without even triggering collection
> fetches, and get at the root object with java accessors."
>
> Big thanks to Rogers George for the above information.  My  
> particular need
> involves multiple collection-valued reference, and I'll be  
> investigating
> using fetch groups or fetch plans to tune my query for these tests.   
> Once
> it's working, I'll try to post up some code snippets in case others  
> have
> this trouble down the line.

Looks like solid advice.  Let us know how it works out.

-dain

Mime
View raw message