-->
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: Knowing the next number of a sequence
PostPosted: Thu Mar 27, 2008 4:58 pm 
Newbie

Joined: Tue Jan 22, 2008 9:53 am
Posts: 18
Hi ppl,

I have a strange doubt. I need to insert in two tables. One of them has a sequencial primary key. Ok till them, but i need to insert in other table with a composite key. One of the composed fields must have the same value of the primary key given to the first table.
So... i have two possibilities.
I need to know what will be the number that the record will get according to the sequence and use it to build my composite key... or...
I could use a foreign generator in just one field of a composite key.

i don´t know how to do any of these possibilities.

Have anyone solved any problem like this.

This is the mapping of my key:

<composite-id>
<key-property name="card_id" type="integer" />
<key-property name="card_property_id" type="integer" />
</composite-id>

Thanks in advance for any ideas

T.H.


Top
 Profile  
 
 Post subject: Re: Knowing the next number of a sequence
PostPosted: Thu Mar 27, 2008 8:46 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
You could use a <key-many-to-one ...> if there is a logical relation between the key and the entity.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 8:12 am 
Newbie

Joined: Tue Jan 22, 2008 9:53 am
Posts: 18
Hi,

It´s not exactly my case. I tried to use a foreign generator in composite key, but it didn´t work.
Probably, te better way is find out how to get the sequence number the record will receive.

Have any idea ?

Thanks

Thiago


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.