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).
1 of 1 people found this helpful
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!