Create Java Persistence Entities


The Tutorial Object Model contains three entities: Employee, Address, and PhoneNumber. Use this procedure to add the entities to the project.

  1. Right-click the Employee project in the Package Explorer and select New > Other. The Select a Wizard dialog appears.

  2. In the Select a Wizard dialog, select Java Persistence > Entity and click Next. The Java Class page of the Create New Java Persistence Entity wizard appears.

  3. On the Java Class page, enter a package name (such as dali.tutorial.model), class name (such as Employee), and click Finish.

Eclipse adds the Employee entity to the Package Explorer and adds the @Entity annotation to the class. Notice that the Problems view reports several errors for each entity. We'll address these shortly.

Repeat this procedure to add the PhoneNumber and Address entities.

Next, you will Add Fields to the Entities.