休眠序列不存在

新手上路,请多包涵

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

 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)

错误仍然存在。

原文由 rParvathi 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 731
2 个回答

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

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

原文由 rParvathi 发布,翻译遵循 CC BY-SA 4.0 许可协议

你也可以把:

 @GeneratedValue(strategy = GenerationType.IDENTITY)

并让 DateBase 管理主键的递增:

 AUTO_INCREMENT PRIMARY KEY

原文由 Kikou 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题