First page Back Continue Last page Graphics

Load & Store


Notes:

The EntityBean interface has two methods that SessionBean lacks, because they pertain to persistence. ejbLoad( ) is called just after the container loads the bean's state from the database. ejbStore( ) is called just before the container saves the bean's state.
The bean class would use these methods to synchronize additional state data such as calculated fields or related data. Most container-managed persistence beans will leave these methods empty. But if certain data is held in a different format in the database than in the bean instance, these two methods can be used to convert back and forth.
These methods will be empty in most CMP beans. But the following example shows a possible use for them in the CMP CustomerBean class: to store the full name in a String variable and return its value from getFullName( ) rather than call getFirstName( ) and getLastName( ) every time.
The class has a private instance variable for the full name.
The variable is updated whenever new data is loaded from or written to the database.

See the code on the next page...