Hallo,
first of all, we are using
Hibernate 2.0.3
JBoss 3.0.4
MySQL 4.1a
What we are trying to do, is using Hibernate with JTA. The config-file looks something like
Code:
...
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.datasource">java:/MyOwnDS</property>
<property name="session_factory_name">java:/hibernate/HibernateFactory</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="jta.UserTransaction">UserTransaction</property>
<mapping file="...
As I understood, we can use the Hibernate-Transaction-API together with BMT- and CMT-EJBs:
Code:
//--- SFSB method
UserTransaction ut = (UserTransaction)initialContext().lookup("UserTransaction");
ut.begin();
...
session.reconnect();
Transaction tx = session.beginTransaction();
ValueObject vo1 = session.load(ValueObject.class, id);
vo1.someAttribute = 123;
tx.commit();
session.disconnect();
...
ut.rollback();
Rollback was successful, no DB changes were made.
Later we load the same Object again
Code:
session.reconnect();
Transaction tx = session.beginTransaction();
ValueObject vo2 = session.load(ValueObject.class, id);
tx.commit();
session.disconnect();
but Hibernate serves the request from its Session cache(?) and vo2.someAttribute is still == 123. So it looks like the cache is not aware of the JTA transaction.
It would be great if someone could give me a hint, what we are missing here.
TIA
Philipp