hibernate create自动创建表异常问题

Hibernte中的hibernate.hbm2ddl.auto设置成create,让Hibernate帮助自动建表,但不成功,报如下信息:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 1

    我的mysql 数据库是5.7版本的,所以要改变方言,因为:type=InnoDB在5.0以前是可以使用,但5.1之后就不行了。

  如果把type=InnoDB改为engine=InnoDB就不会有这个问题。

但是想使用Hibernate,自动建表就需要将:

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

改为:

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

猜你喜欢

转载自my.oschina.net/u/2358326/blog/1649184