JPA Manager Beans

JPA Manager Beans are service beans that act as façades or controllers over a particular JPA entity. They encapsulate and abstract all of the data access code for creating, updating, deleting, and displaying information from your database using JPA entities.

JPA Manager beans map in a one-to-one relationship to a JPA entity. For example, if you have a Department entity, you can create a JPA Manager Bean named DepartmentManager, which contains all of the data access logic needed to work with the Department entity.

JPA Manager Beans are a programming model that is ideal for use in two-tier Web environments. JPA Manager Beans fill a role that is similar to the one filled by a session bean in an EJB environment; all of the business logic related to an entity is performed by the JPA Manager Bean.

The use of JPA Manager Beans is not limited to Web applications; they can be used anywhere that you want to take advantage of their data abstraction capabilities, such as a JPA Utility project, or even a plain Java™ project.

It is also possible for you to JPA Manager beans in an EJB project; however, they are not designed or optimized for this purpose. If you want to use JPA inside of an EJB project, then instead of using JPA Manager beans, you might want to create an EJB Session Bean to contain all of your JPA logic so that you get the benefits that the EJB container provides.

JPA entities do not need to reside in the same project as the JPA Manager Beans. For example your JPA entities can exist in a JPA Utility project, and you can generate JPA Manager Beans for those entities inside of a Web project.


Feedback