Creating a JPA entity bean by adding persistence to a POJO

With the JPA Tools you to add persistence to plain old Java™ objects (POJOs)

About this task

To create a JPA entity bean:

Procedure

  1. If you have not done so already, create a JPA project or enable JPA support in an appropriate project. Ensure that an active database connection is defined for the project.
  2. Open the JPA perspective. (Click Window > Open Perspective > Other > JPA.)
  3. Create a new Java class (File > New > Class).
  4. In the JPA Structure view, click the name of the class. (If you want to work with another class, first double-click the class in the Package Explorer view to show the class name in the JPA Structure view).
  5. In the JPA Details view, click the Map As drop-down list and select from the following types of persistence to add to the class:
  6. If you selected entity in the previous step, you can further configure the properties of the entity using the JPA details view.
  7. For each attribute in your persistent class, you can specify the mapping of the attribute. In this step, you define how each class attribute maps to the database. In the JPA Structure view, click the attribute that you want to map, and then in the JPA Details view, click the Map As drop-down list. You can choose the following types of mappings (see the Java Persistence Tools User Guide for details on completing the fields) :
    Note: Entity (@Entity) persistent classes must have one attribute with an ID mapping.

Feedback