Hello,
Upgrading from 2.1.2 to 2.2.0 (tried with 2.3.0-M6 also) i'm facing the following issue:
Trying to issue 2 delete statements:
this.em.createQuery("delete from whatever_entity_with_empty_table") ... ;
this.em.createQuery("delete from annother_entity_with_empty_table") ... ;
<property name="eclipselink.jdbc.batch-writing" value="JDBC" />
<property name="eclipselink.jdbc.native-sql" value="true" />
using MySQL 5 as database, throws an org.eclipse.persistence.exceptions.OptimisticLockException with
Exception Description: One or more objects cannot be updated because it has changed or been deleted since it was last read
Tracing the code until the second statement is processed , the execution reaches executeBatchedStatements method in
ParameterizedSQLBatchWritingMechanism and the condition in 'if' evaluates to true as
executionCount is 0 (coming from MySQLPlatform.executeBatch ) and statementCount =1
PreparedStatement statement = this.prepareBatchStatements(session);
executionCount += this.databaseAccessor.executeJDK12BatchStatement(statement, this.lastCallAppended, session, true);
this.databaseAccessor.writeStatementsCount++;
if (this.previousCall.hasOptimisticLock() && (executionCount!=statementCount)){
throw OptimisticLockException.batchStatementExecutionFailure();
}
I'm not really getting the point here, maybe there is something i'm missing in an upper level.
Any idea about this ?
Thank you