HHH-7984 Handle Oracle statements on release

This commit is contained in:
Brett Meyer 2013-03-26 10:58:17 -04:00
parent ac55afbd65
commit 1a3be54c85
16 changed files with 39 additions and 37 deletions

View File

@ -96,7 +96,7 @@ public class PessimisticReadSelectLockingStrategy extends AbstractSelectLockingS
}
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
}
finally {

View File

@ -95,7 +95,7 @@ public class PessimisticWriteSelectLockingStrategy extends AbstractSelectLocking
}
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
}
finally {

View File

@ -96,7 +96,7 @@ public class SelectLockingStrategy extends AbstractSelectLockingStrategy {
}
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
}
finally {

View File

@ -374,7 +374,7 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
LOG.tracev( "Registering result set [{0}]", resultSet );
if ( statement == null ) {
try {
statement = resultSet.getStatement(); // best guess
statement = resultSet.getStatement();
}
catch ( SQLException e ) {
throw exceptionHelper.convert( e, "unable to access statement from resultset" );
@ -399,14 +399,15 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
}
@Override
public void release(ResultSet resultSet) {
public void release(ResultSet resultSet, Statement statement) {
LOG.tracev( "Releasing result set [{0}]", resultSet );
Statement statement;
try {
statement = resultSet.getStatement();
}
catch ( SQLException e ) {
throw exceptionHelper.convert( e, "unable to access statement from resultset" );
if ( statement == null ) {
try {
statement = resultSet.getStatement();
}
catch ( SQLException e ) {
throw exceptionHelper.convert( e, "unable to access statement from resultset" );
}
}
if ( statement != null ) {
// Keep this at DEBUG level, rather than warn. Numerous connection pool implementations can return a

View File

@ -184,8 +184,9 @@ public interface JdbcCoordinator extends Serializable {
* Release a previously registered result set.
*
* @param resultSet The result set to release.
* @param statement Statement from which {@link ResultSet} has been generated.
*/
public void release(ResultSet resultSet);
public void release(ResultSet resultSet, Statement statement);
/**
* Does this registry currently have any registered resources?

View File

@ -64,7 +64,7 @@ public class GUIDGenerator implements IdentifierGenerator {
result = rs.getString(1);
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
LOG.guidGenerated(result);
return result;

View File

@ -105,7 +105,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator {
}
finally {
if ( rs != null ) {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, insert );
}
}
}
@ -150,7 +150,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator {
);
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, insert );
}
}

View File

@ -139,7 +139,7 @@ public class IncrementGenerator implements IdentifierGenerator, Configurable {
}
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
}
finally {

View File

@ -128,7 +128,7 @@ public class SequenceGenerator
return result;
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
}
finally {

View File

@ -107,7 +107,7 @@ public class SequenceStructure implements DatabaseStructure {
}
finally {
try {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
catch( Throwable ignore ) {
// intentionally empty

View File

@ -87,7 +87,7 @@ public abstract class AbstractSelectingDelegate implements InsertGeneratedIdenti
return getResult( session, rs, binder.getEntity() );
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, idSelect );
}
}
finally {

View File

@ -1806,7 +1806,7 @@ public abstract class AbstractCollectionPersister
return rs.next() ? rs.getInt( 1 ) - baseIndex : 0;
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
}
finally {
@ -1845,7 +1845,7 @@ public abstract class AbstractCollectionPersister
return rs.next();
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
}
catch ( TransientObjectException e ) {
@ -1884,7 +1884,7 @@ public abstract class AbstractCollectionPersister
}
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
}
finally {

View File

@ -1278,7 +1278,7 @@ public abstract class AbstractEntityPersister
}
finally {
if ( rs != null ) {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, ps );
}
}
}
@ -1535,7 +1535,7 @@ public abstract class AbstractEntityPersister
return values;
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, ps );
}
}
finally {
@ -1586,7 +1586,7 @@ public abstract class AbstractEntityPersister
return (Serializable) getIdentifierType().nullSafeGet( rs, getIdentifierAliases(), session, null );
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, ps );
}
}
finally {
@ -1890,7 +1890,7 @@ public abstract class AbstractEntityPersister
return getVersionType().nullSafeGet( rs, getVersionColumnName(), session, null );
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
}
finally {
@ -2918,7 +2918,7 @@ public abstract class AbstractEntityPersister
}
if ( sequentialResultSet != null ) {
session.getTransactionCoordinator().getJdbcCoordinator().release( sequentialResultSet );
session.getTransactionCoordinator().getJdbcCoordinator().release( sequentialResultSet, sequentialSelect );
}
return values;
@ -4657,7 +4657,7 @@ public abstract class AbstractEntityPersister
}
finally {
if ( rs != null ) {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, ps );
}
}
}
@ -4756,7 +4756,7 @@ public abstract class AbstractEntityPersister
return snapshot;
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, ps );
}
}
finally {
@ -4814,7 +4814,7 @@ public abstract class AbstractEntityPersister
return (Serializable) getIdentifierType().hydrate( rs, getIdentifierAliases(), session, null );
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs );
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, ps );
}
}
finally {

View File

@ -132,7 +132,7 @@ public class BasicOperationsTest extends BaseCoreFunctionalTestCase {
s.getTransactionCoordinator().getJdbcCoordinator().register(columnInfo, columnInfo.getStatement());
assertTrue( columnInfo.next() );
int dataType = columnInfo.getInt( "DATA_TYPE" );
s.getTransactionCoordinator().getJdbcCoordinator().release( columnInfo );
s.getTransactionCoordinator().getJdbcCoordinator().release( columnInfo, columnInfo.getStatement() );
assertEquals(
columnName,
JdbcTypeNameMapper.getTypeName( expectedJdbcTypeCode ),

View File

@ -72,13 +72,13 @@ public class GeneralWorkTest extends BaseCoreFunctionalTestCase {
resultSet = ((SessionImplementor)session).getTransactionCoordinator().getJdbcCoordinator().getResultSetReturn().extract( statement, "select * from T_JDBC_PERSON" );
}
finally {
releaseQuietly( ((SessionImplementor)session), resultSet );
releaseQuietly( ((SessionImplementor)session), resultSet, statement );
}
try {
((SessionImplementor)session).getTransactionCoordinator().getJdbcCoordinator().getResultSetReturn().extract( statement, "select * from T_JDBC_BOAT" );
}
finally {
releaseQuietly( ((SessionImplementor)session), resultSet );
releaseQuietly( ((SessionImplementor)session), resultSet, statement );
}
}
finally {
@ -145,7 +145,7 @@ public class GeneralWorkTest extends BaseCoreFunctionalTestCase {
assertEquals( 1L, personCount );
}
finally {
releaseQuietly( ((SessionImplementor)session2), resultSet );
releaseQuietly( ((SessionImplementor)session2), resultSet, statement );
}
}
finally {
@ -178,12 +178,12 @@ public class GeneralWorkTest extends BaseCoreFunctionalTestCase {
}
}
private void releaseQuietly(SessionImplementor s, ResultSet resultSet) {
private void releaseQuietly(SessionImplementor s, ResultSet resultSet, Statement statement) {
if ( resultSet == null ) {
return;
}
try {
s.getTransactionCoordinator().getJdbcCoordinator().release( resultSet );
s.getTransactionCoordinator().getJdbcCoordinator().release( resultSet, statement );
}
catch (Exception e) {
// ignore

View File

@ -136,7 +136,7 @@ public class AutoDiscoveryTest extends BaseCoreFunctionalTestCase {
Assert.assertFalse( "bad dialect.getColumnAliasExtractor impl", column1Alias.equals( column2Alias ) );
}
finally {
sessionImplementor.getTransactionCoordinator().getJdbcCoordinator().release( rs );
sessionImplementor.getTransactionCoordinator().getJdbcCoordinator().release( rs, ps );
sessionImplementor.getTransactionCoordinator().getJdbcCoordinator().release( ps );
}
}