3 Replies Latest reply on Nov 25, 2014 1:32 AM by hchiorean

    how to choice the type of node

    a175335

          In my worksapce ,I created two nodes ,their name is A and B. I want A reference to B ,but When I delete B, B in A also be removed. I try to use the NodeType of WEAKREFERENCE ,but it dose not work.So whice type should I select to achieve this scenario ?

        • 1. Re: how to choice the type of node
          hchiorean
          When I delete B, B in A also be removed.

          if you mean you want the reference property on node A to be automatically deleted, there is no such functionality in the JCR spec. ModeShape has 3 reference types: STRONG, WEAK (from the JCR standard) and SIMPLE (a ModeShape extension of the weak reference type which does not maintain back-reference "pointers") but none of those has "auto-delete" functionality. This is something which you have to code - for example when removing node B issue a query that finds all the nodes which are referencing node B and manually set their properties to "null".

          1 of 1 people found this helpful
          • 2. Re: how to choice the type of node
            a175335

            Hi ,thanks for your respone.But why the code of the logic designed that can't auto-delete? I delete B ,the refrence property on A is still existing. When I can get refrence property ,but I can't get the refrence Node because I had already deleted it.

            • 3. Re: how to choice the type of node
              hchiorean

              Such a behavior would be problematic for several reasons: for one, you can always set the value of such a property to point to another node. Also, these properties can be defined in the node type definitions and removing it would be simply wrong.

              But most important of all, ModeShape is a JSR 283 implementation and there's simply no such thing in the spec: http://www.day.com/maven/jcr/2.0/3_Repository_Model.html#3.8%20Referenceable%20Nodes