-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Sequence id for a key in composite id
PostPosted: Sun Feb 28, 2016 7:15 pm 
Newbie

Joined: Sun Feb 28, 2016 6:49 pm
Posts: 1
HI I have a requirement where a class has two keys..one key is an identifier--manually assigned while inserting and the other one is a sequence value for the next value of that column with that identifier in that table.


So I tried doing like this
<composite-id>
<key-property name="XXX" type="XXX" length="XX">
<column name="matching-name" not-null="XX"/>
</key-property>

<key-property name="seq" type="XXX" length="XX">
<column name="matching-table_name_SEQ" not-null="XX"/>
</key-property>


</composite-id>

Now i need to make the second key(the highlighted-one) as a generator.. I tried to insert the generator class element inside <key-property> But it is not accepting...Can any one suggest me how to make the second as a sequence generator.

Thank you very much.


Top
 Profile  
 
 Post subject: Re: Hibernate Sequence id for a key in composite id
PostPosted: Mon Feb 29, 2016 2:17 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The generator only works for identifiers. You can use a @Generated column and set the column value during insert with a database trigger.


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