[cdi-dev] Support Request (and Conversation?) Scope in @Singleton @Startup @PostConstruct methods
Mark Struberg
struberg at yahoo.de
Thu Mar 15 10:40:25 EDT 2012
Stu,
usually a select for update is done _explicitely_ to prevent others from doing something with this entity. We do not have control whether this is good or not.
I do agree with you that this should barely be used in a webapp, because sometimes this can even lead to a table-lock (some dbs cannot do a simple record lock without either locking the page or sometimes even the whole table).
Imo this functionality should NEVER have added to the EntityManager but might have been provided via a separate API, etc. But that's how it is currently :/
But this is not the only reason why the EM is not Serializable. If you did serialize an old Hibernate-2 EM then you lost all the non-persistent status. This doesn't sound sane neither...
LieGrue,
strub
----- Original Message -----
> From: Stuart Douglas <stuart.w.douglas at gmail.com>
> To: Mark Struberg <struberg at yahoo.de>
> Cc: Christian Bauer <christian.bauer at gmail.com>; "cdi-dev at lists.jboss.org" <cdi-dev at lists.jboss.org>
> Sent: Thursday, March 15, 2012 12:34 PM
> Subject: Re: [cdi-dev] Support Request (and Conversation?) Scope in @Singleton @Startup @PostConstruct methods
>
>
> 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.
>
> Stuart
>
>
>>
>> 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
>>>
>> _______________________________________________
>> 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