Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » [toplink] em.merge() changes Java Identity of detached object
[toplink] em.merge() changes Java Identity of detached object [message #493700] Tue, 27 October 2009 15:36 Go to next message
Sebastian Fuchs is currently offline Sebastian FuchsFriend
Messages: 94
Registered: July 2009
Member
Hello,

I am still working with toplink essentials - but maybe someone can help
me anyway.

The merge-operation of the entity manager switches some Java instances
of my detached object-graph so that I loose the Java identity for
further processing of the detached object.

The managed entity(-graph) is correctly changed and the database
operations are correct - even the detached entity is structural
(identifiers, values and associations) correct.
But some of the detached objects have changed their Java identity after
merging. Particular these are entities which are referenced multiple
times within the graph.
Please have a look at my log.

The JPA specs say nothing about the Java identity of the detached
objects after a merge operation.

I did some experiments with the cache type, even set the
CACHE_TYPE_DEFAULT to CacheType.NONE without success.
I also had no luck by fine tuning the Cascade arguments in way to avoid
cyclic navigation to the misbehaving entities.

Is there a way to control the behaviour ?
The only solution I see at this time is to manually merge my working
copy into the managed entity and switch to em.persist(managedEntity).

Thanks
Sebastian


BEFORE MERGE

MANAGED ENTITY
EinwirkungKombination@1efb003 id = 34
EinwirkungKombinationFaktor@10cc730 id = 56
EigenLast@1e940a6 id = 1

DETACHED ENTITY (WORKING COPY)
EinwirkungKombination@1ce168b id = 0
EinwirkungKombinationFaktor@12a09d5 id = 0
OK --> EigenLast@8af0b0 id = 1



AFTER MERGE

MANAGED ENTITY
EinwirkungKombination@9a47d id = 37
EinwirkungKombinationFaktor@190ed52 id = 61
EigenLast@1e940a6 id = 1

DETACHED ENTITY (WORKING COPY)
EinwirkungKombination@1ce168b id = 37
EinwirkungKombinationFaktor@12a09d5 id = 61
WRONG --> EigenLast@1176e5f id = 1



EXPECTED JAVA IDENTITY OF WORKING COPY (at all times):
EigenLast@8af0b0
Re: [toplink] em.merge() changes Java Identity of detached object [message #494218 is a reply to message #493700] Thu, 29 October 2009 15:47 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

I can't see how this could occur. Perhaps try it with EclipseLink and see if it has been fixed. Maybe also try the latest TopLink Essentials patch.

Are you using property access or field access? I could have something to do with property access possibly, if you have side-effects in your get/set methods. Try using field access.



James : Wiki : Book : Blog : Twitter
Re: [toplink] em.merge() changes Java Identity of detached object [message #494245 is a reply to message #494218] Thu, 29 October 2009 17:20 Go to previous message
Sebastian Fuchs is currently offline Sebastian FuchsFriend
Messages: 94
Registered: July 2009
Member
Hi James,

I updated to the latest toplink version but the issue is still there.
I already use field access.

Sebastian


James schrieb:
> I can't see how this could occur. Perhaps try it with EclipseLink and
> see if it has been fixed. Maybe also try the latest TopLink Essentials
> patch.
>
> Are you using property access or field access? I could have something
> to do with property access possibly, if you have side-effects in your
> get/set methods. Try using field access.
>
>
Previous Topic:query conflicts and "unexpected token [count]"
Next Topic:Query historical data with JPA
Goto Forum:
  


Current Time: Sat Nov 22 16:48:51 GMT 2014

Powered by FUDForum. Page generated in 0.02750 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software