-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: DOM4J mode - problem setting foreign keys of nested elements
PostPosted: Wed Dec 14, 2005 11:39 am 
Newbie

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.