-->
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: Problem with TreeSet creation
PostPosted: Mon Feb 11, 2008 3:21 am 
Newbie

Joined: Tue Jan 29, 2008 2:49 am
Posts: 2
Hi ,

I have bidirectional one-to-many entity relation ship between two tables say PARENT and CHILD and i am using set TreeSet for storing objects of CHILD table. The problem i am facing is that when i am trying to add the second child to the set i am getting an exception "{Class} cannot be cast to java.lang.Comparable" , also when i am trying to save without adding the second child to the parent set i am able to successfully save both child records and the parent.


{ .....

parent.addTochildren(child1);
child1.setMaster1(parent);

parent.addTochildren(child2);//Exception here and
// successfully saved the records when eliminating the same statement

child2.setMaster1(parent);

.......

}
Can any body suggest solution for this ? Is that problem caused by the usage of TreeSet , then please suggest the correct usage of the same.

Thanks in advance

Regards sajith


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 11:04 pm 
Newbie

Joined: Fri Mar 21, 2008 4:09 am
Posts: 6
Location: Kyiv, Ukraine
Class child1 have to implement the Comparable interface or added a Comparator object to the tree. It's quite simple. In fact the first variant needs You add method compareTo(). See for details
here


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.