Bean Managed Persistence   «Prev  Next»

Lesson 12

Bean Managed Persistence Conclusion

In this module you examined the code for both the home and remote interfaces for entity beans.
Except for addition of the findByPrimaryKey, these were very similar to the code used for session beans.

Creating and finding Beans

The bean provides ejbCreate() and ejbfindByPirmaryKey() methods. ejbCreate() creates both the bean instance and the underlying persistent entity object and synchronizes them. The ejbFindByPrimaryKey() method finds an existing persistent object and synchronizes its data with the bean instance.

Callbacks

The callbacks setEntityContext() and unsetEntityContext() pass the instance's context to the instance and allow the bean to allocate resources. ejbStore() and ejbLoad() allow the container to tell the bean instance when to load and store the data to and from the instance variables. You use ejbActivate() and ejbPassivate() to facilitate the pooling of instances by the container. Finally, ejbRemove() allows the instance to both remove the underlying entity and to put the instance back in the pool.
The next module introduces entity bean finder methods.

Bean Managed Persistent Bean - Exercise

Click the Exercise link below to check your understanding of this module as you complete the project exercise.
Bean Managed Persistent Bean - Exercise