-->
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.  [ 1 post ] 
Author Message
 Post subject: Primary key and alternate key each with its own sequence
PostPosted: Thu Jan 10, 2008 1:06 pm 
Newbie

Joined: Thu Jan 10, 2008 12:53 pm
Posts: 1
Hibernate version:
3.2.5.ga

Name and version of the database you are using:
Oracle

I have a table with a primary key 'id' and an alternate key 'public key'. The primary key column gets its values from one sequence and the public key gets its value from another sequence.

How can I specify this in my mapping file? I can use a sequence generator for the id column, but I need another sequence generator for the public key column, and the mapping file only allows one id/generator.

Is this a situation to use a Generated Property? It doesn't seem like it, because the public key value is not determined by a trigger. Typical sql for inserting a row would be something like:

Code:
insert into mytable (id, public_key, blahblah) values ((select ID_SEQ.NEXTVAL from dual), (select PUBKEY_SEQ.NEXTVAL from dual), ?)


Changing the table schema is not an option.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.