-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping problems using DOM4J
PostPosted: Wed Jun 28, 2006 10:45 am 
Newbie

Joined: Fri Apr 07, 2006 8:36 am
Posts: 1
I've been having a couple of problems trying to use DOM4J and entity mode mapping and I just wanted to know if these are known problems or if I'm doing something silly.

The XML structure I'm trying to map is not within my control and is somewhat complex so I've simplified the problems I'm seeing into two test cases cases below.

Hibernate version: 3.1.2, 3.1.3

Mapping documents:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class entity-name="a">
     <id name="id" type="long" node="@id">
         <generator class="increment"/>
     </id>
     <property name="name" type="string" length="64"/>
</class>

<class entity-name="b">
    <id name="id" type="long" node="@id">
        <generator class="increment"/>
    </id>
    <property name="colour" type="string" length="64"/>
</class>

<class entity-name="test1">
   <component name="header">
      <set name="a" node="." cascade="all">
               <key not-null="true" column="ida"/>
               <one-to-many entity-name="a"/>
           </set>
   </component>
</class>

<class entity-name="test2">
   <set name="a" node="." cascade="all">
            <key not-null="true" column="ida"/>
            <one-to-many entity-name="a"/>
        </set>
   <set name="b" node="." cascade="all">
            <key not-null="true" column="idb"/>
            <one-to-many entity-name="b"/>
        </set>
</class>

</hibernate-mapping>


Name and version of the database you are using: Apache Derby

Test Case #1
The XML structure is fairly simple;

Code:
<test1>
   <header>
      <a>
         <name>test</name>
      </a>
      <a>
         <name>test</name>
      </a>
      etc...
   </header>
</test1>


Having persisted this and retrieved it what I get back is:

Code:
<test1>
   <a>
      <name>test</name>
   </a>
   <a>
      <name>test</name>
   </a>
   <header/>
</test1>


I can't seem to get the <a> node to correctly appear back under the header sub-node.

Test Case #2

I basically have two different sets at the same level:

Code:
<test2>
   <a>
      <name>test</name>
   </a>
   <a>
      <name>test</name>
   </a>
   etc..
   <b>
      <colour>test</colour>
   </b>
   <b>
      <colour>test</colour>
   </b>
   etc...
</test2>


This will produce a "Found shared references to a collection" error as it seems you can't have two node="." at the same node level.

If anyone could shed any light on these two issues I would be most grateful.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 4:13 am 
Newbie

Joined: Fri Aug 04, 2006 3:39 am
Posts: 3
Hi,
I have the same problem. Did you find a solution ?

According to the post http://forum.hibernate.org/viewtopic.ph ... ight=dom4j I have to rename my set nodes to : node="." in order to be used in the XML import.


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

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.