I have following mapping:
<id name="id" type="java.lang.Long" column="id">
<generator class="sequence">
<param name="sequence">tracksdata_seq</param>
</generator>
</id>
Everything went fine when I worked with it in Hibernate 4.2. Now I am migrating to Hibernate 5 and facing following issue:
2015-10-06 19:49:50 DEBUG SQL:92 - select nextval ('hibernate_sequence')
2015-10-06 19:49:50 DEBUG SqlExceptionHelper:122 - could not extract ResultSet [n/a]
org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist
How to resolve this issue?
P.S. Hibernate 5.0.2.Final.
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>
Use "sequence_name"
instead of "sequence"
in <param name="sequence">
.
That worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With