-->
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: Why to create ID column when table is mapped to two tables?
PostPosted: Thu Oct 26, 2006 3:36 am 
Beginner
Beginner

Joined: Mon Jul 03, 2006 5:40 am
Posts: 20
Location: Russia
I have a general question (simple, I hope) about hibernate mappings:

suppose, I have 3 tables:
test
testrun
testresult

"testresult" table is linked to "test" and "testrun" through foreign keys,
so it has a composite primary key consisting from 2 foreign keys.

I saw somewhere in the documentation that it is recommented to always create numeric primary key (ID) in every table for hibernate.
so, in this case "testresult" table would have "ID" primary key, and not "test_id & run_id".

would such a change improve/simplify development with Hibernate?
is it useful to modify the scheme to add this field in my case?

here's a quotation from the documentation:
Quote:
1.2.1. The first class
..........
The id property holds a unique identifier value for a particular event. All persistent entity classes (there are less important dependent classes as well) will need such an identifier property if we want to use the full feature set of Hibernate.


Top
 Profile  
 
 Post subject: Re: Why to create ID column when table is mapped to two tabl
PostPosted: Thu Oct 26, 2006 8:11 am 
Beginner
Beginner

Joined: Thu Sep 22, 2005 10:48 am
Posts: 30
Location: Rio de Janeiro, Brazil
alskor wrote:
in this case "testresult" table would have "ID" primary key, and not "test_id & run_id".

Use composite-id . If you have a problem to mapping this, post replay :)

_________________
Please don't forget to rateME!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 12:47 am 
Beginner
Beginner

Joined: Mon Jul 03, 2006 5:40 am
Posts: 20
Location: Russia
well, the same documentation says the use of composite-id is intended for legacy data and not recommended for anything else...
since I have a new database, so can freely modify it - I'd like to adjust it for best hibernate usage.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.