Creating a JPA entity bean using a wizard

You can create JPA entity beans using the New Entity wizard.

Before you begin

If you have not done so already, create a JPA project or enable JPA support in an appropriate project.

About this task

To create a JPA entity bean:

Procedure

  1. Open the JPA perspective (Window > Open Perspective > Other > JPA).
  2. In the Package Explorer view, right-click the project that you want to add the entity to and click New > JPA Entity.
  3. Ensure that to the correct Project to add your entities to is selected in the Project field.
  4. In the Source folder field, type or browse to the path to the folder that contains the Java™ source file for your entity.
  5. In the Java package field, type or browse to the Java package for your entities.
  6. Type the class name of the entity in the corresponding field.
  7. Optional: If your entity is derived from a superclass, type the name of superclass in the corresponding field.
  8. Under Inheritance, select
    • Entity (this is selected by default)
    • Mapped Superclass
    • Inheritance
  9. To add the entity mappings to an XML mapping file (usually META-INF/orm.xml), click Add to entity mappings in XML.
  10. Click Next.
  11. Type the name of your entity. By default it is pre-filled with the class name.
  12. Under Table Name, type the name of the database table your entity maps to. By default, the table name is the same as your class name.
  13. Add fields to your entity. To add field, click Add under Entity Fields and do the following steps:
    1. Select the type.
    2. Type the field name.
  14. In the Key column of the Entity Fields table, click one or more fields that are the primary key for your entity.
  15. Select if the access type for the entity is field- based or property-based.
  16. Click Next.
  17. Optionally, add the entity class to a class diagram for visualization.
  18. Click Finish.

Results

The JPA entity is created for your project.

What to do next

You can further configure your entity (for example, by adding relationship mappings) by using the following tools:
  • The Configure JPA Entities wizard. (Right-click the entity and click JPA Tools > Configure JPA Entities).
  • The JPA Details view and the JPA structure view.
Icon that indicates the type of topic Task topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: t_jpa_entity_create_wiz.html