【发布时间】:2011-08-10 05:36:15
【问题描述】:
我在尝试使用 jpa.AM 持久化对象时遇到以下错误
NestedThrowables:
<openjpa-1.2.2-SNAPSHOT-r422266:778978M-OPENJPA-975 nonfatal store error> org.apache.openjpa.persistence.OptimisticLockException: An optimistic lock violation was detected when flushing object instance "org.apache.openjpa.enhance.com$ibm$cloud$bss$client$db$data$Offeringattribute$pcsubclass-com.ibm.cloud.bss.client.db.data.Offeringattribute-10013800" to the data store. This indicates that the object was concurrently modified in another transaction.
现在我上次通过插入一些刷新语句解决了这个错误,如下所示
em.persist(xyz);
em.flush(); //added this line
dbAttr.setOid((xyz.getId());
em.merge((xyz);
但我不记得上次我是否做了其他事情。即使在添加了这个刷新语句之后,我也会收到这个错误。
注意:我的应用程序作为独立控制台应用程序运行,并且确定只有 1 个线程在运行
【问题讨论】:
-
在 openJPA 中,我从未设法对同一个实体进行 2 次操作。试试