Enterprise JavaBeans
Types of EJBs
Entity Beans
- Used to model persistent objects
- Object state is stored in a persistent data store, usually a relational or
object database
- A primary key class is used to identify an individual object
- Lifecycle methods are used to locate objects and manage the persistence
- Create new object (SQL Insert)
- Destroy object (SQL Delete)
- Save state (SQL Update)
- Find an existing object and retrieve its state (SQL Select)
- Two ways to manage persistence
- Container-managed persistence (CMP)
- Tools are used to map object attributes to a database
- The mapping is deployed to the EJB container
- The container generates the necessary SQL at runtime
- In EJB 1.1, CMP is limited to objects that map to a single
database table (i.e. no dependent object, no table joins); this
restriction is relaxed in EJB 2.0
- Bean-managed persistence (BMP)
- The application developer supplies the appropriate code in the
various lifecycle methods
- The EJB container calls the lifecycle methods when necessary