hibernate 无法自动创建表 的解决办法

来源:互联网 发布:python判断是否是str 编辑:程序博客网 时间:2024/05/21 10:40

执行session.save() 时出现异常:

org.hibernate.exception.SQLGrammarException: could not execute statement

无法创建表。

解决方法:

1)确定配置:

<property name="hibernate.hbm2ddl.auto">update</property>


2)如果是mysql5的话,确定配置:

<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>

注意红字部分。

MySQLInnoDBDialect,生成的建表语句中用type=InnoDB,

而MySQL5InnoDBDialect是ENGINE=InnoDB

1 0
原创粉丝点击