1

我正在尝试使用 UNION 来收集多个节点类型的所有唯一标识符(jcr:uuid)并获得 InvalidQueryException,而实际的 SELECT 语句本身是成功的。
长耳兔版本:2.12.1

SELECT [jcr:uuid] FROM [base:nodeType1]
UNION
SELECT [jcr:uuid] FROM [base:nodeType2]

堆栈跟踪:

SELECT [jcr:uuid] FROM [base:nodeType1]
UNION(*)SELECT [jcr:uuid] FROM [base:nodeType2]; expected: <end>
at org.apache.jackrabbit.rmi.server.ServerObject.getRepositoryException(ServerObject.java:113)
  at org.apache.jackrabbit.rmi.server.ServerQueryManager.createQuery(ServerQueryManager.java:74)
  at sun.reflect.GeneratedMethodAccessor2078.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
  at sun.rmi.transport.Transport$1.run(Transport.java:200)
  at sun.rmi.transport.Transport$1.run(Transport.java:197)
  at java.security.AccessController.doPrivileged(Native Method)
  at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
  at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
  at java.security.AccessController.doPrivileged(Native Method)
  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
at org.apache.jackrabbit.rmi.server.ServerQueryManager_Stub.createQuery(Unknown Source)
at org.apache.jackrabbit.rmi.client.ClientQueryManager.createQuery(ClientQueryManager.java:66)
4

1 回答 1

0

您的查询包含多个选择器,因此您必须在查询中使用选择器名称。仅当只有一个选择器时,该名称才是可选的。

尝试这个:

SELECT [jcr:uuid] FROM [base:nodeType1] AS a
UNION
SELECT [jcr:uuid] FROM [base:nodeType2] AS a
于 2016-04-29T14:24:56.070 回答