JCR 2.0 SQL-2 Grammar

Query
Column
Selector
Join
Constraint
And Condition
Condition
Comparison
Fulltext Search Expression
Static Operand
Literal
Number Literal
Number
Dynamic Operand
Ordering
Name

These railroad diagrams are based on the JCR 2.0 specification.

The diagrams are created with a small Java program and this BNF. The program uses the BNF parser / converter of the the H2 database engine.

Please send feedback to the Jackrabbit User List.


Query

SELECT
*
column
 
, ...
FROM selector
 
join ...

 
WHERE constraint
 
ORDER BY ordering
 
, ...

 


Column

 
selectorName .
propertyName
 
AS columnName
selectorName . *

 


Selector

nodeTypeName
 
AS selectorName

 


Join

INNER
LEFT
RIGHT
OUTER
JOIN rightSelector ON

selectorName . propertyName = joinSelectorName . joinPropertyName
ISSAMENODE ( selectorName , joinSelectorName
 
, selectorPathName
)
ISCHILDNODE ( childSelectorName , parentSelectorName )
ISDESCENDANTNODE ( descendantSelectorName , ancestorSelectorName )

 


Constraint

andCondition
 
OR andCondition
 
...

 


And Condition

condition
 
AND condition
 
...

 


Condition

comparison
NOT constraint
( constraint )
 
selectorName .
propertyName IS
 
NOT
NULL
CONTAINS (
 
selectorName .
propertyName
selectorName . *
, fulltextSearchExpression )
ISSAMENODE
ISCHILDNODE
ISDESCENDANTNODE
(
 
selectorName ,
PathName )

 


Comparison

dynamicOperand
=
< >
<
< =
>
> =
LIKE
staticOperand

 


Fulltext Search Expression

' anything '
$ bindVariableName

 


Static Operand

literal
$ bindVariableName
CAST ( literal AS
STRING
BINARY
DATE
LONG
DOUBLE
DECIMAL
BOOLEAN
NAME
PATH
REFERENCE
WEAKREFERENCE
URI
)

 


Literal

' anything '
" anything "
numberLiteral

 


Number Literal

 
+
-
number
 
. number
. number
 
E
 
+
-
expNumber
 
...

 


Number

0-9
 
...

 


Dynamic Operand

 
selectorName .
propertyName
LENGTH (
 
selectorName .
propertyName )
NAME
LOCALNAME
SCORE
(
 
selectorName
)
LOWER
UPPER
( dynamicOperand )

 


Ordering

simpleName
 
ASC
DESC

 


Name

simpleName
[ quotedName ]