I am using hibernate as a ORM tool for my application. When I made any hibernate call to database I am getting the below exception.
Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - no Session
The exception is quite new for me and not getting any proper solution to get relieve from this. Please suggest!
I didn't got any hibernate version or the pojo declaration means, is your mapping based on annotation or mapping file from your description?
And if you are using hibernate relationships then its a common exception for all. I am assuming you declared any relationships on your mapping configuration with LAZY loading.
So just follow below solution to recover from your LazyInitializationException issue.
For Annotation Based : Set from "fetch=FetchType.LAZY" to "fetch=FetchType.EAGER" will fixed the issue.
For Mapping Based : Just add lazy="false" (default to true) with your relationship configuration.