Joined: Wed Dec 14, 2005 9:06 am Posts: 1 Location: Zürich Switzerland
|
Hibernate version: 3.1rc3
Name and version of the database you are using: Oracle 10g
Mapping documents, source code etc.: Zipped & available on req.
Hello Hibernate Community,
I am trying to use hibernates xml/relational persistence but I'm having
problems because I can't setup the foreign keys of my child elements properly.
The XML I want to persist looks like this...
<nest id="1" location="in the apple tree">
<birds>
<bird id="1" type="sparrow"/>
<bird id="2" type="sparrow"/>
<bird id="3" type="sparrow"/>
<bird id="4" type="cuckoo"/>
</birds>
</nest>
And I have 2 mapping files...
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.ubs.odi.hibernate.nesting">
<class name="com.ubs.odi.hibernate.nesting.Nest" table="NEST" lazy="true" node="nest">
<id name="id" column="NEST_ID" node="@id">
<generator class="assigned" />
</id>
<property name="location" column="LOCATION" node="@location"/>
<set name="birds" cascade="save-update" inverse="true">
<key column="NEST_ID" />
<one-to-many class="com.ubs.odi.hibernate.nesting.Bird" />
</set>
</class>
</hibernate-mapping>
and
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.ubs.odi.hibernate.nesting">
<class name="com.ubs.odi.hibernate.nesting.Bird" table="BIRD" node="bird">
<id name="id" column="BIRD_ID" node="@id">
<generator class="assigned" />
</id>
<property name="type" column="TYPE" node="@type"/>
<many-to-one column="NEST_ID" name="nest" class="com.ubs.odi.hibernate.nesting.Nest" node="nest/@id" cascade="save-update" embed-xml="false"/>
</class>
</hibernate-mapping>
I want hibernate to populate all of the columns in my 2 tables but the
NEST_ID column in BIRD never gets populated.
Can anyone see my mistake?
Many thanks in advance
Michael Shaw
|
|