org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: contacts.resources.Category.subcategory, could not initialize proxy - no Session


Samebug tips

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


,
via Stack Overflow by JamesENL

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


,
via Stack Overflow by Kleber Mota

Solutions on the web

Solution icon of stackoverflow
failed to lazily initialize a collection of role: contacts.resources.Category.subcategory, could not initialize proxy - no Session

Solution icon of stackexchange-tridion
failed to lazily initialize a collection of role: com.sdl.web.discovery.datalayer.model.jpa.JPAConfigurationItem.using, could not initialize proxy - no Session

Solution icon of stackoverflow
failed to lazily initialize a collection of role: es.mycompany.myapp.Patient.ids, could not initialize proxy - no Session

Solution icon of coderanch
failed to lazily initialize a collection of role: org.jbiz.model.Country.regions, could not initialize proxy - no Session

Solution icon of github
failed to lazily initialize a collection of role: com.jhipster.domain.Job.tasks, could not initialize proxy - no Session

Solution icon of github
via GitHub by mvysny
, 3 months ago
failed to lazily initialize a collection of role: com.example.vok.Article.comments, could not initialize proxy - no Session

Solution icon of github
failed to lazily initialize a collection of role: org.osc.core.broker.model.entities.virtualization.SecurityGroup.securityGroupMembers, could not initialize proxy - no Session

Solution icon of spring
via Spring JIRA by Gavin Foley, 1 year ago
failed to lazily initialize a collection of role: com.example.domain.AuthorEntity.books, could not initialize proxy - no Session

Solution icon of stackoverflow
failed to lazily initialize a collection of role: com.kyrogaming.models.Users.matchs, could not initialize proxy - no Session

Solution icon of stackoverflow
failed to lazily initialize a collection of role: com.br.common.catalog.entity.Category.allParentCategoryXrefs, could not initialize proxy - no Session

Stack trace

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: contacts.resources.Category.subcategory, could not initialize proxy - no Session
	at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:575)

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

3 times, 2 weeks ago
Once, 3 months ago
5 times, 3 months ago
3 times, 3 months ago
Once, 4 months ago
40 more bugmates