-->
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.  [ 4 posts ] 
Author Message
 Post subject: When should I use the session.disconnect() method??
PostPosted: Mon Aug 30, 2004 1:33 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Hi everyone:

I had seen this article:

http://www.hibernate.org/hib_docs/reference/en/html/transactions.html
The
Code:
session.disconnect()
and
Code:
session.reconnect()
method puzzled me all the time. I use
Code:
session.close()
when I complete a transaction.And I will use the
Code:
session=sf.openSession()
when I need a new session. But when should I use the session.disconnect() and session.reconnect() method?
Please give me some example .Thks![/code]

_________________
You are not alone...


Top
 Profile  
 
 Post subject: This maillist come across the same problem!
PostPosted: Mon Aug 30, 2004 1:42 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
The url is :
http://www.mail-archive.com/hibernate-devel@lists.sourceforge.net/msg02730.html

The content is here :
Code:
Hi, I am a newbie in Hibernate and I am thinking about applying Hibernate to
a project I will work on in the next few month. And for the project,
concurrency may not be high but data stale can be a disaster. Thus, I am
wondering if it is better to always use session.disconnect() in the business
layer. In fact, if anybody can better explain the difference between these
two methods, i will so much appreciate. Is it true that to use
session.disconnect() may not be necessarily better, but no doubt more
secure?


It is exactly what my problem is. What different between session.close() and session.disconnect() ? [/url]

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 2:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
by calling session.disconnect(), you can reuse the session later (you may also call session.reconnect()).
When you close a session, then you have to discard it... it is _dead_.

reconnect is usefull when having long transaction, for example that spans many user requests, but be very carefull when doing such things, be sure you know exactly what you are doing.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: What is long transaction?
PostPosted: Mon Aug 30, 2004 3:47 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Thk u for your reply.

But What is
Code:
long transaction
? Can you give me an simple example ? I will understand it if I know what is "long transaction". Thks!

I search "long transaction " in google but find few example. : (

_________________
You are not alone...


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