Save entity object with foreign key using CrudRepository
I have two entity classes with @ManyToOne relationship as below. @Entity public class Student { @Id private Integer studentId; @Column(nullable = false) private String studentName; @ManyToOne(targetEntity = School.class, fetch = FetchType.LAZY, optional = false) @JoinColumn(referencedColumnName = "schoolId", insertable = false, updatable = false) private School school; //Getters and Setters methods . @Entity public class School { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer schoolId; @Column(nullable = false) private String schoolName; //Getters and Setters methods When
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.