1 Reply Latest reply on Dec 3, 2014 1:00 PM by Randall Hauch

    Querying for UUID using XPath

    Jochen Kraushaar Newbie

      Hi there,

       

      I like to query ModeShape 4.0.0 for nodes given an UUID. The query should look like:

       

      /jcr:root//element(*,nt:folder)[@jcr:uuid = '9fd12a6b-f037-4d30-b965-b5f3a05ea6bc']

       

      But this query doesn't return any nodes. On the other hand querying for the title gives me a result:

       

      /jcr:root//element(*,nt:folder)[@jcr:title = 'test']

       

      Is @jcr:uuid supported in ModeShape or isn't it possible to get a node this way?

       

      Regards

      Jochen

        • 1. Re: Querying for UUID using XPath
          Randall Hauch Master

          Is the target node a 'mix:referenceable' node? If not, there really is no "jcr:uuid" property, but you could use the "mode:id" pseudocolumn that corresponds to Node.getIdentifier(). See the documentation for details.

           

          If the target node is 'mix:referenceable', then make sure that you're using the correct literal value, which should correspond to Node.getUUID().

           

          BTW, you can always check the query plan to see how ModeShape executes your query. Under the covers ModeShape converts XPath queries into JCR-SQL2, and the query plan will show the JCR-SQL2 representation. See this test case for finding a node by UUID using JCR-SQL and JCR-SQL2 (but not XPath).