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)

Henno


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

Hello,

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: 
http://openjpa.208410.n2.nabble.com/FetchPlan-FetchGroup-behaviour-tp7583329p7583362.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to