-->
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.  [ 1 post ] 
Author Message
 Post subject: Doubts using JTA (BMT) and Hibernate Transaction API
PostPosted: Sat Mar 20, 2010 6:15 pm 
Newbie

Joined: Sat Mar 20, 2010 6:11 pm
Posts: 1
Hello, I'm writing to ask about some doubts that I have using JTA (BMT) and Hibernate Transaction API.

According to Hibernate reference documentation (3.8.3 - Current Session context management with JTA)
- "If there is no Hibernate Session associated with the current JTA transaction, one will be started and associated with that JTA transaction the first time you call 'sessionFactory.getCurrentSession()'"
- "Your code can either use JTA programmatically through UserTransaction, or (recommended for portable code) use the Hibernate Transaction API to set transaction boundaries"

But, according to section (11.2.2. Using JTA)
- "If you use bean-managed transactions (BMT), Hibernate will tell the application server to start and end a BMT transaction if you use the Transaction API. The transaction management code is identical to the non-managed environment"
- "If you want to use a transaction-bound Session, that is, the getCurrentSession() functionality for easy context propagation, use the JTA UserTransaction API directly"

My doubts according tests that I have made and example codes of section 11.2.2 "BMT idiom, BMT idiom with getCurrentSession()" are:
- If I use JTA "BMT idiom" without using "JTA UserTransaction API" I can't use getCurrentSession() method?
- So, if I want to use getCurrentSession() method I am forced to use the JTA UserTransaction API directly to get the transaction?
- I can't understand the concept of portability using the Hibernate Transaction API if I use the method 'getCurrentSession()' using the "JTATransactionFactory" configuration, because that method force me to use the "JTA UserTransaction API" which precisely introduces the non-portable code:
Code:
UserTransaction trx = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction")


This doubts have stucked me and don't let me understand this important part of Hibernate's configuration, hope somebody could help with them.

Regards and Thanks!


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

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.