Hibernate version: 2.1.7c
Name and version of the database you are using: Oracle 10g
IDE: JDeveloper 10g (9.0.5.2)
EJB Container: JDeveloper Embedded OC4J
Hi,
I'm not sure whether the problem is Hibernate's bug or not,
I have following properties in hibernate.cfg.xml
<property name="connection.datasource">jdbc/myDataSource</property>
<property name="hibernate.transaction.manager_lookup_class">net.sf.hibernate.transaction.OrionTransactionManagerLookup</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
Inside a CMT (container managed transaction) session bean with transaction attribute REQUIRED in all methods, I call a data modify method , and then call sessionContext.setRollbackOnly(); but the data modification is done, and transaction is not rolled back!
is it a hibernate bug? or some other thing is wrong?
------------------
the codes are as follow:
try {
Session session = PersistenceUtils.currentSession();
PersistenceUtils.currentTransaction();
session.save(myObject);
session.setFlushMode(FlushMode.COMMIT);
PersistenceUtils.commitTransaction();
return result;
} catch (HibernateException e) {
try {
PersistenceUtils.rollbackTransaction();
} catch (HibernateException he) {
throw PersistenceUtils.translateException(e);
}
logger.error(e, e);
throw PersistenceUtils.translateException(e);
} finally {
try {
PersistenceUtils.closeSession();
} catch (HibernateException he) {
logger.error(he, he);
throw PersistenceUtils.translateException(he);
}
}
-------------------------------------------
CurrentSession and CurrentTransaction are ThreadLocal properties,
according to Hibernate In Action bood, the JTA transaction should not be committed by calling commit on Hibernate Transaction, but the insert is taken place even if I call sessionContext.setRollbackOnly() or throwing a RuntimeException.
_________________ don't forget to credit!
Amir Pashazadeh Payeshgaran MT پايشگران مديريت طرح http://www.payeshgaran.co http://www.payeshgaran.org http://www.payeshgaran.net
|