These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: transaction could not be rolled back!
PostPosted: Mon Jun 27, 2005 9:21 am 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 5:14 am 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
When I run the same code on Weblogic 7.1 with a TxDataSource the transaction is rolled back, but with a DataSource (non Tx) the transation will not be rolled back eighter.

mmm, Is there any way to build a TxDataSource on OC4J?

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.