This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I am developing a sample struts-spring-hibernate program. I have a login screen where user enters his id. In the UserProcessAction app validates whether this user exists. This is implemented in spring-hibernate which return a User object (detached object). Then app will show an account information jsp which ask account information to the user. There is one � to- many mapping between User and Account class. After user enters information about the account , the CreateAccountAction add this account object to User object (User has Set of accounts). But I am not able to save this updated user object. It is throwing following exception �
failed to lazily initialize a collection of role: UserDetails.accounts - no session or session was closed Please help me to solve this problem
Well in order to access the database there has to be a session around. If there is no session, you don't have a Connection to the database. Since the data is not in the object, it was lazy loaded, later on when you try to access the attributes of the object it will want to go to the database, but there is no session and it can't. Bam Exception.
Are you accessing the data in a JSP page, do a search for the "Open Session In View" Design Pattern, or consider eager loading that data.