openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henno Vermeulen <>
Subject RE: FetchPlan/FetchGroup behaviour
Date Fri, 05 Apr 2013 08:22:25 GMT
Hi Guillaume,

I downloaded your Maven project and after some head-scratching I found the problem.
In testEmulateEmmiter you are adding the fetch group to the query fetch plan which means that
the query will eagerly fetch the collection.
However when detaching based on fetch groups, the entityManager fetch plan is used, not the
fetchplan of the query that happened to fetch the entity because different queries on the
same entity manager context may use different fetch plans.

Your problem is easily solved by (also/instead) adding the fetch group to the entityManager
fetch plan.

When you use only the entityManager fetch plan be sure to set it up before creating the query,
otherwise the query will not use the fetchplan. This would mean that the collection is not
loaded when the query is executed and is loaded when detaching the copy. (Actually the external
behavior will be the same but this may perform worse when there are many fetch groups)


-----Oorspronkelijk bericht-----
Van: Guillaume Chauvet [] 
Verzonden: donderdag 4 april 2013 17:50
Onderwerp: RE: FetchPlan/FetchGroup behaviour


Thank you for your answer. I tried DetachedStateField=true/false and
openjpa.AutoDetach=commit properties, unsuccessfully.
Moreover, I'm 100% sure that all collections are not empty (checked with
assertions in the supplied draft).

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message