-->
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: How to map tree like table
PostPosted: Fri Jan 28, 2005 11:14 pm 
Newbie

Joined: Fri Jan 28, 2005 11:03 pm
Posts: 2
I have a table, It's structure like bellow:
Code:
id long
value varchar
parentId long


the class is :
Code:
class Node {
long id;
String value;
Node parent;

.....
}


the map file is:
[code] <class name="Node" table="TreeNodes">
<id name="id" type="long" column="id">
<generator class="hilo">
</id>
<property name="value" not-null="true"/>
<many-to-one name="parent" class="Node" column="parentId"/>
<set name="children" lazy="true" >
<key column="parent"/>
<one-to-many class="Node"/>
</set>
</class>code]

I think it's not right, when the node is root will throw null exception, because the root's parent is null, could you tell me some other solutions, thanks very much


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 30, 2005 6:53 am 
Newbie

Joined: Fri Jan 28, 2005 11:03 pm
Posts: 2
need help, thanks


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.