org.hibernate.LazyInitializationException

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

Samebug tips2

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

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

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web146

Stack trace

  • 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 org.hibernate.collection.internal.PersistentBag.iterator(PersistentBag.java:294) at java.lang.Iterable.forEach(Iterable.java:74)

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

serious2monkeysserious2monkeys
26 times, last one
Unknown visitor
Unknown visitor2 times, last one
treanztreanz
4 times, last one
Unknown visitor
Unknown visitorOnce,
PilleoPilleo
Once,
40 more bugmates