Tengo esta relación donde la clave principal de publications depende de la clave principal de teacher_profile_post y funciona como clave principal y foránea, nose cómo representarla en spring boot.
Este es el codigo de teacher_profile_post:
public class TeacherProfilePost {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;//tipo objetuales no primitivos
@OneToOne(mappedBy = "teacherProfilePost", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private Publication publication;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "student_id")
private Student student;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "teacher_id")
private Teacher teacher;}
Este es el codigo de publications solo me faltaria especificar la relación:
public class Publication {
@OneToOne(mappedBy = "publication", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private CommentReport commentReport;
@ManyToOne
@JoinColumn(name = "parent_id")
private Publication parent;
@Column(nullable = false)
private String comment;
@Column(nullable = false)
private int like;
@Column(nullable = false)
private int dislike;}