Java – hibernate 5: generator class = “sequence” does not work properly
•
Java
I have the following mappings:
<id name="id" type="java.lang.Long" column="id"> <generator class="sequence"> <param name="sequence">tracksdata_seq</param> </generator> </id>
When I used it in Hibernate 4.2, everything went well Now I am migrating to hibernate 5 and facing the following problems:
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 solve this problem?
Attachment: Hibernate 5.0 2.Final.
Solution
You have two choices:
>You will hibernate id.new_ generator_ Set the mappings configuration property to false and switch back to the old identifier generator > you can change the mapping as follows:
<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>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码