我有两个表和对象:StudentInGroup 和 GroupRegistration。
class StudentInGroup {
@Id
@Column (name = "ID")
private Integer id;
// other fields
@ManyToOne(fetch = FetchType.EAGER, targetEntity = GroupRegistration.class)
@JoinColumn(name = "GROUP_CODE")
private GroupRegistration groups;
// other methods
}
class GroupRegistration {
@Id
@Column (name = "ID")
private Integer Id;
// other fields
@Column(name = "GROUP_CODE")
private Integer groupCode; // this is not primary key
// other methods
}
我有表格和方法 insertStudentInGroup(StudentInGroup student); 但是当我调用这个方法时,我得到了异常:对象引用了一个未保存的瞬态实例 - 在刷新之前保存瞬态实例:StudentInGroup.groups -> GroupRegistration
我看到人们有这种问题,但他们使用了级联,我不需要级联。有谁能够帮我。