jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: Checking for null reference properties
Date Mon, 02 Mar 2009 09:23:10 GMT

I quickly tried this out and it worked as expected:

    public void testRefProp() throws RepositoryException {
        Node n = testRootNode.addNode(nodeName1);
        Node n2 = testRootNode.addNode(nodeName2);
        n2.setProperty(propertyName1, n);
        executeXPathQuery(testPath + "/*[@" + propertyName1 + "]", new
        executeSQLQuery("select * from nt:base where " + propertyName1
                + " is not null and jcr:path like '" + testRoot +
"/%'", new Node[]{n2});

On Mon, Mar 2, 2009 at 04:57, NAO <Nerolie.Oakes@csiro.au> wrote:
> I have been trying to run a query to collect all the nodes where a reference
> property has been set.
> The SQL query string
> Query q = queryManager.createQuery("select * from ala:TypeA where
> ala:typeBRef is not null",Query.SQL);
> works where ala:typeBRef is defined as a string value, but if it has been
> defined as a reference, the search returns no nodes regardless of what
> getProperty returns.
> Could someone please explain to me why this should be the case, and how I
> can do a global search for the nodes where a reference link exists?

are you searching for nodes that have a reference property, or do you
rather want the nodes that are referenced? If it's the latter you can
use the jcr:deref() function (only available in XPath):

//element(*, nt:base)/jcr:deref(@ala:typeBRef, '*')

returns all nodes that are referenced by a ala:typeBRef property.

see also: http://www.day.com/specs/jcr/1.0/


View raw message