I have been reading various posts on this topic. The most significant being:
http://www.hibernate.org/124.html
I was wondering is there some pattern or design to allow lazy instantiation failover? Such as from the UI.
The very simplest would be have a configuration such that you could catch LazyInstantiationException and then take the suspect object and lock it to a newly created session.
One example I have of this is using the DisplayTag TagLib. If I don't preload the entire bean list that I pass to the UI it will throw an exception if I try to do an XML export etc. To work around this I have only found 2 solutions. The first is to preload every attribute of each bean at the DAO level when I retrieve them. This is obvously not a great solution. The second is to call a specific method in my DAO to preload specific attributes of the beans. This also is not the best since I have to anticipate what attributes will be accessed.
Another solution that I am considering is to somehow intercept the 'LazyInstantiationException' and have the framework auto associate the object with a new or current session. I am not sure how to approach this exactly and would welcome comments.
Thanks
Troy McKinnon