OK. Thats much better! I am now using 1.2.0 nightly build of 25 July. I can
now create objects conforming to the ERD I mentioned before. Thank You!
But one problem. I get "org.apache.openjpa.persistence.RollbackException:
Optimistic locking errors were detected when flushing to the data store. ",
when I delete a child instance and then delete a parent. That is I deleted a
'z' first then deleted the 'y' that the 'z' had a reference to. One deleting
'y' I get the following trace:
<openjpa-1.2.0-SNAPSHOT-rexported fatal store error>
org.apache.openjpa.persistence.RollbackException: Optimistic locking errors
were detected when flushing to the data store. The following objects may
have been concurrently modified in another transaction:
[jpatest.Z-jpatest.Z-jpatest.Z$ZId@5e03fc]
at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:523)
at jpatest.TestXYZ.testCascadeDelete(TestXYZ.java:161)
....
Caused by: <openjpa-1.2.0-SNAPSHOT-rexported nonfatal store error>
org.apache.openjpa.persistence.OptimisticLockException: Optimistic locking
errors were detected when flushing to the data store. The following objects
may have been concurrently modified in another transaction:
[jpatest.Z-jpatest.Z-jpatest.Z$ZId@5e03fc]
at
org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2160)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
.....
Caused by: <openjpa-1.2.0-SNAPSHOT-rexported nonfatal store error>
org.apache.openjpa.persistence.OptimisticLockException: An optimistic lock
violation was detected when flushing object instance
"jpatest.Z-jpatest.Z-jpatest.Z$ZId@5e03fc" to the data store. This
indicates that the object was concurrently modified in another transaction.
FailedObject: jpatest.Z-jpatest.Z-jpatest.Z$ZId@5e03fc
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:124)
at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:82)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:89)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:72)
Here is code fragment that caused the problem:
em.getTransaction().begin();
Z z = (Z) em.createQuery("select Z from Z z where
z.zid=302").getSingleResult();
System.out.println(z);
em.remove(z);
em.getTransaction().commit();
em.getTransaction().begin();
Y y = (Y) em.createQuery("select y from Y y where
y.yid=202").getSingleResult();
System.out.println(y);
em.remove(y);
em.getTransaction().commit();
The object diagram was Y(202) --< Z(302).
y still have a reference to the deleted z, but the row corresponding to z is
already deleted from the Z table.
I am doing any thing wrong or an OpenJPA bug?
Thanks
Gopal
--
View this message in context: http://n2.nabble.com/support-for-identifying-relations-in-JPA-OpenJPA-tp660963p662322.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
|