HHH-17688 Make statement release more consistent in mutation delegates
This commit is contained in:
parent
02fa42d90c
commit
9f3676d690
|
@ -99,9 +99,10 @@ public abstract class AbstractMutationExecutor implements MutationExecutor {
|
|||
|
||||
// If we get here the statement is needed - make sure it is resolved
|
||||
session.getJdbcServices().getSqlStatementLogger().logStatement( statementDetails.getSqlString() );
|
||||
valueBindings.beforeStatement( statementDetails );
|
||||
|
||||
try {
|
||||
valueBindings.beforeStatement( statementDetails );
|
||||
|
||||
final int affectedRowCount = session.getJdbcCoordinator()
|
||||
.getResultSetReturn()
|
||||
.executeUpdate( statementDetails.getStatement(), statementDetails.getSqlString() );
|
||||
|
|
|
@ -204,9 +204,10 @@ public class MutationExecutorPostInsert implements MutationExecutor, JdbcValueBi
|
|||
);
|
||||
|
||||
session.getJdbcServices().getSqlStatementLogger().logStatement( statementDetails.getSqlString() );
|
||||
valueBindings.beforeStatement( statementDetails );
|
||||
|
||||
try {
|
||||
valueBindings.beforeStatement( statementDetails );
|
||||
|
||||
final int affectedRowCount = session.getJdbcCoordinator()
|
||||
.getResultSetReturn()
|
||||
.executeUpdate( statementDetails.getStatement(), statementDetails.getSqlString() );
|
||||
|
@ -224,6 +225,8 @@ public class MutationExecutorPostInsert implements MutationExecutor, JdbcValueBi
|
|||
|
||||
@Override
|
||||
public void release() {
|
||||
// The mutation delegate already releases the identity insert statement
|
||||
assert identityInsertStatementDetails.getStatement() == null;
|
||||
secondaryTablesStatementGroup.release();
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,8 @@ public class MutationExecutorPostInsertSingleTable implements MutationExecutor,
|
|||
|
||||
@Override
|
||||
public void release() {
|
||||
identityInsertStatementDetails.releaseStatement( session );
|
||||
// Nothing to do - the mutation delegate already releases the identity insert statement
|
||||
assert identityInsertStatementDetails.getStatement() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,8 +38,21 @@ public abstract class AbstractReturningDelegate implements InsertGeneratedIdenti
|
|||
Object entity,
|
||||
SharedSessionContractImplementor session) {
|
||||
session.getJdbcServices().getSqlStatementLogger().logStatement( insertStatementDetails.getSqlString() );
|
||||
valueBindings.beforeStatement( insertStatementDetails );
|
||||
return executeAndExtract( insertStatementDetails.getSqlString(), insertStatementDetails.getStatement(), session );
|
||||
try {
|
||||
valueBindings.beforeStatement( insertStatementDetails );
|
||||
return executeAndExtract(
|
||||
insertStatementDetails.getSqlString(),
|
||||
insertStatementDetails.getStatement(),
|
||||
session
|
||||
);
|
||||
}
|
||||
finally {
|
||||
if ( insertStatementDetails.getStatement() != null ) {
|
||||
insertStatementDetails.releaseStatement( session );
|
||||
}
|
||||
valueBindings.afterStatement( insertStatementDetails.getMutatingTableDetails() );
|
||||
session.getJdbcCoordinator().afterStatementExecution();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,10 +70,19 @@ public abstract class AbstractSelectingDelegate implements InsertGeneratedIdenti
|
|||
final JdbcServices jdbcServices = session.getJdbcServices();
|
||||
|
||||
jdbcServices.getSqlStatementLogger().logStatement( insertStatementDetails.getSqlString() );
|
||||
jdbcValueBindings.beforeStatement( insertStatementDetails );
|
||||
|
||||
jdbcCoordinator.getResultSetReturn()
|
||||
.executeUpdate( insertStatementDetails.resolveStatement(), insertStatementDetails.getSqlString() );
|
||||
try {
|
||||
jdbcValueBindings.beforeStatement( insertStatementDetails );
|
||||
jdbcCoordinator.getResultSetReturn()
|
||||
.executeUpdate( insertStatementDetails.resolveStatement(), insertStatementDetails.getSqlString() );
|
||||
}
|
||||
finally {
|
||||
if ( insertStatementDetails.getStatement() != null ) {
|
||||
insertStatementDetails.releaseStatement( session );
|
||||
}
|
||||
jdbcValueBindings.afterStatement( insertStatementDetails.getMutatingTableDetails() );
|
||||
session.getJdbcCoordinator().afterStatementExecution();
|
||||
}
|
||||
|
||||
// the insert is complete, select the generated id...
|
||||
|
||||
|
|
|
@ -100,10 +100,10 @@ public class GetGeneratedKeysDelegate extends AbstractReturningDelegate {
|
|||
|
||||
jdbcServices.getSqlStatementLogger().logStatement( insertSql );
|
||||
|
||||
final PreparedStatement insertStatement = insertStatementDetails.resolveStatement();
|
||||
jdbcValueBindings.beforeStatement( insertStatementDetails );
|
||||
|
||||
try {
|
||||
final PreparedStatement insertStatement = insertStatementDetails.resolveStatement();
|
||||
jdbcValueBindings.beforeStatement( insertStatementDetails );
|
||||
|
||||
jdbcCoordinator.getResultSetReturn().executeUpdate( insertStatement, insertSql );
|
||||
|
||||
try {
|
||||
|
@ -131,16 +131,20 @@ public class GetGeneratedKeysDelegate extends AbstractReturningDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( insertStatement );
|
||||
catch (SQLException e) {
|
||||
throw jdbcServices.getSqlExceptionHelper().convert(
|
||||
e,
|
||||
"Unable to extract generated-keys ResultSet",
|
||||
insertSql
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw jdbcServices.getSqlExceptionHelper().convert(
|
||||
e,
|
||||
"Unable to extract generated-keys ResultSet",
|
||||
insertSql
|
||||
);
|
||||
finally {
|
||||
if ( insertStatementDetails.getStatement() != null ) {
|
||||
insertStatementDetails.releaseStatement( session );
|
||||
}
|
||||
jdbcValueBindings.afterStatement( insertStatementDetails.getMutatingTableDetails() );
|
||||
jdbcCoordinator.afterStatementExecution();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,9 +77,6 @@ public class InsertReturningDelegate extends AbstractReturningDelegate {
|
|||
insertSql
|
||||
);
|
||||
}
|
||||
finally {
|
||||
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( resultSet, insertStatement );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -73,9 +73,5 @@ public class SybaseJConnGetGeneratedKeysDelegate extends GetGeneratedKeysDelegat
|
|||
insertSql
|
||||
);
|
||||
}
|
||||
finally {
|
||||
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( resultSet, insertStatement );
|
||||
jdbcCoordinator.afterStatementExecution();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue