Two Laptop Bag
The moose likes Object Relational Mapping and the fly likes close() / reconnect() / disconnect() question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "close() / reconnect() / disconnect() question" Watch "close() / reconnect() / disconnect() question" New topic
Author

close() / reconnect() / disconnect() question

pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
hi

after i called Session.close() i can still retrieve a Connection trough the Session.connection() method. Shouldnt this method throw an Exception or return null after close() ?

Also after Session.close() i can call Session.reconnect() and get a Exception telling me that the Session is already connected. From what i read in the API the Session.close() cleans up and disconnects the session (yup, i know that i should not reconnect a closed session ... i was just experimenting and this exception puzzled me)

cheers

pascal
Gavin King
author
Ranch Hand

Joined: Aug 31, 2004
Posts: 76
Ah looks like you noticed a little bug. This occurs only if you have a session that never uses the JDBC connection (not even to commit the transaction) which would never occur in practice.

Its a trivial fix.


Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/193239415X/ref=jranch-20" target="_blank" rel="nofollow">Hibernate in Action</a>
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: close() / reconnect() / disconnect() question
 
Similar Threads
Hibernate, ResultSet and PrepareStatement
why to use session.beginTransaction & transaction.commit
Loading and Garbage Collection of EntityClasses by Hibernate
session.close() in hibernate
NullPointerException at the SessionFactory create line.