-->
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: PROBLEM with a set...perhaps i am just a loser..
PostPosted: Tue Aug 26, 2003 5:33 pm 
Newbie

Joined: Tue Aug 26, 2003 5:23 pm
Posts: 1
Location: FRANCE
hello,
please i just escuse me if my request is not very interesting...

i just want to show you something what i dont understand :
context : hibernate2.0, mySqL

i want ...to realize a many-to-many relation between two tables ...
"user" and "role"
(i try just like the doc example : work and author ...)

my problem was first :
i could add the first "role" in the user set. but i
couldnot add a second ...

so i test the method : set.contains() ..that show me that the set did not
want to add another "role" object (even if it's a different one ...)
i don't understand why...

after a little time now ...the problem is resolve..but i don't know why
...(object are add and are in my "user_role" mysql table ) but if i use
set.contains() it still says to me that the object is soon in the set...
a little disapointing think
and when i access to user.getRoles() it gives me only the first tuple of my user-role link....

should i post my code ??
perhaps i should not use a java.util.set ....

another think is that i can not use the <many-tomany> <column name=""...> format ..the parser says to me that column must have a "=" after it ...

thanks for every replies to my request....

_________________
sorry for my english....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 9:27 am 
Newbie

Joined: Tue Aug 26, 2003 9:59 am
Posts: 19
Location: Atlanta, GA
It sounds like you may not be implementing equals() and hashCode() in the class stored in the Set. Also, you should post the relevant mappings if you have not resolved the problem.

From one newbie to another, properly implementing equals() and hashCode() is critical when working with Collections in Hibernate. That is one of the first things to check.

_________________
Bill Siggelkow


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 1:31 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 7:53 pm
Posts: 66
Location: Lakeland, Florida USA
I had to also implement the Comparable interface for the objs stored in Set but right now can't remember why. You might want to think about this if hashCode & equals doesn't solve the problem.

Jeff


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 2:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Jeff, you might need Comparable if it was a sorted set. Otherwise you don't need it.


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.