-->
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.  [ 4 posts ] 
Author Message
 Post subject: Does the primary key have to be the first column in the tabl
PostPosted: Tue Jun 20, 2006 12:23 pm 
Newbie

Joined: Tue Jun 20, 2006 12:06 pm
Posts: 2
Hi there,

just trying to plug hibernate into some legacy tables and have come a bit unstuck with the primary key.

In one of the tables the primary key is the second column in the table. Now when I create the objectname.hbm.xml I have to declare the ID before the property columns. This seems to imply that the primary key (or composite PK) has to be first in the table.

Does anyone know a way around this at all - changing the table is not an option.

Thanks in advance.
Cheers,
Maggie.


Top
 Profile  
 
 Post subject: Re: Does the primary key have to be the first column in the
PostPosted: Tue Jun 20, 2006 1:05 pm 
Beginner
Beginner

Joined: Sun Jul 10, 2005 12:11 pm
Posts: 32
Location: Hertfordshire, England
mflavell wrote:
<snip>
In one of the tables the primary key is the second column in the table. Now when I create the objectname.hbm.xml I have to declare the ID before the property columns. This seems to imply that the primary key (or composite PK) has to be first in the table.

Does anyone know a way around this at all - changing the table is not an option.


There's absolutely no requirement that columns are in the same order in the database; in fact SQL doesn't specify column / fields ordering either.

Try it and see - it should work just fine as long as the column names are correct!

Christian Ashby

_________________
--
Christian Ashby
Spiralinks, Inc.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 21, 2006 5:00 am 
Newbie

Joined: Tue Jun 20, 2006 12:06 pm
Posts: 2
Cool, thanks for that.

I hadn't tried with the existing database, just used a new one for testing that was created from the xxx.hbm.xml files hence I thought there was a problem.

Cheers,
Maggie.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 21, 2006 5:21 am 
Beginner
Beginner

Joined: Sun Jul 10, 2005 12:11 pm
Posts: 32
Location: Hertfordshire, England
Thanks! Please don't forget to rate!

_________________
--
Christian Ashby
Spiralinks, Inc.


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