You are right. The List of Items is only populated (and you'll sure wait a long time!) when the 2nd call is made. For sure, if you are to populate so many objects in one List, you will have to find a better way to populate only a part of it.
Also, make sur the the List implementation you are using is not final. As far as I known, there are no "final" Lists in java.util. Additionnal note : be carefull of your getter and setter in Category. They must only set and get without any kind of validation to make sure everything works right (I'm pretty sure you do it correctly anwyay...). Happy time saving! Christian -----Original Message----- From: Dodo [mailto:[EMAIL PROTECTED] Sent: Wednesday, 14 June 2006 12:32 To: [email protected] Subject: Re: lazy loading Cool, Poitras, Just some clarification. So if I retrieve a Category object that has an ArrayList of 1 million Item objects as below Category cat = dao.getCategory( new Long(1) ); this call shud return very quickly as an ArrayList of 1 million Item objects will not be populated. However, if I access Arraylist thru getter of Category as below and try to access list thru its methods as u say List list = cat.getItemList(); // 1st line Item item = (Item)list.get(4); // 2nd line Then it will indeed load those 1 million objects, right?? I assume its the 2nd line above that will actually load the objects from database. Correct me if wrong. If this is the case, it wud be too coool! As this will allow me to pass the list in to methods, presentation tier, different objects and load data only when actually needed. Thanks, Samuel
