openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Curtis (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-1966) Entity graphs containing bi-directional references may not merge correctly if an entity does not contain a state manager
Date Wed, 11 Jun 2014 19:20:01 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14028253#comment-14028253
] 

Rick Curtis commented on OPENJPA-1966:
--------------------------------------

Have you tried the attached patch to see if it resolves your issue?

> Entity graphs containing bi-directional references may not merge correctly if an entity
does not contain a state manager
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1966
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1966
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.0.4, 1.2.2, 2.0.1, 2.1.0
>            Reporter: Jeremy Bauer
>            Assignee: Jeremy Bauer
>         Attachments: OPENJPA-1966.patch, OPENJPA-1966.patch
>
>
> An entity graph (with cascade) containing bi-directional relationships or circular references
may fail to merge properly if one or more of the entities in the graph do not have a state
manager - either an active or detached state manager.  The result is that one or more of the
merged entities may end up with a reference to a detached object.  This may not be immediately
evident and could cause problems in subsequent operations. It can even affect the ordering
of SQL statements since foreign keys may not be properly associated with the detached entities.
> For example:  A <- OneToOne -> B
> em.clear()
> Detached graph:  B <--> A
> A: Is detached, has DetachedStateManager
> B: Is detached, No state manager, only detached state field.  (ie. @DetachedState Object
state)
> Merge: B
> After merge:  B' --> A' --> B (detached)
> If B contains a state manager the result of the merge is correct: B' <--> A'
> The source of the problem is that the "no state manager" attachment path creates a new
PC + state manager and assigns this state manager to the detached instance so that it can
be used to attach all its fields.  During a cascade, this detached entity (with borrowed state
manager) looks persistent, so it can get attached into the resulting merge graph.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message