请教各大牛,遇到了这么一种情况
有学生和学校两种实体,它们是多对一的关系,在学生实体中用school字段引用学校
伪代码和Hibernate Mapping文件如下Class School {
 String id;
}
Class Student {
 String id;
 School school;
}School Mapping
<property name="id" column="ID" />
Student Mapping
<property name="id" column="ID" />
<many-to-one name="school" column="SCHOOL" />
有一种情况是:
我想插入一条学生记录,但是学生暂时还没有学校,也就是SCHOOL字段为空
我试过两种情况:
1,当Student.school = null
2,当Student.school = new School(),但是Student.school.id = null
可Hibernate都是报
object references an unsaved transient instance - save the transient instance before flushing 的错
请问这是什么回事呢?我该怎么插入null值呢?