An error occurred while creating tables in Hibernate4 and later versions of MySQL5.1. type = InnDB, hibernate4mysql5.1

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.