In an application (http://euregjug.eu, also on Github), i have the requirements to run on H2 and on Postgres.
Tables are generated with "serial" primary key columns, that is auto incrementing primary keys.
In Hibernate 4.3 I could use the following ID column mappings:
On H2, it picked up Identity, on Postgres it chose Sequence, using the given sequence which is automatically created by Postgres when used something like
After upgrading to Hibernate 5.0.9 and setting "hibernate.id.new_generator_mappings" to false, Hibernate does seem to lookup the generator but doesn't pick up the sequence, instead tries to use hibernate_sequence.
It picks up the correct sequence when using the new_generator_mappings, but then i have to configure "allocationSize = 1, initialValue = 1" or even worse, have to resort to GenericGenerator for configuring which optimization to use.
What does work for both databases is using Identiy (which basically is what i want anyway for both H2 and Postgres, see https://github.com/EuregJUG-Maas-Rhine/site/commit/7070dcebd432a338e14efb82b2d8abbae00b4b18), but Hibernate not picking up the sequence is an annoyance, especially due to the fact of recently released Spring Boot 1.4, which sets the new_generator_mappings to false by default.
Attached are two test cases, one for 4 and one for 5, running agains Postgres.
4 works as expected, 5 not. For 5 I'd expect hibernate to pick up the "links_id_seq" and fail then on the insert as the sequence is not correctly configured for use with the new, optimized sequence generator.
The "Link" example is from my JUGs site.
Thanks for looking at this,