How does EJBs address this issue? thanks.
-----Original Message----- From: Gavin King [mailto:[EMAIL PROTECTED] Sent: Monday, 27 October 2003 2:12 PM To: Andrew Zeon Cc: Hibernate (E-mail) Subject: Re: [Hibernate] Lazy initialization problem Really, the correct approach is to use lazy initialization together with "open session in view". Alternatively, you can use an OUTER JOIN FETCH query to retrieve the users more efficiently. Andrew Zeon wrote: >Hi, > >I have a class called CompanyImpl which represents a company. Within this >class I have a list of users (List that contains a UserImpl objects). Our >application uses a MVC model. Right now, we have a class callled >DataAccessLayer which has all the persistence methods. There are 'restore' >methods which restore enties such as companies or users. > >The problem I have is, when restoring a company, Hibernate restores all the >user's within the company since CompanyImpl has a List of UserImpl. I tried >using lazy initialization but did not work due to the reason that the >session has been committed before I retrieve the users. > >I found this FAQ on the Hibernate website: > >http://hibernate.bluemars.net/118.html#A11 > >I was wondering if anyone has an alternate solution to this problem. When a >company has many users, it is taking ages to load up since it has to restore >all the users within the company. I could write hand-written JDBC code >instead of using Hibernate's session.load method, but I wanted to ask the >Hibernate community first to see if there are any other alternatives. > >Thanks. > >Regards, > >Andrew > > >------------------------------------------------------- >This SF.net email is sponsored by: The SF.net Donation Program. >Do you like what SourceForge.net is doing for the Open >Source Community? Make a contribution, and help us add new >features and functionality. Click here: http://sourceforge.net/donate/ >_______________________________________________ >hibernate-devel mailing list >[EMAIL PROTECTED] >https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > ------------------------------------------------------- This SF.net email is sponsored by: The SF.net Donation Program. Do you like what SourceForge.net is doing for the Open Source Community? Make a contribution, and help us add new features and functionality. Click here: http://sourceforge.net/donate/ _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel