Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Lazy Loading

 
muin shariff
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic