So erstellen Sie eine optimale Verbindung mit der richtigen Kaskade zwischen zwei Entitäten im Springboot für einen FilmJava

Java-Forum
Anonymous
 So erstellen Sie eine optimale Verbindung mit der richtigen Kaskade zwischen zwei Entitäten im Springboot für einen Film

Post by Anonymous »

Hallo, ich erstelle ein Content -Management -System für eine Award -Nachtfirma. Wir werden in der Lage sein, neue Einträge einzunehmen und dann Gewinner zu nominieren und auszuwählen.@Entity
@Data
public class AwardCategory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long awardCategoryId;
private String awardCategoryName;
}
< /code>
@Entity
@Data
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long contentId;
private String contentName;
@Column(columnDefinition = "TEXT")
private String synopsis;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "content_type_id")
private ContentType contentType;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "country_code")
private Country countryCode;
private String portraitUrl;
private String landscapeUrl;
private Boolean featured;
private ContentApprovalStatus approvalStatus;
@CreationTimestamp
private LocalDateTime createTime;
@UpdateTimestamp
private LocalDateTime updateTime;
@ManyToMany
@JoinTable(
name = "content_genre",
joinColumns = @JoinColumn(name = "content_id"),
inverseJoinColumns = @JoinColumn(name = "genre_id")
)
private Set genres;
@ManyToMany
@JoinTable(
name = "content_language",
joinColumns = @JoinColumn(name = "content_id"),
inverseJoinColumns = @JoinColumn(name = "language_id")
)
private Set languages;
@OneToMany(mappedBy = "content", cascade = CascadeType.ALL, orphanRemoval = true)
private Set contentCrews;
}

< /code>
@Entity
@Data
public class ContentCrew {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "content_id")
private Content content;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "crew_id")
private Crew crew;
private String role;
}
< /code>
@Entity
@Data
public class ContentType {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long contentTypeId;
private String contentTypeName;
}
< /code>
@Entity
@Data
public class Country {
@Id
private String countryCode;
private String countryName;
}
< /code>
@Entity
@Data
public class Crew {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long crewId;
private String crewName;
@Column(name = "crew_dob")
private Date crewDoB;
@Enumerated(EnumType.STRING)
private Gender crewGender;
@Column(columnDefinition = "TEXT")
private String bio;
private String image_url;
@OneToMany(mappedBy = "crew", cascade = CascadeType.ALL, orphanRemoval = true)
private Set contentCrews;
}
< /code>
@Entity
@Data
public class Genre {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long genreId;
private String genreName;
}
< /code>
@Entity
@Data
public class Language {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long languageId;
private String languageName;
}
< /code>
@Entity
@Data
public class Submission {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long submissionId;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "content_id")
private Content contentId;
private Integer submissionYear;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "award_category_id")
private AwardCategory awardCategory;
private Integer nominationYear=0;
private Integer awardYear=0;
}
< /code>
Is this good enough to make a content management system as i want to have complete control over almost every aspect of this. Once the content management is complete the submissions entity and the content entity will be used to populate the site using a rest api which i will work on later.
My current entity relation design

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post