-->
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: XML import syntax
PostPosted: Mon Feb 08, 2010 1:14 pm 
Newbie

Joined: Mon Feb 08, 2010 12:58 pm
Posts: 1
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?


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.