Код: Выделить всё
@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
< /code>
.
@Entity
public class School {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer schoolId;
@Column(nullable = false)
private String schoolName;
//Getters and Setters methods
{
"studentId": "2015020",
"studentName": "ABC",
"school": {
"schoolId": 1
}
}
]
< /code>
Я новичок в Spring Data JPA, так что это может быть очень основной ошибкой. < /p>
Подробнее здесь: https://stackoverflow.com/questions/430 ... repository