Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-901

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 3.0M2
    • Core Library
    • None

    Description

      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.

      Attachments

        Activity

          People

            andrus Andrus Adamchik
            nirvdrum Kevin Menard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: