File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Lazy Loading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Lazy Loading" Watch "Lazy Loading" New topic
Author

Lazy Loading

muin shariff
Greenhorn

Joined: Apr 29, 2004
Posts: 1
Hi all,
I am searching for a sample implementation of lazy loading in bmp entity beans.My Application requires that part of the entity bean be loaded when a particular API1 is called and the full details when API2 is called.I want to use the same entity bean for both the calls.Could some one help me out....
thanks.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Say you had a customer index file that registered what products were owned by customers, and a whole set of product files that had product details, like what color and size and other options they ordered.

The first call to create a new product from database data might not read the database at all. It builds an empty shell of a product object. The second call to getOwner() might read the customer index to populate owner fields. And the last call to getSize() might read the product file to populate product fields.
I'm makin this up as I go, so it's not a great looking example. But you get the idea that it may be expensive to get some of the data so we only fetch the data if a client asks for it.
Thinking about it, I've seen something like this with browsing. Maybe you only have to display customer name and product type in the browse products window. You could build Product objects with only this much data. Then when the user selects one product from the list and you want to show all the details, the Product object would know to fetch the rest of the data.
Any of that help?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
GeeCON Prague 2014
 
subject: Lazy Loading