]
Gail Badner closed HHH-4791.
----------------------------
Resolution: Fixed
Invalid assumption made in
org.hibernate.envers.tools.Tools#getTargetFromProxy
------------------------------------------------------------------------------
Key: HHH-4791
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4791
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.5.0-Beta-3
Reporter: Steve Ebersole
Assignee: Steve Ebersole
Fix For: 3.5.0-Beta-3
Time Spent: 2 hours
Remaining Estimate: 0 minutes
org.hibernate.envers.tools.Tools.getTargetFromProxy() attempts to initialize a proxy in a
temporary session by calling AbstractLazyInitializer.setSession(tempSession) and
explicitly initializing it.
After HHH-4735 was fixed, AbstractLazyInitializer.setSession(tempSession) started failing
if the proxy was already connected to a session (different from tempSession).
As a result, BidirectionalReference.initData() is failing.
There is another problem with Tools.getTargetFromProxy(). After the proxy is initialized
in the temporary session, it is not reconnected to the original session.
Both issues are fixed by using Session.get() to get the target from the temporary session
and injecting the target into the proxy.
Specifically, the following:
proxy.getHibernateLazyInitializer().setSession((SessionImplementor) tempSession);
proxy.getHibernateLazyInitializer().initialize();
return proxy.getHibernateLazyInitializer().getImplementation();
is replaced with:
Object target = tempSession.get(
proxy.getHibernateLazyInitializer().getEntityName(),
proxy.getHibernateLazyInitializer().getIdentifier()
);
proxy.getHibernateLazyInitializer().setImplementation( target );
return target;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: