[cdi-dev] Support Request (and Conversation?) Scope in @Singleton @Startup @PostConstruct methods

Mark Struberg struberg at yahoo.de
Thu Mar 15 07:26:27 EDT 2012


Simply as that: as the EntityManager per spec doesn't implement Serializable.


Also the EJB spec explicitely states it as well in Section 4.2:
> - A container must not passivate a stateful session bean with an extended 
> persistence context unless ...


Thus an Extended EM doesn't need to be Serializable. If you build a feature based on the assumption that each EntityManager is Serializable, then it will result in non-portable behaviour.

Well, in JPA-1 it would at least have been possible to implement a Serializable EM, but in JPA2 you are mostly out of luck.

There are tons of indicators. As an example: how would you serialize an EntityManager which holds a pessimistic lock() on the database? ^^

LieGrue,
strub




----- Original Message -----
> From: Christian Bauer <christian.bauer at gmail.com>
> To: cdi-dev at lists.jboss.org
> Cc: 
> Sent: Thursday, March 15, 2012 9:18 AM
> Subject: Re: [cdi-dev] Support Request (and Conversation?) Scope in @Singleton @Startup @PostConstruct methods
> 
> 
> On Mar 6, 2012, at 2:58 , Mark Struberg wrote:
> 
>>  The EM is per JPA spec NOT Serializable and thus must not get stored in the 
> Session.
> 
> Chapter and section?
> 
> 
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
> 


More information about the cdi-dev mailing list