您的位置:首页 > 编程语言 > Java开发

关于hibernate5.1.0中Table 'spring.hibernate_sequence' doesn't exist的解决办法

2016-05-22 16:51 549 查看
错误主要信息:
 第一部分:at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) at
org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)org.hibernate.exception.SQLGrammarException: error performing isolated work
第二部分java.sql.SQLException: Table 'spring.hibernate_sequence' doesn't exist

 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)

 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
参考链接 http://stackoverflow.com/questions/32968527/hibernate-sequence-doesnt-exist 解决方法
方法1).在hibernate.cfg.xml中添加配置信息
<property name="hibernate.id.new_generator_mappings">false</property>
因为国外大神的简写自己改成上面的样子就可以。设置后如果hibernate.cfg.xml中设置的方言仍是旧版可能会引起方言问题,设置方式请自行百度
方法2)将id的生成策略设置成@GeneratedValue(strategy = GenerationType.IDENTITY)
虽然我也不知道,但是确实正确完成了。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: