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.
The above is the detailed content of How to Create MySQL InnoDB Tables with Hibernate?. For more information, please follow other related articles on the PHP Chinese website!