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
- Open the JPA perspective ().
- In the Package Explorer view, right-click the project that
you want to add the entity to and click .
- Ensure that to the correct Project to add your entities
to is selected in the Project field.
- In the Source folder field, type
or browse to the path to the folder that contains the Java™ source file for your entity.
- In the Java package
field, type or browse to the Java package
for your entities.
- Type the class name of the entity in the corresponding
field.
- Optional: If your entity is derived from a
superclass, type the name of superclass in the corresponding field.
- Under Inheritance, select
- Entity (this is selected by default)
- Mapped Superclass
- Inheritance
- To add the entity mappings to an XML mapping file (usually
META-INF/orm.xml), click Add to entity mappings in XML.
- Click Next.
- Type the name of your entity. By default it is pre-filled
with the class name.
- 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.
- Add fields to your entity. To add field, click Add under
Entity Fields and do the following steps:
- Select the type.
- Type the field name.
- In the Key column of the Entity Fields table, click one
or more fields that are the primary key for your entity.
- Select if the access type for the entity is field- based
or property-based.
- Click Next.
- Optionally, add the entity class to a class diagram for
visualization.
- 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 ).
- The JPA Details view and the JPA structure view.