Author Login
Post Reply
Author: steve.ebersole@(protected)
Date: 2008-09-09 17:27:11 -0400 (Tue, 09 Sep 2008)
New Revision: 15167
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/context/JTASessionContext.java
Log:
HHH-3472 : WebSphere + JTASessionContext
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/context/JTASessionContext.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/context/JTASessionContext.java 2008-09-09 19:22:59 UTC (rev 15166)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/context/JTASessionContext.java 2008-09-09 21:27:11 UTC (rev 15167)
@@(protected) @@
throw new HibernateException( "Problem locating/validating JTA transaction", t );
}
- Session currentSession = ( Session ) currentSessionMap.get( txn );
+ final Object txnIdentifier = factory.getSettings().getTransactionManagerLookup() == null
+ ? txn
+ : factory.getSettings().getTransactionManagerLookup().getTransactionIdentifier( txn );
+ Session currentSession = ( Session ) currentSessionMap.get( txnIdentifier );
+
if ( currentSession == null ) {
currentSession = buildOrObtainSession();
try {
- txn.registerSynchronization( buildCleanupSynch( txn ) );
+ txn.registerSynchronization( buildCleanupSynch( txnIdentifier ) );
}
catch ( Throwable t ) {
try {
@@(protected) @@
throw new HibernateException( "Unable to register cleanup Synchronization with TransactionManager" );
}
- Object txnIdentifier = factory.getSettings().getTransactionManagerLookup() == null
- ? txn
- : factory.getSettings().getTransactionManagerLookup().getTransactionIdentifier( txn );
currentSessionMap.put( txnIdentifier, currentSession );
}
return currentSession;
}
- private CleanupSynch buildCleanupSynch(Transaction txn) {
- return new CleanupSynch( txn, this );
+ /**
+ * Builds a {@(protected)
+ * callback.
+ *
+ * @param transactionIdentifier The transaction identifier under which the current session is registered.
+ * @return The cleanup synch.
+ */
+ private CleanupSynch buildCleanupSynch(Object transactionIdentifier) {
+ return new CleanupSynch( transactionIdentifier, this );
}
/**
@@(protected) @@
* JTA transaction synch used for cleanup of the internal session map.
*/
protected static class CleanupSynch implements Synchronization {
- private Transaction txn;
+ private Object transactionIdentifier;
private JTASessionContext context;
- public CleanupSynch(Transaction txn, JTASessionContext context) {
- this.txn = txn;
+ public CleanupSynch(Object transactionIdentifier, JTASessionContext context) {
+ this.transactionIdentifier = transactionIdentifier;
this.context = context;
}
@@(protected) @@
* {@(protected)}
*/
public void afterCompletion(int i) {
- context.currentSessionMap.remove( txn );
+ context.currentSessionMap.remove( transactionIdentifier );
}
}
}
_______________________________________________
hibernate-commits mailing list
hibernate-commits@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-commits