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
2
votes
0 answers

Finding node/asset using Name LIKE in CQ5?

I want to find an asset under a particular path and that has a name like '%xyz%'. I referred to this page "9 JCR Queries every AEM developer should know" Please refer to point number 7. It clearly states that I can use a combination of Name() Like…
Oliver
  • 6,152
  • 2
  • 42
  • 75
2
votes
2 answers

How to retrieve the data from database without using apache jackrabbit datastore?

I have integrated the jack rabbit with Oracle database and I am storing the Data using Jackrabbit, if I don't want to retrieve the data using the Jackrabbit, in what way I can get the data. In database data is storing in blob type.
2
votes
2 answers

"order by" based on a expression

Given a comparator: public int compareTo(Person p1, Person p2) { String val1 = StringUtils.isEmpty(p1.nickName) ? p1.name : p1.nickName; String val2 = StringUtils.isBlank(p2.nickName) ? p2.name : p2.nickName; return…
Andrzej Bobak
  • 2,106
  • 3
  • 28
  • 36
2
votes
1 answer

Understanding CQ5 Lucene indexing rule

Information: I have provided an indexing configuration file to cq5. I have not indexed on the property cq:template by specifying the following rule:
user3189453
  • 21
  • 1
  • 2
2
votes
2 answers

CQ5 JCR query in multiple paths

I need to have a JCR SQL query of this form : select * from jcr:content where cq:template like '%myTemplate%' and ( jcr:path like '%path1%' or jcr:path like '%path2%') But I get an exception saying that "incorrect use of property jcr:path" Is there…
Riju Mahna
  • 6,718
  • 12
  • 52
  • 91
1
vote
1 answer

jcr query construct

I am building a jcr query and receive data from repository. Here is my code: String queryString = "SELECT * FROM public:hours"; try { // get session Session session = requestContext.getSession(); // create query from queryString…
Allan Jiang
  • 11,063
  • 27
  • 104
  • 165
1
vote
1 answer

Select only particular pages of a template in AEM if that component exist in that page

I have a template in AEM where I have to select all pages for the template where the component is present in pages. Current query: SELECT * FROM [cq:PageContent] AS page WHERE ISDESCENDANTNODE(page, '/content') AND…
Bharat Wadhwa
  • 107
  • 1
  • 11
1
vote
1 answer

Exclude child path from fulltext search parent path using Querybuilder OR get search hit excerpt from XPATH/JCR SQL2 query

I want to exclude child nodes path from search path using querybuilder for example - parent folder is /content/mysite/en and subfolders are /content/mysite/en/testfolder1 /content/mysite/en/testfolder2 I want query builder to write a query to…
cqsapientuser
  • 65
  • 3
  • 12
1
vote
1 answer

Escape special characters in JCR SQL2 Query

I am using a JCR SQL2 query as below: SELECT parent.* FROM [rep:User] AS parent INNER JOIN [nt:unstructured] AS child ON ISCHILDNODE(child,parent) WHERE ISDESCENDANTNODE(parent,'/website/test/users') AND (UPPER(child.[email])…
PV_PN
  • 103
  • 2
  • 7
1
vote
1 answer

Implement AEM search using query builder API using wildcard-contains in node name

I have a requirement to fetch search results based on partial/wild card in node name to retrieve AEM forms portal data. For example, if there are multiple draft Id node under any user-email (Unique node created under /conten/forms/fp). each draft…
Vijay D
  • 57
  • 9
1
vote
0 answers

What happen if disable lease check in jackrabbit oak implementation

We are using jackrabbit oak in our application. we are getting below error while processing requests. *"This oak instance failed to update the lease in time and can therefore no longer access this DocumentNodeStore."* Any impact on application…
abn
  • 41
  • 1
  • 8
1
vote
1 answer

Path not included in Queryresult (row.getValue)

we still have Jackrabbit 2 (2.18.0) in use and I have a problem with loading the "jcr:path" in the Query-Result. In this example we have a custom node "org:permission" with a custom property "org:permissionHolderIds". The custom property is filled…
Martin
  • 107
  • 1
  • 8
1
vote
0 answers

Duplicate Rows JCR-SQl2 AEM

I've faced with a duplicate rows issue when I use JCR-SQl2 query for getting data in AEM 6.3.1. I attached the SQl2 query below. SELECT s.* FROM [rep:User] AS s LEFT OUTER JOIN [nt:base] AS c ON ischildnode(c, s) WHERE…
Mike
  • 11
  • 3
1
vote
0 answers

Why Jackrabbit Full text Query doesn't work?

I tring working with jcr jackrabbit oak, mongoDb and query. The first I added a few file to repository. Now I would like use full-text search. When I use query : Session session = getSessions(); Workspace workspace =…
1
vote
1 answer

Adding restrictions to ACLs yields empty results for queries in Jackrabbit Oak

Using Jackrabbit Oak, I've been attempting to configure security through SecurityProvider and SecurityConfigurations. In particular, I've been using the restrictions which generally works as expected. However, when dealing with JCR-SQL2 queries,…
Søren
  • 95
  • 8