[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3846) LazyInit error on persting with detached association
Shorn Tolley (JIRA)
noreply at atlassian.com
Wed Apr 1 21:38:38 EDT 2009
LazyInit error on persting with detached association
----------------------------------------------------
Key: HHH-3846
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3846
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1, 3.2.5
Environment: Reproduced on 3.2.5 and 3.3.1 on Ingres and Postgress databases.
Reporter: Shorn Tolley
Attachments: patch.txt, Sample.zip
Basically, the scenario is, if you try to persist an object that has a detached association AND the target of that association has been loaded by some other code for the same session.
When the above conditions are met, Hibernate will throw a LazyInitException during th persist() operation - which if you think about, doesn't really make much sense.
It is not feasible to reset the association to point to the attached version of the object, as the two pieces of code are completely orthogonal, they just happen to refer to the same object within the scope of a single session. This kind of scenario will occur on any sufficiently complex project.
More details can be found here in this forum post: http://forum.hibernate.org/viewtopic.php?t=995977
I have attached some sample code to reproduce the error in as simple a manner as possible: sample.zip
I have also attached a patch with the change suggested by "nordborg" on the forum: patch.txt
--
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