Hi,
We are using Hibernate for a web application using Oracle 10g as the appn server and Oracle 9.0.2 as the database. We are using Hibernate2.
There are many related objects and thereby, lazy loading is an imp feature which we would want to use. There is a problem in using it by keeping the session open till all the values are loaded. If we do not use lazy loading, then it loads all the objects and thereby the system is very slow and runs out of memory and we need to restart the appn server.
We want to close the session immediately after use. At the same time, want lazy loading feature. We did go thru some of the queries and found the following block in your site.
-----------------------------------------------------------------------------------
Do I have to keep the Session open if I want to use lazy initalization?
Pick one:
Have to keep the Session open (several strategies) until all lazily loaded collections/proxies have been loaded because they have been called.
************* We don't want to keep the session open till all values are accessed ***************
Eagerly fetch all required data with an HQL query before closing the Session.
*********** We are not using HQL *****************************
Reattach, by calling lock() or update() (see the API documentation) a Detached Object (you don't have to do anything special for that) to a new (second) Session when a view that is rendered accesses a lazily loaded property.
************************************************************
Plz let know how the above can be used with small piece of code.
Is it possible to close the session after use and when lazy loading happens, it can load values generating a session if one is not available.
************************************************************
Initialize all (by the specific application use case) required lazy collections and proxies manually with initialize() before you close the Session.
********************This is not using lazy loading which is not a feasible solution as the appn is very slow with all objects loaded ********************
----------------------------------------------------------------------------------
Your help is appreciated.
Thanks and Regards.
Deivanai
|