JSF vs. CDI SessionScope has odd consequences for Statelss EJB transaction. Can anyone explain?

I have a managed SessionScoped bean (UserInfoController) with an Injected Session without a bean (UserInfoService).

UserInfoController calls UserInfoService to update UserInfo entries. UserInfoService loads the corresponding UserInfo entry, modifies it, and finally calls em.flush ();

When a managed bean UserInfoController is annotated with a CDI annotation (javax.enterprise.context.SessionScoped), the user record is not updated unless an administrator of entities without a bean state is annotated with PersistenceContextType.EXTENDED.

When a managed bean is annotated with a JSF annotation (javax.faces.bean.SessionScoped), the record is successfully updated using PersistenceContextType.TRANSACTION.

Can anyone explain this behavior? Should the transaction boundary be limited to a bean, regardless of whether the caller is JSF managed or a CDI SessionScoped bean? (TransactionAttributeType is undefined: it should default to NECESSARY)

Any information would be greatly appreciated! Thank you Ben

+4
source share
1 answer

The type of PersistenceContext depends on the EJB bean session, not for bean support, as what is explained in this link What is the difference between a Persistence context scope and an Extended Persistence context?

I use @Named CDI beans with the default PersistenceContext type (TRANSACTION) in my case and successfully update records when I use javax.enterprise.context.SessionScoped

+1
source

Source: https://habr.com/ru/post/1435525/


All Articles