Unfortunately, I am not convinced and it seems like a bug in Hibernate itself.
According to my understanding, if we close the session (session.close()), the underlying connection should get closed and become unusable. However this does not seem to be the case because we can continue to do operations on PreparedStatement and Resultset even after session.close() has been called. Please run the below code for confirmation.
Re-read my post: don't close the session, close the connection. What Hibernate is allowing is a route to use direct JDBC via a Sesson. You need to uses it pretty much as you would without Hibernate, i.e. obtain a connection, do your work, close the connection. Closing the session implies nothing about the connection.
Hmm. That's interesting, and not how I understand it should work (though admittedly I'm getting this understanding from documentation, rather then playing with the code). Here's an idea: if you are worried about the Connection, why use one? You could just use createSQLQuery(). [ June 23, 2006: Message edited by: Paul Sturrock ]