org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: test.lazysetinit.Record.titles, no session or session was closed

Hibernate JIRA | Artur Jonak | 1 decade ago
  1. 0

    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

    Hibernate JIRA | 1 decade ago | Artur Jonak
    org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: test.lazysetinit.Record.titles, no session or session was closed
  2. 0

    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

    Hibernate JIRA | 1 decade ago | Artur Jonak
    org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: test.lazysetinit.Record.titles, no session or session was closed
  3. 0

    Hibernate Collection Initailization issue

    Stack Overflow | 5 months ago | Aksanth
    org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.MainData.association, no session or session was closed
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hibernate org.hibernate.LazyInitializationException

    Stack Overflow | 5 years ago | varsha
    org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.ecomm.ultimatesms.messaging.persistence.pojos.Mno.startnumbers, no session or session was closed
  6. 0

    Hibernate LazyInitializationException in web application Struts as MVC, Spring as IOC and Hibernate as ORM layer

    Google Groups | 8 years ago | Amit Jain
    org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.yashbinary.crtracker.vo.MemberVO.apsses, no session or session was closed

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. 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()
    2. Hibernate
      AbstractPersistentCollection.read
      1. org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
      2. org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
      3. org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
      4. org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
      4 frames