-->
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.  [ 5 posts ] 
Author Message
 Post subject: confused with session.close()
PostPosted: Sun Jul 11, 2004 9:18 pm 
Newbie

Joined: Mon Apr 05, 2004 3:48 am
Posts: 8
Software Environment:
WinXP
Hibernate2.1.4
jdk1.4.1
eclipse3.0

As we all know, when we use session's close() function, it will run clearup() and disconnect(). But in disconnect(), there exists some codes as follows:

if (connect) {
connect = false;
return null;
}

My confusion : why not set variable connection null ?

I guess for this reason the test codes as follows can run .

Session session = _sessions.openSession();
session.close();

session.beginTransaction();
session.save(Object);

Another Question:

I guess that no one agree on the pattern of "session per operation", but in a Swing application, how can I manage the session and transaction?
As I know, ThreadLocal and Filter can use in Web App. Maybe I can use
Threadlocal in "session per a frame or dialog".

Any idea?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 4:49 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
The right way is to use session per transaction for any kind of application.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 4:57 am 
Newbie

Joined: Mon Apr 05, 2004 3:48 am
Posts: 8
but how about the granularity of transaction?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 5:04 am 
Newbie

Joined: Mon Apr 05, 2004 3:48 am
Posts: 8
In my application, I use the default transaction, namely jdbc transaction.
And the transaction will declared after session is opened.

In the session per transaction , I guess that I have to use JTA.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 6:24 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
You need JTA for distributed transactions only, but it is more about implementation. You need to think about transaction demarcation only, it is not a persistence aspect, transaction is conceptual thing ( "unit of work" ), but in implementation it can be same as JDBC transaction. You need to use new session per transaction because session local cache becomes invalid at the end of transaction, transaction must be thread local too, but you can have many transactions in the same thread (It is implementation limitation, but it is not problem)


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