-->
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.  [ 3 posts ] 
Author Message
 Post subject: jta transaction doesnt rollback hibernate update in case of
PostPosted: Tue Nov 01, 2005 2:35 pm 
Beginner
Beginner

Joined: Tue Jul 12, 2005 1:50 pm
Posts: 26
Hibernate version: 3.0
Name and version of the database you are using:MySQL

I am using hibernate3, EJB3.0 in jboss-4.0.3SP1. I want jta does all transaction. But, if my ejb cause an exception my hibernate update doesnt rollback.
I dont have any transaction control in my hibernate. and I get the session from session = getSessionFactory().getCurrentSession();
and I dont close session.

Here is my jboss-service.xml:
-------------------------------------
<server>
<mbean code="org.hibernate.jmx.HibernateService"
name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
<attribute name="Datasource">java:/MySqlDS</attribute>
<attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute>
<attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
<attribute name="SecondLevelCacheEnabled">true</attribute>
<attribute name="CacheProviderClass">org.hibernate.cache.EhCacheProvider</attribute>
<attribute name="ShowSqlEnabled">false</attribute>
<attribute name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="FlushBeforeCompletionEnabled">true</attribute>
<attribute name="AutoCloseSessionEnabled">true</attribute>
<attribute name="UserTransactionName">java:/UserTransaction</attribute>
<attribute name="MapResources">
mappings/Users.hbm.xml,
mappings/UserTable.hbm.xml,
mappings/ZoneStates.hbm.xml
...
</attribute>
</mbean>
</server>
------------------------------------------------
And my stateless session bean is like this:

@Stateless
@Local(AdminInt.class)
public class AdminBean implements AdminInt{
...
-------------------------
and the method of ejb is like this:

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public boolean editBedType(BedType bedtype){
BedTypeDAO dao = new BedTypeDAO();
try {
dao.update(bedtype);
int i=100/0;//here I cause an exception. but the update doesnt rollback
} catch (Exception e) {
e.printStackTrace();
}
...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 2:40 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
How should it, if you catch and swallow the exception?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 3:39 pm 
Beginner
Beginner

Joined: Tue Jul 12, 2005 1:50 pm
Posts: 26
Thanks,
You are right. I have to catch HibernateException.
Everything is working fine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.