开发者

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 serve开发者_如何转开发r 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


Use MySQL5InnoDBDialect instead of MySQLInnoDBDialect.


Using 'MySQL5InnoDBDialect' works with 5.1 and 5.5.


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


Just in case if you have changed to org.hibernate.dialect.MySQL5InnoDBDialect (e.g. on MariaDB) and still getting the error check whether the table name (or any other in the query) is not a reserved word or existing object name (e.g. 'position').


After adding MySQL5InnoDBDialect, I got same error but with "Engine=InnoDB". So I added MySQL5InnoDBDialect in properties file and removed @Table annotations from model file.


type is deprecated, and removed from newest versions. Use engine=InnoDB


No meu caso, instalei o MySQL v5.6.20, e ao rodar minha aplicação que usa Hibernate, teve colocar MySQL5InnoDBDialect.

Segue o trecho (persistence.xml) da tag properties:

<properties>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/livrariadb" />
        <property name="javax.persistence.jdbc.user" value="root" />
        <property name="javax.persistence.jdbc.password" value="****" />

        <property name="hibernate.hbm2ddl.auto" value="update" />
        <property name="hibernate.show_sql" value="false" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
</properties>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜