Hi Florian,

ah, of course, you are right.

Michael, can you tell us what nodes remain in the workspace after you removed the assets node and called save?

regards
 marcel

Florian Holeczek wrote:
Hallo Marcel,

are you sure about this? I thought Michael's code produced the
following tree:

      root
       |
     assets
    /      \
asset[1] asset[2]

Regards,
 Florian

Ursprüngliche Nachricht vom 21.07.2008 um 09:07:
Hi Michael,

Michael Harris wrote:
another noob question.  I have the following codes

                Node root = session.getRootNode();
                Node assets = root.addNode("assets");

                // Store content
                Node asset = assets.addNode("asset");
                asset.setProperty("url", "http://asset1url.org";);
                asset.setProperty("name", "Asset 1");
                asset.setProperty("typetype", "image");

                Node asset2 = assets.addNode("asset");

this creates a same named sibling /asset[2]

                asset2.setProperty("url", "http://asset2url.org";);
                asset2.setProperty("name", "Asset 2");
                asset2.setProperty("type", "image");
                session.save();

and then

        Node root = session.getRootNode();
        Node assets = root.getNode("assets");

this will only return the first asset node but not the second one.

        assets.remove();
        session.save();

the more I run the test, the more nodes I get.  Seems like the data in the
TransientRepo is being stored on the disk.  The remove is not cleaning it
up.  For why?

to remove all asset nodes you need to do the following:

for (NodeIterator assets = root.getNodes("assets"); assets.hasNext(); ) {
     assets.nextNode().remove();
}
session.save();

regards
  marcel


Reply via email to