0

我有以下课程:

[用户]

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;

[用户.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>

[机器人.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>

我正在做的应用程序至少需要一个用户才能添加机器人,所以当我尝试添加机器人时,我得到了这个:

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

有没有人有线索?因为我一直在寻找但我无法理解......我被炸了......

4

0 回答 0