Integrate Spanner with Hibernate ORM (PostgreSQL dialect) Stay organized with collections Save and categorize content based on your preferences.
Hibernate is an object-relational mapping tool for the Java programming language.It provides a framework for mapping an object-oriented domain model to a relational database.
You can integrate PostgreSQL-dialect databases with Hibernate using the open sourcePostgreSQL JDBC Driver.Hibernate ORM 6.3is supported with PostgreSQL-dialect databases.
Set up PGAdapter
Ensure that PGAdapter is running on the same machine as the application that isusing Hibernate.
For more information, seeStart PGAdapter.
Set up Hibernate with PostgreSQL
In your project, add Apache Maven dependencies for the Hibernate ORM core and PostgreSQL JDBC Driver.
<!-- Hibernate core dependency --><dependency> <groupId>org.hibernate.orm</groupId> <artifactId>hibernate-core</artifactId> <version>6.3.1.Final</version></dependency><!-- Postgresql JDBC driver dependency --><dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.7.1</version></dependency>Set up Hibernate properties
Configurehibernate.properties to use the PostgreSQL dialect andPostgreSQL JDBC Driver.
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialecthibernate.connection.driver_class=org.postgresql.Driverhibernate.connection.url=jdbc:postgresql://localhost:5432/test-databasehibernate.connection.username=pratickhibernate.connection.pool_size=5hibernate.show_sql=truehibernate.format_sql=true# hibernate.hbm2ddl.auto validatehibernate.hbm2ddl.auto=updateUse Hibernate
For more information about the features and recommendations for integratingHibernate with PostgreSQL-dialect databases, please consult thereference documentationon GitHub.
What's next
- Checkoutcode examples using Hibernate withPostgreSQL.
- Learn more aboutPGAdapter.
- Learn more aboutHibernate ORM.
- For more information about PostgreSQL JDBC driver connection options, seePGAdapter - JDBC Connection Optionsin the PGAdapter GitHub repository.
- Learn more aboutIntegrate Spanner with Hibernate ORM (GoogleSQL dialect).
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-17 UTC.