[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5750) Envers unset session on proxy
Sven Rienstra (JIRA)
noreply at atlassian.com
Wed Nov 24 03:48:13 EST 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39196#action_39196 ]
Sven Rienstra commented on HHH-5750:
------------------------------------
I'm not using the Tools class directly, but after I inserted an audited object, an other audited object had lost it's session and I identified this tools method as the cause. I'll try to explain the scenario:
I have 2 classes Person and Target. Person has a list of targets. Target has a ManyToOne relation to Person and Person has an OneToMany(mappedBy="person"). Both classes are audited.
After I called saveOrUpdate to insert a new target, the session from all proxies in the Person object are gone. So when I try to get the list with targets from the person, I get a no session error.
-- Code fragment:
//Doel = target, Patient = person
//Patientmodel is a Wicket model holding a patient proxy
Doel doel = this.getModelObject();
doel.setZwipPatient(patientModel.getObject());
doelenService.saveOrUpdate(doel);
//Current workaround
hibernateService.getHibernateSession().evict(patientModel.getObject());
patientModel.detach(); <== Creates a new proxy
patientModel.getObject().getDoelen(); <==Breaks without workaround, because the Patient proxy now contains an implementation linked to a closed session. (the temporary session created in the tools method)
-- END
I Hope this clarifies the bug a bit. The only I reason I wrote the testcase this way is because when I was debugging I found the session was removed from the PersistentBag by this method in Tools.
> Envers unset session on proxy
> -----------------------------
>
> Key: HHH-5750
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5750
> Project: Hibernate Core
> Issue Type: Bug
> Components: envers
> Affects Versions: 3.6.0
> Reporter: Sven Rienstra
> Attachments: ToolsTest.java
>
>
> A bug in envers Tools causes proxy objects to lose their session after post-insert actions have been performed. The function Tools.getTargetFromProxy loads an instance of the proxytarget with a temporary session, puts the instance into the proxy and finally closes the session. After this all the persistentbags in the instance have lost their session because it is closed. The attached testcase demonstrates this behavior.
> I'm not sure how this should be fixed, but i guess the proxy should be reattached to the old session after envers is done with it.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list