0

在一项交易中,我运行

delete from OdpObjectScheduleEntity e where e.id = 956101

然后,在另一个事务中(并且日志显示它在前一个事务提交后开始)我尝试OdpObjectScheduleEntity使用 id 956101 持久化一个新事务,但出现异常:

Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal store error> org.apache.openjpa.persistence.EntityExistsException: An object of type "ru.focusmedia.odp.server.datastore.jpa.entity.OdpObjectScheduleEntity" with oid "956101" already exists in this context; another cannot be persisted.
FailedObject: ru.focusmedia.odp.server.datastore.jpa.entity.OdpObjectScheduleEntity@3ad41caa
    at org.apache.openjpa.kernel.BrokerImpl.checkForDuplicateId(BrokerImpl.java:5075)[106:org.apache.openjpa:2.2.0]
    at org.apache.openjpa.kernel.BrokerImpl.persistInternal(BrokerImpl.java:2651)[106:org.apache.openjpa:2.2.0]
    at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2571)[106:org.apache.openjpa:2.2.0]
    at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2554)[106:org.apache.openjpa:2.2.0]
    at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2458)[106:org.apache.openjpa:2.2.0]
    at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1077)[106:org.apache.openjpa:2.2.0]
    at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:716)[106:org.apache.openjpa:2.2.0]
    at org.apache.aries.jpa.container.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:177)[58:org.apache.aries.jpa.container:1.0.0]
    at ru.focusmedia.odp.server.datastore.jpa.repository.RepositoryImpl$36.run(RepositoryImpl.java:2167)[157:ru.focusmedia.odp.server.datastore.jpa:0.1.0]
    at ru.focusmedia.odp.server.datastore.api.CheckedRunnable.call(CheckedRunnable.java:13)[155:ru.focusmedia.odp.server.datastore.api:0.1.0]
    at ru.focusmedia.odp.server.datastore.api.CheckedRunnable.call(CheckedRunnable.java:1)[155:ru.focusmedia.odp.server.datastore.api:0.1.0]
    at ru.focusmedia.odp.server.datastore.jpa.repository.RepositoryImpl.transact(RepositoryImpl.java:879)[157:ru.focusmedia.odp.server.datastore.jpa:0.1.0]
    ... 52 more

这是合法行为吗?

4

0 回答 0