-->
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: Help with mapping with composite-key
PostPosted: Wed Jun 28, 2006 3:34 pm 
Newbie

Joined: Mon Mar 06, 2006 9:41 am
Posts: 3
Hi all, I need some help mapping with composite-keys. I have two tables:

student
Code:
studentid VARCHAR(7)<PK>
age INTEGER
education VARCHAR(5)
faculty VARCHAR(5)
...other fields


studentexam
Code:
studentid VARCHAR(7)<PK>
languageid CHAR(3)<PK>
eventid INTEGER
starttime DATETIME
endtime DATETIME
result FLOAT


I need to map these two tables so that there is a way to find students with an eventid. I am stuck so any good ideas are welcome!!! Thanks in advance!!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 28, 2006 4:49 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Composite id are never a good idea with Hibernate. It's recommended to define a technical id.

Is your schema a legacy one ? I mean : is it new or already existing and used since a long time ?

If new, you should define an id in studentexam. It would be the primary key. Then define the student_id as an ref to student_id in the student table.

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 4:09 am 
Newbie

Joined: Mon Mar 06, 2006 9:41 am
Posts: 3
Schema is new so I will change it to use technical id and use the studentid as a ref. I don't know why I was trying to do this the hard way. Thanks!!!


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.