"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Create MySQL InnoDB Tables with Hibernate?

How to Create MySQL InnoDB Tables with Hibernate?

Published on 2024-11-22
Browse:860

How to Create MySQL InnoDB Tables with Hibernate?

Creating MySQL InnoDB Tables with Hibernate

When utilizing Hibernate with JPA, you may encounter the need to create MySQL tables with the InnoDB engine instead of the default MyISAM. To achieve this dynamically and not through SQL file generation, consider the following solution:

Solution:

Specify the Hibernate dialect using the property:

hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect

For MySQL versions greater than 5.1, use:

hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect

By setting this dialect, Hibernate will automatically create tables with the InnoDB engine, ensuring the desired storage properties and improved performance.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3