Questions tagged [jcr-sql2]

JCR-SQL2 is a query language defined by the Java Content Repository 2.0 (JSR-283) specification. It is similar to a subset of SQL but also provides JCR-specific elements. JCR-SQL2 is an improvement over JCR-SQL, the original language defined in JCR 1.0 that was far less like SQL.

JCR-SQL2 queries are simple string statements that include common relational operators:

  • The SELECT clause identifies which JCR properties are to be returned in the tabular result set, and may include aliases
  • The FROM clause identifies the JCR node types (conceptually similar to tables or view) or joins that are to be sources of nodes
  • The optional WHERE clause lists any predicates that must be satisfied before nodes can be included in the results
  • The optional ORDER BY clause the specifies how the results are to be ordered

An example JCR-SQL2 query is this query:

SELECT file.*,content.* FROM [nt:file] AS file 
JOIN [nt:resource] AS content ON ISCHILDNODE(content,file) 
WHERE LOCALNAME(file,'*.txt') AND ISDESCENDANTNODE(file,[/a/b/c])

This query finds all nodes of type nt:file with a name that matches the *.txt pattern that exist somewhere under the /a/b/c node, and the nt:file node's child of type nt:resource node. The result set will minimally include a column for each of the properties defined on nt:file (e.g., "jcr:created" and "jcr:createdBy") and nt:resource (e.g., "jcr:mimeType", "jcr:encoding", "jcr:lastModified", "jcr:lastModifiedBy"); implementations are allowed to return additional columns.

Some JCR implementations (such as Jackrabbit) support only the required grammar, while other JCR implementations (such as ModeShape) support an extended grammar with additional functionality.

The JCR-SQL2 language is surprisingly powerful and flexible, and provide an easy way to find repository content independent of where that content exists in the repository's hierarchical structure of nodes.

Links

105 questions
0
votes
0 answers

Combine 2 JCR-SQL2 queries to 1 query

I need to merge these 2 queries together: Query 1 SELECT page.* FROM [cq:Page] AS page INNER JOIN [nt:base] AS component ON isdescendantnode(component,page) WHERE component.[sling:resourceType] ='wcm/foundation/components/responsivegrid' This…
superninja
  • 3,114
  • 7
  • 30
  • 63
0
votes
0 answers

Merge ACS Commons Reports AEM

I have multiple queries in JCR-SQL2 and are currently separated in multiple ACS commons reports. This is not very user friendly as we need to go through different reports to look for the data. I was wondering if there's any way to merge these…
superninja
  • 3,114
  • 7
  • 30
  • 63
0
votes
1 answer

Image upload moderation in Jahia

Using a Jahia form to capture image uploads. Unfortunately it doesn’t seem form submissions can be directly edited in Jahia form submission dashboard. I need a way for certain users or roles to be able to mark a particular submission as approved.…
catscancode
  • 115
  • 1
  • 7
0
votes
1 answer

JCR SQL2 query for an empty multivalued field

In our scenario we have a (multivalued) category field on JCR:node and we want to query all nodes that do not have a current selection. In the JCR viewer the fields value is [] but I can't find any query to select nodes with this condition. We have…
Andre Albert
  • 1,386
  • 8
  • 17
0
votes
1 answer

Query JCR SQL2 in Magnolia with a multivalue where-condition

We are implementing a custom REST endpoint in magnolia that queries for pages and it should be able to filter by categories. I found the JCR Query Cheat Sheet, but I could not see an example about filtering a multivalued field. In our case, we have…
Andre Albert
  • 1,386
  • 8
  • 17
0
votes
1 answer

How can i add an expression to jcr sql2 query?

I have query SELECT * FROM [cq:ReplicationStatus] AS node WHERE (ISDESCENDANTNODE(node,'/home/users/we-retail') AND node.[rep:authorizableId] = ${userId}) and I have a function public HashMap getInformation(Integer userId)…
kmj
  • 15
  • 4
0
votes
0 answers

Jackrabbit permission issue with JCR API 2.0

I am new to Jackrabbit and trying create a node and save it in the session. I got the following permission issue: javax.jcr.RepositoryException: Forbidden at org.apache.jackrabbit.spi2dav.ExceptionConverter.generate(ExceptionConverter.java:113) …
junhaotee
  • 483
  • 4
  • 10
0
votes
1 answer

SQL2 query for accessing tags from assets

I want to know what is the SQL2 query for accessing child nodes of a parent node for full text search. I have an image saved into assets named men-watches.png. I have created a tag named watches and assigned this tag to asset mentioned above. I have…
0
votes
1 answer

JackRabbit Oak : my application takes long time to start/restart

I am using JackRabbit oak implementation in my Spring Boot project. My application creates multiple nodes in jcr repository with integration of PostgreSQL db. There are already huge amount of node data available in jcr repository. But, whenever I…
abn
  • 41
  • 1
  • 8
0
votes
1 answer

how to get substring in JCR:SQL2?

Usecase that I am trying to solve is: Find all page references of all components under /apps. i.e. First find all pages where a component is being used, and then do this for all components under /apps. By using the report builder tool for Adobe…
rjn
  • 13
  • 4
0
votes
1 answer

JCR-SQL2 Query Subnodes

I need to find an entry in the JCR where a Date in a list of nodes containing dates matches my criteria. Data Structure is - Event1 -- Dates --- 0 ---- startDate: xyz ---- endDate: xyz --- 1 ---- startDate: xyz ---- endDate: xyz - Event1 --…
Jonas
  • 381
  • 3
  • 15
0
votes
1 answer

JCR-SQL2 Filter Query to get only empty nodes

I have the following JCR-SQL2-Query: SELECT * FROM [nt:base] AS nodes WHERE NAME(nodes) = 'NameOfTheNode' Right now I get all the nodes with the name 'NameOfTheNode'. But I want to limit the results to nodes that are empty respectively have no…
reencode
  • 237
  • 5
  • 15
0
votes
1 answer

Unique identifier for documents stored in Jackrabbit

I m fairly new to Apache Jackrabbit and I could not get a concrete answer to this question as far as I checked. Hence I m posting the following question: I need a unique identifier for the documents stored in Jackrabbit (irrespective of whether the…
Gandhi
  • 11,875
  • 4
  • 39
  • 63
0
votes
2 answers

How search feature works in AEM

 From AEM documents I can figure it out how to write queries for Aem content search, but How search feature works in AEM? Which bundle or framework does the magic of searching the content and present back. How internally content is being traversed…
krish
  • 469
  • 1
  • 15
  • 34
0
votes
1 answer

Find same-name siblings (SNS) using SQL2, SQL, XPath or QueryBuilder query in CQ5/AEM

Is it possible to find same-name siblings (SNS) using SQL2, SQL, XPath or QueryBuilder in Adobe CQ5/Adobe Experience Manager. We are trying to prepare the instance for upgrade to AEM 6.X and as already known jackrabbit oak has disabled the support…
d33t
  • 1,143
  • 6
  • 15