Just started with JBoss + EJB 3 + Hibernate.

I have some simle SessionBean object, in which it obtains Hibernate Session 
object and performs db related operations. I configured the Hibernate to use 
JTA from JBoss by specifying Hibernate property 
jta.UserTransaction=UserTransaction. Then I found that my transaction is not 
committed, nor rolled back on exception. 

It turns out that the UserTransaction object bound to the JNDI name 
UserTransaction from JBoss is a global object that get reused again and again 
in different invocation of the SessionBean methods. I verified this by writing 
a simple add(int a, int b) method which does not use Hibernate at all and 
prints the System.identityHash(UserTransaction) to the console. 

I did try to set the transaction attribute of the method to be REQUIRES_NEW but 
no luck.

It is aparently some basic things I am doing wrong. How do I obtain the 
transaction object that is associated with SessionBean method invocation? The 
transaction object that will auto rollback when I throw an exception and auto 
commit when the method exits properly?

I searched posts and googled a round for a long time but didn't find the 
answer. Thanks in advance for any help!

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954581#3954581

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954581

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to