Hibernate ORM 中文操作指南

Preface

Hibernate 6 是全球最流行、功能最丰富的 ORM 解决方案的一次重大重新设计。重新设计已触及 Hibernate 的几乎每个子系统,包括 API、映射批注和查询语言。此款新的 Hibernate 更强大、更健壮、类型更安全。

Hibernate 6 is a major redesign of the world’s most popular and feature-rich ORM solution. The redesign has touched almost every subsystem of Hibernate, including the APIs, mapping annotations, and the query language. This new Hibernate is more powerful, more robust, and more typesafe.

有了如此多的改进,很难概括此项工作的重大意义。但以下常规主题值得关注。Hibernate 6:

With so many improvements, it’s very difficult to summarize the significance of this work. But the following general themes stand out. Hibernate 6:

  1. finally takes advantage of the advances in relational databases over the past decade, updating the query language to support a raft of new constructs in modern dialects of SQL,

  2. exhibits much more consistent behavior across different databases, greatly improving portability, and generates much higher-quality DDL from dialect-independent code,

  3. improves error reporting by more scrupulous validation of queries before access to the database,

  4. improves the type-safety of O/R mapping annotations, clarifies the separation of API, SPI, and internal implementation, and fixes some long-standing architectural flaws,

  5. removes or deprecates legacy APIs, laying the foundation for future evolution, and

  6. makes far better use of Javadoc, putting much more information at the fingertips of developers.

Hibernate 6 和 Hibernate Reactive 现已成为 Quarkus 3 的核心组件,Quarkus 3 是 Java 中云原生开发最令人兴奋的新环境,而且 Hibernate 仍然是几乎所有主要 Java 框架或服务器的持久性解决方案。

Hibernate 6 and Hibernate Reactive are now core components of Quarkus 3, the most exciting new environment for cloud-native development in Java, and Hibernate remains the persistence solution of choice for almost every major Java framework or server.

不幸的是,Hibernate 6 中的变化致使图书、博客文章和 Stackoverflow 上的有关 Hibernate 的大量信息已过时。

Unfortunately, the changes in Hibernate 6 have obsoleted much of the information about Hibernate that’s available in books, in blog posts, and on stackoverflow.

本指南是对当前功能集和推荐用法进行了讨论的最新且概述性的说明。它不会尝试涵盖每一个功能,应结合其他说明文档使用:

This guide is an up-to-date, high-level discussion of the current feature set and recommended usage. It does not attempt to cover every feature and should be used in conjunction with other documentation:

  1. Hibernate’s extensive Javadoc,

  2. the Guide to Hibernate Query Language, and

  3. the Hibernate User Guide.

Hibernate 用户指南包括对 Hibernate 大多数方面的详细讨论。但是,由于需要涵盖大量信息,因此很难实现可读性,它最有用的部分是作为一种参考。在必要时,我们将提供到用户指南相关部分的链接。

The Hibernate User Guide includes detailed discussions of most aspects of Hibernate. But with so much information to cover, readability is difficult to achieve, and so it’s most useful as a reference. Where necessary, we’ll provide links to relevant sections of the User Guide.