-->
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 configuration
PostPosted: Tue Nov 16, 2004 12:43 am 
Beginner
Beginner

Joined: Fri Jun 25, 2004 5:31 am
Posts: 31
Hibernate version: V2.1.6

Name and version of the database you are using:Oracle 8

JBoss : V4.0.0

I have configured Hibernate in JBoss through .har deployer and get the session by the JNDI to the session factory. All working fine except for Transactions.

I use JTA and have given my Transaction demarcation in the deployment descripter of my stateless session bean as :

Code:
<container-transaction>
   <method>
       <ejb-name>Request</ejb-name>
       <method-intf>Remote</method-intf>
       <method-name>executeProcess</method-name>     
    </method>
    <trans-attribute>Required</trans-attribute>
</container-transaction>


Ideally i need the container to rolback the transaction if anything goes wrong withing the method "executeProcess", which does not happen currently in my application. In that method, i call session.save method several times, but if one save operation fails, it doesn't rollback all the other save operations, which is want i'm trying to acieve.

I understand that when the :

Code:
session = HibernateContext.getSession("java:/hibernate/SessionFactory");
session.save(dao);


- gets called several times withing the same transaction, the sessions used get bound to the current context which means to the current JTA transaction. Then why won't the transaction gets rolled back with all the save commands that took place?

Am i missing something in my JBoss JTA configurations? If so can anyone give me some hints on configuring JTA on JBoss.

Thanks alot for considering my issue.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 17, 2004 7:18 am 
Beginner
Beginner

Joined: Fri Jun 25, 2004 5:31 am
Posts: 31
I still could not find the solution but i got this piece of infor when i did some reading and hope if anyone could give me a clarrification on this.
according to http://java.sun.com/j2ee/1.4/docs/tutorial/doc/ :

Quote:
Rolling Back a Container-Managed Transaction

There are two ways to roll back a container-managed transaction. First, if a system exception is thrown, the container will automatically roll back the transaction. Second, by invoking the setRollbackOnly method of the EJBContext interface, the bean method instructs the container to roll back the transaction. If the bean throws an application exception, the rollback is not automatic but can be initiated by a call to setRollbackOnly.


and according to Enterprise JavaBeans, 4th [O'Reilly-2004].chm
Quote:
System exceptions are java.lang.RuntimeException and its subtypes, including EJBException. An application exception is any exception that does not extend java.lang.RuntimeException or java.rmi.RemoteException.



Does this mean that HibernateException s will never get automatically rolledback by the JBoss container since it's not a sub type of RuntimeException?

Well it seemed like that. I wrapped my Hibernate exceptions in one of my own exception class that extends from RuntimeException and it worked. But i'd like to know how this must be handled properly since this is not an elegant solution.

please help :deeply confused:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 17, 2004 7:29 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This is a very easy explanation you have posted, I don't find it confusing at all.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.