HHH-7689 - Error executing batch should abort rest of batch for "cleanliness" sake
This commit is contained in:
parent
0e164d1c9d
commit
4a898c5524
|
@ -148,36 +148,35 @@ public abstract class AbstractBatchImpl implements Batch {
|
||||||
@Override
|
@Override
|
||||||
public final void execute() {
|
public final void execute() {
|
||||||
notifyObserversExplicitExecution();
|
notifyObserversExplicitExecution();
|
||||||
if ( statements.isEmpty() ) {
|
if ( getStatements().isEmpty() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
doExecuteBatch();
|
||||||
doExecuteBatch();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
releaseStatements();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
statements.clear();
|
releaseStatements();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void releaseStatements() {
|
protected void releaseStatements() {
|
||||||
for ( PreparedStatement statement : getStatements().values() ) {
|
for ( PreparedStatement statement : getStatements().values() ) {
|
||||||
try {
|
clearBatch( statement );
|
||||||
statement.clearBatch();
|
jdbcCoordinator.release( statement );
|
||||||
jdbcCoordinator.release( statement );
|
|
||||||
}
|
|
||||||
catch ( SQLException e ) {
|
|
||||||
LOG.unableToReleaseBatchStatement();
|
|
||||||
LOG.sqlExceptionEscapedProxy( e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
getStatements().clear();
|
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.
|
* Convenience method to notify registered observers of an explicit execution of this batch.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -71,7 +71,13 @@ public class NonBatchingBatch extends AbstractBatchImpl {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getStatements().clear();
|
|
||||||
|
releaseStatements();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void clearBatch(PreparedStatement statement) {
|
||||||
|
// no need to call PreparedStatement#clearBatch here...
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -804,9 +804,9 @@ public interface CoreMessageLogger extends BasicLogger {
|
||||||
void splitQueries(String sourceQuery,
|
void splitQueries(String sourceQuery,
|
||||||
int length);
|
int length);
|
||||||
|
|
||||||
@LogMessage(level = ERROR)
|
// @LogMessage(level = ERROR)
|
||||||
@Message(value = "SQLException escaped proxy", id = 246)
|
// @Message(value = "SQLException escaped proxy", id = 246)
|
||||||
void sqlExceptionEscapedProxy(@Cause SQLException e);
|
// void sqlExceptionEscapedProxy(@Cause SQLException e);
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
@LogMessage(level = WARN)
|
||||||
@Message(value = "SQL Error: %s, SQLState: %s", id = 247)
|
@Message(value = "SQL Error: %s, SQLState: %s", id = 247)
|
||||||
|
|
Loading…
Reference in New Issue