question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider updating the default Hibernate dialect for MySQL databases

See original GitHub issue

Please 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
jhoellercommented, Jan 31, 2019

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.

1reaction
scottyan19commented, Apr 18, 2019

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Caused by: org.hibernate.HibernateException: Access to ...
spring.jpa.database=mysql ... spring.jpa.hibernate.ddl-auto=update ... Reason: Database connection is not satisfied while dialects for db, ...
Read more >
An example hibernate.cfg.xml for MySQL 8 and Hibernate 5
The latest Hibernate 5 release includes updated dialect classes that must be referenced within a hibernate.cfg.xml file for MySQL 8.
Read more >
Hibernate - SQL Dialects - GeeksforGeeks
A hibernate dialect gives information to the framework of how to convert hibernate queries(HQL) into native SQL queries.
Read more >
Using MySQL in Spring Boot via Spring Data JPA and Hibernate
This post shows how to use a MySQL database in a Spring Boot web ... SQL for the chosen database spring.jpa.properties.hibernate.dialect ...
Read more >
5 Things You Need to Know When Using Hibernate with Mysql
If you're working with a MySQL database, you should always use GenerationType.IDENTITY. It uses an autoincremented database column and is the most efficient ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found