-->
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 code: where to put it?
PostPosted: Tue Apr 11, 2006 7:36 am 
Beginner
Beginner

Joined: Wed Apr 05, 2006 3:19 pm
Posts: 43
Code:
hibernateUtil.get.......getCurrentSession.beginTransaction();
hibernateUtil.get.......getCurrentSession.getTransaction().commit();
hibernateUtil.get.......getCurrentSession.flush();
hibernateUtil.get.......getCurrentSession.close();


This is very repetitive code and it appears everywhere in the documentation in all possible forms. In some situations, combination A works, in other situation, you don't have to flush the session, in other situations, you HAVE to flush, but you don't have to close, in other..... and so on, and so on. Sometimes proxies have to be initialized, etc...

Now where exactly does this code belong?

_________________
Don't forget to rate my post if it helped. :)


Top
 Profile  
 
 Post subject: Re: Session/Transaction code: where to put it?
PostPosted: Wed Apr 12, 2006 3:37 am 
Newbie

Joined: Sat Nov 22, 2003 9:21 pm
Posts: 18
Location: Malaysia
The answer is not that simple.

- Are we dealing with long application transaction? Definition of long if an application transaction spans between hibernate transaction.
- Do we want to deal with detached object or open session view (means we will only close the session once the application transaction is finish).

The answer to this question will be very different depending on the answers of these two questions.

Regards,
Edward


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.