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

Reply via email to