Apache Jackrabbit - 重复节点?
使用 Apache Jackrabbit,我在完全相同的路径上创建了两个节点
root.addNode("hello");
,我完全期望第二个添加会抛出 ItemExistsException
如此处所述,但事实并非如此。
当我打印出节点的路径来尝试查看发生了什么时,我看到 /hello
为第一个节点, 第二个节点的 /hello[2]
此外,当我删除节点时,在保存会话之前会通过检查该节点是否存在的测试,但在保存会话后会进行第二次测试同样的条件失败了
session.getNode("/hello").remove();
assertFalse(session.nodeExists("/hello"));
session.save();
assertFalse(session.nodeExists("/hello"));
这是怎么回事?这是 Jackrabbit 的 bug 还是某些功能偏离了规范?
Using Apache Jackrabbit, I created two nodes at exactly the same path
root.addNode("hello");
I was fully expecting the second addition to throw an ItemExistsException
as described here, but it didn't.
When I print out the path of the nodes to try and see what was going on, I see/hello
for the first node and/hello[2]
for the second node
Further, when I delete the node, a test to check for the existence of the node passes before I save the session, but after I save the session a second test of the same condition fails
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 feature of Jackrabbit that deviates from the spec?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所看到的是同名兄弟姐妹,这是 Jackrabbit 和 JCR 的一个功能。 JSR-170 的首席开发人员 David Nuescheler 在 Jackrabbit WIKI 中写道:
基本上,这就是使用同名同级元素来容纳 XML 数据的原因,其中可以有多个同名元素。我曾在 Day 的 CQ WCM 中看到过使用同名兄弟姐妹,但总体而言似乎不鼓励使用它们。
What you are seeing are Same Name Siblings, which is a feature of Jackrabbit and the JCR. David Nuescheler, the lead developer of JSR-170 wrote in the Jackrabbit WIKI:
So basically, the reason you have same name siblings to accommodate XML data where you can have multiple elements of the same name. I have seen same name sibilings used in Day's CQ WCM, but their use overall seems to be discouraged.