hibernate自动键表报MySQL server version for the right syntax to use near 'type=InnoDB' at line 1

来源:互联网 发布:软件测试方法和策略 编辑:程序博客网 时间:2024/05/16 09:30

在用hibernate自动生成表的时候发现报如下错误

    [ERROR][2016-07-05 14:42:00] org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:213) 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 

工作中使用sql语句建表时,发现如下错误:

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不支持type写法,将type关键词改成ENGINE 即可


那么可想而知肯定是Hibernate方言有问题

org.hibernate.dialect.MySQLInnoDBDialect(mysql5.0以前使用)
改为

org.hibernate.dialect.MySQL5InnoDBDialect(mysq5.1-5.5)


或者直接写成

org.hibernate.dialect.MySQLDialect


1 0
原创粉丝点击