I don't want to check anything that has to do with internal state of session, the flag is just a boolean value held inside my FlagHolder, for example:
Code:
class FlagHolder {
Set<SessionImplementor> allowedSessions;
public static boolean isLazyInitAllowed(SessionImplementor session) {
return allowedSessions.contains(session);
}
}
Yes, I would like to associate this type of checking with particular sessions, not with my application context for example. And at this level I don't want to check if the session is connected, if not HibernateException will be thrown later.
I could, of course, hold my own session reference inside my objects, but why should I do this if Hibernate does this for me?