-->
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: Tutorials On XML Mapping
PostPosted: Tue Jul 04, 2006 11:35 am 
Beginner
Beginner

Joined: Tue Jul 04, 2006 11:29 am
Posts: 20
Location: Cambs, UK
Hi all,

I was just wondering if anyone knew of any good tutorials about using Hibernate to populate my DB via XML. I've read through chapter 18 of the Hibernate manual and that has helped me get started. But now I am trying to get the mappings working with associations and I could use a little more guidance.

So if anyone has any suggestions, they'd be greatly appreciated.

Regards,
Lee


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 05, 2006 5:14 am 
Beginner
Beginner

Joined: Tue Jul 04, 2006 11:29 am
Posts: 20
Location: Cambs, UK
A bit of a bump for this topic. Hopefully if I add some code somebody might be able to help a little. So...

Here's the XML I want to map...
Code:
<customerconfig>
    <site name="Page Title" collection="abc123">
        <rule><![CDATA[]]></rule>
        <rule><![CDATA[]]></rule>
        <rule><![CDATA[]]></rule>
        <rule><![CDATA[]]></rule>
    </site>
</customerconfig>


And here are the XML mapping files I would like to map it to:
Code:
<hibernate-mapping>
   <class name="SiteCollection" table="site_collection" node="site">
      <id name="id" column="site_collection_id" node="@collection">
         <generator class="assigned"/>
      </id>
      <property name="name" node="@name"/>
      
      <set name="ruleset" table="ruleset">
          <key column="site_collection_id"/>
          <many-to-many column="rule_id" class="Rule"/>
      </set>
   </class>
</hibernate-mapping>

Code:
<hibernate-mapping>
   <class name="Rule" table="rule">
      <id name="id" column="rule_id">
         <generator class="native"/>
      </id>
      <property name="script" node="rule"/>
      
      <set name="ruleset" table="ruleset" inverse="true">
          <key column="rule_id"/>
          <many-to-many column="site_collection_id" class="SiteCollection"/>
      </set>
   </class>
</hibernate-mapping>


I have managed to do the map the regular properties correctly and that is fine but I have no idea how I would be able to map the XML to my associations.

Is it possible to do with a simple node attribute or would I need to code this?


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.