relations between entities created
This commit is contained in:
parent
7f2c44cd59
commit
b6063cd0b9
5
pom.xml
5
pom.xml
@ -37,6 +37,11 @@
|
||||
<version>RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
<version>3.28.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,6 +1,9 @@
|
||||
package org.example;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name="category")
|
||||
public class FilmCategoryModel {
|
||||
@ -31,6 +34,9 @@ public class FilmCategoryModel {
|
||||
this.filmCategory = filmCategory;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy = "category_id", fetch = FetchType.LAZY)
|
||||
private Set<FilmInfoModel> filmInfoSet = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Category{" +
|
||||
|
@ -86,6 +86,18 @@ public class FilmInfoModel {
|
||||
this.filmCategory = filmCategory;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "language_id")
|
||||
private FilmLanguageModel filmLanguageModel;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "category_id")
|
||||
private FilmCategoryModel filmCategoryModel;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "film_id")
|
||||
private FilmModel film;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FilmInfo{" +
|
||||
|
@ -1,6 +1,9 @@
|
||||
package org.example;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name="language")
|
||||
public class FilmLanguageModel {
|
||||
@ -31,6 +34,9 @@ public class FilmLanguageModel {
|
||||
this.filmLanguage = filmLanguage;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy = "language_id", fetch = FetchType.LAZY)
|
||||
private Set<FilmInfoModel> filmInfoSet = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Language{" +
|
||||
|
@ -31,6 +31,9 @@ public class FilmModel {
|
||||
this.filmTitle = filmTitle;
|
||||
}
|
||||
|
||||
@OneToOne(mappedBy = "film", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private FilmInfoModel filmInfo;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Film{" +
|
||||
|
Loading…
Reference in New Issue
Block a user