Software Development, Linux, and Windows

Notes on Software Development, Linux, and Windows

SpringMVC

How to resolve LazyInitializationException with SpringMVC using JPA with Hibernate

Follow the below steps if you see the org.hibernate.LazyInitializationException being thrown while trying to render your page. Add a filter to your web.xml file: <filter> <filter-name>SpringOpenEntityManagerInViewFilter</filter-name> <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>SpringOpenEntityManagerInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

Posted in Hibernate, JPA, SpringMVC | Comments Off