Java Reference
In-Depth Information
IMPLEMENTING THE DATA ACCESS PATTERN IN JAVA EE
Now you'll go through an example to see how to implement the DAO in Java EE. You are going
to use the movie rental domain and a relational database as the data source. You'll start by
creating a movie entity class and annotating it with appropriate JPA annotations, as shown in
Listing 12‐1.
LISTING 12‐1: The movie entity class
package com.devchronicles.dataaccessobject;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
@Entity
public class Movie implements Serializable {
private static final long serialVersionUID = -6580012241620579129L;
@Id @GeneratedValue
private int id;
private String title;
private String description;
private int price;
//Some runtime value which
//does not need to be persisted
@Transient
private int runtimeId;
public Movie() {}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return this.description;
continues
 
Search WWH ::




Custom Search