org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.XXX.collection, could not initialize proxy - no Session

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

Samebug tips

,
via Stack Overflow by JamesENL

Use the proper ORM annotations (@ManyToOne and @OneToMany).

,
via Stack Overflow by Kleber Mota

Use eager fetch (fetch = FetchType.EAGER) annotation.

Solutions on the web

via GitHub by janeklb
, 1 year ago
failed to lazily initialize a collection of role: com.XXX.collection, could not initialize proxy - no Session
via Stack Overflow by svjn
, 2 years ago
failed to lazily initialize a collection of role: com.wpt.models.Item.itemCategory, could not initialize proxy - no Session
via Stack Overflow by Hemanth Gowda
, 2 years ago
failed to lazily initialize a collection of role: com.hemanths.expense.manager.api.hibernate.entity.Category.subCategories, could not initialize proxy - no Session
via Stack Overflow by douglaslee1990
, 1 year ago
failed to lazily initialize a collection of role: com.models.PlanDetail.brochureSections, could not initialize proxy - no Session
via rapidminer.com by Unknown author, 1 year ago
failed to lazily initialize a collection of role: de.rapidanalytics.entity.PropertiesMap.properties, could not initialize proxy - no Session
via Stack Overflow by Faraine
, 2 years ago
failed to lazily initialize a collection of role: xy.Employee.legitimacies, could not initialize proxy - no Session
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.XXX.collection, could not initialize proxy - no Session
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:575)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:214)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:554)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:142)
at java.lang.Iterable.forEach(Iterable.java:74)

Users with the same issue

26 times, 19 hours ago
Once, 4 weeks ago
87 times, 1 month ago
12 times, 2 months ago
Once, 5 months ago

Write tip

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