我有一个带有注入的无状态会话bean (UserInfoService)的SessionScoped托管Bean (UserInfoController)。
UserInfoController调用UserInfoService来更新UserInfo记录。UserInfoService加载适当的UserInfo记录,修改它,最后调用em.flush();
当受管bean UserInfoController使用CDI注解(javax.enterprise.context.SessionScoped)注解时,除非使用PersistenceContextType.EXTENDED注解无状态bean的实体管理器,否则不会更新用户记录。
如果受管bean使用JSF注解(javax.faces.bean.SessionScoped)注解,则在使用PersistenceContextType.TRANSACTION时,记录会成功更新。
有人能解释这种行为吗?不管调用者是JSF还是CDI SessionScoped托管bean,事务边界不应该被限制到无状态Bean吗?(未定义TransactionAttributeType:默认为必填)
任何信息都将不胜感激!谢谢!本
发布于 2013-04-29 16:33:04
PersistenceContext类型依赖于EJB会话bean,而不是这个链接What is the difference between Transaction-scoped Persistence context and Extended Persistence context?中解释的支持bean。
在我的例子中,我正在使用带有默认PersistenceContext类型(事务)的@命名CDI,并且在我使用javax.enterprise.context.SessionScoped时记录更新成功
https://stackoverflow.com/questions/12533628
复制相似问题