HHH-7212 - Fix

This commit is contained in:
Lukasz Antoniak 2012-08-23 22:41:04 +02:00
parent d33d481b52
commit dafe837487
1 changed files with 6 additions and 1 deletions

View File

@ -82,7 +82,7 @@ public class Tools {
public static Object getTargetFromProxy(SessionFactoryImplementor sessionFactoryImplementor, HibernateProxy proxy) {
if (!proxy.getHibernateLazyInitializer().isUninitialized()) {
if (!proxy.getHibernateLazyInitializer().isUninitialized() || activeProxySession(proxy)) {
return proxy.getHibernateLazyInitializer().getImplementation();
}
@ -102,6 +102,11 @@ public class Tools {
}
}
private static boolean activeProxySession(HibernateProxy proxy) {
Session session = (Session) proxy.getHibernateLazyInitializer().getSession();
return session != null && session.isOpen() && session.isConnected();
}
/**
* @param clazz Class wrapped with a proxy or not.
* @param <T> Class type.