The hibernate.dialect property tells Hibernate which SQL dialect to generate for your database. The dialect controls how types are mapped, how pagination and identity columns are written, which functions are available in HQL, and how schema DDL looks. Since Hibernate 6, the dialect is detected automatically from the JDBC connection metadata, so in most applications you no longer need to set this property at all.
Setting it explicitly is still useful when the database cannot be reached at startup, when you want to pin a specific database version, or when you use a database that needs a community dialect.
Hibernate is database-neutral at the mapping level, but SQL is not. Every vendor differs in small and large ways, and the org.hibernate.dialect.Dialect class hides those differences. A dialect decides:
boolean, uuid, jsonb, timestamp with time zone)LIMIT/OFFSET or FETCH FIRST pagination is writtenfor update skip lockedIf the wrong dialect is used, you typically see SQL syntax errors, wrong column types in generated schemas, or silently inefficient queries.
Before Hibernate 6, forgetting the property often produced the error Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set. Modern Hibernate resolves the dialect from the database product name and version reported by the JDBC driver. When the first connection is obtained at startup, Hibernate picks the best matching dialect and applies version-dependent features, such as newer SQL syntax on recent PostgreSQL releases.
In Hibernate 6 the version-specific dialect classes (for example PostgreSQL10Dialect or MySQL57Dialect) were deprecated and then removed. A single class per database family now adjusts its behaviour to the detected version.
| Database | Dialect class (Hibernate 6 and later) |
|---|---|
| PostgreSQL | org.hibernate.dialect.PostgreSQLDialect |
| MySQL | org.hibernate.dialect.MySQLDialect |
| MariaDB | org.hibernate.dialect.MariaDBDialect |
| Oracle | org.hibernate.dialect.OracleDialect |
| SQL Server | org.hibernate.dialect.SQLServerDialect |
| H2 | org.hibernate.dialect.H2Dialect |
| HSQLDB | org.hibernate.dialect.HSQLDialect |
Dialects for older or less common databases (for example Derby, Informix, SAP HANA or Cache) moved to the separate hibernate-community-dialects artifact, where classes live in the org.hibernate.community.dialect package.
Set the property when you want to override detection. In persistence.xml it looks like this:
With Spring Boot, use the JPA properties in application.properties:
When building the SessionFactory programmatically, pass the setting through the registry:
Spring Boot with Hibernate 6 and later logs a warning if you set a dialect that merely repeats what detection would choose, because the property is no longer needed in most cases.
hibernate.boot.allow_jdbc_metadata_access to false and provide the dialect and version yourself.jakarta.persistence.database-product-version (or hibernate.dialect.version on some setups) to tell Hibernate which server version to target.hibernate-community-dialects.A small custom dialect that registers a database function looks like this in Hibernate 6:
You then reference it with hibernate.dialect=com.example.AppPostgresDialect. Check the Hibernate ORM documentation for the exact extension points of the version you use, because the registration APIs changed between 5 and 6.
MySQL57Dialect or PostgreSQL95Dialect fails with a class-not-found error. Remove the property or switch to the family class.MariaDBDialect, or let detection decide.hibernate.dialect alone in application.properties is ignored. It has to be spring.jpa.properties.hibernate.dialect or spring.jpa.database-platform.No. In Hibernate 6 and 7 it is optional because the dialect is resolved from the JDBC connection. It is only required when metadata cannot be read at startup.
You may get SQL syntax errors, wrong column types in generated DDL, or unsupported features such as the wrong pagination syntax. Remove the setting or use the dialect that matches your database.
One dialect class per database family, such as MySQLDialect and PostgreSQLDialect, which adapts to the version it detects.
Enable logging for org.hibernate.orm.deprecation and org.hibernate.dialect, or check the startup log line that reports the dialect in use.
The hibernate.dialect property selects the database-specific SQL generation rules. Current Hibernate versions detect the dialect automatically, so you normally omit it. Set it explicitly only for offline startup, version pinning, community dialects or custom dialect subclasses, and use the family classes such as PostgreSQLDialect instead of removed version-specific ones.