An error occurred while creating tables in Hibernate4 and later versions of MySQL5.1. type = InnDB, hibernate4mysql5.1
When building the springmvc framework, the bottom layer uses hibernate4.1.8, and the database uses mysql5.1. When hibernate is used to automatically generate a database table, the hibernate dialect uses org. hibernate. dialect. mySQLInnoDBDialect: an error occurs when the table is automatically generated, as shown in the following code:
Copy codeThe Code is as follows: [13-04-13 19:11:37. 190] {resin-60} 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 8
Later, I searched the internet and found that the reason was that type = InnoDB was usable before 5.0, but it would not work after 5.1. If we change type = InnoDB to engine = InnoDB, this problem will not occur. However, I want to use Hibernate to automatically create tables for me. What should I do. This is related to the database dialect we specified (dialect.
You only need to modify the configuration:
Hibernate. dialect = org. hibernate. dialect. MySQLInnoDBDialect
To:
Hibernate. dialect = org. hibernate. dialect. MySQL5InnoDBDialect
To sum up, use MySQL5InnoDBDialect in MySQL and later versions.
The above is how to solve the problem of automatically creating tables in MySQL5.1 by Hibernate4. I hope to give you a reference and learn more about MySQL syntax. You can follow MySQL 5.1 reference manual. we also hope that you can support the customer's home.