1

我一直在尝试在我的 JCR 存储库 (AEM) 上运行特定查询,但由于某种原因,我无法多次使用 LENGTH 函数。这意味着以下查询运行良好:

SELECT * FROM [cq:PageContent] AS page
WHERE ISDESCENDANTNODE(page, '/content') AND (
    ( page.[offTime] IS NOT NULL AND LENGTH(page.[offTime]) < 29 )
)

但是,如果我在块中添加另一个条件:

SELECT * FROM [cq:PageContent] AS page
WHERE ISDESCENDANTNODE(page, '/content') AND (
    ( page.[onTime] IS NOT NULL AND LENGTH(page.[onTime]) < 29 ) OR
    ( page.[offTime] IS NOT NULL AND LENGTH(page.[offTime]) < 29 )
)

它抛出以下异常(省略了堆栈跟踪):

javax.jcr.UnsupportedRepositoryOperationException: Unknown operand type: LENGTH(page.onTime)

可以解决这个问题,但只能以一种涉及代码膨胀的令人讨厌的迟钝方式。有任何想法吗?这看起来确实像是查询语言应该处理的事情。

----------更新----------

运行以下版本的查询似乎可以正常编译,但会产生相同的错误:

SELECT * FROM [cq:PageContent] AS page
WHERE ISDESCENDANTNODE(page, '/content')
AND ( page.[offTime] IS NOT NULL AND LENGTH(page.[offTime]) < 29 )
OR  ( page.[onTime]  IS NOT NULL AND LENGTH(page.[onTime])  < 29 )

与:

SELECT * FROM [cq:PageContent] AS page
WHERE ISDESCENDANTNODE(page, '/content') AND (
    page.[onTime]      IS NOT NULL AND LENGTH(page.[onTime])      < 29 OR
    page.[offTime]     IS NOT NULL AND LENGTH(page.[offTime])     < 29 OR
    page.[jcr:created] IS NOT NULL AND LENGTH(page.[jcr:created]) < 29
)
4

0 回答 0