0

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

  • `` you have no field with this name in user class. maybe you have to do something to make hibernate know it comes from `BaseObject`. also you should try to not use class-names which are not already in use by java like the `java.awt.Robot` – XtremeBaumer May 22 '17 at 07:01
  • XTremeBaumer. Thankx foryour time... I will check carefully what you said... :) Maybe the fact that it's 3:50am here is the reason jaja – Agustn Ernesto Cardeilhac Bans May 22 '17 at 07:04
  • Didn't understand what did you meant with this observation: `` ?... I have a firstName attribute in the User class; I didnt put it for the sake of the clarity... jeje... sorry about that... – Agustn Ernesto Cardeilhac Bans May 22 '17 at 07:10
  • update your code and show all fields. also show your `BaseObject` class. also you might want to have a look [here](http://stackoverflow.com/questions/6389600/not-null-property-references-a-null-or-transient-value) – XtremeBaumer May 22 '17 at 07:11
  • [User] https://drive.google.com/file/d/0B7-mfEn02hE5Q21XMndDRkRXeU0/view?usp=sharing [Robot] https://drive.google.com/file/d/0B7-mfEn02hE5YW51YUlPRXByWDg/view?usp=sharing [BaseObject] https://drive.google.com/file/d/0B7-mfEn02hE5X0YyTzVrM0xucGc/view?usp=sharing What do you think ?... I put them in images as I couldnt format the code... – Agustn Ernesto Cardeilhac Bans May 22 '17 at 07:24
  • update your question. there is an edit button. there you can format your code properly – XtremeBaumer May 22 '17 at 07:26

0 Answers0