-->
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: How can i have a combination of properties as unique
PostPosted: Mon Dec 11, 2006 1:18 am 
Newbie

Joined: Mon Dec 11, 2006 1:06 am
Posts: 5
Hi ,

Is it possible to have a combination of properties as unique ??

For ex : Consider name ,company name are separate properties.

Is it possible to have name and company name combined together as unique??? How can i specify in mapping ???

Thanks in Advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 11, 2006 1:58 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Good question, I'm not sure it's possible. Maybe yes if you map your three properties as one component, then redefine equals/hashCode so as to compare your objects equality the way you want ?

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject: How can i have a combination of properties as unique
PostPosted: Mon Dec 11, 2006 8:25 am 
Newbie

Joined: Mon Dec 11, 2006 1:06 am
Posts: 5
Hi ,

There is another option in addition to your answer .You can use composite key also..

Thanks a lot :)


Top
 Profile  
 
 Post subject: Re: How can i have a combination of properties as unique
PostPosted: Mon Dec 11, 2006 8:38 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
jothiprasadh wrote:
There is another option in addition to your answer. You can use composite key also..

Yes, but you didn't say that those properties were keys or your class, that's why I didn't speak about composite-id. By the way, note that it's said to be better to map a component as a composite key instead of mapping many fields as belonging to the key. I'm not sure I'm very clear :-).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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.