openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: EntityManager.clear() doesn't totally detaches an entity
Date Tue, 15 Jan 2013 14:23:36 GMT
Hi vitalyla,
I'm not sure if I followed your scenario exactly, but what version of
OpenJPA are you using?  As we were developing OpenJPA 2.x, we discovered a
few inconsistencies with the clear processing, serializing, and detachment
in general.  These inconsistencies were documenting in this section of the
user manual:

http://people.apache.org/~mikedd/nightly.builds/apache-openjpa-2.3.0-SNAPSHOT/docs/docbook/manual.html#migration_detach_behavior

At the same time, I'm wondering about your getter method...  I would not
expect your getter method to be allocating storage for Child (new
ArrayList...).  I would expect that type of processing in your setter
method.

A few things to consider...  Good luck.
Kevin

On Mon, Jan 14, 2013 at 7:27 AM, vitalyla <vitaly.lavrusevich@gmail.com>wrote:

> Hi,
>
> I am facing an issue with detached entities when using
> EntityManager.clear()
> operation along with Local EJB.
> Lets consider the case in which entity is returned from the query and later
> detached by invoking clear() API:
>
> Parent
> |
> |_ Child (LAZY fecthed)
>
> implementation of getChild in Parent entity:
>
> Child getChild () {
>
> if (child == null) { child = new ArrayList....; }
>
> return child;
> }
>
> The problem is that when Parent entity is detached through /clear()/ API it
> is very common that at line when /child /object is returned it is still
> NULL, regardless the fact that it was initialized a line before.
>
> But, when the same entity Parent is getting detached through
> *serialization*, query exposed as remote EJB, then everything works as
> expected.
>
> After checking an enhanced class it was found out that some state is
> preserved in StateManager internal class when clear() is invoked but is
> cleaned-up upon serialization.
>
> Please advise if it is a bug or this is how it works in: Local EJB +
> EntityManager.clear() constellation.
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/EntityManager-clear-doesn-t-totally-detaches-an-entity-tp7582558.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message