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

时间:2022-06-24 01:37:49

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

 org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:213) You have an error in your SQL syntax; check the manual that corresponds to yourMySQL server version for the right syntax to use near 'type=InnoDB' at line 7

工作中使用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 line7

二、解决方案:

这个报错是由于某些版本的mysql不支持type写法,将type关键词改成ENGINE 即可


那么可想而知肯定是Hibernate方言有问题 [html] view plain copy print?hibernate自动键表报MySQL server version for the right syntax to use near 'type=InnoDB' at line 7hibernate自动键表报MySQL server version for the right syntax to use near 'type=InnoDB' at line 7
  1. org.hibernate.dialect.MySQLInnoDBDialect(mysql5.0以前使用)  
改为 [html] view plain copy print?hibernate自动键表报MySQL server version for the right syntax to use near 'type=InnoDB' at line 7hibernate自动键表报MySQL server version for the right syntax to use near 'type=InnoDB' at line 7
  1. org.hibernate.dialect.MySQL5InnoDBDialect(mysq5.1-5.5)  


或者直接写成

[html] view plain copy print?hibernate自动键表报MySQL server version for the right syntax to use near 'type=InnoDB' at line 7hibernate自动键表报MySQL server version for the right syntax to use near 'type=InnoDB' at line 7
  1. org.hibernate.dialect.MySQLDialect