Hibernate version:
3.0.5 / 3.1.3
Configuration:
The hibernate configuration:
Code:
<property name="connection.datasource">java:comp/env/jdbc/POCTEST</property>
<property name="transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
Name and version of the database:MS SQL Server 2000
CodeI have a CMT session bean with following business method :
Code:
public void testHistory() {
Configuration config = new Configuration();
config.configure();
factory = config.buildSessionFactory();
s = factory.openSession(new TestInterceptor());
Customer cust = (Customer)s.load(Customer.class, new Integer(1001));
cust.setName("New Name");
s.update(cust);
}
When this EJB method is called from a servlet, Customer object is updated successfully in DB. On this hibernate calls following interceptor callback methods (Note that I have not started/comitted the transaction explicitly nor closed the session):
Code:
onLoad()
preFlush()
onFlushDirty()
postFlush()
beforeTransactionCompletion()
The problem is,
Transaction argument passed to the
beforeTransactionCompletion() is null and hence I am not able to rollback the parent transaction if my code in this method fails.
The transaction is null even if I explicitly begin/commit the transaction on hibernate session.
Instead of EJB if I run the above method from a standalone application it works fine.
Any help on this is really appreciated.