LegacyFallbackInterpreter does not set properly sequence name

Description

This bug was found in 5.0.9 though it seems to be the same for latest versions as well.

As part of migration from hibernate 4 to 5, system that already have data and thus can't use the new generators (due to them being incompatible) ran into problems with duplicated ids for primary keys because of the shared hibernate_sequence was used instead of sequence per table (entity) that was already existing and with correct information (current value) in postgresql db.

This looks like an issue with wrong parameter name in here:
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/boot/internal/IdGeneratorInterpreterImpl.java#L189

it uses "sequence" instead of "sequence_name" that is expected here:
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java#L275

Environment

PostgreSQL 9.4 with hibernate 5.0.9

Activity

Show:
Andrea Boriero
March 7, 2017, 11:29 AM

I'll give a look, Thanks

Andrea Boriero
March 7, 2017, 11:42 AM

, can u provide a test please? Thanks

Maciej Swiderski
March 7, 2017, 12:44 PM
Edited

test case attached - when you run it see the output of the getting sequence number. Please note that this is for local postgresql data base as I found it to be an issue there. Tested with 5.0.9 version as this is the one we currently use. We do plan to upgrade to 5.1.4 soon, will test it with that version as well.

relevan output from the test

Maciej Swiderski
March 7, 2017, 12:48 PM

hmm interesting as this seems to work fine in 5.1.4, moreover I tested the 5.0.x versions and the first one that does work as expected is 5.0.11. It produces following output:

so talking that into consideration looks like the problem has been already fixed.

Andrea Boriero
March 7, 2017, 12:49 PM

, Thanks a lot

Assignee

Andrea Boriero

Reporter

Maciej Swiderski

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure