hi,
i just realized i'm very often facing repeating problem, maybe someone has suggestions on any pattern to solve it...
suppose there is part of web application where user browses data of some object (and related objects). the view is spawned on several pages (kind of workflow). the object being browsed is loaded on start of the browsing and is being kept in http session for later usage.
the object is related with some other objects and the relation is lazy-loaded.
the problem is that, the first access to the relation is not on first page of the workflow, so it doesn't get initialized (when using thread local session pattern). then the session is closed and relation cannot be loaded.
the only solution that comes to me is to force initialization of the relation after loading the object... but it's inconvenient and ugly - makes my view layer dependent on specific behaviour of data access layer.
session disconnection/reconnection could be solution here, but's inconvenient , too, and has it's drawbacks.
are there any other solutions of the problem?
the perfect one would be to force hibernate to always use current session to load lazy-initialized objects instead of throwing lazyinitializationfailedexception. i guess it's not that simple...
wojtek
|