O'Reilly logo

Special Edition Using Enterprise JavaBeans™ 2.0 by Brian Keeton, Chuck Cavaness

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading and Storing an Entity

Other than executing business methods, most of the work done by your entity bean involves keeping its state in synch with its corresponding data in the database. This work is done by your ejbLoad and ejbStore methods.

Implementing ejbLoad

The container calls ejbLoad when an entity is activated and needs to guarantee that its state in memory matches what’s in the database. Listing 6.7 shows the ejbLoad method for EnglishAuctionBean.

Listing 6.7. ejbLoad–A BMP ejbLoad Method Retrieves Data from the Database
 package com.que.ejb20.auction.model; ... public class EnglishAuctionBean extends AbstractEntity implements EntityBean { ... public void ejbLoad() { Connection con = null; PreparedStatement stmt = null; ResultSet ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required