meghanai_99 wrote:
Thank you so much for your replies. I got correct antrl jar in the class path and removed 'select' and 'as' keywords from the query. That seemed to work for simple columns.
But I got 'LazyInitializationException' when it tried to get usergroups which is a 'Set' in my class for individual user. It seems when I try to get the group information in my JSP frontend, it tries to populate the 'Set' at that time so my 'session.commit()' is already called in the user manager's search method and session is lost.
Is there a way to override the 'Late Binding'?
Thank you,
Meghana
JSP... ah lookup "Open Session in View" design pattern. I swear by it :)
What is happening is that you are expecting to be able to reference an object you found in your servlet from your JSP code.
The problem, the normal HibernateSession Singleton pattern people start out with only exists around the Servlet part (the Controller part) and by the time the JSP is executed (the View part) the session is closed.
You can't access proxied objects after you close the session.
http://www.hibernate.org/43.html
Other choices you have (since Open Session in View is not trivial to setup for the beginner):
Configure lazy settings in your map files:
http://www.hibernate.org/315.html
If your application is simple maybe you can turn a proxied object into a detached one before you pass it to JSP. Infact if you find out how to do this please post back here :) but I can imagine the reasons why you cant, since do you deep-clone or not and if you deep-clone how do you deal with circular references backed by infinaly huge graphs. Minefield!
No Open Session in View is the way :)
Or be hardcore and create your own Data Transfer Objects for the presenation layer.