Introduction to Entity Beans
This module introduces entity beans and discusses their architecture and will look at how entity beans differ from session beans.
Entity beans represent some persistent data that is stored somewhere on-line, locally, or remotely. As this data is unique and has a unique
identity, entity beans use primary keys
to identify them. You will learn to create and use these primary keys.
Bean-managed and container-managed persistence
With entity beans, there are two kinds of persistence. When the programmer writes code that stores and retrieves the data within the bean, it is
called bean-managed persistence
If this responsibility is delegated to the container, which then reads and writes the data automatically on behalf of the bean, it is known as
- container-managed-persistence: The persistence of the data is managed by the ejb container.
Entity bean lifecycle
You will be introduced to the lifecycle of the entity bean. It describes how the container manages the EJBObject, the instances, and their primary keys.
Java EE 8 Application Development
Starting with J2EE 1.3, the specification was developed by the Java Community Process (JCP) under the JSR 58.
Support for entity beans was made mandatory, and EJBs introduced XML deployment descriptors to store metadata (which was serialized in a file in EJB 1.0). This version addressed the overhead of passing arguments by value with remote interfaces, by introducing local interfaces and passing arguments by reference. J2EE Connector Architecture (JCA) was introduced to connect Java EE to EIS.
Java EE was first released in 1999, and ever since, new specifications have been added at each release .
This became a problem in terms of size, implementation, and adoption. Some features were not well supported or not widely deployed because they were technologically outdated or other alternatives
were made available in the meantime. So the expert group decided to propose the removal of some features through pruning. The pruning process (also known as marked for deletion) consists of proposing a list of features for possible
removal in the following Java EE release. Note that none of the proposed removal items are actually removed from the current version but could be in the following one. Java EE 6 proposed the following specification and features to be
pruned, and they indeed disappeared from Java EE 7:
- EJB 2.x Entity Beans CMP (was part of JSR 318): The complex and heavyweight persistent component model of EJB 2.x entity beans has been replaced by JPA.
- JAX-RPC (JSR 101): This was the first attempt to model SOAP web services as RPC calls. It has now been replaced by the much easier to use and robust JAX-WS
- JAXR (JSR 93): JAXR is the API dedicated to communicating with UDDI registries. Because UDDI is not widely used, JAXR has left Java EE and evolves as a separate JSR.
- Java EE Application Deployment (JSR 88): JSR 88 is a specification that tool developers can use for deployment across application servers. This API hasn’t gained much vendor support, so it leaves Java EE 7 to evolve as a separate JSR.
The next lesson introduces the architecture of entity beans.
Uniquely identifies a row in a database.
The enterprise java bean itself is responsible for storing and restoring its state to and from the database.