-->
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: Oracle composite PKs and sequences
PostPosted: Thu Mar 15, 2007 11:53 am 
Beginner
Beginner

Joined: Tue Mar 13, 2007 9:46 am
Posts: 20
I have a primary key of a table "tabA" that consists of two columns "colA" and "colB". My questions are:

1. How can I specify a mapping so that each of these columns have a separate sequence associated. As far I can see, the generator-element does not apply to a column, but the primary key as a whole?

2. How can I specify a mapping so that when I assign the value of one of these id-fields, the other get populated by a sequence specified by a generator-element?

I suspect I have to do all this manually by querying the sequence first and then assign the values to the Ids, but I was hoping to avoid this.

Regards,
Stein


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 12:43 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
It's not possible with Hibernate at the moment. In fact, you'll have to retrieve values by yourself, because composite ids are considered assigned (which seems logical to me).

It's simply impossible because it's not even possible to specify any custom IdentifierGenerator, which would have made it quite feasible.

I suppose you're accessing a legacy schema and so that you can't define a surrogate primary key?

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


Top
 Profile  
 
 Post subject: Re: Oracle composite PKs and sequences
PostPosted: Thu Mar 15, 2007 10:55 pm 
Newbie

Joined: Tue Mar 13, 2007 9:49 pm
Posts: 8
steinrr wrote:
I have a primary key of a table "tabA" that consists of two columns "colA" and "colB". My questions are:

1. How can I specify a mapping so that each of these columns have a separate sequence associated. As far I can see, the generator-element does not apply to a column, but the primary key as a whole?

2. How can I specify a mapping so that when I assign the value of one of these id-fields, the other get populated by a sequence specified by a generator-element?

I suspect I have to do all this manually by querying the sequence first and then assign the values to the Ids, but I was hoping to avoid this.

Regards,
Stein


Just curious, how would a table be designed like this ?
Normally, a composite key should happen what the key columns itself is a foriegn key.

If the columns are not referenced to any tables, why you want a multiple key columns ?


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.