StudentsInGroup と GroupRegistration の 2 つのテーブルとオブジェクトがあります。
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
人々がこの種の問題を抱えているのを見ましたが、彼らはカスケードを使用していました。カスケードは必要ありません。誰でも私を助けることができますか?