Ok! we have partly solved the problem of lazy loading in our application, but we have something more over here.
Consider a hierarchy of model objects (or value objects) as:
A contains B
A contains C <Set>
A contains D
... and a few more associations
In my A.hbm.xml and other files i've lazy loading turned on for B,C and D. I display a list of A's in my jsp and it displays fine inspite of the jsp accessing the other embedded objects (because i have configured the OpenSessionInView filter.. and it works fine).
Now the user selects a particular A (out of the list displayed) and different parts of object A is displayed in various tabs in the application. So in the first tab, i get the A from the database (depending upon the id passed in the previous page) and display (say just the B part). Here the user can make changes to B.
I need to save the changes that user makes to B (or effectively A) while the user 'tabs' back and forth in various pages to see the other objects B, C and D. Therefore i need to store A in session and cannot get it from the DB.
When i tab back and forth in various tabs, the jsp's try to access the un-initialized B, set of C, D .. etc. there by causing LazyInitializationException.
Does any one out here face a situation like this? If yes, how do you solve this case? I have one way, but to be honest i dont like that approach.
Any ideas, clues?
My apologies for the lengthy problem statement/ description but it couldn't have helped in any other way.
cheers
nik
|