2 Replies Latest reply on Jul 29, 2013 10:45 AM by rhauch

    Modeshape regarding the search functionality in JCR2.0 (JCR-SQL2)

    dsteigne

      I have something that I wanted to discuss with any one who has experience with Modeshape regarding the search functionality in JCR2.0 (JCR-SQL2).

      I noticed one thing in query functionality that UNDEFINED properties in node are not returned with the nodes returned by search result.

      E.g,

      here is my CND similar to what we have,

             [cldscp:CardResourceType]

             - * (UNDEFINED)

                      - * (UNDEFINED) multiple 

              - test1 (string)

             - test2 (string)

       

       

      Now  I create a node of the type cldscp:CardResourceType with following properties,

             {

                      "test1":"value1",

                      "test2":"value2",

                      "test3":"value3",

                      "test4":"value4",

             }

       

      Now if I want to search this node by this query,

        SELECT * FROM [cldscp:cardResourceType]

       

      I get the Node but properties test3 and test4 which were defined as (UNDEFINED) are not retrieved within the Node.

       

      I wanted to know if my assumption is right? Or We are doing something wrong?

      If my assumption is right? Then do we have any way to fetch the UNDEFINED properties?

        • 1. Re: Modeshape regarding the search functionality in JCR2.0 (JCR-SQL2)
          hchiorean

          Hi Debbie,

           

          As per the JCR 2.0 spec, when "*" is used for the list of selected columns, the result set is expected to minimally include, for each selector, a column for each single-valued non-residual property of the selector's node type, including those explicitly declared on the node type and those inherited from the node's supertypes. ModeShape's query engine implementation adheres to the above, which explains the reason why in the above query "test3" and "test4" are not returned by default.

           

          AFAIK the only way to get residual properties is to query for them explicitly - SELECT card.test3, card.test4 from [cldscp:cardResourceType] as card.

           

          More information regarding the query capabilities can be found here https://docs.jboss.org/author/display/MODE28/Querying+and+Searching+using+JCR (for ModeShape 2.x) or https://docs.jboss.org/author/display/MODE/Query+language+grammars (for ModeShape 3.x).

          • 2. Re: Modeshape regarding the search functionality in JCR2.0 (JCR-SQL2)
            rhauch

            Horia is correct.

             

            To put it another way, the "test3" and "test4" properties are what JCR calls residual properties, because there is no explicit property definition that applies to them so they instead get the residual property definition (that is, the property definition defined by the * name). If there were a property definition (on the primary type or mixin types, or on any of their supertypes) that applied to 'test3' or 'test4', then they would then become non-residual properties.

             

            Now, regarding the query results, JCR does not require including residual properties in query results because of how it maps the node types onto tables. Non-residual properties are defined on the node types, and thus are easily "projected" into a relational table/view. However, non-residual properties by definition are not defined on the node types, and thus can't really appear in any of the relational table/view definitions. Thus, these are not included in the results of "SELECT *" queries.

             

            However, as Horia mentioned, you can explicitly include non-residual properties in the SELECT clause, and ModeShape will include them in the query results. In this case, you're essentially overriding the relational table/view definitions by telling ModeShape that there are some additional columns that should be included.

             

            Hope this helps!

            1 of 1 people found this helpful