O'Reilly logo

Java Enterprise in a Nutshell, Second Edition by David Flanagan, Jim Farley, William Crawford

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

Implementing Entity Beans

An entity bean represents data that is stored in a database or some other persistent storage. Entity beans are persistent across client sessions and the lifetime of the server. No matter when or where you get a reference to an entity bean with a given identity, the bean should reflect the current state of the persistent data it represents. Multiple clients can access entity beans with the same identity at the same time. The EJB container manages these concurrent transactions for the underlying entity, ensuring that client transactions are properly isolated from each other, consistent, persistent, etc.

An entity bean can be passivated by its container, but the meaning of being passivated is slightly different than it is with session beans. A container passivates an entity bean (calling its ejbPassivate( ) method in the process) when it wants to disassociate the bean from the persistent data entity it has been representing. After being passivated, the bean may be put into the container’s “wait” pool, to be associated with another client-requested entity at a later time, or it may be removed from the server altogether.

At a fundamental level, entity beans are implemented similarly to session beans. You need to provide a local and/or home interface, a local and/or remote client interface, and a bean implementation. An entity bean, however, requires some additional methods in its home interface and bean implementation, to support the management of its persistent ...

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