Java Reference
In-Depth Information
this.edition = edition;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "section",
fetch = FetchType.EAGER)
@JoinTable(name = "Section_Article", joinColumns = {
@JoinColumn(name = "section_id",
referencedColumnName = "id") },
inverseJoinColumns = {
@JoinColumn(name = "article_id",
referencedColumnName = "id") })
public List<Article> getArticles() {
return articles;
public void setArticles(List<Article> articles) {
this.articles = articles;
public void addArticle(Article article) {
public void removeArticle(Article article) {
Article entity
Similarly, in the Article entity, add named queries to find all Article entities and
find an Article entity by ID. Add @ManyToOne annotations to define the many-to-
one relationships between the Article entity and the Edition and Section entities.
The Article entity is listed as follows:
package model;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
Search WWH ::

Custom Search