openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
Subject Re: Best practice: Using fetch groups or a "simple" DTO?
Date Tue, 26 Jul 2011 15:33:26 GMT
Hi,
  How are you verifying whether a field data has been loaded in an entity
instance or not?
Please note that if you simply do
   myEntity.getSomeField();
within an active persistence context, then as a side-effect, the getter 
will fetch the field value from the database (you can see extra SQL being
issued if you turn on SQL tracing). This is a case of classic Schrodinger's
Observer Effect as related to JPA :)

   So to verify correctly, close the persistence context before accessing
the fields. 

   Also, instead of 
  ojpaQuery.getFetchPlan().removeFetchGroup(FetchGroup.NAME_DEFAULT); 
   do
   ojpaQuery.getFetchPlan().clearFetchGroups(); 

-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/Best-practice-Using-fetch-groups-or-a-simple-DTO-tp6598057p6622661.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message