[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3586) SequenceHiLoGenerator generates values ahead of the actual sequence

Robin Sander (JIRA) noreply at atlassian.com
Fri Mar 26 05:29:32 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3586?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35967#action_35967 ] 

Robin Sander commented on HHH-3586:
-----------------------------------


@Krasimir: you got me wrong, I should better have written:
"The multiplication is needed to "reserve" a sequence of identifiers without increasing the sequence for every one".
I used quotes for reserve, because those values aren't really reserved in the database.
To use your example:

1. sequence has current value 1000
2. fetch nextval and "reserve" 50 values, so in memory we would have values from 1001 to 1051
3. sequence has current value 1001 now

What happens now if the sequence is used for another type or by another cluster node?
You would use values from 1002 to 1052 so we would have a big problem.

I think what you got in mind is to increase the value of the sequence by (step+1) and hence really reserve those values
in the database. I don't know whether this is possible or not (performance?), maybe some core developers could shed some
light on this topic?
(I've got nothing to do with the code nor the algorithm, just stumbled accross this issue because I wondered about those
 gaps in ID generation myself)


> SequenceHiLoGenerator generates values ahead of the actual sequence
> -------------------------------------------------------------------
>
>                 Key: HHH-3586
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3586
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.1
>         Environment: Hibernate 3.3.1, Oracle 10G
>            Reporter: Krasimir Chobantonov
>   Original Estimate: 1 hour
>  Remaining Estimate: 1 hour
>
> The code that needs to be change in on line 83 of the SequenceHiLoGenerator
> here is the line
> 			hi = hival * ( maxLo+1 );
> basically we should add (+) the maxLo +1 to the current sequence value represented bu the hival instead of using multiply (*)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list