-->
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: How to reset the ID generators per table
PostPosted: Tue Aug 19, 2008 4:33 am 
Newbie

Joined: Tue Aug 19, 2008 4:08 am
Posts: 2
How can I reset (force) the ID generation to be started from 1 per each table? currently I am using the <generator class="native"> element for each object id mapping. but when it comes to DB insertion the ID keep incremented uniquely per all tables. can I make it unique only per each table..

e.g

if I inserted 3 customer objects (into customer table) then inserted 3 order object (into order table)

Customer table
-----------------
customer_id (will take the following values) ---> 1,2,3

order table
-------------
Order_id (will take the following values) ---> 4,5,6

What I need to do is to make the order_id takes values of 1,2,3 so the ID will be unique per table.

Appreciate your help,


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 19, 2008 6:36 am 
Newbie

Joined: Mon Aug 18, 2008 6:37 am
Posts: 4
if your database supports sequences, then you can have sequence defined for each table and use it with the below configuration setup in hbm files

<id name="id" type="long" column="emp_id">
<generator class="sequence">
<param name="sequence">emp_id_sequence</param>
</generator>

</id>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 19, 2008 6:47 am 
Newbie

Joined: Tue Aug 19, 2008 4:08 am
Posts: 2
thank you so much.


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.