HHH-13528 Invoke afterStatements only at the end of releasing all statements for a batch

This commit is contained in:
Sanne Grinovero 2019-07-31 10:59:49 +01:00 committed by Sanne Grinovero
parent 51c94121cb
commit 2c304a5e18
1 changed files with 7 additions and 4 deletions

View File

@ -21,6 +21,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.resource.jdbc.ResourceRegistry;
/**
* Convenience base class for implementers of the Batch interface.
@ -152,12 +153,14 @@ public abstract class AbstractBatchImpl implements Batch {
}
protected void releaseStatements() {
for ( PreparedStatement statement : getStatements().values() ) {
final LinkedHashMap<String, PreparedStatement> statements = getStatements();
final ResourceRegistry resourceRegistry = jdbcCoordinator.getResourceRegistry();
for ( PreparedStatement statement : statements.values() ) {
clearBatch( statement );
jdbcCoordinator.getResourceRegistry().release( statement );
jdbcCoordinator.afterStatementExecution();
resourceRegistry.release( statement );
}
getStatements().clear();
jdbcCoordinator.afterStatementExecution();
statements.clear();
}
protected void clearBatch(PreparedStatement statement) {