Hibernate cannot resolve org.hibernate.dialect.MySQL5Dialect as a strategy
Unable to resolve name [org.hibernate.dialect.MySQL5Dialect] as strategy [org.hibernate.dialect.Dialect]Short answer
Hibernate 6 stopped using version-specific dialects such as MySQL5Dialect. Dialects now detect the database version themselves, and the legacy classes left the main module. Remove the dialect setting so Hibernate detects MySQL, or name org.hibernate.dialect.MySQLDialect. Only a very old MySQL needs the community dialect package.
Fix it fast
1Find out which cause you have
Find every place the dialect class name is set: Spring properties, hibernate.cfg.xml, persistence.xml or Java config.
grep -rn "MySQL5Dialect\|hibernate.dialect\|database-platform" src/ pom.xml build.gradle* 2>/dev/null2Match what you see, then jump to its fix
- 1
The class name in the message is MySQL5Dialect, MySQL57Dialect or similar, after an upgrade to Hibernate 6.A version-specific dialect name is still configuredFix - 2
You set the dialect only because older tutorials did.The setting is not needed at allFix - 3
The error stays after the change, and the server is MySQL older than 5.7.The database is older than Hibernate supportsFix
- 1
What does the error look like?
Unable to resolve name [org.hibernate.dialect.MySQL5Dialect] as strategy [org.hibernate.dialect.Dialect]
Cause 1 of 3
A version-specific dialect name is still configured
1Check
The Hibernate 6.0 migration guide says version-specific dialects are deprecated because dialects detect and adapt to the database version. Its list of dialects to use instead includes org.hibernate.dialect.MySQLDialect.
grep -rn "MySQL[0-9]*Dialect" src/2Fix
Replace the old name with MySQLDialect. In Spring Boot the setting is spring.jpa.database-platform; a raw Hibernate property goes under spring.jpa.properties.
# application.properties
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
# or the pass-through form
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect3Verify
Start the application; the SessionFactory builds without the strategy error.
./gradlew bootRunConfirmed by docs.hibernate.org
Cause 2 of 3
The setting is not needed at all
1Check
The Spring Boot how-to says the JPA provider detects the dialect automatically, and that spring.jpa.database-platform is only for setting one yourself.
grep -rn "dialect\|database-platform" src/main/resources/2Fix
Delete the dialect line and let Hibernate pick it from the JDBC connection.
# application.properties: remove these lines
# spring.jpa.database-platform=...
# spring.jpa.properties.hibernate.dialect=...3Verify
The application starts and queries run against MySQL.
./gradlew bootRunConfirmed by docs.spring.io
Cause 3 of 3
The database is older than Hibernate supports
1Check
The Hibernate 6.2 migration guide lists 5.7 as the minimum MySQL version. Legacy dialect code for unsupported versions moved out of hibernate-core into the hibernate-community-dialects module, under the org.hibernate.community.dialect package.
mysql --version2Fix
Upgrade the database to a supported version. If you cannot, add the hibernate-community-dialects module at the same version as Hibernate and use the matching class from the org.hibernate.community.dialect package.
// build.gradle: same version as hibernate-core
implementation 'org.hibernate.orm:hibernate-community-dialects:<hibernate-version>'3Verify
The class resolves and the application starts.
./gradlew dependencies --configuration runtimeClasspath | grep hibernateConfirmed by docs.hibernate.org
How do I stop it coming back?
- Do not name a database version in the dialect; use the plain dialect or none.
- Read the migration guide of the Hibernate version a Spring Boot upgrade brings.
- Search the whole repository, including test resources, for old dialect names after an upgrade.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Databases
Hibernate fails on a CREATE or ALTER TABLE statement at startup
Error executing DDL "alter table events drop foreign key FKg0mkvgsqn8584qoql6a2rxheq" via JDBC Statement
Hibernate generated a CREATE, ALTER or DROP statement and MySQL refused it.
3 causes, each with a fixDatabases
Spring Boot fails on startup: HikariPool-1 exception during pool initialization
Caused by: ... (the underlying driver exception)
HikariCP opens one connection when the pool starts, and the startup fails when that connection fails.
3 causes, each with a fixDatabases
Java cannot log in to MySQL 8: authentication plugin caching_sha2_password not supported
ERROR 2061 (HY000): Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection.
MySQL 8 accounts use the caching_sha2_password plugin by default, and Connector/J releases before 8.0.9 cannot use it.
3 causes, each with a fixDatabases
MySQL error 1364: Field 'id' doesn't have a default value on INSERT
Field '%s' doesn't have a default value (the server's message pattern; %s is the column name)
Error 1364 means the INSERT left out a NOT NULL column that has no default, and strict SQL mode (the default) refuses to guess.
3 causes, each with a fixDatabases
Spring Boot does not create the schema on MySQL or PostgreSQL
No CREATE TABLE statements from Hibernate appear at startup
Spring Boot only defaults ddl-auto to create-drop for an embedded database with no Flyway or Liquibase.
3 causes, each with a fixDatabases
Spring Boot in a container cannot connect to the MySQL container
Communications link failure
In Compose the app and MySQL are separate containers.
3 causes, each with a fix