[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-3810) Transient entities can be inserted twice on merge

Gail Badner (JIRA) noreply at atlassian.com
Tue Jun 2 22:25:13 EDT 2009


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3810?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner resolved HHH-3810.
------------------------------

    Resolution: Fixed

Fixed in trunk / Branch_3_3 / Branch_3_2 /  Branch_3_2_4_SP1_CP

> Transient entities can be inserted twice on merge
> -------------------------------------------------
>
>                 Key: HHH-3810
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3810
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.6, 3.3.0.GA, 3.3.1
>            Reporter: Gail Badner
>            Assignee: Gail Badner
>             Fix For: 3.2.x, 3.3.x, 3.5
>
>
> A transient entity being merged can be inserted twice if there is a cascade back to that same entity before it has been saved.
> This bug was introduced by the fix for HHH-3229.
> This can be illustrated by the following mapping (adapted from the test case at HHH-3046):
> Route -- (1 : N) -- Node -- (N : 1) -- Tour            
> There are 3 objects:
>    route (persistent) 
>    pickupNode (transient)
>    tour (transient)
> Collections are sets.
> node.route has cascade="none".
> All other associations are cascade="merge,refresh"
> route.nodes { pickupNode }
> tour.nodes = { pickupNode }
> pickupNode.route = route
> pickupNode.tour = tour
> The following shows the execution path that results in pickupNode being saved twice.
> MERGE EVENT route (persistent)
>   MERGE EVENT pickupNode (transient)
>   |  
>   | A) CASCADE_BEFORE_SAVE pickupNode
>   |    
>   |    MERGE EVENT tour (transient)
>   |    | 
>   |    | A) CASCADE_BEFORE_SAVE tour (nothing to do)
>   |    |
>   |    | B) SAVE tour
>   |    |
>   |    | C) CASCADE_AFTER_SAVE tour
>   |    |    
>   |    |    MERGE EVENT pickupNode (still transient)
>   |    |    | (BUG: embedded merge event for same transient entity!!!)
>   |    |    |    
>   |    |    | A) CASCADE_BEFORE_SAVE pickupNode
>   |    |    |
>   |    |    |    MERGE EVENT tour (skip because it is already merged)
>   |    |    |
>   |    |    | B) SAVE pickupNode 
>   |    |    |    (BUG: saved in embedded merge event!!!)
>   |    |    |
>   |    |    | C) CASCADE_AFTER_SAVE pickupNode
>   |    |    |
>   |
>   | B) SAVE pickupNode
>   |    (BUG: saved again in original merge event!!!)
>   |
>   | C) CASCADE_AFTER_SAVE pickupNode (nothing to do)
>   
> Prior to applying the fix for HHH-3229, the execution path was:
> MERGE EVENT route (persistent)
>   MERGE EVENT pickupNode (transient)
>   |  
>   | A) CASCADE_BEFORE_SAVE pickupNode
>   |    
>   |    MERGE EVENT tour (transient)
>   |    | 
>   |    | A) CASCADE_BEFORE_SAVE tour (nothing to do)
>   |    |
>   |    | B) SAVE tour
>   |    |
>   |    | C) CASCADE_AFTER_SAVE tour
>   |    |    
>   |    |    MERGE EVENT pickupNode (still transient; skip because it is already being merged)
>   |  
>   | B) SAVE pickupNode
>   |
>   | C) CASCADE_AFTER_SAVE pickupNode (nothing to do)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list