mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 16:44:57 +00:00
HHH-13050 - On release of batch it still contained JDBC statements logged
(cherry picked from commit 11e71f6977fcf4366eb6875d9fc1ce46f029853c)
This commit is contained in:
parent
1642853c89
commit
fdab459b82
@ -40,8 +40,8 @@ public abstract class AbstractBatchImpl implements Batch {
|
||||
private final SqlStatementLogger sqlStatementLogger;
|
||||
private final SqlExceptionHelper sqlExceptionHelper;
|
||||
|
||||
private LinkedHashMap<String,PreparedStatement> statements = new LinkedHashMap<String,PreparedStatement>();
|
||||
private LinkedHashSet<BatchObserver> observers = new LinkedHashSet<BatchObserver>();
|
||||
private LinkedHashMap<String, PreparedStatement> statements = new LinkedHashMap<>();
|
||||
private LinkedHashSet<BatchObserver> observers = new LinkedHashSet<>();
|
||||
|
||||
protected AbstractBatchImpl(BatchKey key, JdbcCoordinator jdbcCoordinator) {
|
||||
if ( key == null ) {
|
||||
@ -162,7 +162,15 @@ protected void releaseStatements() {
|
||||
|
||||
protected void clearBatch(PreparedStatement statement) {
|
||||
try {
|
||||
statement.clearBatch();
|
||||
// This code can be called after the connection is released
|
||||
// and the statement is closed. If the statement is closed,
|
||||
// then SQLException will be thrown when PreparedStatement#clearBatch
|
||||
// is called.
|
||||
// Ensure the statement is not closed before
|
||||
// calling PreparedStatement#clearBatch.
|
||||
if ( !statement.isClosed() ) {
|
||||
statement.clearBatch();
|
||||
}
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
LOG.unableToReleaseBatchStatement();
|
||||
|
@ -77,6 +77,7 @@ public void addToBatch() {
|
||||
currentStatement.addBatch();
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
abortBatch();
|
||||
LOG.debugf( "SQLException escaped proxy", e );
|
||||
throw sqlExceptionHelper().convert( e, "could not perform addBatch", currentStatementSql );
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.JDBCException;
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.MappingException;
|
||||
@ -3171,9 +3172,8 @@ protected void insert(
|
||||
.executeUpdate( insert ), insert, -1
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch (SQLException | JDBCException e) {
|
||||
if ( useBatch ) {
|
||||
session.getJdbcCoordinator().abortBatch();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user