Java Reference
In-Depth Information
Specify the identifier property for the
Edition
entity. The
@GeneratedValue
annotation is not required if the ID value is set in the application and not
generated automatically:
@Id
@GeneratedValue
public String getId() {
return id;
}
Similarly add a
@OneToMany
mapping to the
Article
entity. The
Edition
entity class
is listed as follows:
package model;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
@Entity
@NamedQueries( {
@NamedQuery(name = "findEditionsAll",
query = "select o from Edition o"),
@NamedQuery(name = "findEditionById",
query = "SELECT o from Edition o
WHERE o.id = :id") })
public class Edition implements Serializable {
static final long serialVersionUID = 1;
private List<Section> sections;
private List<Article> articles;
@Column(length = 100)
private String edition;
@Id
@Column(nullable = false, length = 100)
private String id;
@Column(length = 100)
private String journal;
@Column(length = 100)
private String publisher;


Search WWH ::

Custom Search