i want define a 0-1 relation between person and cat.
cat has owner as property, and person knows nothing about cat.
Below are the Person and Cat mappings respectively:
<class name="model.Cat" table="CAT">
<id name="id" type="long">
<column name="CAT_ID" not-null="true" />
<generator class="native" />
</id>
<property name="name"><column name="name" not-null="false" /> </property>
<property name="sex"><column name="sex" not-null="false" /> </property>
<property name="weight"><column name="weight" not-null="false" /> </property>
<many-to-one name="owner" class="model.Person" column="person_id"/>
</class>
<class name="model.Person" table="PERSON">
<id name="id" type="long">
<column name="PERSON_ID" not-null="true" />
<generator class="native" />
</id>
<property name="forename">
<column name="forename" not-null="false" />
</property>
<property name="surname">
<column name="surname" not-null="false" />
</property>
</class>
after insert i get null for person_id in cat table.
Code:
Person p = new Person();
p.setForename("Xiaofeng");
p.setSurname("Wu");
Cat cat = new Cat(p);
cat.setName("mimi");
did i do something wrong? how can i define a 0-1 relation in HB?