I tried to upgrade hibernate from 4 to 5 in my project with spring 4.2
version. After this upgrade, I found the following error in my stack trace when I called a method for updating.
10:53:32,185 ERROR TableStructure:149 - could not read a hi value
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.hibernate_sequence' doesn't exist
I changed the auto incremented Id with annotation
@GeneratedValue(strategy=GenerationType.AUTO)
still the error remains.
By default, Hibernate generates key from hibernate_sequence table, we can disable it by setting this hibernate. use-new-id-generator-mappings to false.
If you use strategy="AUTO" , Hibernate will generate a table called hibernate_sequence to provide the next number for the ID sequence. You may have forgotten to add the AutoIncrement feature to your table's PK.
hibernate_sequence' doesn't exist error occurs when the hibernate_sequence table does not exist in the database and auto id generation in hibernate is enabled. Hibernate generates and stores the current id for auto-increment column values in the hibernate sequence table. The error java. sql.
Hibernate 3.5 introduced a core property named hibernate. id. new_generator_mappings that directs how identity or sequence columns are generated when using @GeneratedValue .
You can also put :
@GeneratedValue(strategy = GenerationType.IDENTITY)
And let the DateBase manage the incrementation of the primary key:
AUTO_INCREMENT PRIMARY KEY
You need to set for Hibernate5.x <property name="hibernate.id.new_generator_mappings">false</property>
.. see and link.
For older version of hibernate 4.x:
<prop key="hibernate.id.new_generator_mappings">false</prop>
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