hibernate/hibernate-orm · critical · StrategySelectionException

Couldn't load the dialect class for the 'hibernate.dialect'

Error message

Couldn't load the dialect class for the 'hibernate.dialect' [<dialectFqn>], because the application is missing a dependency on the hibernate-community-dialects module. Hibernate 6.2 dropped support for database versions that are unsupported by vendors  and code for old versions was moved to the hibernate-community-dialects module. For further information, read https://in.relation.to/2023/02/15/hibernate-orm-62-db-version-support/

What it means

Loading the dialect class named by hibernate.dialect failed, and its FQN is in Hibernate's LEGACY_DIALECTS list - dialects for database versions vendors no longer support, which were moved out of hibernate-core into the hibernate-community-dialects module in Hibernate 6.2. The fix-oriented message tells you to add that artifact; the original StrategySelectionException is chained.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java:160

							throw new StrategySelectionException(
									String.format( "Could not instantiate named dialect class [%s]", dialectClass.getName() ),
									e
							);
						}
					}
			);
			if ( dialect == null ) {
				throw new HibernateException( "Unable to construct requested dialect [" + dialectReference + "]" );
			}
			else if ( Dialect.class.getPackage() == dialect.getClass().getPackage() ) {
				DEPRECATION_LOGGER.automaticDialect( dialect.getClass().getSimpleName() );
			}
			return dialect;
		}
		catch (StrategySelectionException e) {
			final String dialectFqn = dialectReference.toString();
			if ( LEGACY_DIALECTS.contains( dialectFqn ) ) {
				throw new StrategySelectionException(
						"Couldn't load the dialect class for the 'hibernate.dialect' [" + dialectFqn + "], " +
								"because the application is missing a dependency on the hibernate-community-dialects module. " +
								"Hibernate 6.2 dropped support for database versions that are unsupported by vendors  " +
								"and code for old versions was moved to the hibernate-community-dialects module. " +
								"For further information, read https://in.relation.to/2023/02/15/hibernate-orm-62-db-version-support/",
						e
				);
			}
			throw e;
		}
		catch (HibernateException e) {
			throw e;
		}
		catch (Exception e) {
			throw new HibernateException( "Unable to construct requested dialect [" + dialectReference + "]", e );
		}
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Add the dependency: org.hibernate.orm:hibernate-community-dialects (same version as hibernate-core)
  2. Better long-term: upgrade the database to a vendor-supported version and switch to the corresponding supported dialect
  3. Alternatively implement a custom Dialect extending the closest supported one for the legacy database
  4. Check the chained cause to confirm it is a ClassNotFound-style failure for the legacy class

Example fix

# before (ClassNotFoundException wrapped in StrategySelectionException)
hibernate.dialect=org.hibernate.dialect.MySQL57Dialect

# after: add the artifact (Maven)
<dependency>
  <groupId>org.hibernate.orm</groupId>
  <artifactId>hibernate-community-dialects</artifactId>
  <version>${hibernate.version}</version>
</dependency>
# and use the relocated class name
hibernate.dialect=org.hibernate.community.dialect.MySQL57Dialect
Defensive patterns

Strategy: validation

Validate before calling

// fail with a clear message at startup instead of during EMF build
try {
    Class.forName("org.hibernate.community.dialect.CommunityDialect", false, getClass().getClassLoader());
} catch (ClassNotFoundException e) {
    throw new IllegalStateException(
        "Legacy dialects require org.hibernate.orm:hibernate-community-dialects on the classpath");
}

Prevention

When it happens

Trigger: hibernate.dialect references a legacy dialect class (older MySQL/MariaDB/DB2/etc. versions whose classes moved to org.hibernate.community.dialect) while org.hibernate.orm:hibernate-community-dialects is not on the runtime classpath.

Common situations: Upgrading Hibernate 5.x/6.0/6.1 to 6.2+ while keeping an old dialect class name; staying on an EOL database version (MySQL 5.5/5.7, old MariaDB) after the 6.2 support cut; WARs assembled without the community dialects jar.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/8f7a5e428f105f3f. Report an issue: GitHub.