I am trying to understand why my web application throws a LazyInitializationException when trying to lazily initialize a collection in an entity object.
>From what I have read, I needed to setup a filter for Hibernate in my web.xml and since I am using JPA the filter was defined as follows: <filter> <filter-name>hibernateFilter</filter-name> <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInVie wFilter</filter-class> <init-param> <param-name>entityManagerFactoryBean</param-name> <param-value>entityManagerFactory</param-value> </init-param> </filter> And then the mapping was set as follows: <filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> // LoginAction.java public String execute() { User user = userService.authenticate(userName,password); if(user != null) { setSessionObject(Constants.USER_KEY, user); return Action.SUCCESS; } return Action.ERROR; } When a user is at the login form and the LoginAction execute() method is called, the user object is instantiated properly from the user service and contains all the eagerly pulled values. I then click on another URL which calls another action's execute method that does the following: public String execute() { User user = getSessionObject(Constants.USER_KEY); if(user != null) { if(user.getUserRoles().size() > 0) { // do some other stuff } } return Action.ERROR; } The problem is when getUserRoles() is called, I get the error because they are not pulled eagerly when the User entity is first fetched from the database. Is there a way I can avoid this LazyInitializationException problem? --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org