Incorrect Mapping Between Classes

46 views Asked by At

I have the following classes:

[User]

public class User extends BaseObject {
    private Date birthday;
    private Robot robot;

   public Robot getRobot() {
    return robot;
   }

[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>

The application I am doing needs to have a user at least to be able to add a Robot so, when I try to add a Robot, I get this:

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

Does anyone hasa clue ?. Because I've been searching but I cant understand... I am fried...

0

There are 0 answers