Add persistence to the project


Use this procedure to add persistence to the Employee project.

  1. Right-click the Employee project in the Explorer and select Java Persistence > Add Java Persistence. The Add Java Persistence Dialog appears.

  2. In the Database Settings area select a database connection that you created earlier (see "Create a database connection").

    You must be connected to the database before adding persistence to the project.

  3. Click Configure the project build path to add the library or JARs that contain the Java Persistence API (JPA) and entities to the project's Java Build Path.

  4. In the Packaging Settings area select the Create persistence.xml option and complete the following fields:

    • Persistence Version: 1.0

    • Persistence Provider: Enter the name of the JPA provider that you selected in step 3 (such as TopLink Essentials).

    • Persistence Unit Name: Dali Tutorial

    Add Persistence Dialog

    This figure shows the Add Java Persistence dialog.
  5. Click Finish. You can now work in the Persistence perspective.

  6. Select Window > Open Perspective > Other. The Select Perspective dialog appears.

  7. Select Persistence and click OK. The Persistence Outline and Properties views appear.

    Persistence Perspective

    This figure shows the main parts of the Persistence Perspective: The Persistence Outline and Persistence Properties views.

The next step is to Create persistent Java entities.