Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL 5.5.9 and Hibernate table creation error on TYPE

While trying to recreate my database using Hibernate + Spring, the SQL that get's generated appends "type=InnoDB" to the end of each creation statement. This seems to cause problems with my MySQL5.5.9 setup. It produces the following error:

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

If I manually remove the type=InnoBD and paste the create command in MySQL, it works fine.

Has someone else come across this error? Is it maybe just a MySQL setting that I need to change? I am using the my-innodb-heavy-4G.cnf template as my /etc/my.cnf.

I also know that the type syntax has been deprecated by MySQL, and that engine should be used (and it does if I manually alter the create statements). Is there any way to configure this in Hibernate?

Thanks

like image 622
Nico Huysamen Avatar asked Mar 08 '11 10:03

Nico Huysamen


3 Answers

Use MySQL5InnoDBDialect instead of MySQLInnoDBDialect.

like image 160
axtavt Avatar answered Oct 11 '22 08:10

axtavt


Using 'MySQL5InnoDBDialect' works with 5.1 and 5.5.

like image 36
redBeard Avatar answered Oct 11 '22 09:10

redBeard


In Grails:

Change the dialect statement in DataSource.groovy

Example:

Use "dialect=org.hibernate.dialect.MySQL5InnoDBDialect" instead of "dialect=org.hibernate.dialect.MySQLInnoDBDialect"

You can use the same approach for your project i guess.

Thanks

like image 42
Saeed Afzal Avatar answered Oct 11 '22 07:10

Saeed Afzal