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 source
PostgreSQL JDBC Driver. Hibernate ORM 6.3
is supported with PostgreSQL-dialect databases.
Set up PGAdapter
Ensure that PGAdapter is running on the same machine as the application that is
using Hibernate.
For more information about the features and recommendations for integrating
Hibernate with PostgreSQL-dialect databases, please consult the
reference documentation
on GitHub.
What's next
Checkout code examples using Hibernate with
PostgreSQL.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Integrate Spanner with Hibernate ORM (PostgreSQL dialect)\n\nHibernate is an object-relational mapping tool for the Java programming language.\nIt provides a framework for mapping an object-oriented domain model to a relational database.\n\nYou can integrate PostgreSQL-dialect databases with Hibernate using the open source\nPostgreSQL JDBC Driver. [Hibernate ORM 6.3](https://hibernate.org/orm/)\nis supported with PostgreSQL-dialect databases.\n\nSet up PGAdapter\n----------------\n\nEnsure that PGAdapter is running on the same machine as the application that is\nusing Hibernate.\n\nFor more information, see [Start PGAdapter](/spanner/docs/pgadapter-start).\n\nSet up Hibernate with PostgreSQL\n--------------------------------\n\nIn your project, add Apache Maven dependencies for the Hibernate ORM core and PostgreSQL JDBC Driver. \n\n \u003c!-- Hibernate core dependency --\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003eorg.hibernate.orm\u003c/groupId\u003e\n \u003cartifactId\u003ehibernate-core\u003c/artifactId\u003e\n \u003cversion\u003e6.3.1.Final\u003c/version\u003e\n \u003c/dependency\u003e\n\n \u003c!-- Postgresql JDBC driver dependency --\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003eorg.postgresql\u003c/groupId\u003e\n \u003cartifactId\u003epostgresql\u003c/artifactId\u003e\n \u003cversion\u003e42.7.1\u003c/version\u003e\n \u003c/dependency\u003e\n\nSet up Hibernate properties\n---------------------------\n\nConfigure `hibernate.properties` to use the PostgreSQL dialect and\nPostgreSQL JDBC Driver. \n\n hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect\n hibernate.connection.driver_class=org.postgresql.Driver\n\n hibernate.connection.url=jdbc:postgresql://localhost:5432/test-database\n hibernate.connection.username=pratick\n\n hibernate.connection.pool_size=5\n\n hibernate.show_sql=true\n hibernate.format_sql=true\n\n # hibernate.hbm2ddl.auto validate\n hibernate.hbm2ddl.auto=update\n\nUse Hibernate\n-------------\n\nFor more information about the features and recommendations for integrating\nHibernate with PostgreSQL-dialect databases, please consult the\n[reference documentation](https://github.com/GoogleCloudPlatform/pgadapter/blob/-/samples/java/hibernate/README.md)\non GitHub.\n\nWhat's next\n-----------\n\n- Checkout [code examples](https://github.com/GoogleCloudPlatform/pgadapter/blob/-/samples/java/hibernate) using Hibernate with PostgreSQL.\n- Learn more about [PGAdapter](/spanner/docs/pgadapter).\n- Learn more about [Hibernate ORM](https://hibernate.org/orm/).\n- For more information about PostgreSQL JDBC driver connection options, see [PGAdapter - JDBC Connection Options](https://github.com/GoogleCloudPlatform/pgadapter/blob/-/docs/jdbc.md) in the PGAdapter GitHub repository.\n- Learn more about [Integrate Spanner with Hibernate ORM (GoogleSQL dialect)](/spanner/docs/use-hibernate)."]]