Lazily loaded collections has no session if method is not marked @Transactional
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
_From [alex.chevelev](https://code.google.com/u/110346463942972762684/) on August 19, 2013 11:18:19_
Description of the issue: Encountered a problem with how lazy loaded collections were workng. When I request collection data in the processing I'm getting:
{{{
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ..., no session or session was closed
}}}
I've found that there's no session in hibernate's PersistentBag I access. I've tried to mark method as `@`Transactional and it worked to my confusion.
I really dislike the solution as my *data-reading* method may now modify underlying data as a side-effect. Steps to reproduce: 1. Create a class with lazily loaded collection (N-N in my case).
2. Query the data so the lazily loaded collection field wasn't fetched
3. Try to iterate over collection
4. org.hibernate.LazyInitializationException is thrown
Guice-Persist 3.0
Hibernate 3.6.10.
_Original issue: http://code.google.com/p/google-guice/issues/detail?id=765_
Contributor guide
Assessment
This issue has not been assessed yet.