-->
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: How to set an inital value for hilo algorithm
PostPosted: Tue Jun 01, 2010 2:28 am 
Newbie

Joined: Sun Mar 28, 2010 10:37 am
Posts: 2
Hi All,

I have an application that one of the entities' id was defined as 'native':

Code:
<id name="id" column="id">
            <generator class="native"/>
</id>


now, I would like to change the generator to use hilo algorithm:

Code:
        <id name="id" column="id">
            <generator class="org.hibernate.id.TableHiLoGenerator">
                <param name="table">uid_table</param>
                <param name="column">next_hi_value_column</param>
            </generator>
        </id>


However, since the table already existed (and had several entries in it), I would like the id generator not to start from '1', but from the next available id (if, for example, the last generated id was '10', I would like the next id to be no less than '11'). I do not expect it to be the exact number, but the problem now is that I get duplicate entries (with the same id) after the change.

My question is:
1. Can I define the first value that will be used as the ID?
2. Can I define the initial value for the ''next_hi_value_column" ? If i can change it to a greater number than the default, I will know for sure that the generated ids will be large enough and duplications will be avoided.

Do you have any idea?

Tnx!


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.