1 of 1 people found this helpful
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".
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.
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