Mapping files:
- <class name="om.Employee" table="Employee" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" batch-size="1" select-before-update="false" optimistic-lock="version">
- <id name="employeeOid" type="java.lang.Integer" column="employeeOid" unsaved-value="null">
<generator class="native" />
</id>
<property name="locale" type="java.lang.String" column="locale" not-null="true" length="64" unique="false" update="true" insert="true" />
<one-to-one name="Office" class="om.Office" outer-join="auto" constrained="false" />
</class>
- <class name="om.Office" table="Office" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" batch-size="1" select-before-update="false" optimistic-lock="version">
- <id name="employeeOid" type="java.lang.Integer" column="employeeOid" unsaved-value="null">
<generator class="native" />
</id>
<one-to-one name="Employee" class="om.Employee" outer-join="auto" constrained="true" />
</class>
Acco Lade wrote:
I have 2 classes,
An Employee has an Office. A 1 to 1 relationship.
So, after middlegen, hbm2java I ended up with 1 Employee and 1 Office POJO.
Employee e = new Employee();
e.setOffice(new Office());
Then I used the Hibernate session to save Employee. The Employee got created successfully, but the Office did not get created. Is there a way to make Hibernate traveser the object graph or do I have to do the traversal myself? Thanks.