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