I can help with the different size of the result list. 

I think you're seeing  https://issues.apache.org/jira/browse/OPENJPA-894
OPENJPA-894 . The first time the results of a FETCH JOIN query are read from
the database OpenJPA only returns the unique rows. Subsequent FETCH JOIN
queries will return duplicates (as defined by the spec). There's also 
https://issues.apache.org/jira/browse/OPENJPA-1365 OPENJPA-1365 , which
complicates things.

I think the best workaround for these issues is to make use of OpenJPA's
FetchPlans to eagerly load a relationship. 

Something like this would work :


OpenJPAEntityManager em = OpenJPAPersistence.cast(entityManager);

FetchPlan plan = em.getFetchPlan();
plan.addField(Node.class, "children");

Query query = em.createQuery("SELECT n from Node n");

I'm not sure whether this will help with your detachment problem though, but
it's worth a try.

-mike--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Same-JPQL-different-results-tp6317274p6317928.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to