RSS

Search Engine

Tuesday, September 7, 2010

Using Dali

2.1. Project

Create a new project "sawan.modi.dali.first" via File -> New -> Others -> JPA -> JPA Project.

Tip

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

Click twice next.

The JPA perspective should now be opened.

Create a package "sawan.modi.dali.first".

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

   
package sawan.modi.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".

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

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".

0 comments:

Post a Comment