openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henno Vermeulen <he...@huizemolenaar.nl>
Subject two issues when not using a DetachedStateField
Date Wed, 13 Apr 2011 12:30:13 GMT
We use OpenJPA 2.1.0 with build time enhancement. We have a client/server situation so we always
detach + serialize entities on commit using fetch groups:

<property name="openjpa.DetachState" value="fetch-groups(DetachedStateField=false)" />
            <property name="openjpa.AutoDetach" value="commit" /

We currently don't use a DetachedStateField or DetachedStateManager because everything worked
fine without them until now.

I found two issues that don't occur when I use DetachedStateField=true. (According to the
user guide OpenJPA should function just as well without one except that it may be less efficient.
"OpenJPA can take advantage of a detached state field to make the attach process more efficient.
This field is added by the enhancer and is not visible to your application.")


Issue 1:
When I add a new entity to a List of a detached (but not Serialized) entity and then merge,
OpenJPA throws:

org.apache.openjpa.persistence.InvalidStateException: The context has been closed.  The stack
trace at which the context was closed is held in the embedded exception.
FailedObject: java.lang.IllegalStateException
            at org.apache.openjpa.kernel.BrokerImpl.assertOpen(BrokerImpl.java:4615)
.......

We don't experience this as a problem because we always Serialize an entity before adjusting
it!!!


Issue 2:
We have an object graph of four entities with autogenerated Id columns:

Event (OneToMany bidirectional) Activity (OneToMany) ProductOrderLine (OneToOne) StringI18N

All relations are FetchType.EAGER and Cascade.ALL.

When I add a new Activity (with one new ProductOrderLine with one new StringI18N) to an existing
Event and then merge the Event, OpenJPA tries to insert a null value into the StringI18N Id
column. This seems to be only detected on transaction commit.

This problem does not occur when:

-          I make the Event - Activity relation unidirectional, i.e. Activity does not know
it's parent Event.

-          The Event is new as well.

-          (workaround) I first add the new Activity to the Event but with no ProductOrderLines,
then merge the Event, then add the ProductOrderLine to the Activity in the and merge the Event
again.

Are these known issues? What is the best way for me to go? Should I do my workaround or should
I try to use a detached state field?
Shall I report this to JIRA? I have a test case which shows these issues.


Regards,

Henno Vermeulen
Huize Molenaar

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message