[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

nhhockeyplayer (JIRA) noreply at atlassian.com
Mon Mar 10 15:02:36 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29747 ] 

nhhockeyplayer commented on HHH-2183:
-------------------------------------

This one remains an issue for

		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate</artifactId>
			<version>3.2.5.ga</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-commons-annotations</artifactId>
			<version>3.3.0.ga</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-annotations</artifactId>
			<version>3.3.0.ga</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-validator</artifactId>
			<version>3.0.0.ga</version>
		</dependency>

We have a persistence service that implements OpenSessionInView and works.

This stack trace though is one hard to crack.

Here is the guy that causes it

Organization.JAVA operates a collection
    Organization--<>----Coach

Coach.JAVA extends from person.JAVA
    Person--<----------Coach

Organization.JAVA
	@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
	@JoinColumn(name = "coach_organization_fk", insertable = true, updatable = true, nullable = true)
	@Collection(child = true, inverse = "organization")
	@PropertyDescriptor(readOnly = false, searchable = true)
	public Set<Coach> getCoaches()
	{
		return coaches;
	}

No fix for this exists


cannot even go near the collection


> 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
>          Issue Type: Bug
>          Components: core
>    Affects 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