HHH-7090 - Temporary session closing affects original session

This commit is contained in:
Steve Ebersole 2012-03-20 08:40:50 -05:00
parent 38c4f02cea
commit 1877315ee3
4 changed files with 12 additions and 13 deletions

View File

@ -85,8 +85,8 @@ public class TransactionCoordinatorImpl implements TransactionCoordinator {
TransactionContext transactionContext) { TransactionContext transactionContext) {
this.transactionContext = transactionContext; this.transactionContext = transactionContext;
this.jdbcCoordinator = new JdbcCoordinatorImpl( userSuppliedConnection, this ); this.jdbcCoordinator = new JdbcCoordinatorImpl( userSuppliedConnection, this );
this.transactionEnvironment = transactionContext.getTransactionEnvironment(); this.transactionEnvironment = transactionContext.getTransactionEnvironment();
this.transactionFactory = this.transactionEnvironment.getTransactionFactory(); this.transactionFactory = this.transactionEnvironment.getTransactionFactory();
this.observers = new ArrayList<TransactionObserver>(); this.observers = new ArrayList<TransactionObserver>();
this.synchronizationRegistry = new SynchronizationRegistryImpl(); this.synchronizationRegistry = new SynchronizationRegistryImpl();
reset(); reset();
@ -105,8 +105,8 @@ public class TransactionCoordinatorImpl implements TransactionCoordinator {
List<TransactionObserver> observers) { List<TransactionObserver> observers) {
this.transactionContext = transactionContext; this.transactionContext = transactionContext;
this.jdbcCoordinator = jdbcCoordinator; this.jdbcCoordinator = jdbcCoordinator;
this.transactionEnvironment = transactionContext.getTransactionEnvironment(); this.transactionEnvironment = transactionContext.getTransactionEnvironment();
this.transactionFactory = this.transactionEnvironment.getTransactionFactory(); this.transactionFactory = this.transactionEnvironment.getTransactionFactory();
this.observers = observers; this.observers = observers;
this.synchronizationRegistry = new SynchronizationRegistryImpl(); this.synchronizationRegistry = new SynchronizationRegistryImpl();
reset(); reset();

View File

@ -236,13 +236,14 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled; this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled;
if ( transactionCoordinator == null ) { if ( transactionCoordinator == null ) {
this.isTransactionCoordinatorShared = false;
this.connectionReleaseMode = connectionReleaseMode;
this.autoJoinTransactions = autoJoinTransactions;
this.transactionCoordinator = new TransactionCoordinatorImpl( connection, this ); this.transactionCoordinator = new TransactionCoordinatorImpl( connection, this );
this.transactionCoordinator.getJdbcCoordinator().getLogicalConnection().addObserver( this.transactionCoordinator.getJdbcCoordinator().getLogicalConnection().addObserver(
new ConnectionObserverStatsBridge( factory ) new ConnectionObserverStatsBridge( factory )
); );
this.isTransactionCoordinatorShared = false;
this.connectionReleaseMode = connectionReleaseMode;
this.autoJoinTransactions = autoJoinTransactions;
} }
else { else {
if ( connection != null ) { if ( connection != null ) {

View File

@ -218,7 +218,7 @@ public class AggressiveReleaseTest extends ConnectionManagementTestCase {
Session s = getSessionUnderTest(); Session s = getSessionUnderTest();
s.beginTransaction(); s.beginTransaction();
List entities = new ArrayList(); List<Silly> entities = new ArrayList<Silly>();
for ( int i = 0; i < 10; i++ ) { for ( int i = 0; i < 10; i++ ) {
Other other = new Other( "other-" + i ); Other other = new Other( "other-" + i );
Silly silly = new Silly( "silly-" + i, other ); Silly silly = new Silly( "silly-" + i, other );
@ -227,9 +227,7 @@ public class AggressiveReleaseTest extends ConnectionManagementTestCase {
} }
s.flush(); s.flush();
Iterator itr = entities.iterator(); for ( Silly silly : entities ) {
while ( itr.hasNext() ) {
Silly silly = ( Silly ) itr.next();
silly.setName( "new-" + silly.getName() ); silly.setName( "new-" + silly.getName() );
silly.getOther().setName( "new-" + silly.getOther().getName() ); silly.getOther().setName( "new-" + silly.getOther().getName() );
} }

View File

@ -7,7 +7,7 @@
<class name="Silly"> <class name="Silly">
<id name="id" type="long"> <id name="id" type="long">
<generator class="native"/> <generator class="increment"/>
</id> </id>
<property name="name"/> <property name="name"/>
<many-to-one name="other" class="Other" cascade="all"/> <many-to-one name="other" class="Other" cascade="all"/>
@ -15,7 +15,7 @@
<class name="Other"> <class name="Other">
<id name="id" type="long"> <id name="id" type="long">
<generator class="native"/> <generator class="increment"/>
</id> </id>
<property name="name"/> <property name="name"/>
</class> </class>