Using the EntityManager

The entity is used in conjunction with an EntityManager to persist and otherwise ensure the state of the entity is consistent with the database. In this recipe we will examine the use of the PartsBeanFacade class.

Getting ready

To use the entity in a client we need to:

  1. Inject the session facade EJB into the client
  2. Use the methods of the facade

    We will build upon the EntityBeanApplication application developed in the first recipe.

How to do it...

Add a package called servlet and a servlet called PartsServlet to the WAR module. The PartsBeanFacade class extends the AbstractFacade class as developed in the Creating an entity facade recipe. It is associated with a persistence unit through the use of the @PersistenceContext annotation. ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.