Monday, January 30, 2012

hbm2ddl SchemaExport: You have an error in your SQL syntax near 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'

I used to create my MySQL DBs with ant and everything was working. Now, moving to maven and hbm2ddl I get this error.
After some searching it comes out that it's a problem of incompatibility between the MySQL Java connector (5.1) and the MySQL version (5.5) where type InnoDB was dropped and replaced with engine.

The solution is to change the MySQL dialect from org.hibernate.dialect.MySQLInnoDBDialect to org.hibernate.dialect.MySQL5InnoDBDialect.

Places where this generally occurs are hibernate.cfg.xml and hibernate.properties.

Tested on MySQL 5.5.22

No comments: