NoopOptimizer ignores negative allocationSize; uses default of 1 instead

Description

In my ORM.xml I have

<sequence-generator name="MY_SEQ" allocation-size="-1"
sequence-name="MY_SEQ"
initial-value="-10" />

When Hibernate creates the sequence the following statement executes:

create sequence MY_SEQ start with -10 increment by 1

In Derby, negative values can be used in Sequences

http://db.apache.org/derby/docs/10.6/ref/rrefsqljcreatesequence.html

I also noticed that if I have:

<sequence-generator name="MY_SEQ" allocation-size="1"
sequence-name="MY_SEQ"
initial-value="-10000000" />

The first time an Id is generated, Hibernate seems to be looping from 0 to initial-value for some reason.

I kept seeing "values next value for" printed to my output. It took about 5 minutes to get the first id generated.

Activity

Former userApril 29, 2017 at 2:52 AM

Fixed in master.

Former userApril 29, 2017 at 2:37 AM

When explicitly using NoopOptimizer and mapping indicates allocation size < -1; Hibernate will log a warning and use -1 as its allocation size.

This is similar to what Hibernate does when NoopOptimizer is explicitly used with an allocation size > 1; Hibernate logs a warning and uses 1 as its allocation size.

Former userApril 29, 2017 at 1:19 AM

I'll fix it so a negative allocation size works with negative sequence values for this issue.

will fix NoopOptimizer so it no longer skips negative values and 0 when it has a positive incrementSize.

Former userApril 27, 2017 at 5:19 AM

This is still an issue in 5.2.10.

Brett MeyerJuly 8, 2014 at 3:10 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Fixed

Details

Assignee

Reporter

Fix versions

Affects versions

Priority

Created February 16, 2011 at 2:57 PM
Updated September 13, 2017 at 6:25 PM
Resolved April 29, 2017 at 2:52 AM