当我执行session.save(Object)时,Hibernate给出了很多错误。我已经在尽可能多的论坛上发布了这个问题
第一个错误:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'entity.listOfcases' doesn't exist
然后我也看到了另一个错误:
check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 1
我在休眠映射文件中都使用了“ update”和“ create”,但仍未在数据库中自动创建表。
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.hbm2ddl.auto">update</property>
上面同时使用了它们。
第三错误:"org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator"
我已经检查了所有的getter设置程序和所有的POJO类。一切顺利。当我手动创建表时,一切工作都很好,只是当我删除这些表并尝试自动创建它们时,它不起作用。
在您的Hibernate映射文件中,即hibernate.cfg.xml中进行以下更改:
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
而不是现在所说的。我假设:
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
如果您说您已经检查了其余代码,那么这肯定会解决所有错误。
对我来说,当我从org.hibernate.dialect.MySQLDialect至org.hibernate.dialect.MySQL57Dialect