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.  [ 4 posts ] 
Author Message
 Post subject: parent/child using list????
PostPosted: Fri Jan 23, 2004 5:31 am 
Beginner
Beginner

Joined: Fri Jan 23, 2004 5:08 am
Posts: 21
Hi guys! I have a tree structure table and use the composite pattern

...........................
<set name="child" inverse="true" lazy="false" cascade="save-update">
<key column="industry_id_fk"/>
<one-to-many class="com.eon.cms.vo.Industry"/>
</set>
<many-to-one name="parent" column="industry_id_fk" cascade="save-update" class="com.eon.cms.vo.Industry"/>
............................

and its working fine. I'm displaying it as a tree in jsp( using javascript). My problem is this i want my data to be displays all the nodes that have children first. But the data return by set is inconsistent.

first query:

A
---A1
-----A1.2
---A2

as i query again here's the result:

A
---A2
---A1
-----A1.2

Do i missed something here?


thanks.

raymond


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2004 6:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
In this case I would really recommend using the sort attribute of the set mapping, and use a custom comparator (I think you have to use a SortedSet probably)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2004 6:58 am 
Beginner
Beginner

Joined: Fri Jan 23, 2004 5:08 am
Posts: 21
Does anyone teach me to use the sort attribute of set using the "comparator class"?

<!ATTLIST set sort CDATA "unsorted">
<!-- unsorted|natural|"comparator class" -->


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2004 7:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Just specify the class name of a class you write which implements the comparator interface I think. Probably you might need to use SortedSet in your classes for the association, I am not sure though. Might work without changes in the class, too.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.