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

Replace Existing OneToOne From New Object

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.3, 4.1.1, 4.2, 5.0-M1
    • 4.2.1, 5.0-M1
    • Core Library
    • None

    Description

      We have a One to One (belongsTo on both sides) relationships between 2 Models (A & B), very similar to the Painting < - > PaintingInfo in the test environment.

      When we have an existing a1 related to b1 (and vice-versa b1 to a1), and we create a new b2. Then set b2.toA = a1. We find out that b1.toA is still related to a1 instead of null

      The closest test that I found is in

      CDOOneDep2OneIT.testReplace

      but just need to set from the other side of the relationship instead.

      I can push up a breaking test soon. Not sure if you prefer it to be on master or STABLE-4.2.

      It seems that during b2.setToA(a1) the call to setToOneTarget("toA", a1, true) triggers a call to setReverseRelationship("toA", a1) , which triggers a call to setToOneTarget("toB", b2, false). In here it accesses the oldTarget which is b1. This is where I feel it should nullify b1.toA using unsetReverseRelationship("toB", b1). However, it does NOT because setReverse was passed in as false. Since it does not, at this point if you check the relationships:
      b2.toA == a1 GOOD
      a1.toB == b2 GOOD
      b1.toA == a1 BAD

      Attachments

        Activity

          People

            ntimofeev Nikita Timofeev
            mattraydub Matt Watson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m