When using stateless session with jdbc batch size we get an
HHH000352: Unable to release batch statement..
error in session.close() after rollback:
Code:
Configuration cfg = new Configuration();
cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "10");
factory = cfg.configure().buildSessionFactory();
StatelessSession session = factory.openStatelessSession();
Transaction tx = session.beginTransaction();
Employee employee = new Employee("1", "2", 1);
employee.setId(id++);
session.insert(employee);
tx.rollback();
session.close();
In rollback the statements are closed but still remain in the jdbc batch,
which is trying to close them a second time on session.close().
Quote:
ResourceRegistryStandardImpl.close(Statement) line: 148
ResourceRegistryStandardImpl.releaseResources() line: 292
LogicalConnectionManagedImpl(AbstractLogicalConnectionImplementor).afterTransaction() line: 55
LogicalConnectionManagedImpl.afterTransaction() line: 149
LogicalConnectionManagedImpl.afterCompletion() line: 260
LogicalConnectionManagedImpl(AbstractLogicalConnectionImplementor).rollback() line: 122
JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.rollback() line: 239
TransactionImpl.rollback() line: 100
HTransaction.rollback(boolean) line: 179
HTransaction.rollback() line: 157
DBContextSingleton(AbstractDBContext).rollback() line: 113
HibernateJDBCBatch.testBatchSize(HSessionFactory) line: 145
HibernateJDBCBatch.work() line: 51
HibernateJDBCBatch(AbstractTestDBAnwendung).start(String[]) line: 176
HibernateJDBCBatch.main(String[]) line: 38
There should not be an error message, since everything is clear up in rollback.
Instead rollback should close the batch too.