Lazy loading BMP beans in VisualAge for Java 4.0 Websphere Test Environment?
1 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Thursday, November 8, 2001 11:31 PM

How do I implement lazy loading (BMP) in VA Java's Websphere test environment?

I tried like this:




select Foreign key of related table



some method ()

lookup for other bean



Re: Lazy loading BMP beans in VisualAge for Java 4.0 Websphere Test Environment?

Posted By:   Bozidar_Dangubic  
Posted On:   Sunday, November 11, 2001 11:40 AM

well, you may need to elaborate on "lazy loading" the container uses bean callbacks when certain client operations are peformed. the container will call ejbLoad() to load the data if client performs findByPrimaryKey because it knows what to load. the container will not call ejbLoad() if client invokes findBySomethingElse which returns a Collection as a result. you can say that container performs lazy loading for you automatically when search results are Collection versus single result (such as the case with findByPrimaryKey). if you want to implement lazy loading even for findByPrimaryKey call, leave ejbLoad() blank. create a method which loads the data for you and call at the top of each business method. therefore, nothing will get loaded until the client actually needs it. so simple example: lets say you have two business methods in your bean, getStockPrice(String company) and setStockPrice(String company). here is what you can do.

public void ejbLoad()
// ... empty for lazy loading

private void loadData()
// ... go to DB and get the data
public double getStockPrice(String company)
return stock_price_of_company;

public void setStockPrice(String company)
About | Sitemap | Contact