Optimistic and Pessimistic Force Increment Update Statements are not committed when using a batch
Description
Activity
Show:

Vincent Sourin July 25, 2023 at 9:36 AM
Same problem here with Quarkus 3.2.2.Final & Hibernate 6.2.6.Final

Stefan Mueller July 16, 2023 at 2:02 PM
We haven exactly the same issue with Hibernate all 6.2.* versions. We downgraded to 6.1.7, which is the last working version.
Fixed
Created July 15, 2023 at 2:47 AM
Updated August 31, 2023 at 5:28 PM
Resolved August 16, 2023 at 1:07 PM
JayVeeInCorp in the above question explains it better. I am going to try to summarize it here.
When batch mode is on,
hibernate.jdbc.batch_size
> 0. The update statement(s) that should increment the versioned column are not included in the committed batch. Then they are released after original batch is closed.I happened to find that question while trying to understand this message in my Spring Boot 3.1.1 project’s log
HHH100503: On release of batch it still contained JDBC statements
The above message shows up, since it is an INFO level but it doesn’t point to a cause or what was missing because of this.
An aside, not knowing a lot about this error, is there a reason
HHH100503
message is INFO and not WARN or even ERROR? Since data loss occurs it is hard to notice that this was part of the cause.I have ORMUnitTestCase that I am translating into a hibernate-orm/hibernate-core test PR and will update this as soon as I have it ready.
The regression started between 6.1 and 6.2. With the current test case it is successful in 5.6.15.Final and 6.1.7.Final but fails on 6.2.0 and above including 6.2.6.Final, 6.2.7-SNAPSHOT and 6.3.0-SNAPSHOT.
Once I increased the log level
these two lines also show up in the debug/trace logs. Along with a lot of other ones I am not sure which ones will be useful.
Log:
Releasing statement [prep3: update HHH123_Calendar set version=? where id=? and version=? {1: 2, 2: CAST(1 AS BIGINT), 3: 1}]
HHH000420: Closing un-released batch
PreparedStatementDetails did not contain PreparedStatement on #releaseStatements : update HHH123_Calendar set version=? where id=? and version=?
Log4j2 properties:
logger.hibernate-cache.name = org.hibernate.cache
logger.hibernate-cache.level = INFO
logger.hibernate-sql.name = org.hibernate.SQL
logger.hibernate-sql.level = DEBUG
logger.hibernate-orm-jdbc-bind.name = org.hibernate.orm.jdbc.bind
logger.hibernate-orm-jdbc-bind.level = TRACE
logger.hibernate-orm-jdbc-batch.name = org.hibernate.orm.jdbc.batch
logger.hibernate-orm-jdbc-batch.level = TRACE
logger.hibernate-resource-jdbc.name = org.hibernate.resource.jdbc
logger.hibernate-resource-jdbc.level = TRACE
logger.hibernate-resource-transaction.name = org.hibernate.resource.transaction
logger.hibernate-resource-transaction.level = TRACE
logger.hibernate-engine-jdbc.name = org.hibernate.engine.jdbc
logger.hibernate-engine-jdbc.level = TRACE