I’m writing a hibernate interceptor and I need to access the hibernate session object. Is their a direct way to access the hibernate session using the interceptor?
What I’m trying to do is to find out what database hibernate has connected to. For various reasons, this is going to be impractical to store as thread local data.
There seems no “official” way of getting hold of the session object neither through
o.h.Interceptorneither througho.h.EmptyInterceptor. Moreover,Interceptor‘s Javadoc says:The only way to get this information seems to be by using reflection and has been answered here.