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
1 answer

JCR SQL2 compare properties on same node

We have some nodes with incorrect properties where cq:title does not equal cq:summary (we want these to always equal). To find them I type: SELECT * FROM [nt:base] AS s WHERE s.[cq:title] <> s.[cq:summary] I get the error: expected: static…
Sameer Technomark
  • 1,399
  • 1
  • 10
  • 12
0
votes
1 answer

JCR SQL2 Query comparing name and path with like

I was trying to execute following jcr sql2 query: String expression = "SELECT * FROM [nt:base] AS p " + "WHERE NAME(p) like 'opony.txt'"; But I got javax.jcr.UnsupportedRepositoryOperationException. Is it any other way to…
biesczadka
  • 571
  • 1
  • 7
  • 19
0
votes
1 answer

How to search JCR nodes with a version label

Following code segment is used to add a label to a node using ModeShape. What query string I could use to query this node with the QueryManager? It seems that the nodes from versionHistory side cannot be queried with the QueryManager. …
0
votes
2 answers

SQL2 equivalent for this XPath query

Is there an SQL2 query that is identical to the following XPath query: /jcr:root/content/ancestor//parent/jcr:content It should return the following nodes, for…
TheFooProgrammer
  • 2,439
  • 5
  • 28
  • 43
0
votes
1 answer

Getting list of nodes for user

I have many 'nt:folder' Nodes created and upon each folder creation, permissions has been granted to different set of users. Now I need to get list of nodes based on user(with read and write) persmissions. Using jackrabbit 2.6.0 Partial snippet…
techie2k
  • 559
  • 1
  • 6
  • 32
0
votes
2 answers

How to check whether jcr node has property or not?

I am retrieving set of nodes from jcr after specific lastModified property. But for some nodes it dont have lastModified property in that case my query have to look for jcr:createdDate. How it will achieved? This is my query SELECT * FROM…
sridhar
  • 303
  • 5
  • 26
0
votes
1 answer

Select formatted Date in JCR SQL2

I would like to execute an JCR SQL2 query, which selects me the year of a date-property. Something like this: SELECT DATE_FORMAT([jcr:created], '%Y') FROM x Is something similar even possible= I have searched and did not find anything, but I could…
Evan
  • 123
  • 1
  • 8
0
votes
1 answer

Compare values as doubles in a JCR-SQL2 query

I am trying to compare JCR node's string properties with a double value in JCR-SQL2. But it is comparing the values as strings. For example: SELECT * FROM [nodex] as x where x.propertyY <= 20.50 Here propertyY is the string in the definition. I…
0
votes
0 answers

Jackrabbit - Select node with maximum property value

Let's say I have several file nodes with a property called foo. In Jackrabbit the xpath query I use to find those nodes by a property value is as follows: /jcr:root/content/*[jcr:uuid='9b3d22fc-2354-49a6-afd0-9b672ae5a553']//file[foo = 10] order by…
0
votes
1 answer

Querying case-insensitive paths with SQL2 ISDESCENDANTNODE in CQ5

I have this SQL2 query that searches for nodes that are descendant of a certain path: SELECT product.* FROM [nt:base] AS product INNER JOIN [nt:base] AS variant ON ISCHILDNODE(variant, product) WHERE ISDESCENDANTNODE(product,…
Henrique Ordine
  • 3,337
  • 4
  • 44
  • 70
0
votes
1 answer

What will be the Query in my situation in Adobe CQ5

Root contains one folder, named pending of type sling:folder. That have numbers of nodes of nt:unstructured type, having name of long value, that long value is very important for my code processing. Now I want to get top 20 nodes(20 minimum node…
devsda
  • 4,112
  • 9
  • 50
  • 87
0
votes
1 answer

OCM Query equivalent to JCR SQL2 query

I am implementing full text search on Jackrabbit Repository. After going through the examples given at http://jackrabbit.apache.org/ocm-search.html, I am able to write perform full text search on repository when only 'and' is required in the…
Vaibhav Raj
  • 2,214
  • 4
  • 23
  • 39
0
votes
1 answer

Querystring for searching content in several paths, using SQL2

Currently I am stuck at the issue to generate a query with multiple paths. I could accomplish the situation searching for childnodes from a specific single rootpath in the crx repository. I use the keyword isdecendantnodenode() for that: select *…
Reporter
  • 3,897
  • 5
  • 33
  • 47
0
votes
1 answer

Modeshape querying mixinTypes

I'm using Modeshape and modeshape-connector-jdbc-metadata. I want to get all nodes representing tables in the storage. That nodes have [mj:catalog] mixin type. I'm querying storage using next code: public List getDatabases() throws…
Gregory Kalabin
  • 1,760
  • 1
  • 19
  • 45
-4
votes
1 answer

When I try to convert the pandas DataFrame to Xarray dataset I get this error

When I try to convert the pandas DataFrame to Xarray dataset I get this error: ValueError: can only convert an array of size 1 to a Python scalar Image: Code: # Convert the DataFrame back to xarray Dataset and assign…
sharaf
  • 3
  • 1
1 2 3 4 5 6
7