Spring Boot 3.5.6
Before testing your custom CustomPostgreSQLDialect, use the defaults without specifying a dialect. Add the debug logging setting org.hibernate.orm.dialect: DEBUG to your application.yaml file and test.
You should normally see the default Using dialect:org.hibernate.dialect.PostgreSQLDialect, version: 18.0 logged.
This step is to confirm that your JPA application runs correctly.
After confirming that your JPA application runs correctly, configure it to use the CustomPostgreSQLDialect ( dialect: org.company.configuration.CustomPostgreSQLDialect).
application.yml - default - no dialect config
spring:
datasource:
url: jdbc:postgresql://localhost:5432/demodb
driver-class-name: org.postgresql.Driver
username: demouser
password: Passw0rd!
jpa:
properties:
hibernate:
format_sql: true
hibernate:
ddl-auto: update
show-sql: true
logging:
level:
# --- Spring Data / ORM ---
org.springframework.data.jpa: DEBUG
# --- Hibernate ---
org.hibernate.orm.dialect: DEBUG
org.hibernate.engine.jdbc.env.internal: DEBUG
org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl: DEBUG
# --- Custom Dialect ---
com.example.CustomPostgreSQLDialect: DEBUG
Build
mvn clean package
Run
java -jar target/app.jar
Output
:: Spring Boot :: (v3.5.6)
2025-10-09T20:22:40.623+08:00 DEBUG 14973 --- [ main] o.h.e.j.e.i.JdbcEnvironmentInitiator : Database ->
name : PostgreSQL
version : 18.0 (Debian 18.0-1.pgdg13+3)
major : 18
minor : 0
2025-10-09T20:22:40.623+08:00 DEBUG 14973 --- [ main] o.h.e.j.e.i.JdbcEnvironmentInitiator : Driver ->
name : PostgreSQL JDBC Driver
version : 42.7.7
major : 42
minor : 7
2025-10-09T20:22:40.689+08:00 DEBUG 14973 --- [ main] org.hibernate.orm.dialect : HHH035001: Using dialect: org.hibernate.dialect.PostgreSQLDialect, version: 18.0
- You can find out that the PostgreSQL version is 18. (My PostgreSQL server version)
- If dialect is not set, the default is
org.hibernate.dialect.PostgreSQLDialect, version: 18.0
Find out JPA, Hibernate version
mvn dependency:tree
get
- org.springframework.boot:spring-boot-starter-data-jpa:jar:3.5.6:compile
- org.springframework.data:spring-data-jpa:jar:3.5.4:compile
- org.hibernate.orm:hibernate-core:jar:6.6.29.Final:compile
- org.hibernate.common:hibernate-commons-annotations:jar:7.0.3.Final:runtime
So, Hibernate 6.6.
https://docs.jboss.org/hibernate/orm/6.6/javadocs/org/hibernate/dialect/package-summary.html
- PostgreSQLDialect A SQL dialect for PostgreSQL 11 and above.
CustomPostgreSQLDialect.java
package org.company.configuration;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CustomPostgreSQLDialect extends PostgreSQLDialect {
private static final Logger logger = LoggerFactory.getLogger(CustomPostgreSQLDialect.class);
public CustomPostgreSQLDialect() {
super();
logger.warn(">>> CustomPostgreSQLDialect INITIALIZED");
}
public CustomPostgreSQLDialect(DialectResolutionInfo info) {
super(info);
logger.warn(">>> CustomPostgreSQLDialect INITIALIZED DialectResolutionInfo info");
}
}
application.yml - CustomPostgreSQLDialect
spring:
datasource:
url: jdbc:postgresql://localhost:5432/demodb
driver-class-name: org.postgresql.Driver
username: demouser
password: Passw0rd!
jpa:
properties:
hibernate:
dialect: org.company.configuration.CustomPostgreSQLDialect
format_sql: true
hibernate:
ddl-auto: update
show-sql: true
logging:
level:
# --- Spring Data / ORM ---
org.springframework.data.jpa: DEBUG
# --- Hibernate ---
org.hibernate.orm.dialect: DEBUG
org.hibernate.engine.jdbc.env.internal: DEBUG
org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl: DEBUG
# --- Custom Dialect ---
com.example.CustomPostgreSQLDialect: DEBUG
Build
mvn clean package
Run
java -jar target/app.jar
Output
:: Spring Boot :: (v3.5.6)
2025-10-09T20:27:23.436+08:00 DEBUG 15456 --- [ main] o.h.e.j.e.i.JdbcEnvironmentInitiator : Database ->
name : PostgreSQL
version : 18.0 (Debian 18.0-1.pgdg13+3)
major : 18
minor : 0
2025-10-09T20:27:23.436+08:00 DEBUG 15456 --- [ main] o.h.e.j.e.i.JdbcEnvironmentInitiator : Driver ->
name : PostgreSQL JDBC Driver
version : 42.7.7
major : 42
minor : 7
2025-10-09T20:27:23.463+08:00 WARN 15456 --- [ main] o.c.c.CustomPostgreSQLDialect : >>> CustomPostgreSQLDialect INITIALIZED DialectResolutionInfo info
2025-10-09T20:27:23.464+08:00 DEBUG 15456 --- [ main] org.hibernate.orm.dialect : HHH035001: Using dialect: org.company.configuration.CustomPostgreSQLDialect, version: 18.0
- DEBUG 15456 --- [ main] org.hibernate.orm.dialect : HHH035001: Using dialect: org.company.configuration.CustomPostgreSQLDialect, version: 18.0
- WARN 15456 --- [ main] o.c.c.CustomPostgreSQLDialect : >>> CustomPostgreSQLDialect INITIALIZED DialectResolutionInfo info
Please add a logging level setting to application.yml to display which class of dialect is being loaded.
Please note that the log shows that the CustomPostgreSQLDialect(DialectResolutionInfo info) constructor with the passed parameters is called instead of the empty constructor.
Also, remember to add the org.hibernate.orm.dialect: DEBUG logging setting to your application.yaml file.
You should see HHH035001: Using dialect: org.company.configuration.CustomPostgreSQLDialect, version: 18.0 in the log, confirming that CustomPostgreSQLDialect is being used.
This version of the answer is modified from the answer to a previous question (CustomH2Dialect in Hibernate 6.5).
CustomH2Dialect in Hibernate 6.5 (CustomH2Dialect in Hibernate 6.5)
spring.jpa.databaseorspring.jpa.database-platformnot both. As you want a custom one ditch thespring.jpa.databaseas that will only resolve to the default Postgres Dialect.