代码改变世界

MySql的数据库方言问题

2013-12-18 11:50  雨打夏夜  阅读(1335)  评论(0编辑  收藏  举报

在使用hibernate将po(一般对象类)转化为数据库表时,如果mysql的版本为5.0之前的,则方言写为:<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>。如果是5.0之后的,则为<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>。否则会报错: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。

在hibernate生成的建表语句里,对于mysql5.0之后的版本,将type=InnoDB改为engine=InnoDB