Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate无法在数据库中创建表。_Hibernate_Hibernate Mapping - Fatal编程技术网

Hibernate无法在数据库中创建表。

Hibernate无法在数据库中创建表。,hibernate,hibernate-mapping,Hibernate,Hibernate Mapping,当我执行session.save(Object)Hibernate时,会出现许多错误。我已经在尽可能多的论坛上发布了这个问题 第一个错误:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Table'entity.listOfcases'不存在 然后我还看到一个错误: check the manual that corresponds to your MySQL server version for the right synta

当我执行session.save(Object)Hibernate时,会出现许多错误。我已经在尽可能多的论坛上发布了这个问题

第一个错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Table'entity.listOfcases'不存在

然后我还看到一个错误:

check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 1
我在hibernate映射文件中使用了“update”和“create”,但仍然没有在数据库中自动创建表

<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.hbm2ddl.auto">update</property>
创建
更新
上面两个都用过

第三个错误:
“org.hibernate.exception.sqlgrammareexception:无法获取增量生成器的初始值”


我已经检查了所有getter setter和所有POJO类。一切都很好。当我手动创建表时,一切都很好,只是当我删除这些表并尝试自动创建它们时,一切都不起作用

在Hibernate映射文件(即Hibernate.cfg.xml)中进行以下更改:

<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
org.hibernate.dialent.mysql5innodbdialent
而不是现在说什么。我假设:

<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
org.hibernate.dialent.mysqlinnodbdialent

如果您说您已经检查了其余的代码,那么这肯定会处理所有的错误

对我来说,当我从 org.hibernate.dialogue.mysqldialogue 到
org.hibernate.dialogue.mysql57dialogue

您是否尝试过自己创建
?如果您手动创建了架构,您是否尝试了
create drop
,然后切换到
create
?但都没有执行。我手动创建的数据库名为“test”,然后我创建了一个名为“entity”的新数据库,然后在所有必要的地方进行了更改。我也会尝试一下。我不敢相信这个小小的更改解决了这个问题。我已经在无数论坛上发布了这篇文章,但毫无用处。:-)非常感谢。请在下次发布代码,这样读者就可以在自己的IDE中复制/粘贴代码,而不是自己编写其余部分。