首页 > 代码库 > 小白自学hibernate5.0文档第一季之架构篇
小白自学hibernate5.0文档第一季之架构篇
果然,hibernate的底层是由JDBC实现的。 --Java Data Base Connectivity,Java数据库连接
--翻译得不到位,敬请批评
Hibernate, as an ORM solution, effectively "sits between" the Java application data access layer and the Relational Database, as can be seen in the diagram above. The Java application makes use of the Hibernate APIs to load, store, query, etc its domain data. Here we will introduce the essential Hibernate APIs. This will be a brief introduction; we will discuss these contracts in detail later.
Hibernate作为一个对象关系映射解决方案,能够在java应用程序数据访问层和关系数据库“中间”起作用,如在上图中可以看出,Java应用程序利用Hibernate API去加载、存储、查询等其它域数据(不懂什么叫域数据),这里我们将介绍基本的Hibernate API。这将是一个简单的介绍;稍后我们将会讨论规约的细节。
As a JPA provider, Hibernate implements the Java Persistence API specifications and the association between JPA interfaces and Hibernate specific implementations can be visualized in the following diagram:
作为JPA(Java Persistence API JAVA持久化API,小白理解其实就是@Entity,@Id,@Column等等之类的规范。)提供者,Hibernate实现Java Persistence API规范和JAP接口与HIbernate特定的实现之间的关联,能够具体化在下面的图示:
--这关系好复杂啊
SessionFactory (org.hibernate.SessionFactory
) --------------- 二级缓存
A thread-safe (and immutable) representation of the mapping of the application domain model to a database. Acts as a factory for org.hibernate.Session
instances. The EntityManagerFactory
is the JPA equivalent of a SessionFactory
and basically those two converge into the same SessionFactory
implementation.
A SessionFactory
is very expensive to create, so, for any given database, the application should have only one associated SessionFactory
. The SessionFactory
maintains services that Hibernate uses across all Session(s)
such as second level caches, connection pools, transaction system integrations, etc.
一个线程安全(并且不可变)域模型到数据库应用程序的映射代表,实际上它是作为一个工厂的org.hibernate.Session实例。这个EntityManagerFactory 是一个JPA Sessionfactory的等价物,主要地它们两个收敛到相同的SessionFactory实现。
去创建一个SessionFactory是非常昂贵的,所以,对于任何给定的数据库,这个应用程序应该只有一个唯一的关联--SessionFactory。SessionFactory维持Hibernate 使用所有的会话作为二级缓存的服务,连接池,事务系统集成等等。
Session (org.hibernate.Session
) ----------------- 一级缓存
A single-threaded, short-lived object conceptually modeling a "Unit of Work" PoEAA. In JPA nomenclature, the Session
is represented by an EntityManager
.
Behind the scenes, the Hibernate Session
wraps a JDBC java.sql.Connection
and acts as a factory for org.hibernate.Transaction
instances. It maintains a generally "repeatable read" persistence context (first level cache) of the application domain model.
一个单例线程,短暂的对象概念建模PoEAA“工作单元”(不愧是Hibernate,费解。。)在JAP术语里,Session是一个EntityManager的代表。在幕后,Hibernate Session包装了一个JDBC java.sql.Connection和实际作为一个工厂用于org.hibernate.Transaction实例它维持一个通常的“可复读”应用域模型的持久化上下文(一级缓存)。
Transaction (org.hibernate.Transaction
)
A single-threaded, short-lived object used by the application to demarcate individual physical transaction boundaries. EntityTransaction
is the JPA equivalent and both act as an abstraction API to isolate the application from the underlying transaction system in use (JDBC or JTA).
一个单例线程,短生命对象通过应用程序去划分个人的的物理事务边界使用。EntityTransaction是一个JPA等价物和充当一个抽象API去使应用程序从底层事务系统中使用(JDBC或者JTA)隔离
小白自学hibernate5.0文档第一季之架构篇