I have following mapping:
I also encountered this problem when migrating from Hibernate 4.3.10 to Hibernate 5.0.4. Like maksim2020, I replaced instances of <generator class="sequence"> with <generator class="identity">. However, to preserve the id sequence for the affected tables I also had to write a sql migration script which set the default value for the column to be the next value of the existing sequence. In PostgreSQL this is done as follows:
ALTER TABLE ONLY affected_table ALTER COLUMN affected_id SET DEFAULT nextval('original_sequence'::regclass);
Use "sequence_name" instead of "sequence" in <param name="sequence">.
That worked for me.
You have two options:
hibernate.id.new_generator_mappings configuration property to false and switch back to the old identifier generatorsYou change the mapping as follows, from this:
<generator class="sequence">
<param name="sequence">MY_SEQUENCE</param>
</generator>
to:
<generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
<param name="optimizer">none</param>
<param name="increment_size">1</param>
<param name="sequence_name">MY_SEQUENCE</param>
</generator>