In what seems like a shocking oversight, it would appear that JDBC batching, when using Optimistic locking and Hibernate Versioning cannot work. It appears that is hasn't worked for a long time (if ever).
If you look at AbstractEntityPersister.isBatchable it evaluates 3 terms to determine is JDBC batching (addBatch/executeBatch) should be used, true on any of the 3 terms enables batching
{{ public boolean isBatchable() { return optimisticLockStyle() == OptimisticLockStyle.NONE || ( !isVersioned() && optimisticLockStyle() == OptimisticLockStyle.VERSION ) || getFactory().getSettings().isJdbcBatchVersionedData(); }}
The first term is presumably is that pessimistic locking is being used.
The third term indicated that versioning is being handled by the database .
The Second term "should" return true if the entity is versioned and hibernate versioning is being used .
However you will notice the logical NOT in front if isVersioned(), it should not be there.
*UNLESS* the intention was to explicitly disable batching if Hibernate Versioning is being used.
I have tested/profiled a number of applications and quite simply removing the NOT enables hibernates JDBC batching mechanism. This bug is probably affecting thousands of applications. |
|