org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.test.hibernate.ChildEntity.parents, no session or session was closed

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Solutions on the web

via Spring JIRA by Siarhei Sakovich, 1 year ago
failed to lazily initialize a collection of role: com.test.hibernate.ChildEntity.parents, no session or session was closed
via Spring JIRA by Siarhei Sakovich, 1 year ago
failed to lazily initialize a collection of role: com.test.hibernate.ChildEntity.parents, no session or session was closed
via Oracle Community by 843833, 1 year ago
failed to lazily initialize a collection of role: entities.User.userattributeCollection, no session or session was closed
via scriptscoop.net by Unknown author, 1 year ago
failed to lazily initialize a collection of role: ru.hostlux.emailmanager.entity.hldovecot .DovecotHost.domains, no session or session was closed
via Stack Overflow by Caleb
, 2 years ago
failed to lazily initialize a collection, no session or session was closed
via Stack Overflow by mtchinthaka
, 2 years ago
failed to lazily initialize a collection of role: com.pos.entities.Item.itemPrices, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.test.hibernate.ChildEntity.parents, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:119)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:644)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:612)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.addWorkToBuilderQueue(BatchedQueueingProcessor.java:270)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.processWorkByLayer(BatchedQueueingProcessor.java:248)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:147)
at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.beforeCompletion(PostTransactionWorkQueueSynchronization.java:70)
at org.hibernate.engine.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:530)
at org.hibernate.jdbc.JDBCContext.beforeTransactionCompletion(JDBCContext.java:229)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:271)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:176)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1396)
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1009)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:374)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at com.test.hibernate.TestService$$EnhancerByCGLIB$$f6772efb.update()
at com.test.hibernate.TestHb.testHb(TestHb.java:26)

Users with the same issue

2 times, 10 months ago
2 times, 1 year ago
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 5 months ago
Samebug visitor profile picture
Unknown user
Once, 10 months ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.