Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] criteriaquery : fetch not working

The default is LAZY for xToMany and EAGER for xToOne. To allow LAZY to work on xToOne, you will have to not only ensure the mapping is marked as LAZY, but also ensure EclipseLink can weave the classes. The classes will be weaved by default on a Java EE 5 compliant container. You will have to use set the eclispelink jar file as with the -javaagent flag in Java SE if you are running standalone. Other cases require other configuration - which are you using?

Looking more closely at your query, you are likely getting more joins than you need. For instance, you are both fetch joining and joining EtdOffEtd_.etdInscCoursCollection. Each of those will result in a join.

You may want to consider using our fetch join query hint that allows you to do multiple level fetch joins.

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Join_Fetch

-Tom

Yannick Majoros wrote:
 Le 4/08/2011 17:11, Tom Ware a écrit :
Hi Yannick,

When you run a query, EclipseLink will get not only the object you are looking for and the items that are fetch joined, but also any EAGERly fetched relationships from any of the entities that are retrieved. That is likely the reason you are seeing additional queries.

  You should take a look at our attribute group feature.  It may help:

http://wiki.eclipse.org/EclipseLink/Examples/JPA/AttributeGroup

Hi Tom,

Thanks for your answer, very quick ;-)

I understand that, but I think there are some issues. I double-checked, we don't have any relation defined as EAGER, and I understand the default is LAZY.

Also, I don't see any effect from the last fetch:

root.join(EtdOffEtd_.epcOffre).fetch(EpcOffre_.epcOffreEleCollection, JoinType.LEFT);

... although I can see the effect of the other fetch calls, and I can see the very first sql query changing if I remove them.

I'd expect EpcOffreEle's to be fetched, which isn't the case.

I tried to get more debugging, but didn't succeed in finding out *why* each sql query is triggered.

Regards,

Yannick
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top