Home Tutorials Training Consulting Products Books Company Donate Contact us









NOW Hiring

Quick links

Share

Eclipse Dali. This article describes how to use Eclipse Dali for JPA mapping. This article is based on Eclipse 3.5 (Eclipse Galileo).

1. Overview

This article describes Eclipse Dali and does not give a general introduction into JPA. Please see Java Persistence API (JPA) with EclipseLink - Tutorial for an introduction.

To use Eclipse Dali you also need Eclipse DTP which is described in Eclipse DTP Tutorial

To use Eclipse Dali you also need Derby which is described in

or independently of Eclipse in Apache Derby.

2. Installation

Use the update manager to install from "Web, XML, and Java Development" the "Dali Java Persistence Tools" and "Dali Java Persistence Tools - EclipseLink Support (Optional)". Install also "EclipseLink JPA" from "EclipseRT Target Platform Components".

3. Using Dali

3.1. Project

Create a new project "de.vogella.dali.first" via File ▸ New ▸ Others ▸ JPA ▸ JPA Project.

You can also add to an existing project the JPA nature. Use the JPA perspective and the right mouse button on the project and select Configure → Convert to JPA Project
dali10

Click twice next.

dali20

The JPA perspective should now be opened.

Create a package "de.vogella.dali.first".

Select File ▸ New ▸ Other ▸ JPA ▸ Entity and create the following class.

dali25
package de.vogella.dali.first;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;

/**
 * Entity implementation class for Entity: Person
 *
 */
@Entity

public class Person implements Serializable {
        @Id
        private int id;
        private String firstName;
        private String lastName;

        private static final long serialVersionUID = 1L;

        public Person() {
                super();
        }

        public int getId() {
                return id;
        }

        public void setId(int id) {
                this.id = id;
        }

        public String getFirstName() {
                return firstName;
        }

        public void setFirstName(String firstName) {
                this.firstName = firstName;
        }

        public String getLastName() {
                return lastName;
        }

        public void setLastName(String lastName) {
                this.lastName = lastName;
        }

}

Annotate now the class with @Entity (before the class name". This will activate the views "JPA Structure" and "JPA Details".

dali30

You can now use the right mouse button in the "JPA Structure" view to map your elements.

dali40

Now you can use the "JPA Details" view to define for example how the primatry keys should get defined, e.g., via a sequence "SEQUENCE".

dali50

4. About this website

Nothing listed. === vogella GmbH training and consulting support

TRAINING SERVICE & SUPPORT

The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”.

The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers.

Copyright © 2012-2016 vogella GmbH. Free use of the software examples is granted under the terms of the EPL License. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.

See Licence.