4.1.3.1 Removing Items

To erase an item, the method Item.remove() is used. For example, continuing from the above code segment, the following code,

// Remove the node /a/e (and its subtree)

myNode.remove();


// Persist the changes

mySession.save();


would result in the node at /a/e (and its child node /a/e/n) being deleted.

In the case of Properties, an alternative to remove is to set the property to null. This can be done in two ways, by calling setValue with null on the property itself, or by calling setProperty with the property name and a null value on the property's parent node:

// Assume we have node /m and two

// properties /m/p and /m/q

Node m = (Node) mySession.getItem("/m");

Property p = m.getProperty("p");


//Remove p by calling setValue on p itself

p.setValue((Value)null);


//Remove q by calling setProperty on q's parent node

m.setProperty("q", (Value)null);


// Persist the changes

mySession.save();



See 4.7.3 No Null Values.