|
The Developer's Resource & Community Site
|
EJB Entity Beans
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Container-Managed Persistence, Bean-Managed Persistence
Pre-required Reading: Enterprise JavaBeans
An Entity Bean represents persistent data that are maintained in a domain model, as well as methods that act on that data. Or to be more specific, an Entity Bean exactly maps to a record in your domain model. In a relational database context, there is one Bean for each row in a table. This is not a new concept, since this is how object databases have been modeled all along. A primary key identifies each Entity Bean. Entity Beans are created by using an object factory create() method. Entity beans are transactional and are recoverable following a system crash. Entity beans are also implicitly persistent. An EJB object can manage its own persistence, or it can delegate its persistence to its container.
Entity Beans always have states which can be persisted and stored across multiple invocations. Multiple EJB Clients may however share an Entity Bean. The lifetime of an Entity Bean is not limited by the lifetime of the virtual machine within which it executes. A crash of the virtual machine may result in a rollback of the current transaction, but will neither destroy the Entity Bean nor invalidate the references that other clients have to this Entity Bean. Moreover, a client can later connect to the same Entity Bean using its object reference since it encapsulates a unique primary key allowing the EJB Bean or its container to reload its state. Entity beans can thus survive system shutdowns.
Persistence in Entity Beans is of two types. They are:
Container-managed persistence: Here, the EJB container is responsible for saving the state of the Entity Bean. Since it is container-managed, the implementation is independent of the data source. However, all container-managed fields need to be specified in the Deployment Descriptor for the persistence to be automatically handled by the container.
Bean-managed persistence: Here, the Entity Bean is directly responsible for saving its own state and the container does not need to generate any database calls. Consequently, this implementation is less adaptable than the previous one as the persistence needs to be hard-coded into the Bean.
Every Entity Bean has the following characteristics:
- Entity beans can share access from multiple users.
- They can participate in transactions.
- Entity beans represent data in a domain model.
- They are persistent. They live as long as the data lives in the domain model.
- Entity beans can survive EJB server crashes. Any EJB server crash is always transparent to the client.
- Entity beans have a persistent object reference. The object reference encapsulates the Persistent key for this Bean.
What do you think of this article?
Have your say about the article. You can make your point about the article by mailing [email protected] (If you haven't allready joined, you can join by going to https://www.onelist.com/community/dev-java).
You can also write a review. We will publish the best ones here on this article. Send your review to [email protected]. Please include the title of the article you are reviewing.
Further Reading
The Enterprise JavaBeans Series:
Enterprise Java Beans By Gopalan Suresh Raj.
In this introduction to Enterprise Java Beans, Gopalan covers the bases then goes on to demonstrate how to build server side business object components. This article is the introduction to Gopalans series of Enterprise JavaBeans articles. (This series of articles is courtesy of Gopalan Suresh Raj)
Author: Gopalan Suresh Raj
Date Submitted: January 6th 2000
Level of Difficulty: Advanced
Subjects Covered: Enterprise JavaBeans, EJB Server, EJB Architecture, Java Naming and Directory Interface, Java Transaction Service.
Pre-required Reading: None
Enterprise Java Beans Series - Components at the Server By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Server side components, CORBA
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Model By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Enterprise JavaBeans, EJB Server, EJB Containers, EJB Clients.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Naming Services and JNDI By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Naming Services, Java Naming Directory Interface
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Transactions and JTS By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Java Transaction Service, Two-phase commits
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Lifecycle By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB server provider, EJB container provider, EJB developer, EJB deployer, Application developer.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Servers By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Server Infrastructure
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Containers By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB Containers, EJB Servers
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Components By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB Object, Home Object, Remote Object
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Session Beans By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Stateful Session Beans, Stateless Session Beans
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing an Entity Bean By Gopalan Suresh Raj.
Part 1 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Developing Entity Beans, Home & Remote Interfaces, Data Sources.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing a Session Bean By Gopalan Suresh Raj.
Part 2 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Developing Session Beans, Home & Remote Interfaces, Deployment Descriptors.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing an EJB Client By Gopalan Suresh Raj.
Part 3 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB Clients.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing an EJB Servlet Client By Gopalan Suresh Raj.
Part 4 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Servlet Clients.
Pre-required Reading: Enterprise JavaBeans
Author: Gopalan Suresh Raj
Gopalan has his own site at Author Central (visit him. He also maintains his own site at https://www.execpc.com/~gopalan/) - Contribute to iDevResource.com and you can have one too!
© Copyright 1997-2000 Gopalan Suresh Raj. Reproduced with Permission
|