Hi,
with OpenJPA 1.2.0 i am having some problems detaching attributes
which are in a fetch-group. My persistence.xml is:
<property name="openjpa.DetachState" value="fetch-
groups(DetachedStateField=true)"/>
My Domain class header:
@FetchGroups({
@FetchGroup(name="posDetail", attributes={
@FetchAttribute(name="deliveryAddresses")
})
})
public class Order {
@OneToMany(mappedBy = "order", cascade = CascadeType.ALL, fetch =
FetchType.LAZY)
List<DeliveryAddress> deliveryAddresses;
...
}
(in fact i also have the @LoadFetchGroup("posDetail") to be sure.....)
Now when i am leaving my DAO layer which means that the persistence
contexts ends, the delivery address is "null" even though its in the
fetch group. I even queried for the fetch group in the DAO before
leaving it via:
OpenJPAQuery oQuery = OpenJPAPersistence.cast(em.createQuery("select o
from Order o where o.oid = ?1"));
oQuery.setParameter(1, oid);
//
oQuery.getFetchPlan().setMaxFetchDepth(3).addFetchGroup("posDetail");
List list = oQuery.getResultList();
if(list != null && list.size() > 0) {
return (Order)list.iterator().next();
}
I know it must be a detach issue because with the following
persistence.xml it works (but i definitely wont use this config in
production)
<property name="openjpa.DetachState" value="all"/>
Am i missing something here? When i debug my DAO, the deliveryAddress
attribute is populated but as soon as i leave my DAO, its lost.
---
regards
Marc Logemann
http://www.logemann.org
http://www.logentis.de