Yes and no ;)

Yes, the EntityManager is not Serializable (at least almost never).
No, it is not a problem. 

This class gets used and stored in the TransactionStrategy. And this is 
@Dependent to the TransactionInterceptor. Which is an interceptor and thus 
@Dependent (per spec) on the intercepted bean.

Most times the bean is an @ApplicationScoped service. But there are times when 
you like to annotate e.g. the action method of your @SessionScoped or 
@ViewAccessScoped JSF backing bean. And in that case serialisation kicks in on 
a clustered system.

What will happen if the setup is sane, e.g. with a @RequestScoped EntityManager 
(a) or an EJB PersistenceContext (b)?
In case a the injected EntityManager is only the proxy shale and thus perfectly 
serializable. It will also not contain any ‚active‘ EntityManager inside - 
because the request is over. 
In case b it is almost the same. The PersistenceContext is still a proxy. The 
difference is that this proxy is not created by the CDI container but by the EE 
container or EJB integration. So all is fine as well.

If people opt to use @ConversationScoped EntityMangers, well then they are 
almost always broken anyway if they like to use clustering…


LieGrue,
strub


> Am 27.11.2015 um 14:47 schrieb John D. Ament <johndam...@apache.org>:
> 
> This requires entity manager to be serializable... Won't work.
> On Nov 27, 2015 08:46, <gpetra...@apache.org> wrote:

Reply via email to