4.1.3 Writing to the Repository

If the repository is level 2 compliant (see 4.2 Compliance Levels) then, having acquired a session, the client can write to the repository by adding or removing nodes and properties or changing the values of properties.

For example, the client can retrieve a node, add a child node to it and add a property to that child node:

// Retrieve a node

Node myNode = (Node) mySession.getItem("/a/e");


// Add a child node

Node newNode = myNode.addNode("n");


// Add a property

newNode.setProperty("x", "Hello");


// Persist the changes

mySession.save();




The node myNode has the path /a/e, so the new node will have path /a/e/n and the new property will have the path /a/e/n/x and the string value “Hello”.