users@glassfish.java.net

Re: EntityManagerWrapper not Serializable....

From: Erik Brakkee <erik.brakkee_at_gmail.com>
Date: Thu, 29 Jul 2010 22:48:56 +0200

On Thu, Jul 29, 2010 at 10:14 PM, Marina Vatkina
<marina.vatkina_at_oracle.com>wrote:

> I'm confused... why would transient fields affect serialization?
>
> thanks,
> -marina
>
>
> The transient fields are not serialized (because they are transient). As a
result, at deserialisation the transient fields are null. The
EntityManagerWrapper depends on these transient fields. Since they are null
after deserialization, deserialized entity manager wrapper objects are
unusable.

Strangely, looking at the code the EntityManagerWrapper seems prepared for
serialization since it implements serializable and also has comments
indicating clearly which fields are serializable. From the looks of it, the
non-transient fields provide sufficient information for obtaining an entity
manager again after deserialization but this is not implemented.