Skip Headers
Dali Java Persistence Tools User Guide
Release 3.2
Release 3.2
Go To Table Of Contents
Go To Index

Requirements and installation

Dali quick start

This section includes information to help you quickly start using Dali to create relational mappings between Java persistent entities and database tables.

Related reference

Creating a new JPA project

This quick start shows how to create a new JPA project.

  1. Select File > New > Project. The Select a Wizard dialog appears.


    You can also select the JPA perspective and then select File > New > JPA Project.

  2. Select JPA Project and then click Next. The New JPA Project page appears.

  3. Enter a Project name (such as QuickStart).

  4. If needed, select the Target Runtime (such as Apache Tomcat) and configuration, such as Default Configuration for Apache Tomcat and then click Next. The Java source page appears.


    The Target Runtime is not required for Java SE development.

  5. If you have existing Java source files, add them to your classpath and then click Next. The JPA Facet page appears.

  6. On the JPA Facet dialog, select your vendor-specific JPA platform (or select Generic 2.0), JPA implementation library (such as EclipseLink), database connection (or create a new connection), define how Dali should manage persistent classes, and then click Finish.


    Select Override the Default Schema for Connection if you require a schema other than the one that Dali derives from the connection information, which may be incorrect in some cases. Using this option, you can select a development time schema for defaults and validation.

Eclipse adds the project to the workbench and opens the JPA perspective.

Figure 1-1 JPA Project in Project Explorer

Package Explorer showing the JPA project.

Now that you have created a project with persistence, you can continue with Creating a Java persistent entity with persistent fields.

Creating a Java persistent entity with persistent fields

This quick start shows how to create a new persistent Java entity. We will create an entity to associate with a database table. You will also need to add the ADDRESS table to your database.

  1. Select the JPA project in the Navigator or Project Explorer and then click New > Other. The Select a Wizard dialog appears.

  2. Select JPA > Entity and then click Next. The Entity Class page appears.

  3. Enter the package name (such as quickstart.demo.model), the class name (such as Address) and then click Next. The Entity Properties page appears, which enables you to define the persistence fields, which you will map to the columns of a database table.

  4. Use the Entity Fields dialog (invoked by clicking Add) to add persistence fields to the Address class:

    private Long id;
    private String city;
    private String country;
    private String stateOrProvince;
    private String postalCode;
    private String street;


    You will also need to add the following columns to the ADDRESS database table:

    NUMBER(10,0) ADDRESS_ID (primary key)

  5. Click Finish. With the Create JPA Entity wizard completed, Eclipse displays the Address entity in the JPA Structure view. includes the @Entity annotation, the persistence fields, as well as getter and setter methods for each of the fields.

Figure 1-2 Address Entity in

Java editor with the Address entity.

Eclipse also displays the Address entity in the JPA Structure view.

Figure 1-3 Address Entity in the JPA Structure View in the JPA Structure View.

After creating the entity, you must associate it with a database table.

  1. Select the Address class in the Project Explorer view.

  2. In the JPA Details view, notice that Dali has automatically associated the ADDRESS database table with the entity because they are named identically.

    Figure 1-4 JPA Details View for Address Entity in the JPA Details view.


    Depending on your database connection type, you may need to specify the Schema.


After associating the entity with the database table, you should update the persistence.xml file to include this JPA entity.

Right-click the persistence.xml file in the Project Explorer and select JPA Tools > Synchronize Class List. Dali adds the following to the persistence.xml file:


Now we are ready to map each fields in the Address class to a column in the database table.

  1. Select the id field in the JPA Details view.

  2. Right-click id and then select Map As > id.

  3. In the JPA Details view, select ADDRESS_ID in the Name field:

    Figure 1-5 JPA Details View for the addressId Field

    The JPA Details view for the Address entity’s id attribute.

    Eclipse adds the following annotations to the Address entity:

  4. Map each of the following fields (as Basic mappings) to the appropriate database column:

    Field Map As Database Column
















Dali automatically maps some fields to the correct database column (such as the city field to the City column) if the names are identical.