Hi Daryl, > Ah, so modifying the fetch plan is for the lifetime of the em? I think I like > that.
Yes. But there is more to it. say em has a fetchplan (say f1). any query q created from that em has the clone of fetchplan f1 (say f2) to begin with. If f2 is changed, that impacts q but not its parent em. Also you can use a stack pattern with these fetch plans. as follows: FetchPlan f1 = em.getFetchPlan(); FetchPlan f2 = em.pushFetchPlan(); // f2 is clone of f1 f2.setSomething(something); em.doSomething(); // f2 is active now em.popFetchPlan(); em.doSomething(); // f1 is active now On Tue, Apr 7, 2009 at 1:11 AM, Jay McHugh <[email protected]> wrote: > > If that doesn't work - or you (cannot/do not want to) eagerly fetch > the relationship all of the time - a quick stab at what using fetch > groups might look like this: > > <example> > > // assuming you already have an entity manager named 'entityManager' > OpenJPAEntityManager em = OpenJPAPersistence.cast(entityManager); > > FetchPlan plan = em.getFetchPlan(); > plan.addField(GrandParent.class, "parents"); > plan.addField(Parent.class, "children"); > > Query query = em.createQuery("select gp from GrandParent as gp"); > > </example> > Ah, so modifying the fetch plan is for the lifetime of the em? I think I like that. Thanks for the help. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:[email protected] ----- Pinaki Poddar http://ppoddar.blogspot.com/ http://www.linkedin.com/in/pinakipoddar OpenJPA PMC Member/Committer JPA Expert Group Member -- View this message in context: http://n2.nabble.com/Multiple-join-fetches-tp2593566p2602050.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
