[hibernate-dev] Negative sequence numbers

Steve Ebersole steve at hibernate.org
Wed Apr 19 09:33:00 EDT 2017


See inline...

On Tue, Apr 18, 2017 at 8:36 PM Gail Badner <gbadner at redhat.com> wrote:

> Should Hibernate support negative sequence values?
>

Absolutely.  Hibernate has historically supported decrementing and/or
negative values - so yes that should continue to work.


If so, is my proposed fix OK?
>

Define "OK" :)

As you said, your testing confirms that your proposed change "works".  So
from that simple perspective, yes it is "OK".  Although I think it can, and
maybe should, be slightly different - namely we really only need to encode
the increment value into the SEQUENCE definition when that increment is
something other than 1 (one) since that is the default increment for
SEQUENCEs.  So something like:

NoopOptimizer {
    ...
    public boolean applyIncrementSizeToSourceValues() {
            assert getIncrementSize() != 0;
            return getIncrementSize() != 1;
        }
}

Can increment for no-op be anything other than 1 or -1?  Zero is not valid.
 1 and -1 are both valid.  But what about 2 or -2?  I'm not sure that makes
sense.  The `!= 1` check handles that case.

However, I do have a concern about the design here and moving forward.  I
think there is some amount of technical debt here, and I think there was a
lot of confusion present even in the original code I wrote here.


More information about the hibernate-dev mailing list