我有以下课程:
[用户]
public class User extends BaseObject {
private Date birthday;
private Robot robot;
public Robot getRobot() {
return robot;
}
[机器人]
public class Robot {
private Date dateOfBuild;
private User user;
[User.hbm.xml]
<hibernate-mapping>
<class name="org.appfuse.model.User" table="app_user">
<id name="id" column="id" unsaved-value="null">
<generator class="increment"/>
</id>
<property name="firstName" column="first_name" not-null="true"/>
<property name="lastName" column="last_name" not-null="true"/>
<property name="birthday" column="birthday" type="java.util.Date"/>
</class>
[Robot.hbm.xml]
<hibernate-mapping>
<class name="org.appfuse.model.Robot" table="robots">
<id name="id" column="id" unsaved-value="null">
<generator class="increment"/>
</id>
<property name="designation" column="designation" not-null="true"/>
<property name="dateOfBuild" column="date_of_build" not-null="true"/>
<property name="qualityCheckPassed" column="quality_check_passed" not-null="true"/>
<many-to-one name="user" unique="true" cascade="all"></many-to-one>
</class>
我正在做的应用程序需要让用户至少能够添加一个Robot,所以当我尝试添加一个Robot时,我得到了这个:
not-null property references a null or transient value: org.appfuse.model.User.firstName; nested exception is
org.hibernate.PropertyValueException: not-null property references a null or transient value: org.appfuse.model.User.firstName
有没有人有线索?因为我一直在寻找,但我无法理解......我被炒了......