-->
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.  [ 3 posts ] 
Author Message
 Post subject: can I use unique key for relation
PostPosted: Thu Apr 22, 2004 5:51 am 
Newbie

Joined: Thu Mar 18, 2004 5:06 am
Posts: 5
Location: Tian Jin University of China
I hope I don't ask a stupid question.
Hibernate recommend seperating object id and business key,for example,
a product has a auto-generate id and a unique product serial No. Here is the question:
I and my colleagues are beginners for hibernate,in a recent project,I stick to the foreign key is referenced by id(auto-generate id),but one of my colleagues argues that we should use the business key(product serial No.) for FK. Of course,hibernate allow both,could you give me some valuable suggestion?thanks very much!

_________________
Nothing is impossible to a willing heart


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 6:15 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Always use the surrogate key for primary and foreign key constraints. Thats the point, really. The purpose of the surrogate key is to allow the separation of database internal semantics (PK and FK constraints) from external business semantics.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 9:14 pm 
Newbie

Joined: Thu Mar 18, 2004 5:06 am
Posts: 5
Location: Tian Jin University of China
Thanks, christian!Your answer comes just in time,by the way I am very glad that you understand my shabby English.

_________________
Nothing is impossible to a willing heart


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.