hibernate/hibernate-orm · critical · HibernateException

Unable to determine Dialect without JDBC metadata (please se

Error message

Unable to determine Dialect without JDBC metadata (please set 'jakarta.persistence.jdbc.url' for common cases or 'hibernate.dialect' when a custom Dialect implementation must be provided)

What it means

DialectFactoryImpl.determineDialect received a null DialectResolutionInfoSource, meaning Hibernate had no live JDBC connection (hence no DatabaseMetaData) from which to auto-detect the dialect, and no explicit hibernate.dialect was set. Since dialect resolution needs one of the two inputs, bootstrap fails fast with guidance to set jakarta.persistence.jdbc.url or hibernate.dialect.

Source

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

		}
		catch (Exception e) {
			throw new HibernateException( "Unable to construct requested dialect [" + dialectReference + "]", e );
		}
	}

	/**
	 * Determine the appropriate Dialect to use given the connection.
	 *
	 * @param resolutionInfoSource Access to DialectResolutionInfo used to resolve the Dialect.
	 *
	 * @return The appropriate dialect instance.
	 *
	 * @throws HibernateException No connection given or no resolver could make
	 * the determination from the given connection.
	 */
	private Dialect determineDialect(DialectResolutionInfoSource resolutionInfoSource) {
		if ( resolutionInfoSource == null ) {
			throw new HibernateException(
					"Unable to determine Dialect without JDBC metadata "
					+ "(please set '" + JdbcSettings.JAKARTA_JDBC_URL + "' for common cases or '" + JdbcSettings.DIALECT + "' when a custom Dialect implementation must be provided)"
			);
		}

		final DialectResolutionInfo info = resolutionInfoSource.getDialectResolutionInfo();
		final Dialect dialect = dialectResolver.resolveDialect( info );

		if ( dialect == null ) {
			throw new HibernateException(
					"Unable to determine Dialect for " + info.getDatabaseName() + " "
					+ info.getDatabaseMajorVersion() + "." + info.getDatabaseMinorVersion()
					+ " (please set 'hibernate.dialect' or register a Dialect resolver)"
			);
		}

		return dialect;
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Set hibernate.dialect (or JPA jakarta.persistence property 'hibernate.dialect') explicitly, e.g. org.hibernate.dialect.PostgreSQLDialect
  2. Or provide a JDBC URL (jakarta.persistence.jdbc.url) so Hibernate can connect and auto-detect
  3. If connections are intentionally deferred, dialect specification is mandatory - wire it from your deployment config
  4. For boot-time schema tools, pass --dialect or the equivalent option

Example fix

# before
jakarta.persistence.jdbc.url is absent, hibernate.dialect absent
# -> Unable to determine Dialect without JDBC metadata

# after
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
Defensive patterns

Strategy: validation

Validate before calling

// assert bootstrap has one of the two dialect inputs before building
boolean hasDialect = settings.get(JdbcSettings.DIALECT) != null;
boolean hasUrl = settings.get(JdbcSettings.JAKARTA_JDBC_URL) != null;
if ( !hasDialect && !hasUrl ) {
    throw new ConfigurationException("Set hibernate.dialect or jakarta.persistence.jdbc.url");
}

Prevention

When it happens

Trigger: Building a SessionFactory/EntityManagerFactory with neither hibernate.dialect nor a resolvable JDBC connection at metadata-building time - e.g. a connection provider that defers connections, schema tools invoked without a connection, or all jdbc.* properties omitted.

Common situations: Multi-tenant apps that intentionally keep no base connection; tests with an empty persistence.xml; copy-pasted configs where the dialect line was dropped during migration from hibernate.dialect to jakarta.* properties; using a custom ConnectionProvider that returns connections lazily.

Related errors


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