[Hibernate-JIRA] Created: (HHH-2119) reloading a detached object with a collection fails
by Gregory Kotsaftis (JIRA)
reloading a detached object with a collection fails
---------------------------------------------------
Key: HHH-2119
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2119
Project: Hibernate3
Type: Bug
Versions: 3.1.3
Environment: Hibernate 3.1.3
firebird 1.5.3.4870 with Jaybird-2.1.0
java 1.5.0_07
Reporter: Gregory Kotsaftis
Hi,
1) I have a simple object <O> with a collection loaded and use <version> for both (no second level cache)
2) The object <O> is associated with session A, via <O> = load(CLASS, <ID>)
3) The session <A> is later closed because e.g. an exception occurs
4) Another session is opened later on, session B
5) If load(<O>, <ID>) is called an NonUniqueObjectException is thrown
(a different object with the same identifier value was already associated with the session)
6) If instead I use the session.refresh(<O>) no exception is thrown, the object is reloaded ok.
It seems this issue might be related with:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-511
but i cannot be sure.
Part of the stacktrace:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [gr.metadata.orthomed.db.Patient#23]
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:132)
at org.hibernate.event.def.DefaultLoadEventListener.returnNarrowedProxy(DefaultLoadEventListener.java:202)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:169)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:770)
at gr.metadata.lib.hibernate.HibernateHelper.reloadObject(HibernateHelper.java:230)
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
16 years, 7 months
[Hibernate-JIRA] Created: (HHH-2183) org.hibernate.LazyInitializationException: failed to lazily initialize a collection while using lazy set with key as property-ref in the mapping
by Artur Jonak (JIRA)
org.hibernate.LazyInitializationException: failed to lazily initialize a collection while using lazy set with key as property-ref in the mapping
------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2183
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2183
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Environment: Oracle 9i
Reporter: Artur Jonak
Priority: Blocker
Attachments: hibernate-testcase.zip
I have an entity which can have multiple titles located in a separate table. I mapped this as a set where key attribute references other property of the entity:
<set name="titles" table="TTitle" cascade="none" lazy="true" inverse="true" mutable="false">
<key column="ID" property-ref="parentId"/>
<!--key column="ID"/-->
<element type="string" column="title"/>
</set>
when I try to display this set I get an exception:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: test.lazysetinit.Record.titles, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
...
The entire mapping is as follows:
<class name="Record" table="TRecord" mutable="false">
<id name="id" type="long">
<column name="ID" sql-type="number" length="12" not-null="true" unique="true"/>
</id>
<set name="titles" table="TTitle" cascade="none" lazy="true" inverse="true" mutable="false">
<key column="ID" property-ref="parentId"/>
<!--key column="ID"/-->
<element type="string" column="title"/>
</set>
<join table="TRecordInfo" inverse="true" fetch="join" optional="false">
<key column="ID"/>
<property name="parentId" not-null="false" />
<property name="status" />
</join>
</class>
Attached the test case: test.lazysetinit.LazySetInitTest. DB schema is located in test/conf/lazysetinit/schema.sql
Regards,
Artur
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
16 years, 8 months