Accessing an Entity Bean

As we know, an entity bean is an EJB that represents a unique instance of an entity in a permanent data store. Each entity bean is represented by a unique ID: a primary key. Unlike session beans, which are usually created for use, an entity bean represents persistent data and is therefore usually found and retrieved from the data store.

The previous example showed the use of JDBC in a helper object for a session bean. The helper object implemented the Data Access Object (DAO) design pattern, which isolates and encapsulates the data access activity into a coarse-grained object. By using this design pattern, the details of the data and the data access are isolated from the session facade bean.

DAOs can also have utility ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.