Intégrer Spanner à Hibernate ORM (dialecte PostgreSQL)
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Hibernate est un outil de mappage objet-relationnel pour le langage de programmation Java.
Il fournit un framework permettant de mapper un modèle de domaine orienté objet sur une base de données relationnelle.
Vous pouvez intégrer des bases de données en dialecte PostgreSQL à Hibernate à l'aide du pilote JDBC PostgreSQL Open Source. Hibernate ORM 6.3 est compatible avec les bases de données en dialecte PostgreSQL.
Configurer PGAdapter
Assurez-vous que PGAdapter s'exécute sur la même machine que l'application qui utilise Hibernate.
Pour en savoir plus sur les fonctionnalités et les recommandations relatives à l'intégration d'Hibernate avec les bases de données en dialecte PostgreSQL, veuillez consulter la documentation de référence sur GitHub.
Étape suivante
Consultez des exemples de code utilisant Hibernate avec PostgreSQL.
Pour en savoir plus sur les options de connexion du pilote JDBC PostgreSQL, consultez PGAdapter - JDBC Connection Options (PGAdapter - Options de connexion JDBC) dans le dépôt GitHub PGAdapter.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/05 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/05 (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)."]]