Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2283

Losing backreferences after modify property reference value

XMLWordPrintable

    • Hide
      JcrNodeTest.java
          @Test
          public void shouldRetrieveReferencePropertiesAfterModifications() throws Exception {
              Node referenceableNode = session.getRootNode().addNode("referenceable");
              referenceableNode.addMixin(JcrMixLexicon.REFERENCEABLE.toString());
      
              Node node1 = session.getRootNode().addNode("node1");
              Property prop1 = node1.setProperty("prop1", session.getValueFactory().createValue(referenceableNode, false));
      
              session.save();
      
              // Do modifications
              node1.setProperty("prop1", (Value) null);
              node1.setProperty("prop1", session.getValueFactory().createValue(referenceableNode, false));
      
              session.save();
      
              // check strong references
              PropertyIterator propertyIterator = referenceableNode.getReferences();
              assertEquals(1, propertyIterator.getSize());
          }
      
      Show
      JcrNodeTest.java @Test public void shouldRetrieveReferencePropertiesAfterModifications() throws Exception { Node referenceableNode = session.getRootNode().addNode( "referenceable" ); referenceableNode.addMixin(JcrMixLexicon.REFERENCEABLE.toString()); Node node1 = session.getRootNode().addNode( "node1" ); Property prop1 = node1.setProperty( "prop1" , session.getValueFactory().createValue(referenceableNode, false )); session.save(); // Do modifications node1.setProperty( "prop1" , (Value) null ); node1.setProperty( "prop1" , session.getValueFactory().createValue(referenceableNode, false )); session.save(); // check strong references PropertyIterator propertyIterator = referenceableNode.getReferences(); assertEquals(1, propertyIterator.getSize()); }
    • Hide

      Do not remove the property before setting it back to the same value that was persisted and then saving.

      Show
      Do not remove the property before setting it back to the same value that was persisted and then saving.

      After clear reference property value and again set it to same old value, referenced node lose backreference, method getReferences not return property.

      Node referenceableNode = session.getRootNode().addNode("referenceable");
      referenceableNode.addMixin(JcrMixLexicon.REFERENCEABLE.toString());
      
      Node node1 = session.getRootNode().addNode("node1");
      Property prop1 = node1.setProperty("prop1", session.getValueFactory().createValue(referenceableNode, false));
      
      session.save();
      
      // Do modifications
      node1.setProperty("prop1", (Value) null);
      node1.setProperty("prop1", session.getValueFactory().createValue(referenceableNode, false));
      
      session.save();
      
      PropertyIterator propertyIterator = referenceableNode.getReferences();
      assertEquals(1, propertyIterator.getSize());
      

              rhauch Randall Hauch (Inactive)
              gbelov_jira German Belov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: