package de.springbootbuch.database_examples.springdata;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "film")
public class FilmEntity implements Serializable {

	private static final long serialVersionUID = 2568012478345384986L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "film_id")
	private Integer id;

	private String title;

	@ManyToOne(optional = false)
	@JoinColumn(name = "language_id")
	private LanguageEntity language;

	private Integer releaseYear;

	protected FilmEntity() {
	}

	public FilmEntity(String title, LanguageEntity language) {
		this.title = title;
		this.language = language;
	}

	// Getter und Setter aus Gründen
	// der Übersicht weggelassen

	public Integer getId() {
		return id;
	}

	public String getTitle() {
		return title;
	}

	public LanguageEntity getLanguage() {
		return language;
	}

	public Integer getReleaseYear() {
		return releaseYear;
	}

	public void setReleaseYear(Integer releaseYear) {
		this.releaseYear = releaseYear;
	}
}

@@ -79,16 +79,64 @@
 izable;%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A
 import j
@@ -152,32 +152,32 @@
 istence.Column;%0A
-
 import javax.per
@@ -333,32 +333,105 @@
 nce.JoinColumn;%0A
+import javax.persistence.JoinTable;%0Aimport javax.persistence.ManyToMany;%0A
 import javax.per
@@ -895,16 +895,230 @@
 eYear;%0A%0A
+%09@ManyToMany%0A%09@JoinTable(%0A%09%09name = %22film_actor%22, %0A%09%09joinColumns = @JoinColumn(name = %22film_id%22),%0A%09%09inverseJoinColumns = @JoinColumn(name = %22actor_id%22)%0A%09)%0A%09private final Set%3CActorEntity%3E actors = new HashSet%3C%3E();%0A%09%0A
 %09protect
@@ -1579,24 +1579,24 @@
 easeYear) %7B%0A
-
 %09%09this.relea
@@ -1619,11 +1619,71 @@
 Year;%0A%09%7D
+%0A%0A%09public Set%3CActorEntity%3E getActors() %7B%0A%09%09return actors;%0A%09%7D
 %0A%7D%0A

Add ManyToMany