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: newbie - request help in mapping problem with list
PostPosted: Sun Dec 12, 2004 9:04 pm 
Newbie

Joined: Sun Dec 12, 2004 5:52 pm
Posts: 9
Hi,

Initially it looked very straight forward to do this, but somehow I must have missed something down the road, I tried all sorts of things inside the <list> tag (see below) but failed, so I dug in the manual and in the forum but still couldn't find an answer...

I have a class which holds a list of children of the same class. Is it possible to map this to just one table ?

code fragment from class defenition:
Code:
public class CI implements java.io.Serializable {
   
   private long id;
   private int version;
   protected CI parent;       
   protected List<CI> children;



mapping file:
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 name="csmc.model.CI" table="ConfigurationItems">
 
            <id name="id" column="CI_ID" unsaved-value="0">                             
                            <generator class="native"/>
                           
            </id>
           
            <version name="version" column="VERSION"/>
           
            <list name="children" cascade="all">
            </list>
</class>
</hibernate-mapping>


the content of <list> tag is intentionally left out.

I'd appreciate any help.

Yaniv


Top
 Profile  
 
 Post subject: i feel kinda stupid... posting a reply to myself :)
PostPosted: Sun Dec 12, 2004 10:41 pm 
Newbie

Joined: Sun Dec 12, 2004 5:52 pm
Posts: 9
but in case anyone else have a similar problem....

this mapping solved the issue:

Code:
         <list name="children" cascade="all">
                            <key column="PARENT_ID"/>
                            <index column="POSITION"/>
                            <one-to-many class="csmc.model.CI"/>
            </list>



I just misunderstood the key concept, stupid me.

I hope i got it right this time :)

Yaniv


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.