On 22 Dec (10:44), Gavin King wrote: > I agree with this. It is the resposibility of the middle tier > to fetch data. If it did not fulfil its part of the contract, > we can't just have the web tier suddenly open connections to > the database. That has all *kinds* of security implications. > > > I can't see any other decent way - the View layer should not > > just assume it got the whole object model available to it...
BTW, using a ThreadLocal is OK in a three tier setup, thanks Gavin for the pointer. I'm not talking about opening "direct connections" to the database, but I think we all agree, that if the View gets an Object from the Business Facade, all properties of this object should be visible and available to the View. They wouldn't be if the Hibernate Session is closed and lazy collections are not initialized. Initializing the Collections in the Business Layer would either mean: a) Initializing all lazy loaded Collections in the Business Layer or DAO with Hibernate.initialize() and serve them with their objects in the usual methods, e.g. "getEmployerByOID()" would return the requested Employer and all of its Employees already initialized, everytime. Somehow, Lazy Loading doesn't make any sense at all. b) Only load the lazy Collections when either a switch is triggered in the Business Facade method "getEmployerByOID(boolean initAll)" or another special method is called "getEmployerByOIDInitAll()". Is there a c)? I'm happy now with the ThreadLocal and a cleanup process at the end of the requeast and just assume, that when I get an Employer from my Business Facade, I can access all its properties. Custom Data Transfer Objects and Data Transfer Maps would somehat remedy this problem, but I don't like these patterns when using POJOs instead of Entity Beans. -- Christian Bauer [EMAIL PROTECTED] ------------------------------------------------------- This SF.NET email is sponsored by: Order your Holiday Geek Presents Now! Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap, MP3 Players, XBox Games, Flying Saucers, WebCams, Smart Putty. T H I N K G E E K . C O M http://www.thinkgeek.com/sf/ _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel