-->
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 maintain uniqueness of composite key for data insert
PostPosted: Thu Feb 02, 2006 1:46 pm 
Newbie

Joined: Thu Feb 02, 2006 1:34 pm
Posts: 6
Hi,

In a table i need to implement composite primary key comprising of two table attributes.

in the hbm mapping file, i declared the composite id as :

<composite-id>
<key-property name="medicareNumber"/>
<key-property name="dependent"/>
</composite-id>

but when i insert data into the table having composite key, i am able to insert same values for composite key attributes for multiple records.

Some how hibernate is not able to verify the uniqueness of the composite key.

Do i need to overide the equals and hashcode method. If so what implementation is reqd so that hibernate can check for composite id uniqueness.

thnx
shankar


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 5:20 am 
Newbie

Joined: Thu Feb 02, 2006 1:34 pm
Posts: 6
sorry guys , the problem was in the database level , so hibernate was able to use the composite key constraint


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.