Cannot set more than one to-one relationship to null.
-----------------------------------------------------

                 Key: CAY-901
                 URL: https://issues.apache.org/cayenne/browse/CAY-901
             Project: Cayenne
          Issue Type: Bug
          Components: Cayenne Core Library
    Affects Versions: 3.0
            Reporter: Kevin Menard
            Assignee: Andrus Adamchik
             Fix For: 3.0


Given three entities Person, Place, Thing.  Person has a to-one relationship to 
Place.  Person has a to-one relationship to Thing.  Calling the following code 
does not work:

person.setPlace(null);
person.setThing(null);
person.getObjectContext().commitChanges();

The place will be set to null, but the thing will not.  The problem appears to 
be in DataDomainDBDiffBuilder#arcDeleted().  There, if the currentArcDiff is 
null, a new one is created and the arc deletion noted.  If the currentArcDiff 
is not null, however, an arc deletion will only be added if the arcId has 
already been added to the map.  In the case of the setThing() call, the 
currentArcDiff will not be null, containing the place deletion, but there will 
be no entry for the thing deletion.  The thing deletion will not be added 
because of the blocking condition.

It appears that either the condition needs to be removed or refined to account 
for such a situation.  Given that I'm not clear on what the original intent 
was, it's hard to recommend a clear solution.  Removing the condition fixed the 
problem in my codebase.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to