HHH-4791 - Invalid assumption made in org.hibernate.envers.tools.Tools#getTargetFromProxy

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18548 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-01-14 00:04:32 +00:00
parent 69d7a853f1
commit 062c5b6ccc
1 changed files with 15 additions and 5 deletions

View File

@ -73,12 +73,22 @@ public class Tools {
} }
SessionImplementor sessionImplementor = proxy.getHibernateLazyInitializer().getSession(); SessionImplementor sessionImplementor = proxy.getHibernateLazyInitializer().getSession();
Session tempSession = sessionImplementor==null ? sessionFactoryImplementor.openTemporarySession() : sessionImplementor.getFactory().openTemporarySession(); Session tempSession = sessionImplementor==null
? sessionFactoryImplementor.openTemporarySession()
: sessionImplementor.getFactory().openTemporarySession();
try { try {
proxy.getHibernateLazyInitializer().setSession((SessionImplementor) tempSession); Object target = tempSession.get(
proxy.getHibernateLazyInitializer().initialize(); proxy.getHibernateLazyInitializer().getEntityName(),
return proxy.getHibernateLazyInitializer().getImplementation(); proxy.getHibernateLazyInitializer().getIdentifier()
} finally { );
proxy.getHibernateLazyInitializer().setImplementation( target );
return target;
// adam, changes in AbstractLazyInitializer render this no longer valid...
// proxy.getHibernateLazyInitializer().setSession((SessionImplementor) tempSession);
// proxy.getHibernateLazyInitializer().initialize();
// return proxy.getHibernateLazyInitializer().getImplementation();
}
finally {
tempSession.close(); tempSession.close();
} }
} }