I am using spring 2.5 and hibernate 3.2 version and a view framework ZK.
My problem is associated with Lazy association fetching. I am using OpenSessionInViewFilter and configured in web.xml successfully.
I can see it working with the spring DEBUG and I see the following out put when a request is initiated :
However, I am unable to get the Lazy loading working. I get the following exception when tried to fetch a Lazy association :
The exception stack trace also shows these lines at the start :
Which shows that OpenSessionInViewFilter did get called and opened the session.
For my own debugging purpose I wrote this line of code just before the line which tries to lazy load the data :
And checked to see if SessionHolder is null, but to my surprise I did get a full object and that means that there is a session bound to thread, then why am I getting the above exception.
I have also got the spring DEBUG logs which shows there is a session bound to the thread:
What am I doing wrong here? I simply can't get Lazy load to work, and right now I am left with nothing but to turn off Lazy loading.
It's impossible to help with the information provided--the OSiV filter works, people use it all the time. It's possible there's something in the framework that renders it non-functional--have you tried doing something in a simple servlet to make sure it's working at least that far? If it is, you'd then need to start looking at how the framework handles requests.You know about import statements, right?
Joined: Apr 24, 2008
Thanks for the reply.
You know about import statements, right?
Actually, that code is from .zul file where I am rendering my entity (User's information) to be updated. And .zul file requires you to mention fully qualified name of the class.
"Hibernate does not support Lazy initialization for detached object"
David, could this be the reason?
If I understood this statement correctly, then is it required that you have to lazy initialize an association in the same hibernate session?
Hibernate doc says :
Now, what, if I do this
In this case there is a session, the error mustn't appear now. Please help me get clarified on this issue, please.