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 GoogleSQL-dialect databases with Hibernate using the open source
Spanner Dialect
(SpannerDialect
). Spanner is
compatible with Hibernate ORM 6.x.
Spanner Dialect produces SQL, DML, and DDL statements for most
common entity types and relationships using standard Hibernate and
Java Persistence annotations.
Set up Hibernate
In your project, add Apache Maven dependencies for Hibernate ORM core, Spanner Dialect, and the Spanner officially supported Open Source JDBC driver.
Configure hibernate.cfg.xml
to use Spanner Dialect and
Spanner JDBC Driver.
The service account JSON credentials
file location should be in the GOOGLE_APPLICATION_CREDENTIALS
environment variable. The driver will use default credentials set
in the Google Cloud CLI gcloud
application otherwise.
Use Hibernate with Spanner GoogleSQL
For more information about the features and recommendations for Hibernate, please consult the reference documentation on GitHub.
What's next
- Checkout code examples using Hibernate with Spanner.
- Try the Spanner with Hibernate ORM codelab.
- Learn more about Hibernate ORM.
- View the repository for Spanner Dialect on GitHub.
- File a GitHub issue to report a bug or ask a question about Hibernate.
- Learn more about Apache Maven.
- Learn more about Integrate Spanner with Hibernate ORM (PostgreSQL dialect).