-->
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: Question about using surrogate primary keys
PostPosted: Wed Jul 08, 2009 7:27 am 
Newbie

Joined: Thu Aug 07, 2008 3:41 pm
Posts: 14
Hello,

So I have this table CLIENT, which has a surrogate PK called CLIENT_ID.
Because CLIENT_ID is generated by the database, how can I prevent it from entering logical duplicates?

I think the CLIENT_NAME is a good indicator for duplicates.
Do I need to query now CLIENT_NAME every time I want to persist / merge?
Because I dont have CLIENT_NAME as PK?

Any suggestions?


Top
 Profile  
 
 Post subject: Re: Question about using surrogate primary keys
PostPosted: Thu Jul 09, 2009 4:40 am 
Newbie

Joined: Wed Apr 25, 2007 8:23 am
Posts: 8
Hello,

if you would have CLIENT_NAME as PK and tried to add a duplicate
the database will generate an error -> exception.
The same effect has an unique key constraint if you leave CLIENT_ID as PK.
Do you want that ?

I think it would be better to search for duplicates in the application and set an unique index on CLIENT_NAME.

Norbert


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.