You can add a fetch join into the JPQL:
"Select a FROM A a left join fetch a.b"
You can also use a query hint or set the mapping to always join using the @JoinFetch Annotation described here: http://wiki.eclipse.org/Optimizing_the_EclipseLink_Applicati on_(ELUG)#How_to_Use_Batch_and_Join_Reading_for_Optimization
Mauro Flores Messages: 83 Registered: September 2009 Location: Brasil
Member
Thanks, Chris. I didn't know that.
But, why do I need to explicitally say that I want a join in this case?
In my oppinion the default should be the faster implementation.
One select with a left join would always be faster than many selects.
That's the behaviour of openjpa implementation.
Is there a property in persistence.xml to make the left join default for all application?