HHH-15082 Correctly propagate the original exception when aborting a JDBC batch fails
Not strictly necessary, but it's related to these changes and I think it's a good idea.
This commit is contained in:
parent
14c8fb752d
commit
cf9d131d35
|
@ -93,8 +93,13 @@ public abstract class AbstractBatchImpl implements Batch {
|
|||
return sqlStatementLogger;
|
||||
}
|
||||
|
||||
protected void abortBatch() {
|
||||
jdbcCoordinator.abortBatch();
|
||||
protected void abortBatch(Exception cause) {
|
||||
try {
|
||||
jdbcCoordinator.abortBatch();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
cause.addSuppressed( e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,12 +78,12 @@ public class BatchingBatch extends AbstractBatchImpl {
|
|||
currentStatement.addBatch();
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
abortBatch();
|
||||
abortBatch( e );
|
||||
LOG.debug( "SQLException escaped proxy", e );
|
||||
throw sqlExceptionHelper().convert( e, "could not perform addBatch", currentStatementSql );
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
abortBatch();
|
||||
abortBatch( e );
|
||||
throw e;
|
||||
}
|
||||
statementPosition++;
|
||||
|
@ -130,12 +130,12 @@ public class BatchingBatch extends AbstractBatchImpl {
|
|||
checkRowCounts( rowCounts, statement, sql );
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
abortBatch();
|
||||
abortBatch( e );
|
||||
LOG.unableToExecuteBatch( e, sql );
|
||||
throw sqlExceptionHelper().convert( e, "could not execute batch", sql );
|
||||
}
|
||||
catch ( RuntimeException re ) {
|
||||
abortBatch();
|
||||
abortBatch( re );
|
||||
LOG.unableToExecuteBatch( re, sql );
|
||||
throw re;
|
||||
}
|
||||
|
|
|
@ -42,11 +42,11 @@ public class NonBatchingBatch extends AbstractBatchImpl {
|
|||
jdbcCoordinator.afterStatementExecution();
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
abortBatch();
|
||||
abortBatch( e );
|
||||
throw sqlExceptionHelper().convert( e, "could not execute non-batched batch statement", statementSQL );
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
abortBatch();
|
||||
abortBatch( e );
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue