Search code examples
javaspringdatabasehibernatesessionfactory

Using load() by second session factory in my project throws org.hibernate.LazyInitializationException: could not initialize proxy - no session error


I implemented the two session factories in my spring hibernate project.

why is it happening, when i use the first session factory for load() it works fine but when i use second session factory for load method it returns the org.hibernate.LazyInitializationException: could not initialize proxy - no session error.


Solution

  • Finally, I got the solution of the above problem. you need to create open session in view for second session factory also and to create the open session in view for second session factory.In web.xml configuration of open session in view for both session factories is required.