Legacy-hilo optimizer does not generate the correct value

I migrated from Hibernate 5 to 6, in the old implementation I used SequenceGenerator @SequenceGenerator(name = "SEQ_NAME", sequenceName = "SEQ_NAME", allocationSize = 50), this called SequenceHiLoGenerator and LegacyHiLoAlgorithmOptimizer.

The behavior was: if the last value of sequence in database is 100, the value is multiplied by allocationSize (100x50=5000), the value of sequence stared in 5000, 5001…5049.

The hibernate 6 version multiple by allocationSize/incrementSize +1.

Below code segment is the implementation of sequence in hibernate 6

@GenericGenerator(
        name = "X_SEQ",
        type = org.hibernate.id.enhanced.SequenceStyleGenerator.class,
        parameters = {
            @Parameter(name = "sequence_name", value = "X_SEQ"),
            @Parameter(name = "initial_value", value = "1"),
            @Parameter(name = "increment_size", value = "50"),
            @Parameter(name = "optimizer", value = "legacy-hilo")
        })

Same example, last value of sequence in database is 100, the value is multiplied by increment_size+1 (100x51=5100), the value of sequence stared in 5100, 5101…5149.

In hibernate 5 the maxLo value is 49 (allocationSize-1), in hibernate 6 the maxLo is the same incrementSize (50)

Is this a bug?
Did I miss something in the configuration?

Thanks in advance.

I gave the code a quick look but couldn’t find a difference between 5 and 6 that would explain this. Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer. Ideally, you’d also provide a reproducer based on ORM 5, for which you should be able to just copy and paste the code.