事务范围的持久性上下文和扩展持久性上下文有什么区别?
差异在JSR-220 http://jcp.org/aboutJava/communityprocess/final/jsr220/index.htmlEnterprise JavaBeans 3.0 规范:
5.6 容器管理的持久化上下文
(...)
容器管理的持久性
上下文可以被定义为具有
仅限于单个的生命周期
交易或延长生命周期
跨越多个交易,
取决于PersistenceContextType
那是
指定当其EntityManager
是
创建的。本规范参考
这样的持久化上下文事务范围的持久化上下文 and 长期坚持
上下文分别。
(...)
5.6.1 容器管理的事务范围持久化上下文
该应用程序可以获得
容器管理的实体管理器
事务范围的持久化上下文
绑定到 JTA 事务
在 JNDI 中注入或直接查找
命名空间。持久化上下文
实体管理器的类型是
默认或定义为PersistenceContextType.TRANSACTION
.
A new persistence context begins when
the container-managed entity manager
is invoked[36] in the scope
of an active JTA transaction, and
there is no current persistence
context already associated with the
JTA transaction. The persistence
context is created and then associated
with the JTA transaction.
当持久化上下文结束时
关联的 JTA 事务提交或
回滚,并且所有实体
由EntityManager管理成为
超然的。
如果调用实体管理器
交易范围之外,
从数据库加载的任何实体
将立即脱离
方法调用结束。
5.6.2 容器管理的扩展持久化上下文
容器管理的扩展
持久化上下文只能是
范围内发起
有状态会话 bean。它存在于
有状态的点
声明一个会话 bean
依赖于实体管理器
类型PersistenceContextType.EXTENDED
被创建,并且据说绑定到
有状态会话 bean。这
对扩展持久性的依赖
上下文是通过以下方式声明的PersistenceContext
注释或
持久性上下文引用部署
描述符元素。
持久化上下文被关闭
容器当@Remove
有状态会话 bean 的方法
完成(或有状态会话
bean 实例否则会被销毁)。
(...)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)