Hmm, no, that's not quite what Tuna said I believe.

Tuna's value should be 5000 (from your first mail) divided by gapsize
(max_lo) 100 = 50.

Algorithm is something like:
next_id = (my_cur_hi * max_lo) + my_cur_low.
with my_cur_low incremented on each iteration.

my_cur_hi is fetched from next_hi in database. So to ensure next_id is
larger than 5000, you need to ensure that your next_hi multiplied by
your configured max_lo is larger than 5000.

Actual implementation:
http://nhibernate.svn.sourceforge.net/viewvc/nhibernate/trunk/nhibernate/src/NHibernate/Id/TableHiLoGenerator.cs?annotate=3318

/Oskar


2010/5/31 Paulo Quicoli <[email protected]>:
> thank you Tuna.  So if my highest PK is 1000, my next_hi will be  502 (for
> safe)  :)
>
> thank you!
>
> 2010/5/31 Tuna Toksoz <[email protected]>
>>
>> Assuming your gapsize is 100, you'll need to set the hi in database to 51,
>> i guess. or 50, but to be safe use 52 :)
>> Tuna Toksöz
>> Eternal sunshine of the open source mind.
>>
>> http://devlicio.us/blogs/tuna_toksoz
>> http://tunatoksoz.com
>> http://twitter.com/tehlike
>>
>>
>>
>>
>> On Mon, May 31, 2010 at 3:31 PM, Paulo Quicoli <[email protected]>
>> wrote:
>>>
>>> Hi friends!
>>>
>>> I'm using Hilo in default way, so I have just one table
>>> (HIBERNATE_UNIQUE_KEY) with only one field (NEXT_HI).
>>>
>>> In this database I did a "conversion" of old data, so I have in other
>>> tables records with PKs from old database. These PKs are per table,
>>> sequenced (1,2,3,4, etc) and for me this is OK.
>>>
>>> I need to know how to configure my Hilo now, to generate correctly new
>>> PKs, as I have only one Hilo for all tables.  If my today my highest PK (in
>>> all existing tables) is 5000, how can I configure Hilo to generate values
>>> bigger than that?
>>>
>>> Thanks !
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Paulo Quicoli
>>> Editor Técnico: .NET Magazine, ClubeDelphi Magazine, WebMobile Magazine
>>> www.devmedia.com.br
>>> http://pauloquicoli.spaces.live.com
>>> twitter:@pauloquicoli
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "nhusers" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/nhusers?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>
>
>
> --
> Paulo Quicoli
> Editor Técnico: .NET Magazine, ClubeDelphi Magazine, WebMobile Magazine
> www.devmedia.com.br
> http://pauloquicoli.spaces.live.com
> twitter:@pauloquicoli
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to