In fact, when I call, for debugging purpose, the fetchPlan.getFields() methods, 
I can check that the field I need and only the fields I need are there.
=> the fetchPlan itself is correct.

Then, what should I do to "use" the fetchplan ? I can't find my old test that 
was pure OpenJPA (without all my application code I have now) but I remember I 
can use entityManager just as simply as without fetchplan.
The fact to create and set a fetchplan from that entityManager is enough to 
tell the entityManager to "use" it. 

Am i right ?

Also, here in the doc : 
http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_fetch.html
I read that example :

   OpenJPAEntityManager kem = OpenJPAPersistence.cast(em);
   kem.getFetchPlan().addField(Magazine.class, "publisher");
   Magazine mag = em.find(Magazine.class, magId);

Will it work also with a query and not only with the find(id) method ?
Something like that : em.createQuery("SELECT blablabla ..."); ??


On Dec 7, 2009, at 15:20 , Jean-Baptiste BRIAUD -- Novlog wrote:

> I call this 2 methods before adding the fields I want but still it doesn't 
> behave like expected.
> 
> On Dec 7, 2009, at 13:00 , Michael Vorburger wrote:
> 
>>> how to dynamically, using fetch plan, exclude (rather than adding) to
>> the fetch plan some attribute not to retrieve 
>> 
>> I probably misunderstand, but doesn't FetchPlan.clearFields() +
>> FetchPlan.clearFetchGroups() followed by a few addField() do what you
>> want (I haven't tried) ?
>> 
>> http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/javadoc
>> /org/apache/openjpa/persistence/FetchPlan.html
>> 
> 
> 

Reply via email to