我正在使用eclipse HistoryPolicy生成历史记录。当我尝试删除审核表中没有记录的实体(通过简单的SQL查询插入的实体)时,我在日志中看到了SQL查询:
UPDATE FOO_AUDIT SET AUDIT_END = ?, DEL_USER_NAME = ? WHERE ((AUDIT_END IS NULL) AND (FOO_ID = ?))
但是FOO_AUDIT没有包含具有该ID的FOO实体的记录,所以我得到了:
org.eclipse.persistence.exceptions.OptimisticLockException
Exception Description: One or more objects cannot be updated because it has changed or been deleted since it was last read.
它与weblogic 10.3.5和eclipselink-2.4.1。兼容。 有人可以提供一些反馈吗?
eclipselink版本-2.7.3, WildFly版本12.0.0;
经过一些调试后,我发现它是由ParameterizedSQLBatchWritingMechanism.class中的批处理修复引起的
try {
int rowCount = (Integer)this.databaseAccessor.basicExecuteCall(this.previousCall, null, session, false);
if (this.previousCall.hasOptimisticLock()) {
if (rowCount != 1) {
throw OptimisticLockException.batchStatementExecutionFailure();
}
}
} finally {
clear();
}
Update语句更新0行,并且previousCall具有对FOO的类描述符的乐观锁定。