Not sure if this is the desired behavior here, however, I am providing my own database connections on session creation. I am using the Session as a cache for retrieving specific user data within form fields for prepopulating them. I do not have a datasource defined in my hibernate properties since I am providing my own connections at session creation.
What I'm doing is calling sessionFactory.openSession() without passing in a jdbc connection which gets me a Session without a db connection. However I notice the isConnected() method returns true. I could get around that by calling session.disconnect(). Now here comes the weird part. Before retrieving data, I call session.reconnect() and pass in a jdbc connection. If I then call session.disconnect() after I'm done, I get an UsupportedOperationException and the session says I need to provide a jdbc connection. This behavior doesn't happen if I initially open the session with a jdbc connection and call disconnect() then reconnect() repeatedly.
It seems questionable why I am doing this, however, I'm trying to not tie up my database connections since they're very "precious". :)
I know this is probably atypical behavior, however, it seems that the session object shouldn't behave this way.
If anyone has any comments, etc, I'd be more than happy to read them.
-John
_________________ ---
John Caruso
Senior Nut
ivillage.com
|