休眠序列不存在

2022-08-31 10:40:15

我试图在我的项目中使用春季版本将休眠从4升级到5。此升级后,当我调用更新方法时,我在堆栈跟踪中发现了以下错误。4.2

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 

我更改了带有注释的自动递增 Id

@GeneratedValue(strategy=GenerationType.AUTO) 

错误仍然存在。


答案 1

你也可以把:

@GeneratedValue(strategy = GenerationType.IDENTITY)

并让 DateBase 管理主键的递增:

AUTO_INCREMENT PRIMARY KEY

答案 2

您需要为Hibernate5.x设置.查看并链接<property name="hibernate.id.new_generator_mappings">false</property>

对于旧版本的休眠 4.x:<prop key="hibernate.id.new_generator_mappings">false</prop>


推荐