Apache Jackrabbit - Duplicate Node?

Using Apache Jackrabbit, I created two nodes in exactly the same path

root.addNode("hello"); 

I fully expected the second addition to throw an ItemExistsException as described here , but it is not.

When I print out the path to the nodes to try to see what happens, I see /hello for the first node and /hello[2] for the second node

Also, when I delete the node, the test that checks for the existence of the node passes before I save the session, but after saving the session, the second test of the same condition failed

 session.getNode("/hello").remove(); assertFalse(session.nodeExists("/hello")); session.save(); assertFalse(session.nodeExists("/hello")); 

What's going on here? Is this a bug or some kind of Jackrabbit feature that is different from the spec?

+4
source share
1 answer

What you see is the Siblings Same Name, which is a feature of Jackrabbit and JCR. David Nuescheler, lead developer of the JSR-170, wrote in Jackrabbit WIKI :

While Siblings Same Name (SNS) was introduced into the specification to ensure compatibility with data structures that are developed and expressed through XML, and therefore they are extremely valuable for JCR, SNS have significant overhead and complexity for the repository.

...

For importing XML or interacting with existing XML, SNS may be necessary and useful, but I have never used SNS and will never be in green field data models.

Basically, the reason you have brothers and sisters of the same name for hosting XML data is where you can have multiple elements with the same name. I saw the same-name siblings used in the Day CQ WCM, but their use seems generally discouraged.

+4
source

All Articles