Consider updating the default Hibernate dialect for MySQL databases
See original GitHub issuePlease consider updating the default Hibernate dialect for MySQL databases.
org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#determineDatabaseDialectClass
currently returns org.hibernate.dialect.MySQL5Dialect
for MySQL databases, while the following newer versions are available:
org.hibernate.dialect.MySQL55Dialect
(MySQL 5.5 was first released in 2010)org.hibernate.dialect.MySQL57Dialect
(MySQL 5.7 was first released in 2014)org.hibernate.dialect.MySQL8Dialect
(MySQL 8.0 was first released in 2018)
As you can see, the default dialect selected by Spring Framework 5.1.3 targets a MySQL version which is over 9 years old. Therefore I propose to update the default dialect for MySQL.
Background
We’re running a Spring Boot 2.1.2 application on MySQL 8 which leads to SQL errors when using the default dialect selected by Spring. Manually updating the dialect to at least MySQL55Dialect
resolves these issues.
This is the line in question: https://github.com/spring-projects/spring-framework/blob/7a77e83e1099d29fd68f1f0a94216bb1e3d5cec7/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java#L192
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (8 by maintainers)
I’m afraid we can’t enforce a newer dialect variant at this point since
MySQL55Dialect
and higher have only been introduced in Hibernate ORM 5.2/5.3, whereas our JPA support needs to remain compatible with Hibernate ORM 5.1 as well (since that used to be the version in JBoss EAP for several years). Once we raise the baseline to JPA 2.2+, we can easily require Hibernate ORM 5.3+ and MySQL 5.7+.As for
MySQL55Dialect
specifically, it seems that all it changes is InnoDB over MyISAM by default. That’s a viable assumption in recent years, of course, but quite a significant change that we can’t easily sneak into a minor release. That said, there’s nothing wrong with selecting a specific Hibernate dialect in an application setup; Spring’s database enum is only meant as a starting point to begin with.I wonder why SpringBoot 1.5.x will select innodb as its default storage engine, but SpringBoot 2.x select MyISAM as default, what’s the point?