I'm trying to import from XML into my class structure but the XML format doesn't match up nicely to the class structure. I'm stuck with this XML format for various reasons. It looks like this:
Code:
<Item>
<Location>
<x>1</x>
<y>1</y>
<z>1</z>
<region>3</region>
</Location>
</Item>
My class structure looks like this:
Code:
class Item {
CartesionPoint position;
int region;
}
class CartesianPoint {
int x;
int y;
int z;
}
I thought I could use the pathing feature for the 'node' attribute in the mapping file like below to fill out the data:
Code:
<hibernate-mapping>
<class name="my.package.Item">
<id name="id">
<generator class="native"/>
</id>
<many-to-one name="point" class="CartesianPoint" node="Location">
<column name="point"/>
</many-to-one/>
<property name="region" type="integer" node="Location/region"/>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class name="my.package.CartesianPoint" node=".">
<property name="x" node="x"/>
<property name="y" node="y"/>
<property name="z" node="z"/>
</class>
</hibernate-mapping>
The region field is never being populated. Is my syntax wrong or can Hibernate not handle a mapping like this?