根据报错信息,错误在’type=InnoDB’,这个和版本有关系。
具体报错信息:
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 7
解决方案:
<!-- <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> -->
//将上述配置改为一下方言
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
说明:
使用org.hibernate.dialect.MySQLInnoDBDialect后,hibernate5.0之后的版本会报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 7,这个问题只需要将’type=InnoDB’改为”Engine=InnoDB”,也就是因为hibernate 使用的方言问题,将方言给org.hibernate.dialect.MySQL5InnoDBDialect即可。
总结:hibernate中,对于mysql version5.1~5.5,都是‘MySQL5InnoDBDialect’!