HHH-7689 - Error executing batch should abort rest of batch for "cleanliness" sake

This commit is contained in:
Steve Ebersole 2013-10-04 13:39:52 -05:00
parent 0e164d1c9d
commit 4a898c5524
3 changed files with 26 additions and 21 deletions

View File

@ -148,36 +148,35 @@ public abstract class AbstractBatchImpl implements Batch {
@Override
public final void execute() {
notifyObserversExplicitExecution();
if ( statements.isEmpty() ) {
if ( getStatements().isEmpty() ) {
return;
}
try {
try {
doExecuteBatch();
}
finally {
releaseStatements();
}
doExecuteBatch();
}
finally {
statements.clear();
releaseStatements();
}
}
private void releaseStatements() {
protected void releaseStatements() {
for ( PreparedStatement statement : getStatements().values() ) {
try {
statement.clearBatch();
jdbcCoordinator.release( statement );
}
catch ( SQLException e ) {
LOG.unableToReleaseBatchStatement();
LOG.sqlExceptionEscapedProxy( e );
}
clearBatch( statement );
jdbcCoordinator.release( statement );
}
getStatements().clear();
}
protected void clearBatch(PreparedStatement statement) {
try {
statement.clearBatch();
}
catch ( SQLException e ) {
LOG.unableToReleaseBatchStatement();
}
}
/**
* Convenience method to notify registered observers of an explicit execution of this batch.
*/

View File

@ -71,7 +71,13 @@ public class NonBatchingBatch extends AbstractBatchImpl {
throw e;
}
}
getStatements().clear();
releaseStatements();
}
@Override
protected void clearBatch(PreparedStatement statement) {
// no need to call PreparedStatement#clearBatch here...
}
@Override

View File

@ -804,9 +804,9 @@ public interface CoreMessageLogger extends BasicLogger {
void splitQueries(String sourceQuery,
int length);
@LogMessage(level = ERROR)
@Message(value = "SQLException escaped proxy", id = 246)
void sqlExceptionEscapedProxy(@Cause SQLException e);
// @LogMessage(level = ERROR)
// @Message(value = "SQLException escaped proxy", id = 246)
// void sqlExceptionEscapedProxy(@Cause SQLException e);
@LogMessage(level = WARN)
@Message(value = "SQL Error: %s, SQLState: %s", id = 247)