[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-17 (世界標準時間)。"],[],[],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)."]]