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.

Environment

Hibernate 3.6.0, Derby 10.6

Activity

Show:
Brett Meyer
July 8, 2014, 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!

Gail Badner
April 27, 2017, 5:19 AM

This is still an issue in 5.2.10.

Gail Badner
April 29, 2017, 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.

Gail Badner
April 29, 2017, 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.

Gail Badner
April 29, 2017, 2:52 AM

Fixed in master.

Assignee

Gail Badner

Reporter

Rich Sayre

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure