[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2183) org.hibernate.LazyInitializationException: failed to lazily initialize a collection while using lazy set with key as property-ref in the mapping

Belto Nathankuty Thresammal (JIRA) noreply at atlassian.com
Fri Nov 10 01:22:04 EST 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2183?page=comments#action_25229 ] 

Belto Nathankuty Thresammal commented on HHH-2183:
--------------------------------------------------

<set name="titles" table="TTitle" cascade="none" lazy="false" inverse="true" mutable="false">
<key column="ID" property-ref="parentId"/>
<!--key column="ID"/-->
<element type="string" column="title"/>
</set> 

Change lazy="false" 
Ithink it will work

> 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.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list