> ojem.getFetchPlan().addField(A.class, "B"); Mike is right.
Michael Dick wrote: > > Hi Chris, > I'm not an expert on FetchPlans / FetchGroups, but it sounds like example > 5.22 from [1] is what you're trying to do.. > > [1] > http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_fetch_single_field > > > So your code would look like this : > > OpenJPAEntityManager ojem = OpenJPAPersistence.cast(em); > ojem.getFetchPlan().addField(A.class, "B"); > // run query as normal. > > You'd have to reset the fetchPlan afterwards > (getFetchPlan().removeField(A.class, "B") should work). Alternatively you > could use the @FetchGroup annotation and specify that on your query. > > There may be other paths to achieve your goal, but these are what I would > try first. > > Hope this helps, > > -mike > > On Tue, Sep 29, 2009 at 11:02 AM, Christopher Giblin > <[email protected]>wrote: > >> >> Hi, >> I have a class, "A", with a one-to-many relationship to another class, >> "B". >> Thus A refers to a collection of B. >> Normally I want to load the collection lazy and therefore set fetch to >> "LAZY" in my orm.xml. In one case, however, I want to load A eagerly. >> >> I thought the following would do the trick : >> >> Query query = em.createQuery("select m from ..."); >> OpenJPAQuery jpaQ = OpenJPAPersistence.cast(query); >> JDBCFetchPlan fetchPlan = (JDBCFetchPlan) jpaQ.getFetchPlan(); >> fetchPlan.setEagerFetchMode(FetchMode.PARALLEL); >> List<Identity> results = query.getResultList(); >> >> but in the debugger, I see the collection is loaded lazily. >> >> I also tried using the property instead : >> >> query.setHint("openjpa.FetchPlan.EagerFetchMode","parallel"); >> >> >> But this resulted in a IllegalArugmentException. >> >> What am I missing? >> >> Thanks,chris >> >> > > ----- Pinaki -- View this message in context: http://n2.nabble.com/noob-understanding-dynamic-fetch-modes-tp3737203p3740471.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
