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 #1The 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 #2I 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.