我一直在尝试在我的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 )
)
抛出以下异常(stacktrace省略):
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
)