我们在写NHibernate的HQL语句
下面是这方面的指南
HQL BNF
Outdated Hibernate 2.x docume
Here is a partial BNF for the Hibernate2 Query Language (this is meant more for the purposes of documentation than as a grammer for a parser compiler).
query:
[selectClause] fromClause [whereClause] [groupByClause]
[havingClause] [orderByClause];
selectClause:
SELECT DISTINCT? selectedPropertiesList |
( NEW className OPEN selectedPropertiesList CLOSE );
fromClause:
FROM className AS? identifier
( ( COMMA className AS? identifier ) |
( joinType path AS? identifier ) )*;
joinType:
( ( 'left'|'right' 'outer'? ) | 'full' | 'inner' )? JOIN FETCH?;
groupByClause:
GROUP_BY path ( COMMA path )*;
orderByClause:
ORDER_BY selectedPropertiesList;
havingClause:
HAVING logicalExpression;
whereClause:
WHERE logicalExpression;
selectedPropertiesList:
( path | aggregate ) ( COMMA path | aggregate )*;
aggregate:
( aggregateFunction OPEN path CLOSE ) |
( COUNT OPEN STAR CLOSE ) | ( COUNT OPEN DISTINCT |
ALL path CLOSE );
aggregateFunction:
COUNT | 'sum' | 'avg' | 'max' | 'min';
logicalExpression: TODO!
expression: TODO!
collection: ( OPEN query CLOSE ) |
( 'elements'|'indices' OPEN path CLOSE );
quantifiedExpression: 'exists' | ( expression 'in' ) |
( expression OP 'any' | 'some' ) collection;
compoundPath: path ( OPEN_BRACKET expression CLOSE_BRACKET
( '.' path )? )*;
path: identifier ( '.' identifier )*;
className: path;
OP: EQ | LT | GT | LE | GE | NE | SQL_NE | LIKE;
AS: 'as';
DISTINCT: 'distinct';
ALL: 'all';
COUNT: 'count';
SELECT: 'select';
FROM: 'from';
JOIN: 'join;
FETCH: 'fetch'
BY: 'by';
GROUP_BY: 'group' BY;
ORDER_BY: 'order' BY;
HAVING: 'having';
WHERE: 'where';
NEW: 'new';
LIKE: 'like';
EQ: '=';
LT: '<';
GT: '>';
SQL_NE: "<>";
NE: "!=" | "^=";
LE: "<=";
GE: ">=";
COMMA: ',';
OPEN: '(';
CLOSE: ')';
OPEN_BRACKET: '[';
CLOSE_BRACKET: ']';
CONCAT: "||";
PLUS: '+';
MINUS: '-';
STAR: '*';
DIV: '/';