[cdi-dev] Support Request (and Conversation?) Scope in @Singleton @Startup @PostConstruct methods
stuart.w.douglas at gmail.com
Thu Mar 15 07:34:30 EDT 2012
On 15/03/2012, at 10:26 PM, Mark Struberg wrote:
> 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? ^^
If you are holding a lock longer that a request you are doing something wrong. As you are probably not going to want to serialise the entity manager in the middle of a request it should be possible to work around it.
Also not everyone uses HA clusters or persistent sessions, so the conversation scope is not always actually serialised.
There are still a lot of use cases for this, but it obviously there are limitations.
> ----- Original Message -----
>> From: Christian Bauer <christian.bauer at gmail.com>
>> To: cdi-dev at lists.jboss.org
>> 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
>> Chapter and section?
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
More information about the cdi-dev