Show TOC

Using Session Bean CRUD Facade TemplateLocate this document in the navigation structure

Use

To operate with the database of your application you need at least the four basic functions - create, read, update, and delete (CRUD). These functions are provided by the CRUD facade. Using the SAP NetWeaver Developer Studio you can apply the Session Bean CRUD Facade template to one or several entities, and generate CRUD facades using stateless session beans. After applying the template, you can implement the business logic of your application.

Prerequisites

You have an EJB project created with Java Persistence facet with at least one entity to which you want to apply the Session CRUD template.

Procedure

You can generate a Session Bean CRUD Facade template in the Project Explorer of the Java EE perspective, or in the JPA diagram editor.

  1. In the Project Explorer , expand the ejbModule node of the EJB project, and select an entity.

  2. In the context menu, choose Apply Template .

  3. In the Templates dialog, select Session Bean CRUD Facade , then choose Next .

  4. (Optional) In the EJB project field, specify the project to store the stateless session beans. You can use an existing EJB project or create a new one. At this point, you can also specify another entity to apply the template to by choosing another persistence unit from a different project in the Persistence unit field and selecting the appropriate checkbox in the Entities field.

  5. Choose Next .

  6. (Optional) Specify the bean class, name, and package for the session bean, then choose Next .

  7. (Optional) Specify additional information about the session bean, such as the mapped name and transaction type, then choose Next .

  8. (Optional) Select the appropriate fields for the named queries.

    Note

    You use these named queries when you want to search by some of the attributes of the entity. The primary key is not listed because it has a named query created by default.

  9. Choose Finish .