JPA翻译一

Let’s begin by reintroducing the core terms of the Java Persistence API. A persistence unit

is a named configuration of entity classes. A persistence context is a managed set of entity

instances. Every persistence context is associated with a persistence unit, restricting the classes of

the managed instances to the set defined by the persistence unit. Saying that an entity instance

is managed means that it is contained within a persistence context and that it may be acted

upon by an entity manager. It is for this reason that we say an entity manager manages a persis-

tence context.

让我们通过介绍JPA的核心术语开始。一个持久化单元是一个被命名为实体类们的命配置(文件)。一个持久化上下文件是一个受管实体实例们的集合。每一个持久化上下文被一个持久化单元所关联,约束着受管理实例至由持久化单元定义的集合。说一个实体实例是受管的意味着它被一个持久化上下文所包含并且它也许被实体管理者所执行。我们说一个实体管理者管理一个持久化上下文正是因为这个原因。

 

Understanding the persistence context is the key to understanding the entity manager. An

entity’s inclusion or exclusion from a persistence context will determine the outcome of any

persistent operations on it. If the persistence context participates in a transaction, then the in-

memory state of the managed entities will get synchronized to the database. Yet despite the

important role that it plays, the persistence context is never actually visible to the application.

It is always accessed indirectly through the entity manager and assumed to be there when we

need it.

明白了持久化上下文对理解实体管理者是一个关键。一个实体从一个持久化上下文的包含、剔除将会确定任何在该实体上持久化操作的结果。如果一个持久化上下文件参与一个事务,那么受管实体在内存中的状态将会与数据库同步。尽管持久化上下文扮演着重要角色,持久化上下文实际上对应用程序而言是不可见的。它总是间接地通过实体管理者被访问并且当我们需要它时,会有一个。

 

how does the persistence context get created and when does this occur?

How does the entity manager figure into the equation? This is where it starts to get interesting.

但是持久化上下文如何创建并且这又是在什么时候发生的呢?实体管理者如何figure into the equation?这正是我们发生兴趣的地方。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值