Interceptor.afterTransactionCompletion not called with JTATransaction (CacheSynchronization.hibernateTransaction not set)
-------------------------------------------------------------------------------------------------------------------------
Key: HHH-1956
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1956
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.2
Environment: JBoss 4.0.3SP1 under Windows XP
Reporter: Eric Sword
interceptor.afterTransactionCompletion should be invoked in SessionImpl.afterTransactionCompletion, but it is only called if the tx parameter is not null. When running under a JTA environment, that parameter will always be null. This is the stack which leads to the call (line numbers are from v3.1.2 code):
org.hibernate.impl.SessionImpl.afterTransactionCompletion(boolean, org.hibernate.Transaction) line: 442
org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(boolean, org.hibernate.Transaction) line: 205
org.hibernate.transaction.CacheSynchronization.afterCompletion(int) line: 85
org.jboss.tm.TransactionImpl.doAfterCompletion() line: 1508
org.jboss.tm.TransactionImpl.completeTransaction() line: 1180
org.jboss.tm.TransactionImpl.commit() line: 359
org.jboss.tm.TxManager.commit() line: 224
org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit() line: 126
org.hibernate.transaction.JTATransaction.commit() line: 146
The problem is that the hibernateTransaction member variable of the CacheSynchronization object is never set. Here is the call stack for how that object is created:
org.hibernate.transaction.CacheSynchronization.<init>(org.hibernate.transaction.TransactionFactory$Context, org.hibernate.jdbc.JDBCContext, javax.transaction.Transaction, org.hibernate.Transaction) line: 34
org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible() line: 149
org.hibernate.transaction.JTATransaction.begin() line: 102
org.hibernate.impl.SessionImpl.beginTransaction() line: 1309
com.osc.util.hibernate.HibernateManager.getSession(org.hibernate.Interceptor) line: 204
You can see in the JDBCContext.registerSynchronizationIfPossible() method that the parameter to set the transaction is always null, even though the JDBCContext object does have a reference to the hibernateTransaction at that point. The CacheSynchronization only uses that reference for beforeTransactionCompletion and afterTransactionCompletion calls. The beforeTransactionCompletion works because the SessionImpl.beforeTransactionCompletion call doesn't check if the tx is null, while the afterTransactionCompletion does.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
|