HHH-15082 Abort JDBC batches on runtime exceptions as well as SQLException
This commit is contained in:
parent
73e9859fea
commit
ec6cd5d0cc
|
@ -82,6 +82,10 @@ public class BatchingBatch extends AbstractBatchImpl {
|
|||
LOG.debug( "SQLException escaped proxy", e );
|
||||
throw sqlExceptionHelper().convert( e, "could not perform addBatch", currentStatementSql );
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
abortBatch();
|
||||
throw e;
|
||||
}
|
||||
statementPosition++;
|
||||
if ( statementPosition >= getKey().getBatchedStatementCount() ) {
|
||||
batchPosition++;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class NonBatchingBatch extends AbstractBatchImpl {
|
|||
abortBatch();
|
||||
throw sqlExceptionHelper().convert( e, "could not execute non-batched batch statement", statementSQL );
|
||||
}
|
||||
catch (JDBCException e) {
|
||||
catch (RuntimeException e) {
|
||||
abortBatch();
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -3357,7 +3357,7 @@ public abstract class AbstractEntityPersister
|
|||
);
|
||||
}
|
||||
}
|
||||
catch (SQLException | JDBCException e) {
|
||||
catch (SQLException | RuntimeException e) {
|
||||
if ( useBatch ) {
|
||||
session.getJdbcCoordinator().abortBatch();
|
||||
}
|
||||
|
@ -3558,7 +3558,7 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch (SQLException | RuntimeException e) {
|
||||
if ( useBatch ) {
|
||||
session.getJdbcCoordinator().abortBatch();
|
||||
}
|
||||
|
@ -3684,11 +3684,11 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
|
||||
}
|
||||
catch (SQLException sqle) {
|
||||
catch (SQLException | RuntimeException e) {
|
||||
if ( useBatch ) {
|
||||
session.getJdbcCoordinator().abortBatch();
|
||||
}
|
||||
throw sqle;
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
if ( !useBatch ) {
|
||||
|
|
Loading…
Reference in New Issue