seam事务管理
[该贴被admin于2009-02-18 16:02修改过]
是的,我比较厌恶的是那些配置文件,从以前的struts到现在学习seam,无不为此困。,回头去看,我花了太多的时间来“配置”,结果呢仍然没有好的效果。框架嘛,一方面把这问题的解决过程分层管理,配置层间的联系,这本是不可少的,想想也是,要了解一个框架并应用某个框架是多么痛苦的事。
components.xml:
seam核心的、也是唯一的一个正真完全由seam使用的xml,所有配置 —— 无论seam自己的、seam对jsf的整合、seam对jbpm的整合、seam对ejb的整合……等等 —— 均遵循统一的原则 (one way principle)
Seam managed transactions 的配置:
默认情况下,seam使用JTA transaction component来容器管理和/或编程式的EJB transactions。
* 如果在Java EE 5+ 环境中,你应该在components.xml中安装EJB synchronization component
|
* JPA RESOURCE_LOCAL transactions with the javax.persistence.EntityTransaction interface. EntityTransaction begins the transaction at the beginning of the apply request values phase.
|
* Hibernate managed transactions with the org.hibernate.Transaction interface.
HibernateTransaction begins the transaction at the beginning of the apply request values
phase.
|
* Spring managed transactions with the
org.springframework.transaction.PlatformTransactionManager interface. The Spring
PlatformTransactionManagement manager may begin the transaction at the beginning of the
apply request values phase if the userConversationContext attribute is set.
|
* Explicitly disable Seam managed transactions
|
详见 seam reference doc [http://docs.jboss.com/seam/latest/reference/en-US/html/]:
* 9.2. Seam managed transactions
* 27.5. Using Spring PlatformTransactionManagement
[该贴被dearshor于2009-02-19 20:42修改过]
seam 实现了conversation scoped的 Persistence context,支持可以跨越多个request的optimistic transactions,无须merge(),无须在每一个request开始时re-load data,不用担心LazyInitializationException or NonUniqueObjectException。