In our scenario we have a (multivalued) category field on JCR:node and we want to query all nodes that do not have a current selection. In the JCR viewer the fields value is [] but I can't find any query to select nodes with this condition. We have tries:
SELECT * FROM [mgnl:page] as p WHERE p.[categories]=''
or
SELECT * FROM [mgnl:page] as p WHERE p.[categories]=[]
or
SELECT * FROM [mgnl:page] as p WHERE p.[categories] is null
But they aren't working or don't select the proper result. How can we write a query selecting these nodes?
From the JSR 283:
From the JavaDocs:
Unfortunately, this does not make it clear what the result of
LENGTH([multivaluedProperty)]is in a SQL2 query.Though, after some manual testing, it seems that the
LENGTHoperand returns some number smaller than 0. Therefore, you could tryselect * from [nt:base] where LENGTH([multivaluedProperty]) < 0Let me know whether this works for you :)