Query Builder Sling

JCR Java Query Object Model (JQOM) – Adobe AEM Query


JQOM (Java Query Object Model) is the new Query language that has been support by AEM from its latest version 6.x for its latest repository Jackrabbit Oak. This post aims at introducing to the JQOM APIs with an example. JQOM is like a ‘prepared statements’ and SQL2 is like ‘statements’ in our JDBC queries.


Let us take an usecase to Get all the nodes from ‘Geometrixx’ which has the property ‘pageTitle’  and see how to write JQOM.

QueryObjectModelFactory get the instance of the JCR Object Model.

Selector is used to set the type of node that the query needs to look at

Constraint is used to add all the constraints which is like where condition into the query model

Finally we need to create a query with these selector and constraint and capture the response as a QueryObjectModel


Servlet has been created for the same which can be downloaded from github. Once you install the project hit the servlet url (localhost:4502/services/query) to see the output

Query Servlet Output

Play around in changing the query model and check the output.


2 thoughts on “JCR Java Query Object Model (JQOM) – Adobe AEM Query

  1. How would you check for a page that has a specific page title? I’m having lots of trouble finding the right way to compare a property against a specific value. If that’s too complicated, all I really need is to find specific cq:templates, so like cp:template is equal to “x/x” where x/x is the path of the template (in full, no ‘contains’ necessary)

    1. Hi Michael,

      Sorry for the delayed response. However you can do that adding a Constraint with a ‘DynamicOperand’ as shown in the example below
      String operator = QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO;
      DynamicOperand dynOperand = qf.propertyValue(“s”, “jcr:title”);
      StaticOperand statOperand = qf.literal(valueFactory.createValue());
      constriant = qf.and(constriant, qf.comparison(dynOperand , operator, statOperand));

      you can also refer the service class in my github ‘https://github.com/AEMClub/adobe-aem-club/blob/master/testsite.jcrquery/src/main/java/org/mindtree/testsite/core/servlets/QueryServlet.java’ where I added this piece of code as commented


Leave a Reply

Your email address will not be published. Required fields are marked *