@Entity
@Data
@Table(name = "students")
public class Student implements Serializable {
@Id
@GeneratedValue
private Integer id;
private String name;
private String email;
@OneToOne(mappedBy = "student", cascade = CascadeType.ALL)
private StudentDetails studentDetails;
}
@Entity
@Data
@Table(name = "student_details")
public class StudentDetails implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String studentDetailsInfo;
@OneToOne
@JoinColumn(name = "student_id")
@MapsId
private Student student;
}