Defining the global fetch plan have to define this fetch plan, the part of your object network that you want to always load into memory. Let s assume that you always require the seller of an Item. In Hibernate XML mapping metadata you d map the association from Item to User as lazy=”false”: … … The same always load guarantee can be applied to collections for example, all bids of an Item: … … If you now get() an Item (or force the initialization of a proxied Item), both the seller object and all the bids are loaded as persistent instances into your persistence context: Item item = (Item) session.get(Item.class, new Long(123)); The persistence context after this call is shown graphically in figure 13.3. Other lazy mapped associations and collections (the bidder of each Bid instance, for example) are again uninitialized and are loaded as soon as you access them. Imagine that you close the persistence context after loading an Item. You can now navigate, in detached state, to the seller of the Item and iterate through all the bids for that Item. If you navigate to the categories this Item is assigned to, you get a LazyInitializationException! Obviously, this collection
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.
This entry was posted
on Tuesday, January 22nd, 2008 at 11:10 am and is filed under j2ee.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.