-->
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: Scope of session vs JTA transaction
PostPosted: Mon Jan 05, 2004 7:58 pm 
Regular
Regular

Joined: Thu Nov 13, 2003 2:55 am
Posts: 71
Location: Sweden
Does the fact that a Hibernate session might span several JTA transactions mean that the session must surround the transaction?

Which of the following are allowed?

1. Session surrounding
Code:
  Session session = sessionFactory.openSession();

  userTransaction.begin();

  // Perform work
 
  userTransaction.commit();

  session.close();

2. Transaction surrounding
Code:
  userTransaction.begin();

  Session session = sessionFactory.openSession();

  // Perform work
 
  session.close();
 
  userTransaction.commit();

3. Transaction "first"
Code:
  userTransaction.begin();

  Session session = sessionFactory.openSession();

  // Perform work
 
  userTransaction.commit();

  session.close();

4. Session "first"
Code:
  Session session = sessionFactory.openSession();

  userTransaction.begin();

  // Perform work
 
  session.close();

  userTransaction.commit();


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 8:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
All depends on the context.
Transaction starting from the session is the most common.
CMT and user transactions conceptually wrap the session.
You can disconnect the session and thus make it span multiple transactions.

All depends on the context and what you are trying to achieve.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 06, 2004 3:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Its preferrable that the session surround the JTA transaction if you are using the read-write cache concurrency strategy.


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.