gpt4 book ai didi

java - 如何在 JCR-SQL2 中应用聚合函数(如 MIN、MAX、COUNT)?

转载 作者:行者123 更新时间:2023-12-02 11:24:01 25 4
gpt4 key购买 nike

我在 JCR 中存储了一些作为节点的记录,节点的名称是主键。例如1,2,3。但问题从这里开始,

记录如下1,2,6,53,54

其中上面的数字是EMP非结构化节点下的节点。如果我这样做

int count=empNode.getNodeIterator().getSize() 我会得到 5 因为有 5 个节点

所以我进行了 count++,它给了我 6,但 6 已经存在,所以我无法在 EMP[nt:unstructred] 下创建名称为 6 的节点,这就是为什么我想应用 MAX(nodeNames)

更新::我用的是CQ5.5。 EMP 是/content/EMP 等内容下的非结构化节点。在这个(EMP)下,我有非结构化节点来保存我的数据。这些节点的名称为 1,2 等

最佳答案

我尝试使用我的 CQ5.4 实例来寻找解决方案。不幸的是我的尝试没有成功。当我在 Google 上使用关键字“sql2 count”时,我发现 this页。有人问了同样的问题,答案是

There is no count(*) or group by selector in JCR SQL 1, XPath [2] orJCR-SQL2/AQM [3].

To implement such a tag cloud, you can run one query that fetches allyour content containing the relevant "tag" property:

//element(*, my:Article)[@tag]

and then iterate over the result and count your tags on theapplication side by looking at the tag property values and using somehashmap (tagid -> count).

http://www.day.com/specs/jcr/1.0/ (section 8.5)

http://www.day.com/specs/jcr/1.0/ (section 6.6)

http://www.day.com/specs/jcr/2.0/6_Query.html

我认为你可以将这个答案与 MAX() 和 MIN() 连接起来。

关于java - 如何在 JCR-SQL2 中应用聚合函数(如 MIN、MAX、COUNT)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26400206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com