-->
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.  [ 2 posts ] 
Author Message
 Post subject: Session/Transaction life cycle question
PostPosted: Fri Feb 18, 2005 2:25 pm 
Newbie

Joined: Wed Sep 29, 2004 10:10 am
Posts: 13
Location: Washington D.C. USA
Hi

I am using Hibernate 2.1. My web application is comprised of Presentation, business and data layers.
1. The business layer has a stateless session bean which calls DAO in the data layer.
2. The DAO gets session from SessionFactory calling its openSession method.
3. DAO then begins transaction, calls session.saveOrUpdateCopy(), commits the transaction, and finally calls closeSession().

I am under the impression that stateless session bean will start a transaction upon the entry in any of its method. DAO's begin transaction should join the current transaction. My question is, do DAO's calls to commit the transaction and closing the session cause actual update in the database ? If yes, how will session bean's setRollbackOnly() works ?

My assumption is Hibernate just does the commit to the session cache and at the end of session bean's method, actual commit to the database happens. Is it correct ?

If my assumption is wrong, how would you suggect to handle a session and a transaction so I can call session bean's setRollbackOnly to rollback the transaction in case of an exception in business layer ?

Thank you.
Ram Mahajan


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 19, 2005 8:14 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I think you misunderstood how hibernate transaction api works. Have a look at the reference guide and if you can, buy and read Hibernate in Action. Your ideas will be much more clear.

_________________
Emmanuel


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