Unless I'm not understanding your problem, what you are really dealing with is a problem that the connection pool should be handling. For example, if you are using c3p0, there are quite a few settings that you can use to avoid getting broken connections in a Session:
http://www.mchange.com/projects/c3p0/index.html
Quote:
maxIdleTime
Default: 0
Seconds a Connection can remain pooled but unused before being discarded. Zero means idle connections never expire.
Quote:
idleConnectionTestPeriod
Default: 0
If this is a number greater than 0, c3p0 will test all idle, pooled but unchecked-out connections, every this number of seconds.
Quote:
testConnectionOnCheckin
Default: false
If true, an operation will be performed asynchronously at every connection checkin to verify that the connection is valid. Use in combination with idleConnectionTestPeriod for quite reliable, always asynchronous Connection testing. Also, setting an automaticTestTable or preferredTestQuery will usually speed up all connection tests.
Quote:
testConnectionOnCheckout
Default: false
Use only if necessary. Expensive. If true, an operation will be performed at every connection checkout to verify that the connection is valid. Better choice: verify connections periodically using idleConnectionTestPeriod. Also, setting an automaticTestTable or preferredTestQuery will usually speed up all connection tests.
As far as I know, there is no built-in way to recover a session if the connection gets dropped while the session is open. So if it's critical to be able to recover, you will probably have to explicitly handle that exception and retry (or whatever your recovery strategy is) with a new session.
Hope that helps.