> as far as I can see the default behaviour of
> hibernate is, as you said, 
> to fetch an object's collections when it is loaded.
> To avoid fetching 
> too many objects hibernate recommends to use lazy
> loading. With lazy 
> loading you have to initialize an object's
> collection before you can 
> access it.

You have not. It's done automatically. ( Hibernate
uses byte code engineering / voodoo to generate
proxies on the fly. not only for collections )

Typically, there will be collection proxy holding 
query. ON first accsess to collection ( emtiness 
/ size check ) ID of persistent objects will be loaded
( proxies for object are created in collection ) 

Objects itself will be fetched if and only you access
it.  This behaviour can be tuned pretty well...


> However you need a hibernate session to initialize
> collections but in a 
> layered architecture you typically can not (and do
> not want to) retrieve 
> a hibernate session in every layer. If this is the
> case there is no 
> choice but explicitly asking the "hibernated layer"
> to initialize the 
> collection, right? Is there some recommended
> strategy / pattern / 
> anything else?

You do not have to retrieve session.  Persistent
object proxy knows where the session is. You have to
watch that this session is stil alive when you access
this 
object.

BUt typically when you use layered architecture, you 
are in web environment. There is common pattern to
manage session in request filter, or store it in
thread local ( iut's not threadsafe anyway ) 




I would really recomend reading hibernate forum. 
There is lot of information about layered
architectures etc. 

regards,

=====
----[ Konstantin Pribluda ( ko5tik ) ]----------------
Zu Verst�rkung meines Teams suche ich ab Sofort einen
Softwareentwickler[In] f�r die Festanstellung. 
Arbeitsort: Mainz 
Skills:  Programieren, Kentnisse in OpenSource-Bereich
----[ http://www.pribluda.de ]------------------------

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster
http://search.yahoo.com


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to