Hibernate SVN: r16432 - in core/branches/antlr3/src: main/antlr3/org/hibernate/sql/ast/phase/hql/resolve and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: porcelli
Date: 2009-04-23 15:20:25 -0400 (Thu, 23 Apr 2009)
New Revision: 16432
Modified:
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLLexer.g
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLParser.g
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g
core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolver.java
core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g
core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java
Log:
added the order_spec
Modified: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLLexer.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLLexer.g 2009-04-23 17:38:50 UTC (rev 16431)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLLexer.g 2009-04-23 19:20:25 UTC (rev 16432)
@@ -59,7 +59,6 @@
AND;
ANY;
AS;
- ASC;
AVG;
BETWEEN;
BIT_LENGTH;
@@ -76,7 +75,6 @@
CURRENT_TIMESTAMP;
DAY;
DELETE;
- DESC;
DISTINCT;
ELEMENTS;
ELSE;
@@ -124,6 +122,7 @@
ON;
OR;
ORDER_BY;
+ ORDER_SPEC;
OUTER;
POSITION;
PROPERTIES;
Modified: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLParser.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLParser.g 2009-04-23 17:38:50 UTC (rev 16431)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLParser.g 2009-04-23 19:20:25 UTC (rev 16432)
@@ -523,7 +523,7 @@
sortSpecification
@init{boolean generateOmmitedElement = true;}
: sortKey collationSpecification? (orderingSpecification {generateOmmitedElement = false;})?
- -> {generateOmmitedElement}? ^(SORT_SPEC sortKey collationSpecification? ASC)
+ -> {generateOmmitedElement}? ^(SORT_SPEC sortKey collationSpecification? ORDER_SPEC["asc"])
-> ^(SORT_SPEC sortKey collationSpecification? orderingSpecification?)
;
@@ -544,8 +544,8 @@
;
orderingSpecification
- : ascending_key
- | descending_key
+ : ascending_key -> ORDER_SPEC[$ascending_key.start, "asc"]
+ | descending_key -> ORDER_SPEC[$descending_key.start, "desc"]
;
logicalExpression
@@ -1438,13 +1438,11 @@
;
ascending_key
- : {(validateIdentifierKey("ascending") || validateIdentifierKey("asc"))}?=> id=IDENTIFIER
- -> ASC[$id]
+ : {(validateIdentifierKey("ascending") || validateIdentifierKey("asc"))}?=> IDENTIFIER
;
descending_key
- : {(validateIdentifierKey("descending") || validateIdentifierKey("desc"))}?=> id=IDENTIFIER
- -> DESC[$id]
+ : {(validateIdentifierKey("descending") || validateIdentifierKey("desc"))}?=> IDENTIFIER
;
collate_key
Modified: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g 2009-04-23 17:38:50 UTC (rev 16431)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g 2009-04-23 19:20:25 UTC (rev 16432)
@@ -75,7 +75,7 @@
throw new UnsupportedOperationException( "must be overridden!" );
}
- protected void normalizeIntermediateIndexOperation( PathedPropertyReferenceSource propertyReferenceSource, Tree collectionProperty,
+ protected PathedPropertyReferenceSource normalizeIntermediateIndexOperation( PathedPropertyReferenceSource propertyReferenceSource, Tree collectionProperty,
Tree selector ) {
throw new UnsupportedOperationException( "must be overridden!" );
}
@@ -107,7 +107,7 @@
protected void popStrategy(){
throw new UnsupportedOperationException( "must be overridden!" );
- }
+ }
}
filterStatement[String collectionRole]
@@ -251,7 +251,7 @@
;
sortSpecification
- : ^(SORT_SPEC valueExpression COLLATE? (ASC|DESC))
+ : ^(SORT_SPEC valueExpression COLLATE? ORDER_SPEC)
;
searchCondition
@@ -586,7 +586,7 @@
: {(isPersisterReferenceAlias())}?=> IDENTIFIER { $propertyReferenceSource = normalizeQualifiedRoot( $IDENTIFIER ); }
| {(isUnqualifiedPropertyReference())}?=> IDENTIFIER { $propertyReferenceSource = normalizeUnqualifiedRoot( $IDENTIFIER ); }
| intermediatePathedPropertyReference { $propertyReferenceSource = $intermediatePathedPropertyReference.propertyReferenceSource; }
- | intermediateIndexOperation { $propertyReferenceSource = null; }
+ | intermediateIndexOperation { $propertyReferenceSource = $intermediateIndexOperation.propertyReferenceSource; }
;
intermediatePathedPropertyReference returns [PathedPropertyReferenceSource propertyReferenceSource]
@@ -594,9 +594,9 @@
{ $propertyReferenceSource = normalizePropertyPathIntermediary( $pathedPropertyReferenceSource.propertyReferenceSource, $IDENTIFIER ); }
;
-intermediateIndexOperation
+intermediateIndexOperation returns [PathedPropertyReferenceSource propertyReferenceSource]
: ^( LEFT_SQUARE indexOperationSource indexSelector )
- { normalizeIntermediateIndexOperation( $indexOperationSource.propertyReferenceSource, $indexOperationSource.collectionProperty, $indexSelector.tree ); }
+ { $propertyReferenceSource = normalizeIntermediateIndexOperation( $indexOperationSource.propertyReferenceSource, $indexOperationSource.collectionProperty, $indexSelector.tree ); }
;
terminalIndexOperation
Modified: core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolver.java
===================================================================
--- core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolver.java 2009-04-23 17:38:50 UTC (rev 16431)
+++ core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolver.java 2009-04-23 19:20:25 UTC (rev 16432)
@@ -1,16 +1,23 @@
/*
- * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party
+ * contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
- * This copyrighted material is made available to anyone wishing to use, modify,
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
+ * Lesser General Public License, as published by the Free Software
+ * Foundation.
*
* This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
@@ -25,6 +32,7 @@
import org.antlr.runtime.tree.CommonTree;
import org.antlr.runtime.tree.Tree;
import org.antlr.runtime.tree.TreeNodeStream;
+
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.persister.entity.Queryable;
import org.hibernate.sql.ast.alias.DefaultTableAliasGenerator;
@@ -41,6 +49,7 @@
import org.hibernate.sql.ast.tree.Table;
import org.hibernate.sql.ast.tree.Table.EntityTableSpace;
import org.hibernate.sql.ast.util.TreePrinter;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,25 +66,26 @@
private boolean isProcessingFunction = false;
- public HQLResolver( TreeNodeStream input,
- SessionFactoryImplementor sessionFactory ) {
+ public HQLResolver(TreeNodeStream input,
+ SessionFactoryImplementor sessionFactory) {
this( input, new RecognizerSharedState(), sessionFactory );
}
- public HQLResolver( TreeNodeStream input, RecognizerSharedState state,
- SessionFactoryImplementor sessionFactory ) {
+ public HQLResolver(TreeNodeStream input, RecognizerSharedState state,
+ SessionFactoryImplementor sessionFactory) {
super( input, state );
this.sessionFactory = sessionFactory;
this.persisterSpaceContext = new RootPersisterSpaceContext();
this.defaultTableAliasGenerator = new DefaultTableAliasGenerator(
- sessionFactory.getDialect() );
+ sessionFactory.getDialect()
+ );
this.printer = new TreePrinter( HQLParser.class );
this.pathResolutionStrategyStack = new PathResolutionStrategyStack();
this.pathResolutionStrategyStack
.push( new BasicPathResolutionStrategySupport( this ) );
}
- protected void registerPersisterSpace( Tree entityName, Tree alias ) {
+ protected void registerPersisterSpace(Tree entityName, Tree alias) {
String entityPersisterName = sessionFactory
.getImportedClassName( entityName.getText() );
Queryable entityPersister = ( Queryable ) sessionFactory
@@ -84,7 +94,8 @@
TableAliasGenerator.TableAliasRoot tableAliasRoot = getTableAliasGenerator()
.generateSqlAliasRoot( entityPersister, alias.getText() );
EntityTableSpace tableSpace = new Table.EntityTableSpace(
- entityPersister, tableAliasRoot );
+ entityPersister, tableAliasRoot
+ );
registerPersisterSpace( tableSpace.getPersisterSpace() );
}
@@ -116,21 +127,24 @@
return pathResolutionStrategyStack.getCurrent();
}
- public void registerAssociationFetch( PersisterSpace persisterSpace ) {
+ public void registerAssociationFetch(PersisterSpace persisterSpace) {
throw new UnsupportedOperationException( "must be implemented!" );
}
- public void registerPropertyFetch( PersisterSpace persisterSpace ) {
+ public void registerPropertyFetch(PersisterSpace persisterSpace) {
throw new UnsupportedOperationException( "must be implemented!" );
}
- protected void pushFromStrategy( JoinType joinType,
- Tree assosiationFetchTree, Tree propertyFetchTree, Tree alias ) {
+ protected void pushFromStrategy(JoinType joinType,
+ Tree assosiationFetchTree, Tree propertyFetchTree, Tree alias) {
boolean assosiationFetch = assosiationFetchTree != null ? true : false;
boolean propertyFetch = propertyFetchTree != null ? true : false;
- pathResolutionStrategyStack.push( new FromClausePathResolutionStrategy(
- this, joinType, assosiationFetch, propertyFetch, alias
- .getText() ) );
+ pathResolutionStrategyStack.push(
+ new FromClausePathResolutionStrategy(
+ this, joinType, assosiationFetch, propertyFetch, alias
+ .getText()
+ )
+ );
}
protected void pushSelectStrategy() {
@@ -142,7 +156,7 @@
pathResolutionStrategyStack.pop();
}
- private void registerPersisterSpace( PersisterSpace persisterSpace ) {
+ private void registerPersisterSpace(PersisterSpace persisterSpace) {
persisterSpaceContext.registerPersisterSpace( persisterSpace );
}
@@ -150,7 +164,7 @@
return locateOwningPersisterAlias( ( Tree ) input.LT( 1 ) ) != null;
}
- protected String locateOwningPersisterAlias( Tree property ) {
+ protected String locateOwningPersisterAlias(Tree property) {
PersisterSpace persisterReference = getCurrentPersisterSpaceContext()
.locatePersisterSpaceExposingProperty( property.getText() );
return persisterReference == null ? null : persisterReference
@@ -159,84 +173,116 @@
protected boolean isPersisterReferenceAlias() {
Tree alias = ( Tree ) input.LT( 1 );
- log.trace( "Checking [" + textOrNull( alias )
- + "] as persister-ref alias" );
+ log.trace(
+ "Checking [" + textOrNull( alias )
+ + "] as persister-ref alias"
+ );
return getCurrentPersisterSpaceContext().isContainedAlias(
- alias.getText() );
+ alias.getText()
+ );
}
protected PathedPropertyReferenceSource normalizeUnqualifiedPropertyReference(
- Tree property ) {
+ Tree property) {
return getCurrentPathResolutionStrategy().handleRoot(
getCurrentPersisterSpaceContext()
.locatePersisterSpaceExposingProperty(
- property.getText() ) );
+ property.getText()
+ )
+ );
}
protected PathedPropertyReferenceSource normalizeUnqualifiedRoot(
- Tree propertyName ) {
- log.debug( "normalizing path expression root as unqualified property ["
- + textOrNull( propertyName ) + "]" );
+ Tree propertyName) {
+ log.debug(
+ "normalizing path expression root as unqualified property ["
+ + textOrNull( propertyName ) + "]"
+ );
PathedPropertyReferenceSource root = getCurrentPathResolutionStrategy()
.handleRoot(
getCurrentPersisterSpaceContext()
.locatePersisterSpaceExposingProperty(
- propertyName.getText() ) );
+ propertyName.getText()
+ )
+ );
return root.handleIntermediatePathPart( propertyName.getText() );
}
- protected PathedPropertyReferenceSource normalizeQualifiedRoot( Tree alias ) {
- log.debug( "normalizing path expression root as alias ["
- + alias.getText() + "]" );
+ protected PathedPropertyReferenceSource normalizeQualifiedRoot(Tree alias) {
+ log.debug(
+ "normalizing path expression root as alias ["
+ + alias.getText() + "]"
+ );
return getCurrentPathResolutionStrategy().handleRoot(
getCurrentPersisterSpaceContext().locatePersisterSpaceByAlias(
- alias.getText() ) );
+ alias.getText()
+ )
+ );
}
protected Tree normalizePropertyPathTerminus(
- PathedPropertyReferenceSource source, Tree propertyNameNode ) {
- log.trace( "normalizing terminal path expression ["
- + textOrNull( propertyNameNode ) + "]" );
+ PathedPropertyReferenceSource source, Tree propertyNameNode) {
+ log.trace(
+ "normalizing terminal path expression ["
+ + textOrNull( propertyNameNode ) + "]"
+ );
return getCurrentPathResolutionStrategy().handleTerminalPathPart(
- source, propertyNameNode.getText() );
+ source, propertyNameNode.getText()
+ );
}
protected PathedPropertyReferenceSource normalizePropertyPathIntermediary(
- PathedPropertyReferenceSource source, Tree propertyName ) {
- log.trace( "normalizing intermediate path expression ["
- + textOrNull( propertyName ) + "]" );
+ PathedPropertyReferenceSource source, Tree propertyName) {
+ log.trace(
+ "normalizing intermediate path expression ["
+ + textOrNull( propertyName ) + "]"
+ );
return getCurrentPathResolutionStrategy().handleIntermediatePathPart(
( PathedPropertyReferenceSource ) source,
- propertyName.getText() );
+ propertyName.getText()
+ );
}
protected PathedPropertyReferenceSource normalizeUnqualifiedPropertyReferenceSource(
- Tree propertyName ) {
+ Tree propertyName) {
return getCurrentPathResolutionStrategy().handleRoot(
getCurrentPersisterSpaceContext()
.locatePersisterSpaceExposingProperty(
- propertyName.getText() ) );
+ propertyName.getText()
+ )
+ );
}
- protected void normalizeIntermediateIndexOperation(
- PathedPropertyReferenceSource propertyReferenceSource,
- Tree collectionProperty, Tree selector ) {
- throw new UnsupportedOperationException(
- "must be implemented!: normalizeIntermediateIndexOperation" );
+ protected PathedPropertyReferenceSource normalizeIntermediateIndexOperation(
+ PathedPropertyReferenceSource collectionSource,
+ Tree collectionProperty, Tree selector) {
+ log.trace(
+ "normalizing intermediate index access ["
+ + textOrNull( collectionProperty ) + "]"
+ );
+ return getCurrentPathResolutionStrategy()
+ .handleIntermediateIndexAccess(
+ collectionSource,
+ collectionProperty.getText(),
+ new HibernateTree( ( CommonTree ) selector )
+ );
}
protected void normalizeTerminalIndexOperation(
PathedPropertyReferenceSource propertyReferenceSource,
- Tree collectionProperty, Tree selector ) {
- log.trace( "normalizing terminal index access ["
- + textOrNull( collectionProperty ) + "]" );
+ Tree collectionProperty, Tree selector) {
+ log.trace(
+ "normalizing terminal index access ["
+ + textOrNull( collectionProperty ) + "]"
+ );
PathedPropertyReferenceSource collectionSource = propertyReferenceSource;
getCurrentPathResolutionStrategy().handleTerminalIndexAccess(
collectionSource, collectionProperty.getText(),
- new HibernateTree( ( CommonTree ) selector ) );
+ new HibernateTree( ( CommonTree ) selector )
+ );
}
- private String textOrNull( Tree tree ) {
+ private String textOrNull(Tree tree) {
return tree == null ? null : tree.getText();
}
Modified: core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g
===================================================================
--- core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g 2009-04-23 17:38:50 UTC (rev 16431)
+++ core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g 2009-04-23 19:20:25 UTC (rev 16432)
@@ -177,7 +177,7 @@
;
sortSpecification
- : ^(SORT_SPEC valueExpression COLLATE? (ASC|DESC))
+ : ^(SORT_SPEC valueExpression COLLATE? ORDER_SPEC)
;
searchCondition
Modified: core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java
===================================================================
--- core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java 2009-04-23 17:38:50 UTC (rev 16431)
+++ core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java 2009-04-23 19:20:25 UTC (rev 16432)
@@ -39,12 +39,12 @@
super.tearDown();
}
- public void testBasicStructure() throws Throwable {
+ public void testBasicStructure() throws RecognitionException {
Tree queryTree = normalize( "from Animal" );
}
public void testBasicSelectStructure() throws Throwable {
- Tree queryTree = normalize( "from Zoo z where mammals['dog'] = ?" );
+ Tree queryTree = normalize( "from Zoo z where z.mammals['dog'].id = ?" );
}
public Tree normalize( String hql ) throws RecognitionException {
15 years, 7 months
Hibernate SVN: r16431 - in core/branches/antlr3/src: main/antlr3/org/hibernate/sql/ast/phase/hql/resolve and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: porcelli
Date: 2009-04-23 13:38:50 -0400 (Thu, 23 Apr 2009)
New Revision: 16431
Added:
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLLexer.g
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLParser.g
Removed:
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQL.g
Modified:
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g
core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g
Log:
lexer and parser are now splitted
Deleted: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQL.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQL.g 2009-04-23 16:52:44 UTC (rev 16430)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQL.g 2009-04-23 17:38:50 UTC (rev 16431)
@@ -1,1852 +0,0 @@
-grammar HQL;
-
-options {
- output=AST;
-}
-
-tokens {
-//GENERIC SQL TOKENS
- TABLE;
- COLUMN;
- COLUMN_LIST;
-
-//VIRTUAL TOKENS
- ALIAS_NAME;
- ALIAS_REF;
- BETWEEN_LIST;
- COLLATE;
- COLLECTION_EXPRESSION;
- DOT_CLASS;
- DYNAMIC_INSTANTIATION_ARG;
- DYNAMIC_INSTANTIATION;
- ENTITY_NAME;
- ENTITY_PERSISTER_REF;
- FILTER;
- GENERAL_FUNCTION_CALL;
- GROUPING_VALUE;
- IN_LIST;
- INSERTABILITY_SPEC;
- IS_NOT_EMPTY;
- IS_NOT_NULL;
- IS_NULL;
- JAVA_CONSTANT;
- JPA_PARAM;
- NAMED_PARAM;
- NOT_BETWEEN;
- NOT_IN;
- NOT_LIKE;
- NOT_MEMBER_OF;
- PATH;
- PERSISTER_JOIN;
- PERSISTER_SPACE;
- PROP_FETCH;
- PROPERTY_JOIN;
- PROPERTY_REFERENCE;
- QUALIFIED_JOIN;
- QUERY_SPEC;
- QUERY;
- SEARCHED_CASE;
- SELECT_FROM;
- SELECT_ITEM;
- SELECT_LIST;
- SIMPLE_CASE;
- SORT_SPEC;
- SUB_QUERY;
- UNARY_MINUS;
- UNARY_PLUS;
- VECTOR_EXPR;
- VERSIONED_VALUE;
-
-//SOFT KEYWORDS
- ABS;
- ALL;
- AND;
- ANY;
- AS;
- ASC;
- AVG;
- BETWEEN;
- BIT_LENGTH;
- BOTH;
- CAST;
- CHARACTER_LENGTH;
- CLASS;
- COALESCE;
- CONCAT;
- COUNT;
- CROSS;
- CURRENT_DATE;
- CURRENT_TIME;
- CURRENT_TIMESTAMP;
- DAY;
- DELETE;
- DESC;
- DISTINCT;
- ELEMENTS;
- ELSE;
- END;
- ESCAPE;
- EXCEPT;
- EXISTS;
- EXTRACT;
- FETCH;
- FROM;
- FULL;
- GROUP_BY;
- HAVING;
- HOUR;
- IN;
- INDEX;
- INDICES;
- INNER;
- INSERT;
- INTERSECT;
- INTO;
- IS_EMPTY;
- IS;
- JOIN;
- LEADING;
- LEFT;
- LENGTH;
- LIKE;
- LOCATE;
- LOWER;
- MAX;
- MAXELEMENT;
- MAXINDEX;
- MEMBER_OF;
- MIN;
- MINELEMENT;
- MININDEX;
- MINUTE;
- MOD;
- MONTH;
- NEW;
- NOT;
- NULLIF;
- OCTET_LENGTH;
- ON;
- OR;
- ORDER_BY;
- OUTER;
- POSITION;
- PROPERTIES;
- RIGHT;
- SECOND;
- SELECT;
- SET;
- SIZE;
- SOME;
- SQRT;
- SUBSTRING;
- SUM;
- THEN;
- TIMEZONE_HOUR;
- TIMEZONE_MINUTE;
- TRAILING;
- TRIM;
- UNION;
- UPDATE;
- UPPER;
- VERSIONED;
- WHEN;
- WHERE;
- WITH;
- YEAR;
-}
-
-@parser::header {
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- *
- * Portions of SQL grammar parsing copyright (C) 2003 by Lubos Vnuk. All rights
- * reserved. These portions are distributed under license by Red Hat Middleware
- * LLC and are covered by the above LGPL notice. If you redistribute this material,
- * with or without modification, you must preserve this copyright notice in its
- * entirety.
- */
-package org.hibernate.sql.ast.phase.hql.parse;
-
-import java.util.LinkedList;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.Iterator;
-import org.hibernate.sql.ast.tree.EntityNameTree;
-}
-
-@lexer::header {
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- *
- * Portions of SQL grammar parsing copyright (C) 2003 by Lubos Vnuk. All rights
- * reserved. These portions are distributed under license by Red Hat Middleware
- * LLC and are covered by the above LGPL notice. If you redistribute this material,
- * with or without modification, you must preserve this copyright notice in its
- * entirety.
- */
-package org.hibernate.sql.ast.phase.hql.parse;
-}
-
-
-@lexer::members {
- /** The standard method called to automatically emit a token at the
- * outermost lexical rule. The token object should point into the
- * char buffer start..stop. If there is a text override in 'text',
- * use that to set the token's text. Override this method to emit
- * custom Token objects.
-
- public Token emit() {
- Token t = new DroolsToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
- t.setLine(state.tokenStartLine);
- t.setText(state.text);
- t.setCharPositionInLine(state.tokenStartCharPositionInLine);
- emit(t);
- return t;
- } */
-
-}
-
-@parser::members {
- private Stack enableParameterUsage = new Stack();
- private ParserContext context = new ParserContextDefaultImpl();
- private List errorMessages = new LinkedList();
-
- public void setParserContext(ParserContext context){
- this.context = context;
- }
-
- private boolean validateIdentifierKey(String text) {
- return validateLT(1, text);
- }
-
- private boolean validateLT(int LTNumber, String text) {
- String text2Validate = retrieveLT( LTNumber );
- return text2Validate == null ? false : text2Validate.equalsIgnoreCase(text);
- }
-
- private String retrieveLT(int LTNumber) {
- if (null == input)
- return null;
- if (null == input.LT(LTNumber))
- return null;
- if (null == input.LT(LTNumber).getText())
- return null;
-
- return input.LT(LTNumber).getText();
- }
-
- public boolean hasErrors(){
- if ( errorMessages.size() > 0 ) {
- return true;
- }
- return false;
- }
-
- public List getErrorMessages(){
- return errorMessages;
- }
-
- public void reportError( RecognitionException e ) {
- errorMessages.add(generateError(getRuleInvocationStack(e, this.getClass().getName()), this.getTokenNames(), e));
- super.reportError(e);
- }
-
- private String generateError( List invocationStack,
- String[] tokenNames,
- RecognitionException e ) {
- String localization = invocationStack + ": line " + e.line + ":" + e.charPositionInLine + " ";
- return generateError(localization, tokenNames, e);
- }
-
- private String generateError( String localization,
- String[] tokenNames,
- RecognitionException e ) {
- String message = "";
- if (e instanceof MismatchedTokenException) {
- MismatchedTokenException mte = (MismatchedTokenException)e;
- String tokenName = "<unknown>";
- if (mte.expecting == Token.EOF) {
- tokenName = "EOF";
- } else {
- if (tokenNames != null) {
- tokenName = tokenNames[mte.expecting];
- }
- }
- message = localization + "mismatched token: " + e.token + "; expecting type " + tokenName;
- } else if (e instanceof MismatchedTreeNodeException) {
- MismatchedTreeNodeException mtne = (MismatchedTreeNodeException)e;
- String tokenName = "<unknown>";
- if (mtne.expecting == Token.EOF) {
- tokenName = "EOF";
- } else {
- tokenName = tokenNames[mtne.expecting];
- }
- message = localization + "mismatched tree node: " + mtne.node + "; expecting type " + tokenName;
- } else if (e instanceof NoViableAltException) {
- NoViableAltException nvae = (NoViableAltException)e;
- message = localization + "state " + nvae.stateNumber + " (decision=" + nvae.decisionNumber
- + ") no viable alt; token=" + e.token;
- } else if (e instanceof EarlyExitException) {
- EarlyExitException eee = (EarlyExitException)e;
- message = localization + "required (...)+ loop (decision=" + eee.decisionNumber + ") did not match anything; token="
- + e.token;
- } else if (e instanceof MismatchedSetException) {
- MismatchedSetException mse = (MismatchedSetException)e;
- message = localization + "mismatched token: " + e.token + "; expecting set " + mse.expecting;
- } else if (e instanceof MismatchedNotSetException) {
- MismatchedNotSetException mse = (MismatchedNotSetException)e;
- message = localization + "mismatched token: " + e.token + "; expecting set " + mse.expecting;
- } else if (e instanceof FailedPredicateException) {
- FailedPredicateException fpe = (FailedPredicateException)e;
- message = localization + "rule " + fpe.ruleName + " failed predicate: {" + fpe.predicateText + "}?";
- }
-
- return message;
- }
-
- private List extractEntityNames(String entityName) throws RecognitionException {
- List implementors = context.getEntityImplementors(entityName);
- if (implementors == null){
- throw new RecognitionException( );
- }
- return implementors;
- }
-
- private Tree generatePersisterSpacesTree(List persistenceSpaces) {
- List persisterSpaceList = new ArrayList();
- for (Iterator iterator = persistenceSpaces.iterator(); iterator
- .hasNext();) {
- Tree persistenceSpaceData = (Tree) iterator.next();
- if (persistenceSpaceData.getType() == PERSISTER_JOIN || persistenceSpaceData.getType() == PROPERTY_JOIN){
- adaptor.addChild(persisterSpaceList.get(persisterSpaceList.size() - 1), persistenceSpaceData);
- } else {
- Object persistenceSpaceTree = (Object)adaptor.nil();
- persistenceSpaceTree = adaptor.becomeRoot((Object)adaptor.create(PERSISTER_SPACE, "PERSISTER_SPACE"), persistenceSpaceTree);
- adaptor.addChild(persistenceSpaceTree, persistenceSpaceData);
- persisterSpaceList.add(persistenceSpaceTree);
- }
- }
- Tree resultTree = (Tree) adaptor.nil();
- for (Iterator iterator = persisterSpaceList.iterator(); iterator
- .hasNext();) {
- Object persistenceElement = (Object) iterator.next();
- adaptor.addChild(resultTree, persistenceElement);
- }
-
- return resultTree;
- }
-
- private Tree generateUpdateStatementTree(Object updateKey,
- Object entityName, Object aliasClause, Object setClause,
- Object whereClause) {
- Tree result = new CommonTree();
- EntityNameTree entityNameTree = (EntityNameTree) entityName;
- for (int i = 0; i < entityNameTree.getEntityCount(); i++) {
- Tree updateRoot = new CommonTree((CommonTree) updateKey);
-
- updateRoot.addChild(new EntityNameTree(entityNameTree,
- entityNameTree.getEntityName(i)));
-
- if (aliasClause != null) {
- updateRoot.addChild((Tree) aliasClause);
- }
- updateRoot.addChild((Tree) setClause);
-
- if (whereClause != null) {
- updateRoot.addChild((Tree) whereClause);
- }
-
- result.addChild(updateRoot);
- }
- return result;
- }
-
- private Tree generateDeleteStatementTree(Object deleteKey,
- Object entityName, Object aliasClause, Object whereClause) {
- Tree result = new CommonTree();
- EntityNameTree entityNameTree = (EntityNameTree) entityName;
- for (int i = 0; i < entityNameTree.getEntityCount(); i++) {
- Tree deleteRoot = new CommonTree((CommonTree) deleteKey);
-
- deleteRoot.addChild(new EntityNameTree(entityNameTree,
- entityNameTree.getEntityName(i)));
-
- if (aliasClause != null) {
- deleteRoot.addChild((Tree) aliasClause);
- }
-
- if (whereClause != null) {
- deleteRoot.addChild((Tree) whereClause);
- }
-
- result.addChild(deleteRoot);
- }
- return result;
- }
-
- private Tree generateSelecFromTree(Object selectClause, Object fromClause, List aliasList){
- Tree result = new CommonTree(new CommonToken(SELECT_FROM, "SELECT_FROM"));
- Tree selectTree = null;
- result.addChild((Tree) fromClause);
- if (selectClause == null && aliasList != null && aliasList.size() > 0) {
- selectTree = new CommonTree(new CommonToken(SELECT, "SELECT"));
- Tree selectList = new CommonTree(new CommonToken(SELECT_LIST, "SELECT_LIST"));
- for (Iterator iterator = aliasList.iterator(); iterator
- .hasNext();) {
- String aliasName = (String) iterator.next();
- Tree selectElement = new CommonTree(new CommonToken(SELECT_ITEM, "SELECT_ITEM"));
- Tree aliasElement = new CommonTree(new CommonToken(ALIAS_REF, aliasName));
- selectElement.addChild(aliasElement);
- selectList.addChild(selectElement);
- }
- selectTree.addChild(selectList);
- } else {
- selectTree = (Tree) selectClause;
- }
- result.addChild(selectTree);
- return result;
- }
-}
-
-filterStatement[String collectionRole]
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
-@after { enableParameterUsage.pop(); }
- : selectClause? from_key? whereClause? ( groupByClause havingClause?)? orderByClause?
- -> ^(QUERY ^(QUERY_SPEC["filter-query-spec"] FILTER[$collectionRole]
- selectClause? from_key? whereClause? ( groupByClause havingClause?)? orderByClause?))
- //TODO throw an exception here when using from
- ;
-
-statement
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
-@after { enableParameterUsage.pop(); }
- : updateStatement
- | deleteStatement
- | insertStatement
- | selectStatement
- ;
-
-updateStatement
-scope{
- boolean generateVersionedField;
-} : udpate_key
- (versioned_key {$updateStatement::generateVersionedField = true;})?
- from_key? entityName aliasClause[true] setClause whereClause?
- -> { generateUpdateStatementTree($udpate_key.tree, $entityName.tree, $aliasClause.tree, $setClause.tree, $whereClause.tree ) }
- ;
-
-//TODO: check what is necessary to generate at versioned field
-setClause
- : set_key assignment (COMMA assignment)*
- -> {$updateStatement::generateVersionedField}? ^(set_key assignment+ ^(EQUALS VERSIONED_VALUE STRING_LITERAL))
- -> ^(set_key assignment+)
- ;
-
-assignment
- : assignmentField EQUALS^ concatenation
- ;
-
-assignmentField
- : dotIdentifierPath -> ^(PROPERTY_REFERENCE dotIdentifierPath)
- ;
-
-deleteStatement
- : delete_key from_key? entityName aliasClause[true] whereClause?
- -> { generateDeleteStatementTree($delete_key.tree, $entityName.tree, $aliasClause.tree, $whereClause.tree ) }
- ;
-
-insertStatement
- : insert_key^
- intoClause selectStatement
- ;
-
-//TODO: Generate an exception when try to use a polimorfic entity at INTO clause
-intoClause
- : into_key entityName insertabilitySpecification
- -> ^(into_key entityName ALIAS_NAME[context.buildUniqueImplicitAlias()] insertabilitySpecification)
- ;
-
-insertabilitySpecification
- : LEFT_PAREN insertablePropertySpecification ( COMMA insertablePropertySpecification )* RIGHT_PAREN
- -> ^(INSERTABILITY_SPEC insertablePropertySpecification+ )
- ;
-
-insertablePropertySpecification
- : dotIdentifierPath -> ^(PROPERTY_REFERENCE dotIdentifierPath)
- ;
-
-selectStatement
- : queryExpression orderByClause?
- -> ^(QUERY queryExpression orderByClause?)
- ;
-
-//Think about the exception generation where Polimorfic queris are used inside a Mix of results (union, intersect and except)
-queryExpression
- : querySpec ( ( union_key^ | intersect_key^ | except_key^ ) all_key? querySpec )*
- ;
-
-querySpec
- : selectFrom whereClause? ( groupByClause havingClause? )?
- -> ^(QUERY_SPEC selectFrom whereClause? groupByClause? havingClause?)
- ;
-
-groupByClause
- : group_by_key^ groupingSpecification
- ;
-
-havingClause
- : having_key^ logicalExpression
- ;
-
-groupingSpecification
- : groupingValue ( COMMA! groupingValue )*
- ;
-
-groupingValue
- : concatenation collationSpecification?
- -> ^(GROUPING_VALUE concatenation collationSpecification?)
- ;
-
-whereClause
- : where_key^ logicalExpression
- ;
-
-selectFrom
- : sc=selectClause? fc=fromClause
- -> { generateSelecFromTree($sc.tree, $fc.tree, $fc.aliasList)}
- ;
-
-subQuery
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
-@after { enableParameterUsage.pop(); }
- : queryExpression
- -> ^(SUB_QUERY ^(QUERY queryExpression))
- ;
-
-fromClause returns [List aliasList]
-scope{
- List aliases;
-}
-@init { $fromClause::aliases = new ArrayList(); }
-@after { $aliasList = $fromClause::aliases; }
- : from_key^
- persisterSpaces
- ;
-
-persisterSpaces
- : ps+=persisterSpace ( COMMA ps+=persisterSpace )*
- -> {generatePersisterSpacesTree($ps)}
- ;
-
-persisterSpace
- : persisterSpaceRoot ( qualifiedJoin | crossJoin )*
- ;
-
-crossJoin
- : cross_key join_key mainEntityPersisterReference
- -> ^(PERSISTER_JOIN[$join_key.start,"persister-join"] cross_key mainEntityPersisterReference)
- ;
-
-qualifiedJoin
-@init { boolean isEntityReference = false; boolean hasFetch = false; List entityNames = null; }
-@after { if (!hasFetch) $fromClause::aliases.add(((Tree)$ac.tree).getText()); }
- : nonCrossJoinType join_key (fetch_key {hasFetch = true;})? path ac=aliasClause[true]
- ( on_key
- { isEntityReference = true;
- entityNames = extractEntityNames($path.text); }
- logicalExpression
- | propertyFetch? withClause?
- )
- -> {isEntityReference}? ^(PERSISTER_JOIN[$join_key.start,"persister-join"] nonCrossJoinType ^(ENTITY_PERSISTER_REF ENTITY_NAME<EntityNameTree>[$path.start, $path.text, entityNames] aliasClause?) ^(on_key logicalExpression))
- -> ^(PROPERTY_JOIN[$join_key.start, "property-join"] nonCrossJoinType fetch_key? aliasClause? propertyFetch? ^(PROPERTY_REFERENCE path) withClause?)
- ;
-
-withClause
- : with_key^ logicalExpression
- ;
-
-nonCrossJoinType
- : inner_key
- | outerJoinType outer_key?
- | -> INNER
- ;
-
-outerJoinType
- : left_key
- | right_key
- | full_key
- ;
-
-persisterSpaceRoot
-options{
-backtrack=true;
-} : mainEntityPersisterReference
- | jpaCollectionReference
- | hibernateLegacySyntax
- ;
-
-mainEntityPersisterReference
-@after { $fromClause::aliases.add(((Tree)$ac.tree).getText()); }
- : entityName ac=aliasClause[true] propertyFetch?
- -> ^(ENTITY_PERSISTER_REF entityName aliasClause? propertyFetch?)
- ;
-
-propertyFetch
- : fetch_key all_key properties_key
- -> PROP_FETCH[$fetch_key.start, "property-fetch"]
- ;
-
-hibernateLegacySyntax returns [boolean isPropertyJoin]
-@init {$isPropertyJoin = false;}
-@after { $fromClause::aliases.add(((Tree)$ad.tree).getText()); }
- : ad=aliasDeclaration in_key
- ( class_key entityName -> ^(ENTITY_PERSISTER_REF entityName aliasDeclaration)
- | collectionExpression {$isPropertyJoin = true;} -> ^(PROPERTY_JOIN INNER[$in_key.start, "inner legacy"] aliasDeclaration collectionExpression)
- )
- ;
-
-jpaCollectionReference
-@after { $fromClause::aliases.add(((Tree)$ac.tree).getText()); }
- : in_key LEFT_PAREN propertyReference RIGHT_PAREN ac=aliasClause[true]
- -> ^(PROPERTY_JOIN INNER[$in_key.start, "inner"] aliasClause? propertyReference)
- ;
-
-selectClause
- : select_key^ distinct_key? rootSelectExpression
- ;
-
-rootSelectExpression
- : rootDynamicInstantiation
- | jpaSelectObjectSyntax
- | explicitSelectList
- ;
-
-explicitSelectList
- : explicitSelectItem ( COMMA explicitSelectItem )*
- -> ^(SELECT_LIST explicitSelectItem+)
- ;
-
-explicitSelectItem
- : selectExpression
- ;
-
-selectExpression
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.FALSE); }
-@after { enableParameterUsage.pop(); }
-//PARAMETERS CAN'T BE USED -> This verification should be scoped
- : expression aliasClause[false]
- -> ^(SELECT_ITEM expression aliasClause?)
- ;
-
-aliasClause[boolean generateAlias]
-options{
- k=2;
-} : -> {$generateAlias}? ALIAS_NAME[context.buildUniqueImplicitAlias()]
- ->
- | aliasDeclaration
- | as_key! aliasDeclaration
- ;
-
-aliasDeclaration
- : IDENTIFIER -> ALIAS_NAME[$IDENTIFIER]
- ;
-
-aliasReference
- : IDENTIFIER -> ALIAS_REF[$IDENTIFIER]
- ;
-
-rootDynamicInstantiation
- : new_key dynamicInstantiationTarget LEFT_PAREN dynamicInstantiationArgs RIGHT_PAREN
- -> ^(SELECT_ITEM ^(DYNAMIC_INSTANTIATION[$dynamicInstantiationTarget.start, $dynamicInstantiationTarget.text] dynamicInstantiationArgs))
- ;
-
-dynamicInstantiationTarget
- : dotIdentifierPath
- ;
-
-dynamicInstantiationArgs
- : dynamicInstantiationArg ( COMMA! dynamicInstantiationArg )*
- ;
-
-dynamicInstantiationArg
- : selectExpression -> ^(DYNAMIC_INSTANTIATION_ARG selectExpression)
- | rootDynamicInstantiation -> ^(DYNAMIC_INSTANTIATION_ARG rootDynamicInstantiation)
- ;
-
-jpaSelectObjectSyntax
- : object_key LEFT_PAREN aliasReference RIGHT_PAREN
- -> ^(SELECT_ITEM aliasReference)
- ;
-
-orderByClause
- : order_by_key^ sortSpecification ( COMMA! sortSpecification )*
- ;
-
-sortSpecification
-@init{boolean generateOmmitedElement = true;}
- : sortKey collationSpecification? (orderingSpecification {generateOmmitedElement = false;})?
- -> {generateOmmitedElement}? ^(SORT_SPEC sortKey collationSpecification? ASC)
- -> ^(SORT_SPEC sortKey collationSpecification? orderingSpecification?)
- ;
-
-sortKey
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.FALSE); }
-@after { enableParameterUsage.pop(); }
-//PARAMETERS CAN'T BE USED -> This verification should be scoped
- : concatenation
- ;
-
-collationSpecification
- : collate_key collateName
- -> COLLATE[$collateName.start, $collateName.text]
- ;
-
-collateName
- : dotIdentifierPath
- ;
-
-orderingSpecification
- : ascending_key
- | descending_key
- ;
-
-logicalExpression
- : expression
- ;
-
-expression
- : logicalOrExpression
- ;
-
-logicalOrExpression
- : logicalAndExpression ( or_key^ logicalAndExpression )*
- ;
-
-logicalAndExpression
- : negatedExpression ( and_key^ negatedExpression )*
- ;
-
-negatedExpression
- : not_key^ negatedExpression
- | equalityExpression
- ;
-
-equalityExpression
-@init{ boolean isNull = false; boolean isNegated = false;}
- : (relationalExpression -> relationalExpression)
- ( is_key (not_key {isNegated = true;})? (NULL {isNull = true;}|empty_key)
- -> {isNull && isNegated}? ^(IS_NOT_NULL[$not_key.start, "is not null"] $equalityExpression)
- -> {isNull && !isNegated}? ^(IS_NULL[$NULL, "is null"] $equalityExpression)
- -> {!isNull && isNegated}? ^(IS_NOT_EMPTY $equalityExpression)
- -> ^(IS_EMPTY $equalityExpression)
- | ( op=EQUALS | op=NOT_EQUAL ) relationalExpression
- -> ^($op $equalityExpression relationalExpression)
- )*
- ;
-
-relationalExpression
-@init {boolean isNegated = false;}
- : (concatenation -> concatenation)
- (
- ( ( op=LESS | op=GREATER | op=LESS_EQUAL | op=GREATER_EQUAL ) additiveExpression
- -> ^($op $relationalExpression additiveExpression)
- )+
- | (not_key {isNegated = true;} )?
- ( in_key inList
- -> {isNegated}? ^(NOT_IN[$not_key.start, "not in"] $relationalExpression inList)
- -> ^(in_key $relationalExpression inList)
- | between_key betweenList
- -> {isNegated}? ^(NOT_BETWEEN[$not_key.start, "not between"] $relationalExpression betweenList)
- -> ^(between_key $relationalExpression betweenList)
- | like_key concatenation likeEscape?
- -> {isNegated}? ^(NOT_LIKE[$not_key.start, "not like"] $relationalExpression concatenation likeEscape?)
- -> ^(like_key $relationalExpression concatenation likeEscape?)
- | member_of_key path
- -> {isNegated}? ^(NOT_MEMBER_OF[$not_key.start, "not member of"] $relationalExpression ^(PATH path))
- -> ^(member_of_key $relationalExpression ^(PATH path))
- )
- )?
- ;
-
-likeEscape
- : escape_key^ concatenation
- ;
-
-inList
- : collectionExpression
- -> ^(IN_LIST collectionExpression)
- | LEFT_PAREN ( {((validateIdentifierKey("select")|validateIdentifierKey("from")))}?=> subQuery | concatenation (COMMA concatenation)* ) RIGHT_PAREN
- -> ^(IN_LIST concatenation* subQuery?)
- ;
-
-betweenList
- : concatenation and_key concatenation
- -> ^(BETWEEN_LIST concatenation+)
- ;
-
-concatenation
- : additiveExpression (DOUBLE_PIPE^ {enableParameterUsage.push(Boolean.TRUE);} additiveExpression { enableParameterUsage.pop(); })*
- ;
-
-additiveExpression
- : multiplyExpression ( ( PLUS^ | MINUS^ ) {enableParameterUsage.push(Boolean.TRUE);} multiplyExpression { enableParameterUsage.pop(); })*
- ;
-
-multiplyExpression
- : unaryExpression ( ( ASTERISK^ | SOLIDUS^ ) {enableParameterUsage.push(Boolean.TRUE);} unaryExpression { enableParameterUsage.pop(); })*
- ;
-
-unaryExpression
- : MINUS unaryExpression -> ^(UNARY_MINUS[$MINUS] unaryExpression)
- | PLUS unaryExpression -> ^(UNARY_PLUS[$PLUS] unaryExpression)
- | caseExpression
- | quantifiedExpression
- | standardFunction
- | setFunction
- | collectionFunction
- | collectionExpression
- | atom
- ;
-
-caseExpression
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
-@after { enableParameterUsage.pop(); }
- : caseAbbreviation
- | caseSpecification
- ;
-
-caseAbbreviation
- : nullif_key^ LEFT_PAREN! concatenation COMMA! concatenation RIGHT_PAREN!
- | coalesce_key^ LEFT_PAREN! concatenation (COMMA! concatenation)* RIGHT_PAREN!
- ;
-
-caseSpecification
-options{
-backtrack=true;
-} : simpleCase
- | searchedCase
- ;
-
-simpleCase
- : case_key concatenation simpleCaseWhenClause+ elseClause? end_key
- -> ^(SIMPLE_CASE[$case_key.start, $case_key.text] concatenation simpleCaseWhenClause+ elseClause?)
- ;
-
-simpleCaseWhenClause
- : when_key^ concatenation then_key! concatenation
- ;
-
-elseClause
- : else_key^ concatenation
- ;
-
-searchedCase
- : case_key searchedWhenClause+ elseClause? end_key
- -> ^(SEARCHED_CASE[$case_key.start, $case_key.text] searchedWhenClause+ elseClause?)
- ;
-
-searchedWhenClause
- : when_key^ logicalExpression then_key! concatenation
- ;
-
-quantifiedExpression
- : ( some_key^ | exists_key^ | all_key^ | any_key^ )
- ( collectionExpression
- | aliasReference
- | LEFT_PAREN! subQuery RIGHT_PAREN!
- )
- ;
-
-standardFunction
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
-@after { enableParameterUsage.pop(); }
- : castFunction
- | concatFunction
- | substringFunction
- | trimFunction
- | upperFunction
- | lowerFunction
- | lengthFunction
- | locateFunction
- | absFunction
- | sqrtFunction
- | modFunction
- | sizeFunction
- | indexFunction
- | currentDateFunction
- | currentTimeFunction
- | currentTimestampFunction
- | extractFunction
- | positionFunction
- | charLengthFunction
- | octetLengthFunction
- | bitLengthFunction
- ;
-
-castFunction
- : cast_key^ LEFT_PAREN! concatenation as_key! dataType RIGHT_PAREN!
- ;
-
-concatFunction
- : concat_key^ LEFT_PAREN! concatenation ( COMMA! concatenation )+ RIGHT_PAREN!
- ;
-
-substringFunction
- : substring_key^ LEFT_PAREN! concatenation COMMA! concatenation ( COMMA! concatenation)? RIGHT_PAREN!
- ;
-
-trimFunction
- : trim_key LEFT_PAREN trimOperands RIGHT_PAREN
- -> ^(trim_key trimOperands)
- ;
-
-trimOperands
-options{
-k=2;
-}
-@init {boolean hasSecondExpression = false;}
- : trimSpecification from_key concatenation -> ^(trimSpecification STRING_LITERAL[" "] concatenation)
- | trimSpecification concatenation from_key concatenation -> ^(trimSpecification concatenation+)
- | from_key concatenation -> ^(BOTH STRING_LITERAL[" "] concatenation)
- | cn=concatenation ( from_key concatenation {hasSecondExpression = true;} )?
- -> {hasSecondExpression}? ^(BOTH concatenation+)
- -> ^(BOTH STRING_LITERAL[" "] $cn)
- ;
-
-trimSpecification
- : leading_key
- | trailing_key
- | both_key
- ;
-
-upperFunction
- : upper_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
- ;
-
-lowerFunction
- : lower_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
- ;
-
-lengthFunction
- : length_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
- ;
-
-locateFunction
- : locate_key^ LEFT_PAREN! concatenation COMMA! concatenation ( COMMA! concatenation )? RIGHT_PAREN!
- ;
-
-absFunction
- : abs_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
- ;
-
-sqrtFunction
- : sqrt_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
- ;
-
-modFunction
- : mod_key^ LEFT_PAREN! concatenation COMMA! concatenation RIGHT_PAREN!
- ;
-
-sizeFunction
- : size_key^ LEFT_PAREN! propertyReference RIGHT_PAREN!
- ;
-
-indexFunction
- : index_key^ LEFT_PAREN! aliasReference RIGHT_PAREN!
- ;
-
-currentDateFunction
- : current_date_key ( LEFT_PAREN! RIGHT_PAREN! )?
- ;
-
-currentTimeFunction
- : current_time_key ( LEFT_PAREN! RIGHT_PAREN! )?
- ;
-
-currentTimestampFunction
- : current_timestamp_key ( LEFT_PAREN! RIGHT_PAREN! )?
- ;
-
-extractFunction
- : extract_key^ LEFT_PAREN! extractField from_key! concatenation RIGHT_PAREN!
- ;
-
-extractField
- : datetimeField
- | timeZoneField
- ;
-
-datetimeField
- : nonSecondDatetimeField
- | second_key
- ;
-
-nonSecondDatetimeField
- : year_key
- | month_key
- | day_key
- | hour_key
- | minute_key
- ;
-
-timeZoneField
- : timezone_hour_key
- | timezone_minute_key
- ;
-
-positionFunction
- : position_key^ LEFT_PAREN! concatenation in_key! concatenation RIGHT_PAREN!
- ;
-
-charLengthFunction
- : character_length_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
- ;
-
-octetLengthFunction
- : octet_length_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
- ;
-
-bitLengthFunction
- : bit_length_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
- ;
-
-setFunction
-@init { boolean generateOmmitedElement = true; if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
-@after { enableParameterUsage.pop(); }
- : ( sum_key^ | avg_key^ | max_key^ | min_key^ ) LEFT_PAREN! additiveExpression RIGHT_PAREN!
- | count_key LEFT_PAREN ( ASTERISK {generateOmmitedElement = false;} | ( ( (distinct_key | all_key) {generateOmmitedElement = false;} )? countFunctionArguments ) ) RIGHT_PAREN
- -> {generateOmmitedElement}? ^(count_key ASTERISK? ALL countFunctionArguments?)
- -> ^(count_key ASTERISK? distinct_key? all_key? countFunctionArguments?)
- ;
-
-countFunctionArguments
-@init { int type = -1;}
- : propertyReference
- | collectionExpression
- | numeric_literal
- ;
-
-collectionFunction
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
-@after { enableParameterUsage.pop(); }
- : ( maxelement_key^ | maxindex_key^ | minelement_key^ | minindex_key^ ) LEFT_PAREN! propertyReference RIGHT_PAREN!
- ;
-
-collectionExpression
- : (elements_key^|indices_key^) LEFT_PAREN! propertyReference RIGHT_PAREN!
- ;
-
-atom
-@init { int type = -1;}
- : identPrimary
- //TODO if ends with:
- // .class -> class type
- // if contains "()" it is a function call
- // if it is constantReference (using context)
- // otherwise it will be a generic element to be resolved on the next phase (1st tree walker)
- -> {type == 0}? ^(DOT_CLASS identPrimary)
- -> {type == 3}? ^(GENERAL_FUNCTION_CALL identPrimary)
- -> {type == 4}? ^(JAVA_CONSTANT identPrimary) //-> here will have 2 strutctures element and the constant
- -> ^(PATH identPrimary)
- | constant
- | parameterSpecification { if (enableParameterUsage.peek().equals(Boolean.FALSE)) throw new RecognitionException( ); }
- //validate using Scopes if it is enabled or not to use parameterSpecification.. if not generate an exception
- | LEFT_PAREN! ({((validateIdentifierKey("select")|validateIdentifierKey("from")))}?=> subQuery|expressionOrVector) RIGHT_PAREN!
- ;
-
-parameterSpecification
-@init {boolean isJpaParam = false;}
- : COLON IDENTIFIER -> NAMED_PARAM[$IDENTIFIER]
- | PARAM (INTEGER_LITERAL {isJpaParam = true;})?
- -> {isJpaParam}? JPA_PARAM[$INTEGER_LITERAL]
- -> PARAM
- ;
-
-expressionOrVector
-@init {boolean isVectorExp = false;}
- : expression (vectorExpr {isVectorExp = true;})?
- -> {isVectorExp}? ^(VECTOR_EXPR expression vectorExpr)
- -> expression
- ;
-
-vectorExpr
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
-@after { enableParameterUsage.pop(); }
- : COMMA! expression (COMMA! expression)*
- ;
-
-identPrimary
- : IDENTIFIER
- ( DOT^ IDENTIFIER
- | LEFT_SQUARE^ expression RIGHT_SQUARE!
- | LEFT_SQUARE^ RIGHT_SQUARE!
- | LEFT_PAREN^ exprList RIGHT_PAREN!
- )*
- ;
-
-exprList
-@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
-@after { enableParameterUsage.pop(); }
- : expression? (COMMA! expression)*
- ;
-
-constant
- : literal
- | NULL
- | TRUE
- | FALSE
- ;
-
-literal
- : numeric_literal
- | HEX_LITERAL
- | OCTAL_LITERAL
- | CHARACTER_LITERAL
- | STRING_LITERAL
- ;
-
-numeric_literal
- : INTEGER_LITERAL
- | DECIMAL_LITERAL
- | FLOATING_POINT_LITERAL
- ;
-
-entityName
-@init { List entityNames = null; }
- : dotIdentifierPath
- { entityNames = extractEntityNames($dotIdentifierPath.text); }
- //here the polimorfic entities should be resolved... to:
- // 1. to place inside the ENTITY_NAME Token all its possible values, otherwise it would be much difficult to return to the place that should explit the sentence
- // 2. enable exception geration when not supported (union, insert)
- -> ENTITY_NAME<EntityNameTree>[$dotIdentifierPath.start, $dotIdentifierPath.text, entityNames]
- ;
-
-propertyReference
- : path
- -> ^(PROPERTY_REFERENCE path)
- ;
-
-dataType
- : IDENTIFIER
- ;
-
-dotIdentifierPath
- : IDENTIFIER
- ( DOT^ IDENTIFIER )*
- ;
-
-path
- : IDENTIFIER
- ( DOT^ IDENTIFIER
- | LEFT_SQUARE^ expression RIGHT_SQUARE!
- | LEFT_SQUARE^ RIGHT_SQUARE!
- )*
- ;
-
-class_key
- : {(validateIdentifierKey("class"))}?=> id=IDENTIFIER
- -> CLASS[$id]
- ;
-
-new_key
- : {(validateIdentifierKey("new"))}?=> id=IDENTIFIER
- -> NEW[$id]
- ;
-
-else_key
- : {(validateIdentifierKey("else"))}?=> id=IDENTIFIER
- -> ELSE[$id]
- ;
-
-object_key
- : {(validateIdentifierKey("object"))}?=> id=IDENTIFIER
- ;
-
-case_key
- : {(validateIdentifierKey("case"))}?=> IDENTIFIER
- ;
-
-current_date_key
- : {(validateIdentifierKey("current_date"))}?=> id=IDENTIFIER
- -> CURRENT_DATE[$id]
- ;
-
-current_time_key
- : {(validateIdentifierKey("current_time"))}?=> id=IDENTIFIER
- -> CURRENT_TIME[$id]
- ;
-
-current_timestamp_key
- : {(validateIdentifierKey("current_timestamp"))}?=> id=IDENTIFIER
- -> CURRENT_TIMESTAMP[$id]
- ;
-
-timezone_hour_key
- : {(validateIdentifierKey("timezone_hour"))}?=> id=IDENTIFIER
- -> TIMEZONE_HOUR[$id]
- ;
-
-timezone_minute_key
- : {(validateIdentifierKey("timezone_minute"))}?=> id=IDENTIFIER
- -> TIMEZONE_MINUTE[$id]
- ;
-
-character_length_key
- : {(validateIdentifierKey("character_length") || validateIdentifierKey("char_length"))}?=> id=IDENTIFIER
- -> CHARACTER_LENGTH[$id]
- ;
-
-octet_length_key
- : {(validateIdentifierKey("octet_length"))}?=> id=IDENTIFIER
- -> OCTET_LENGTH[$id]
- ;
-
-bit_length_key
- : {(validateIdentifierKey("bit_length"))}?=> id=IDENTIFIER
- -> BIT_LENGTH[$id]
- ;
-
-extract_key
- : {(validateIdentifierKey("extract"))}?=> id=IDENTIFIER
- -> EXTRACT[$id]
- ;
-
-second_key
- : {(validateIdentifierKey("second"))}?=> id=IDENTIFIER
- -> SECOND[$id]
- ;
-
-year_key
- : {(validateIdentifierKey("year"))}?=> id=IDENTIFIER
- -> YEAR[$id]
- ;
-
-month_key
- : {(validateIdentifierKey("month"))}?=> id=IDENTIFIER
- -> MONTH[$id]
- ;
-
-day_key
- : {(validateIdentifierKey("day"))}?=> id=IDENTIFIER
- -> DAY[$id]
- ;
-
-hour_key
- : {(validateIdentifierKey("hour"))}?=> id=IDENTIFIER
- -> HOUR[$id]
- ;
-
-minute_key
- : {(validateIdentifierKey("minute"))}?=> id=IDENTIFIER
- -> MINUTE[$id]
- ;
-
-position_key
- : {(validateIdentifierKey("position"))}?=> id=IDENTIFIER
- -> POSITION[$id]
- ;
-
-sum_key
- : {(validateIdentifierKey("sum"))}?=> id=IDENTIFIER
- -> SUM[$id]
- ;
-
-avg_key
- : {(validateIdentifierKey("avg"))}?=> id=IDENTIFIER
- -> AVG[$id]
- ;
-
-max_key
- : {(validateIdentifierKey("max"))}?=> id=IDENTIFIER
- -> MAX[$id]
- ;
-
-min_key
- : {(validateIdentifierKey("min"))}?=> id=IDENTIFIER
- -> MIN[$id]
- ;
-
-count_key
- : {(validateIdentifierKey("count"))}?=> id=IDENTIFIER
- -> COUNT[$id]
- ;
-
-maxelement_key
- : {(validateIdentifierKey("maxelement"))}?=> id=IDENTIFIER
- -> MAXELEMENT[$id]
- ;
-
-maxindex_key
- : {(validateIdentifierKey("maxindex"))}?=> id=IDENTIFIER
- -> MAXINDEX[$id]
- ;
-
-minelement_key
- : {(validateIdentifierKey("minelement"))}?=> id=IDENTIFIER
- -> MINELEMENT[$id]
- ;
-
-minindex_key
- : {(validateIdentifierKey("minindex"))}?=> id=IDENTIFIER
- -> MININDEX[$id]
- ;
-
-locate_key
- : {(validateIdentifierKey("locate"))}?=> id=IDENTIFIER
- -> LOCATE[$id]
- ;
-
-abs_key
- : {(validateIdentifierKey("abs"))}?=> id=IDENTIFIER
- -> ABS[$id]
- ;
-
-sqrt_key
- : {(validateIdentifierKey("sqrt"))}?=> id=IDENTIFIER
- -> SQRT[$id]
- ;
-
-mod_key
- : {(validateIdentifierKey("mod"))}?=> id=IDENTIFIER
- -> MOD[$id]
- ;
-
-size_key
- : {(validateIdentifierKey("size"))}?=> id=IDENTIFIER
- -> SIZE[$id]
- ;
-
-index_key
- : {(validateIdentifierKey("index"))}?=> id=IDENTIFIER
- -> INDEX[$id]
- ;
-
-leading_key
- : {(validateIdentifierKey("leading"))}?=> id=IDENTIFIER
- -> LEADING[$id]
- ;
-
-trailing_key
- : {(validateIdentifierKey("trailing"))}?=> id=IDENTIFIER
- -> TRAILING[$id]
- ;
-
-upper_key
- : {(validateIdentifierKey("upper"))}?=> id=IDENTIFIER
- -> UPPER[$id]
- ;
-
-lower_key
- : {(validateIdentifierKey("lower"))}?=> id=IDENTIFIER
- -> LOWER[$id]
- ;
-
-length_key
- : {(validateIdentifierKey("length"))}?=> id=IDENTIFIER
- -> LENGTH[$id]
- ;
-
-both_key
- : {(validateIdentifierKey("both"))}?=> id=IDENTIFIER
- -> BOTH[$id]
- ;
-
-trim_key
- : {(validateIdentifierKey("trim"))}?=> id=IDENTIFIER
- -> TRIM[$id]
- ;
-
-substring_key
- : {(validateIdentifierKey("substring"))}?=> id=IDENTIFIER
- -> SUBSTRING[$id]
- ;
-
-concat_key
- : {(validateIdentifierKey("concat"))}?=> id=IDENTIFIER
- -> CONCAT[$id]
- ;
-
-cast_key
- : {(validateIdentifierKey("cast"))}?=> id=IDENTIFIER
- -> CAST[$id]
- ;
-
-any_key
- : {(validateIdentifierKey("any"))}?=> id=IDENTIFIER
- -> ANY[$id]
- ;
-
-exists_key
- : {(validateIdentifierKey("exists"))}?=> id=IDENTIFIER
- -> EXISTS[$id]
- ;
-
-some_key
- : {(validateIdentifierKey("some"))}?=> id=IDENTIFIER
- -> SOME[$id]
- ;
-
-then_key
- : {(validateIdentifierKey("then"))}?=> id=IDENTIFIER
- -> THEN[$id]
- ;
-
-end_key
- : {(validateIdentifierKey("end"))}?=> id=IDENTIFIER
- -> END[$id]
- ;
-
-
-when_key
- : {(validateIdentifierKey("when"))}?=> id=IDENTIFIER
- -> WHEN[$id]
- ;
-
-nullif_key
- : {(validateIdentifierKey("nullif"))}?=> id=IDENTIFIER
- -> NULLIF[$id]
- ;
-
-coalesce_key
- : {(validateIdentifierKey("coalesce"))}?=> id=IDENTIFIER
- -> COALESCE[$id]
- ;
-
-escape_key
- : {(validateIdentifierKey("escape"))}?=> id=IDENTIFIER
- -> ESCAPE[$id]
- ;
-
-like_key
- : {(validateIdentifierKey("like"))}?=> id=IDENTIFIER
- -> LIKE[$id]
- ;
-
-between_key
- : {(validateIdentifierKey("between"))}?=> id=IDENTIFIER
- -> BETWEEN[$id]
- ;
-
-member_of_key
-@init{
- String text = "";
-} : {(validateIdentifierKey("member") && validateLT(2, "of"))}?=> id=IDENTIFIER IDENTIFIER {text = $text;}
- -> MEMBER_OF[$id]
- ;
-
-empty_key
- : {(validateIdentifierKey("empty"))}?=> id=IDENTIFIER
- ;
-
-is_key : {(validateIdentifierKey("is"))}?=> id=IDENTIFIER
- -> IS[$id]
- ;
-
-or_key : {(validateIdentifierKey("or"))}?=> id=IDENTIFIER
- -> OR[$id]
- ;
-
-and_key : {(validateIdentifierKey("and"))}?=> id=IDENTIFIER
- -> AND[$id]
- ;
-
-not_key : {(validateIdentifierKey("not"))}?=> id=IDENTIFIER
- -> NOT[$id]
- ;
-
-set_key
- : {(validateIdentifierKey("set"))}?=> id=IDENTIFIER
- -> SET[$id]
- ;
-
-versioned_key
- : {(validateIdentifierKey("versioned"))}?=> id=IDENTIFIER
- -> VERSIONED[$id]
- ;
-
-udpate_key
- : {(validateIdentifierKey("update"))}?=> id=IDENTIFIER
- -> UPDATE[$id]
- ;
-
-delete_key
- : {(validateIdentifierKey("delete"))}?=> id=IDENTIFIER
- -> DELETE[$id]
- ;
-
-insert_key
- : {(validateIdentifierKey("insert"))}?=> id=IDENTIFIER
- -> INSERT[$id]
- ;
-
-into_key
- : {(validateIdentifierKey("into"))}?=> id=IDENTIFIER
- -> INTO[$id]
- ;
-
-having_key
- : {(validateIdentifierKey("having"))}?=> id=IDENTIFIER
- -> HAVING[$id]
- ;
-
-with_key
- : {(validateIdentifierKey("with"))}?=> id=IDENTIFIER
- -> WITH[$id]
- ;
-
-on_key
- : {(validateIdentifierKey("on"))}?=> id=IDENTIFIER
- -> ON[$id]
- ;
-
-indices_key
- : {(validateIdentifierKey("indices"))}?=> id=IDENTIFIER
- -> INDICES[$id]
- ;
-
-cross_key
- : {(validateIdentifierKey("cross"))}?=> id=IDENTIFIER
- -> CROSS[$id]
- ;
-
-join_key
- : {(validateIdentifierKey("join"))}?=> id=IDENTIFIER
- -> JOIN[$id]
- ;
-
-inner_key
- : {(validateIdentifierKey("inner"))}?=> id=IDENTIFIER
- -> INNER[$id]
- ;
-
-outer_key
- : {(validateIdentifierKey("outer"))}?=> id=IDENTIFIER
- -> OUTER[$id]
- ;
-
-left_key
- : {(validateIdentifierKey("left"))}?=> id=IDENTIFIER
- -> LEFT[$id]
- ;
-
-right_key
- : {(validateIdentifierKey("right"))}?=> id=IDENTIFIER
- -> RIGHT[$id]
- ;
-
-full_key
- : {(validateIdentifierKey("full"))}?=> id=IDENTIFIER
- -> FULL[$id]
- ;
-
-elements_key
- : {(validateIdentifierKey("elements"))}?=> id=IDENTIFIER
- -> ELEMENTS[$id]
- ;
-
-properties_key
- : {(validateIdentifierKey("properties"))}?=> id=IDENTIFIER
- -> PROPERTIES[$id]
- ;
-
-fetch_key
- : {(validateIdentifierKey("fetch"))}?=> id=IDENTIFIER
- -> FETCH[$id]
- ;
-
-in_key
- : {(validateIdentifierKey("in"))}?=> id=IDENTIFIER
- -> IN[$id]
- ;
-
-as_key
- : {(validateIdentifierKey("as"))}?=> id=IDENTIFIER
- -> AS[$id]
- ;
-
-where_key
- : {(validateIdentifierKey("where"))}?=> id=IDENTIFIER
- -> WHERE[$id]
- ;
-
-select_key
- : {(validateIdentifierKey("select"))}?=> id=IDENTIFIER
- -> SELECT[$id]
- ;
-
-distinct_key
- : {(validateIdentifierKey("distinct"))}?=> id=IDENTIFIER
- -> DISTINCT[$id]
- ;
-
-union_key
- : {(validateIdentifierKey("union"))}?=> id=IDENTIFIER
- -> UNION[$id]
- ;
-
-intersect_key
- : {(validateIdentifierKey("intersect"))}?=> id=IDENTIFIER
- -> INTERSECT[$id]
- ;
-
-except_key
- : {(validateIdentifierKey("except"))}?=> id=IDENTIFIER
- -> EXCEPT[$id]
- ;
-
-all_key
- : {(validateIdentifierKey("all"))}?=> id=IDENTIFIER
- -> ALL[$id]
- ;
-
-ascending_key
- : {(validateIdentifierKey("ascending") || validateIdentifierKey("asc"))}?=> id=IDENTIFIER
- -> ASC[$id]
- ;
-
-descending_key
- : {(validateIdentifierKey("descending") || validateIdentifierKey("desc"))}?=> id=IDENTIFIER
- -> DESC[$id]
- ;
-
-collate_key
- : {(validateIdentifierKey("collate"))}?=> IDENTIFIER
- ;
-
-order_by_key
-@init{
- String text = "";
-} : {(validateIdentifierKey("order") && validateLT(2, "by"))}?=> id=IDENTIFIER IDENTIFIER {text = $text;}
- -> ORDER_BY[$id]
- ;
-
-group_by_key
-@init{
- String text = "";
-} : {(validateIdentifierKey("group") && validateLT(2, "by"))}?=> id=IDENTIFIER IDENTIFIER {text = $text;}
- -> GROUP_BY[$id]
- ;
-
-from_key
- : {(validateIdentifierKey("from"))}?=> id=IDENTIFIER
- -> FROM[$id]
- ;
-
-WS : ( ' '
- | '\t'
- | '\f'
- | EOL
- )+
- { $channel=HIDDEN; }
- ;
-
-fragment
-EOL :
- ( ( '\r\n' )=> '\r\n' // Evil DOS
- | '\r' // Macintosh
- | '\n' // Unix (the right way)
- )
- ;
-
-HEX_LITERAL : '0' ('x'|'X') HEX_DIGIT+ INTEGER_TYPE_SUFFIX? ;
-
-INTEGER_LITERAL : ('0' | '1'..'9' '0'..'9'*) ;
-
-DECIMAL_LITERAL : ('0' | '1'..'9' '0'..'9'*) INTEGER_TYPE_SUFFIX ;
-
-OCTAL_LITERAL : '0' ('0'..'7')+ INTEGER_TYPE_SUFFIX? ;
-
-fragment
-HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
-
-fragment
-INTEGER_TYPE_SUFFIX : ('l'|'L') ;
-
-FLOATING_POINT_LITERAL
- : ('0'..'9')+ '.' ('0'..'9')* EXPONENT? FLOAT_TYPE_SUFFIX?
- | '.' ('0'..'9')+ EXPONENT? FLOAT_TYPE_SUFFIX?
- | ('0'..'9')+ EXPONENT FLOAT_TYPE_SUFFIX?
- | ('0'..'9')+ FLOAT_TYPE_SUFFIX
- ;
-
-fragment
-EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
-
-fragment
-FLOAT_TYPE_SUFFIX : ('f'|'F'|'d'|'D') ;
-
-CHARACTER_LITERAL
- : '\'' ( ESCAPE_SEQUENCE | ~('\''|'\\') ) '\''
- ;
-
-STRING_LITERAL
- : '"' ( ESCAPE_SEQUENCE | ~('\\'|'"') )* '"'
- | ('\'' ( ESCAPE_SEQUENCE | ~('\\'|'\'') )* '\'')+
- | '`' ( ESCAPE_SEQUENCE | ~('\\'|'`') )* '`'
- ;
-
-fragment
-ESCAPE_SEQUENCE
- : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
- | UNICODE_ESCAPE
- | OCTAL_ESCAPE
- ;
-
-fragment
-OCTAL_ESCAPE
- : '\\' ('0'..'3') ('0'..'7') ('0'..'7')
- | '\\' ('0'..'7') ('0'..'7')
- | '\\' ('0'..'7')
- ;
-
-fragment
-UNICODE_ESCAPE
- : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
- ;
-
-TRUE
- : 'true'
- ;
-
-FALSE
- : 'false'
- ;
-
-NULL
- : 'null'
- ;
-
-EQUALS
- : '='
- ;
-
-SEMICOLON
- : ';'
- ;
-
-COLON
- : ':'
- ;
-
-NOT_EQUAL
- : '!='
- | '^='
- | '<>'
- ;
-
-PIPE
- : '|'
- ;
-
-DOUBLE_PIPE
- : '||'
- ;
-
-PARAM : '?'
- ;
-
-GREATER
- : '>'
- ;
-
-GREATER_EQUAL
- : '>='
- ;
-
-LESS
- : '<'
- ;
-
-LESS_EQUAL
- : '<='
- ;
-
-ARROW
- : '->'
- ;
-
-IDENTIFIER
- : ('a'..'z'|'A'..'Z'|'_'|'$'|'\u0080'..'\ufffe')('a'..'z'|'A'..'Z'|'_'|'$'|'0'..'9'|'\u0080'..'\ufffe')*
- ;
-
-LEFT_PAREN
- : '('
- ;
-
-RIGHT_PAREN
- : ')'
- ;
-
-LEFT_SQUARE
- : '['
- ;
-
-RIGHT_SQUARE
- : ']'
- ;
-
-COMMA : ','
- ;
-
-DOT : '.'
- ;
-
-PLUS : '+'
- ;
-
-MINUS : '-'
- ;
-
-ASTERISK
- : '*'
- ;
-
-SOLIDUS : '/'
- ;
-
-PERCENT : '%'
- ;
-
-AMPERSAND
- : '&'
- ;
Added: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLLexer.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLLexer.g (rev 0)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLLexer.g 2009-04-23 17:38:50 UTC (rev 16431)
@@ -0,0 +1,364 @@
+lexer grammar HQLLexer;
+
+tokens {
+//GENERIC SQL TOKENS
+ TABLE;
+ COLUMN;
+ COLUMN_LIST;
+
+//VIRTUAL TOKENS
+ ALIAS_NAME;
+ ALIAS_REF;
+ BETWEEN_LIST;
+ COLLATE;
+ COLLECTION_EXPRESSION;
+ DOT_CLASS;
+ DYNAMIC_INSTANTIATION_ARG;
+ DYNAMIC_INSTANTIATION;
+ ENTITY_NAME;
+ ENTITY_PERSISTER_REF;
+ FILTER;
+ GENERAL_FUNCTION_CALL;
+ GROUPING_VALUE;
+ IN_LIST;
+ INSERTABILITY_SPEC;
+ IS_NOT_EMPTY;
+ IS_NOT_NULL;
+ IS_NULL;
+ JAVA_CONSTANT;
+ JPA_PARAM;
+ NAMED_PARAM;
+ NOT_BETWEEN;
+ NOT_IN;
+ NOT_LIKE;
+ NOT_MEMBER_OF;
+ PATH;
+ PERSISTER_JOIN;
+ PERSISTER_SPACE;
+ PROP_FETCH;
+ PROPERTY_JOIN;
+ PROPERTY_REFERENCE;
+ QUALIFIED_JOIN;
+ QUERY_SPEC;
+ QUERY;
+ SEARCHED_CASE;
+ SELECT_FROM;
+ SELECT_ITEM;
+ SELECT_LIST;
+ SIMPLE_CASE;
+ SORT_SPEC;
+ SUB_QUERY;
+ UNARY_MINUS;
+ UNARY_PLUS;
+ VECTOR_EXPR;
+ VERSIONED_VALUE;
+
+//SOFT KEYWORDS
+ ABS;
+ ALL;
+ AND;
+ ANY;
+ AS;
+ ASC;
+ AVG;
+ BETWEEN;
+ BIT_LENGTH;
+ BOTH;
+ CAST;
+ CHARACTER_LENGTH;
+ CLASS;
+ COALESCE;
+ CONCAT;
+ COUNT;
+ CROSS;
+ CURRENT_DATE;
+ CURRENT_TIME;
+ CURRENT_TIMESTAMP;
+ DAY;
+ DELETE;
+ DESC;
+ DISTINCT;
+ ELEMENTS;
+ ELSE;
+ END;
+ ESCAPE;
+ EXCEPT;
+ EXISTS;
+ EXTRACT;
+ FETCH;
+ FROM;
+ FULL;
+ GROUP_BY;
+ HAVING;
+ HOUR;
+ IN;
+ INDEX;
+ INDICES;
+ INNER;
+ INSERT;
+ INTERSECT;
+ INTO;
+ IS_EMPTY;
+ IS;
+ JOIN;
+ LEADING;
+ LEFT;
+ LENGTH;
+ LIKE;
+ LOCATE;
+ LOWER;
+ MAX;
+ MAXELEMENT;
+ MAXINDEX;
+ MEMBER_OF;
+ MIN;
+ MINELEMENT;
+ MININDEX;
+ MINUTE;
+ MOD;
+ MONTH;
+ NEW;
+ NOT;
+ NULLIF;
+ OCTET_LENGTH;
+ ON;
+ OR;
+ ORDER_BY;
+ OUTER;
+ POSITION;
+ PROPERTIES;
+ RIGHT;
+ SECOND;
+ SELECT;
+ SET;
+ SIZE;
+ SOME;
+ SQRT;
+ SUBSTRING;
+ SUM;
+ THEN;
+ TIMEZONE_HOUR;
+ TIMEZONE_MINUTE;
+ TRAILING;
+ TRIM;
+ UNION;
+ UPDATE;
+ UPPER;
+ VERSIONED;
+ WHEN;
+ WHERE;
+ WITH;
+ YEAR;
+}
+
+@header {
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ * Portions of SQL grammar parsing copyright (C) 2003 by Lubos Vnuk. All rights
+ * reserved. These portions are distributed under license by Red Hat Middleware
+ * LLC and are covered by the above LGPL notice. If you redistribute this material,
+ * with or without modification, you must preserve this copyright notice in its
+ * entirety.
+ */
+package org.hibernate.sql.ast.phase.hql.parse;
+}
+
+WS : ( ' '
+ | '\t'
+ | '\f'
+ | EOL
+ )+
+ { $channel=HIDDEN; }
+ ;
+
+fragment
+EOL :
+ ( ( '\r\n' )=> '\r\n' // Evil DOS
+ | '\r' // Macintosh
+ | '\n' // Unix (the right way)
+ )
+ ;
+
+HEX_LITERAL : '0' ('x'|'X') HEX_DIGIT+ INTEGER_TYPE_SUFFIX? ;
+
+INTEGER_LITERAL : ('0' | '1'..'9' '0'..'9'*) ;
+
+DECIMAL_LITERAL : ('0' | '1'..'9' '0'..'9'*) INTEGER_TYPE_SUFFIX ;
+
+OCTAL_LITERAL : '0' ('0'..'7')+ INTEGER_TYPE_SUFFIX? ;
+
+fragment
+HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
+
+fragment
+INTEGER_TYPE_SUFFIX : ('l'|'L') ;
+
+FLOATING_POINT_LITERAL
+ : ('0'..'9')+ '.' ('0'..'9')* EXPONENT? FLOAT_TYPE_SUFFIX?
+ | '.' ('0'..'9')+ EXPONENT? FLOAT_TYPE_SUFFIX?
+ | ('0'..'9')+ EXPONENT FLOAT_TYPE_SUFFIX?
+ | ('0'..'9')+ FLOAT_TYPE_SUFFIX
+ ;
+
+fragment
+EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
+
+fragment
+FLOAT_TYPE_SUFFIX : ('f'|'F'|'d'|'D') ;
+
+CHARACTER_LITERAL
+ : '\'' ( ESCAPE_SEQUENCE | ~('\''|'\\') ) '\''
+ ;
+
+STRING_LITERAL
+ : '"' ( ESCAPE_SEQUENCE | ~('\\'|'"') )* '"'
+ | ('\'' ( ESCAPE_SEQUENCE | ~('\\'|'\'') )* '\'')+
+ | '`' ( ESCAPE_SEQUENCE | ~('\\'|'`') )* '`'
+ ;
+
+fragment
+ESCAPE_SEQUENCE
+ : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+ | UNICODE_ESCAPE
+ | OCTAL_ESCAPE
+ ;
+
+fragment
+OCTAL_ESCAPE
+ : '\\' ('0'..'3') ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7')
+ ;
+
+fragment
+UNICODE_ESCAPE
+ : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ ;
+
+TRUE
+ : 'true'
+ ;
+
+FALSE
+ : 'false'
+ ;
+
+NULL
+ : 'null'
+ ;
+
+EQUALS
+ : '='
+ ;
+
+SEMICOLON
+ : ';'
+ ;
+
+COLON
+ : ':'
+ ;
+
+NOT_EQUAL
+ : '!='
+ | '^='
+ | '<>'
+ ;
+
+PIPE
+ : '|'
+ ;
+
+DOUBLE_PIPE
+ : '||'
+ ;
+
+PARAM : '?'
+ ;
+
+GREATER
+ : '>'
+ ;
+
+GREATER_EQUAL
+ : '>='
+ ;
+
+LESS
+ : '<'
+ ;
+
+LESS_EQUAL
+ : '<='
+ ;
+
+ARROW
+ : '->'
+ ;
+
+IDENTIFIER
+ : ('a'..'z'|'A'..'Z'|'_'|'$'|'\u0080'..'\ufffe')('a'..'z'|'A'..'Z'|'_'|'$'|'0'..'9'|'\u0080'..'\ufffe')*
+ ;
+
+LEFT_PAREN
+ : '('
+ ;
+
+RIGHT_PAREN
+ : ')'
+ ;
+
+LEFT_SQUARE
+ : '['
+ ;
+
+RIGHT_SQUARE
+ : ']'
+ ;
+
+COMMA : ','
+ ;
+
+DOT : '.'
+ ;
+
+PLUS : '+'
+ ;
+
+MINUS : '-'
+ ;
+
+ASTERISK
+ : '*'
+ ;
+
+SOLIDUS : '/'
+ ;
+
+PERCENT : '%'
+ ;
+
+AMPERSAND
+ : '&'
+ ;
\ No newline at end of file
Property changes on: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLLexer.g
___________________________________________________________________
Name: svn:eol-style
+ native
Added: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLParser.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLParser.g (rev 0)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLParser.g 2009-04-23 17:38:50 UTC (rev 16431)
@@ -0,0 +1,1471 @@
+parser grammar HQLParser;
+
+options {
+ tokenVocab=HQLLexer;
+ output=AST;
+}
+
+@parser::header {
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ * Portions of SQL grammar parsing copyright (C) 2003 by Lubos Vnuk. All rights
+ * reserved. These portions are distributed under license by Red Hat Middleware
+ * LLC and are covered by the above LGPL notice. If you redistribute this material,
+ * with or without modification, you must preserve this copyright notice in its
+ * entirety.
+ */
+package org.hibernate.sql.ast.phase.hql.parse;
+
+import java.util.LinkedList;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Iterator;
+import org.hibernate.sql.ast.tree.EntityNameTree;
+}
+
+@parser::members {
+ private Stack enableParameterUsage = new Stack();
+ private ParserContext context = new ParserContextDefaultImpl();
+ private List errorMessages = new LinkedList();
+
+ public void setParserContext(ParserContext context){
+ this.context = context;
+ }
+
+ private boolean validateIdentifierKey(String text) {
+ return validateLT(1, text);
+ }
+
+ private boolean validateLT(int LTNumber, String text) {
+ String text2Validate = retrieveLT( LTNumber );
+ return text2Validate == null ? false : text2Validate.equalsIgnoreCase(text);
+ }
+
+ private String retrieveLT(int LTNumber) {
+ if (null == input)
+ return null;
+ if (null == input.LT(LTNumber))
+ return null;
+ if (null == input.LT(LTNumber).getText())
+ return null;
+
+ return input.LT(LTNumber).getText();
+ }
+
+ public boolean hasErrors(){
+ if ( errorMessages.size() > 0 ) {
+ return true;
+ }
+ return false;
+ }
+
+ public List getErrorMessages(){
+ return errorMessages;
+ }
+
+ public void reportError( RecognitionException e ) {
+ errorMessages.add(generateError(getRuleInvocationStack(e, this.getClass().getName()), this.getTokenNames(), e));
+ super.reportError(e);
+ }
+
+ private String generateError( List invocationStack,
+ String[] tokenNames,
+ RecognitionException e ) {
+ String localization = invocationStack + ": line " + e.line + ":" + e.charPositionInLine + " ";
+ return generateError(localization, tokenNames, e);
+ }
+
+ private String generateError( String localization,
+ String[] tokenNames,
+ RecognitionException e ) {
+ String message = "";
+ if (e instanceof MismatchedTokenException) {
+ MismatchedTokenException mte = (MismatchedTokenException)e;
+ String tokenName = "<unknown>";
+ if (mte.expecting == Token.EOF) {
+ tokenName = "EOF";
+ } else {
+ if (tokenNames != null) {
+ tokenName = tokenNames[mte.expecting];
+ }
+ }
+ message = localization + "mismatched token: " + e.token + "; expecting type " + tokenName;
+ } else if (e instanceof MismatchedTreeNodeException) {
+ MismatchedTreeNodeException mtne = (MismatchedTreeNodeException)e;
+ String tokenName = "<unknown>";
+ if (mtne.expecting == Token.EOF) {
+ tokenName = "EOF";
+ } else {
+ tokenName = tokenNames[mtne.expecting];
+ }
+ message = localization + "mismatched tree node: " + mtne.node + "; expecting type " + tokenName;
+ } else if (e instanceof NoViableAltException) {
+ NoViableAltException nvae = (NoViableAltException)e;
+ message = localization + "state " + nvae.stateNumber + " (decision=" + nvae.decisionNumber
+ + ") no viable alt; token=" + e.token;
+ } else if (e instanceof EarlyExitException) {
+ EarlyExitException eee = (EarlyExitException)e;
+ message = localization + "required (...)+ loop (decision=" + eee.decisionNumber + ") did not match anything; token="
+ + e.token;
+ } else if (e instanceof MismatchedSetException) {
+ MismatchedSetException mse = (MismatchedSetException)e;
+ message = localization + "mismatched token: " + e.token + "; expecting set " + mse.expecting;
+ } else if (e instanceof MismatchedNotSetException) {
+ MismatchedNotSetException mse = (MismatchedNotSetException)e;
+ message = localization + "mismatched token: " + e.token + "; expecting set " + mse.expecting;
+ } else if (e instanceof FailedPredicateException) {
+ FailedPredicateException fpe = (FailedPredicateException)e;
+ message = localization + "rule " + fpe.ruleName + " failed predicate: {" + fpe.predicateText + "}?";
+ }
+
+ return message;
+ }
+
+ private List extractEntityNames(String entityName) throws RecognitionException {
+ List implementors = context.getEntityImplementors(entityName);
+ if (implementors == null){
+ throw new RecognitionException( );
+ }
+ return implementors;
+ }
+
+ private Tree generatePersisterSpacesTree(List persistenceSpaces) {
+ List persisterSpaceList = new ArrayList();
+ for (Iterator iterator = persistenceSpaces.iterator(); iterator
+ .hasNext();) {
+ Tree persistenceSpaceData = (Tree) iterator.next();
+ if (persistenceSpaceData.getType() == PERSISTER_JOIN || persistenceSpaceData.getType() == PROPERTY_JOIN){
+ adaptor.addChild(persisterSpaceList.get(persisterSpaceList.size() - 1), persistenceSpaceData);
+ } else {
+ Object persistenceSpaceTree = (Object)adaptor.nil();
+ persistenceSpaceTree = adaptor.becomeRoot((Object)adaptor.create(PERSISTER_SPACE, "PERSISTER_SPACE"), persistenceSpaceTree);
+ adaptor.addChild(persistenceSpaceTree, persistenceSpaceData);
+ persisterSpaceList.add(persistenceSpaceTree);
+ }
+ }
+ Tree resultTree = (Tree) adaptor.nil();
+ for (Iterator iterator = persisterSpaceList.iterator(); iterator
+ .hasNext();) {
+ Object persistenceElement = (Object) iterator.next();
+ adaptor.addChild(resultTree, persistenceElement);
+ }
+
+ return resultTree;
+ }
+
+ private Tree generateUpdateStatementTree(Object updateKey,
+ Object entityName, Object aliasClause, Object setClause,
+ Object whereClause) {
+ Tree result = new CommonTree();
+ EntityNameTree entityNameTree = (EntityNameTree) entityName;
+ for (int i = 0; i < entityNameTree.getEntityCount(); i++) {
+ Tree updateRoot = new CommonTree((CommonTree) updateKey);
+
+ updateRoot.addChild(new EntityNameTree(entityNameTree,
+ entityNameTree.getEntityName(i)));
+
+ if (aliasClause != null) {
+ updateRoot.addChild((Tree) aliasClause);
+ }
+ updateRoot.addChild((Tree) setClause);
+
+ if (whereClause != null) {
+ updateRoot.addChild((Tree) whereClause);
+ }
+
+ result.addChild(updateRoot);
+ }
+ return result;
+ }
+
+ private Tree generateDeleteStatementTree(Object deleteKey,
+ Object entityName, Object aliasClause, Object whereClause) {
+ Tree result = new CommonTree();
+ EntityNameTree entityNameTree = (EntityNameTree) entityName;
+ for (int i = 0; i < entityNameTree.getEntityCount(); i++) {
+ Tree deleteRoot = new CommonTree((CommonTree) deleteKey);
+
+ deleteRoot.addChild(new EntityNameTree(entityNameTree,
+ entityNameTree.getEntityName(i)));
+
+ if (aliasClause != null) {
+ deleteRoot.addChild((Tree) aliasClause);
+ }
+
+ if (whereClause != null) {
+ deleteRoot.addChild((Tree) whereClause);
+ }
+
+ result.addChild(deleteRoot);
+ }
+ return result;
+ }
+
+ private Tree generateSelecFromTree(Object selectClause, Object fromClause, List aliasList){
+ Tree result = new CommonTree(new CommonToken(SELECT_FROM, "SELECT_FROM"));
+ Tree selectTree = null;
+ result.addChild((Tree) fromClause);
+ if (selectClause == null && aliasList != null && aliasList.size() > 0) {
+ selectTree = new CommonTree(new CommonToken(SELECT, "SELECT"));
+ Tree selectList = new CommonTree(new CommonToken(SELECT_LIST, "SELECT_LIST"));
+ for (Iterator iterator = aliasList.iterator(); iterator
+ .hasNext();) {
+ String aliasName = (String) iterator.next();
+ Tree selectElement = new CommonTree(new CommonToken(SELECT_ITEM, "SELECT_ITEM"));
+ Tree aliasElement = new CommonTree(new CommonToken(ALIAS_REF, aliasName));
+ selectElement.addChild(aliasElement);
+ selectList.addChild(selectElement);
+ }
+ selectTree.addChild(selectList);
+ } else {
+ selectTree = (Tree) selectClause;
+ }
+ result.addChild(selectTree);
+ return result;
+ }
+}
+
+filterStatement[String collectionRole]
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
+@after { enableParameterUsage.pop(); }
+ : selectClause? from_key? whereClause? ( groupByClause havingClause?)? orderByClause?
+ -> ^(QUERY ^(QUERY_SPEC["filter-query-spec"] FILTER[$collectionRole]
+ selectClause? from_key? whereClause? ( groupByClause havingClause?)? orderByClause?))
+ //TODO throw an exception here when using from
+ ;
+
+statement
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
+@after { enableParameterUsage.pop(); }
+ : updateStatement
+ | deleteStatement
+ | insertStatement
+ | selectStatement
+ ;
+
+updateStatement
+scope{
+ boolean generateVersionedField;
+} : udpate_key
+ (versioned_key {$updateStatement::generateVersionedField = true;})?
+ from_key? entityName aliasClause[true] setClause whereClause?
+ -> { generateUpdateStatementTree($udpate_key.tree, $entityName.tree, $aliasClause.tree, $setClause.tree, $whereClause.tree ) }
+ ;
+
+//TODO: check what is necessary to generate at versioned field
+setClause
+ : set_key assignment (COMMA assignment)*
+ -> {$updateStatement::generateVersionedField}? ^(set_key assignment+ ^(EQUALS VERSIONED_VALUE STRING_LITERAL))
+ -> ^(set_key assignment+)
+ ;
+
+assignment
+ : assignmentField EQUALS^ concatenation
+ ;
+
+assignmentField
+ : dotIdentifierPath -> ^(PROPERTY_REFERENCE dotIdentifierPath)
+ ;
+
+deleteStatement
+ : delete_key from_key? entityName aliasClause[true] whereClause?
+ -> { generateDeleteStatementTree($delete_key.tree, $entityName.tree, $aliasClause.tree, $whereClause.tree ) }
+ ;
+
+insertStatement
+ : insert_key^
+ intoClause selectStatement
+ ;
+
+//TODO: Generate an exception when try to use a polimorfic entity at INTO clause
+intoClause
+ : into_key entityName insertabilitySpecification
+ -> ^(into_key entityName ALIAS_NAME[context.buildUniqueImplicitAlias()] insertabilitySpecification)
+ ;
+
+insertabilitySpecification
+ : LEFT_PAREN insertablePropertySpecification ( COMMA insertablePropertySpecification )* RIGHT_PAREN
+ -> ^(INSERTABILITY_SPEC insertablePropertySpecification+ )
+ ;
+
+insertablePropertySpecification
+ : dotIdentifierPath -> ^(PROPERTY_REFERENCE dotIdentifierPath)
+ ;
+
+selectStatement
+ : queryExpression orderByClause?
+ -> ^(QUERY queryExpression orderByClause?)
+ ;
+
+//Think about the exception generation where Polimorfic queris are used inside a Mix of results (union, intersect and except)
+queryExpression
+ : querySpec ( ( union_key^ | intersect_key^ | except_key^ ) all_key? querySpec )*
+ ;
+
+querySpec
+ : selectFrom whereClause? ( groupByClause havingClause? )?
+ -> ^(QUERY_SPEC selectFrom whereClause? groupByClause? havingClause?)
+ ;
+
+groupByClause
+ : group_by_key^ groupingSpecification
+ ;
+
+havingClause
+ : having_key^ logicalExpression
+ ;
+
+groupingSpecification
+ : groupingValue ( COMMA! groupingValue )*
+ ;
+
+groupingValue
+ : concatenation collationSpecification?
+ -> ^(GROUPING_VALUE concatenation collationSpecification?)
+ ;
+
+whereClause
+ : where_key^ logicalExpression
+ ;
+
+selectFrom
+ : sc=selectClause? fc=fromClause
+ -> { generateSelecFromTree($sc.tree, $fc.tree, $fc.aliasList)}
+ ;
+
+subQuery
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
+@after { enableParameterUsage.pop(); }
+ : queryExpression
+ -> ^(SUB_QUERY ^(QUERY queryExpression))
+ ;
+
+fromClause returns [List aliasList]
+scope{
+ List aliases;
+}
+@init { $fromClause::aliases = new ArrayList(); }
+@after { $aliasList = $fromClause::aliases; }
+ : from_key^
+ persisterSpaces
+ ;
+
+persisterSpaces
+ : ps+=persisterSpace ( COMMA ps+=persisterSpace )*
+ -> {generatePersisterSpacesTree($ps)}
+ ;
+
+persisterSpace
+ : persisterSpaceRoot ( qualifiedJoin | crossJoin )*
+ ;
+
+crossJoin
+ : cross_key join_key mainEntityPersisterReference
+ -> ^(PERSISTER_JOIN[$join_key.start,"persister-join"] cross_key mainEntityPersisterReference)
+ ;
+
+qualifiedJoin
+@init { boolean isEntityReference = false; boolean hasFetch = false; List entityNames = null; }
+@after { if (!hasFetch) $fromClause::aliases.add(((Tree)$ac.tree).getText()); }
+ : nonCrossJoinType join_key (fetch_key {hasFetch = true;})? path ac=aliasClause[true]
+ ( on_key
+ { isEntityReference = true;
+ entityNames = extractEntityNames($path.text); }
+ logicalExpression
+ | propertyFetch? withClause?
+ )
+ -> {isEntityReference}? ^(PERSISTER_JOIN[$join_key.start,"persister-join"] nonCrossJoinType ^(ENTITY_PERSISTER_REF ENTITY_NAME<EntityNameTree>[$path.start, $path.text, entityNames] aliasClause?) ^(on_key logicalExpression))
+ -> ^(PROPERTY_JOIN[$join_key.start, "property-join"] nonCrossJoinType fetch_key? aliasClause? propertyFetch? ^(PROPERTY_REFERENCE path) withClause?)
+ ;
+
+withClause
+ : with_key^ logicalExpression
+ ;
+
+nonCrossJoinType
+ : inner_key
+ | outerJoinType outer_key?
+ | -> INNER
+ ;
+
+outerJoinType
+ : left_key
+ | right_key
+ | full_key
+ ;
+
+persisterSpaceRoot
+options{
+backtrack=true;
+} : mainEntityPersisterReference
+ | jpaCollectionReference
+ | hibernateLegacySyntax
+ ;
+
+mainEntityPersisterReference
+@after { $fromClause::aliases.add(((Tree)$ac.tree).getText()); }
+ : entityName ac=aliasClause[true] propertyFetch?
+ -> ^(ENTITY_PERSISTER_REF entityName aliasClause? propertyFetch?)
+ ;
+
+propertyFetch
+ : fetch_key all_key properties_key
+ -> PROP_FETCH[$fetch_key.start, "property-fetch"]
+ ;
+
+hibernateLegacySyntax returns [boolean isPropertyJoin]
+@init {$isPropertyJoin = false;}
+@after { $fromClause::aliases.add(((Tree)$ad.tree).getText()); }
+ : ad=aliasDeclaration in_key
+ ( class_key entityName -> ^(ENTITY_PERSISTER_REF entityName aliasDeclaration)
+ | collectionExpression {$isPropertyJoin = true;} -> ^(PROPERTY_JOIN INNER[$in_key.start, "inner legacy"] aliasDeclaration collectionExpression)
+ )
+ ;
+
+jpaCollectionReference
+@after { $fromClause::aliases.add(((Tree)$ac.tree).getText()); }
+ : in_key LEFT_PAREN propertyReference RIGHT_PAREN ac=aliasClause[true]
+ -> ^(PROPERTY_JOIN INNER[$in_key.start, "inner"] aliasClause? propertyReference)
+ ;
+
+selectClause
+ : select_key^ distinct_key? rootSelectExpression
+ ;
+
+rootSelectExpression
+ : rootDynamicInstantiation
+ | jpaSelectObjectSyntax
+ | explicitSelectList
+ ;
+
+explicitSelectList
+ : explicitSelectItem ( COMMA explicitSelectItem )*
+ -> ^(SELECT_LIST explicitSelectItem+)
+ ;
+
+explicitSelectItem
+ : selectExpression
+ ;
+
+selectExpression
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.FALSE); }
+@after { enableParameterUsage.pop(); }
+//PARAMETERS CAN'T BE USED -> This verification should be scoped
+ : expression aliasClause[false]
+ -> ^(SELECT_ITEM expression aliasClause?)
+ ;
+
+aliasClause[boolean generateAlias]
+options{
+ k=2;
+} : -> {$generateAlias}? ALIAS_NAME[context.buildUniqueImplicitAlias()]
+ ->
+ | aliasDeclaration
+ | as_key! aliasDeclaration
+ ;
+
+aliasDeclaration
+ : IDENTIFIER -> ALIAS_NAME[$IDENTIFIER]
+ ;
+
+aliasReference
+ : IDENTIFIER -> ALIAS_REF[$IDENTIFIER]
+ ;
+
+rootDynamicInstantiation
+ : new_key dynamicInstantiationTarget LEFT_PAREN dynamicInstantiationArgs RIGHT_PAREN
+ -> ^(SELECT_ITEM ^(DYNAMIC_INSTANTIATION[$dynamicInstantiationTarget.start, $dynamicInstantiationTarget.text] dynamicInstantiationArgs))
+ ;
+
+dynamicInstantiationTarget
+ : dotIdentifierPath
+ ;
+
+dynamicInstantiationArgs
+ : dynamicInstantiationArg ( COMMA! dynamicInstantiationArg )*
+ ;
+
+dynamicInstantiationArg
+ : selectExpression -> ^(DYNAMIC_INSTANTIATION_ARG selectExpression)
+ | rootDynamicInstantiation -> ^(DYNAMIC_INSTANTIATION_ARG rootDynamicInstantiation)
+ ;
+
+jpaSelectObjectSyntax
+ : object_key LEFT_PAREN aliasReference RIGHT_PAREN
+ -> ^(SELECT_ITEM aliasReference)
+ ;
+
+orderByClause
+ : order_by_key^ sortSpecification ( COMMA! sortSpecification )*
+ ;
+
+sortSpecification
+@init{boolean generateOmmitedElement = true;}
+ : sortKey collationSpecification? (orderingSpecification {generateOmmitedElement = false;})?
+ -> {generateOmmitedElement}? ^(SORT_SPEC sortKey collationSpecification? ASC)
+ -> ^(SORT_SPEC sortKey collationSpecification? orderingSpecification?)
+ ;
+
+sortKey
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.FALSE); }
+@after { enableParameterUsage.pop(); }
+//PARAMETERS CAN'T BE USED -> This verification should be scoped
+ : concatenation
+ ;
+
+collationSpecification
+ : collate_key collateName
+ -> COLLATE[$collateName.start, $collateName.text]
+ ;
+
+collateName
+ : dotIdentifierPath
+ ;
+
+orderingSpecification
+ : ascending_key
+ | descending_key
+ ;
+
+logicalExpression
+ : expression
+ ;
+
+expression
+ : logicalOrExpression
+ ;
+
+logicalOrExpression
+ : logicalAndExpression ( or_key^ logicalAndExpression )*
+ ;
+
+logicalAndExpression
+ : negatedExpression ( and_key^ negatedExpression )*
+ ;
+
+negatedExpression
+ : not_key^ negatedExpression
+ | equalityExpression
+ ;
+
+equalityExpression
+@init{ boolean isNull = false; boolean isNegated = false;}
+ : (relationalExpression -> relationalExpression)
+ ( is_key (not_key {isNegated = true;})? (NULL {isNull = true;}|empty_key)
+ -> {isNull && isNegated}? ^(IS_NOT_NULL[$not_key.start, "is not null"] $equalityExpression)
+ -> {isNull && !isNegated}? ^(IS_NULL[$NULL, "is null"] $equalityExpression)
+ -> {!isNull && isNegated}? ^(IS_NOT_EMPTY $equalityExpression)
+ -> ^(IS_EMPTY $equalityExpression)
+ | ( op=EQUALS | op=NOT_EQUAL ) relationalExpression
+ -> ^($op $equalityExpression relationalExpression)
+ )*
+ ;
+
+relationalExpression
+@init {boolean isNegated = false;}
+ : (concatenation -> concatenation)
+ (
+ ( ( op=LESS | op=GREATER | op=LESS_EQUAL | op=GREATER_EQUAL ) additiveExpression
+ -> ^($op $relationalExpression additiveExpression)
+ )+
+ | (not_key {isNegated = true;} )?
+ ( in_key inList
+ -> {isNegated}? ^(NOT_IN[$not_key.start, "not in"] $relationalExpression inList)
+ -> ^(in_key $relationalExpression inList)
+ | between_key betweenList
+ -> {isNegated}? ^(NOT_BETWEEN[$not_key.start, "not between"] $relationalExpression betweenList)
+ -> ^(between_key $relationalExpression betweenList)
+ | like_key concatenation likeEscape?
+ -> {isNegated}? ^(NOT_LIKE[$not_key.start, "not like"] $relationalExpression concatenation likeEscape?)
+ -> ^(like_key $relationalExpression concatenation likeEscape?)
+ | member_of_key path
+ -> {isNegated}? ^(NOT_MEMBER_OF[$not_key.start, "not member of"] $relationalExpression ^(PATH path))
+ -> ^(member_of_key $relationalExpression ^(PATH path))
+ )
+ )?
+ ;
+
+likeEscape
+ : escape_key^ concatenation
+ ;
+
+inList
+ : collectionExpression
+ -> ^(IN_LIST collectionExpression)
+ | LEFT_PAREN ( {((validateIdentifierKey("select")|validateIdentifierKey("from")))}?=> subQuery | concatenation (COMMA concatenation)* ) RIGHT_PAREN
+ -> ^(IN_LIST concatenation* subQuery?)
+ ;
+
+betweenList
+ : concatenation and_key concatenation
+ -> ^(BETWEEN_LIST concatenation+)
+ ;
+
+concatenation
+ : additiveExpression (DOUBLE_PIPE^ {enableParameterUsage.push(Boolean.TRUE);} additiveExpression { enableParameterUsage.pop(); })*
+ ;
+
+additiveExpression
+ : multiplyExpression ( ( PLUS^ | MINUS^ ) {enableParameterUsage.push(Boolean.TRUE);} multiplyExpression { enableParameterUsage.pop(); })*
+ ;
+
+multiplyExpression
+ : unaryExpression ( ( ASTERISK^ | SOLIDUS^ ) {enableParameterUsage.push(Boolean.TRUE);} unaryExpression { enableParameterUsage.pop(); })*
+ ;
+
+unaryExpression
+ : MINUS unaryExpression -> ^(UNARY_MINUS[$MINUS] unaryExpression)
+ | PLUS unaryExpression -> ^(UNARY_PLUS[$PLUS] unaryExpression)
+ | caseExpression
+ | quantifiedExpression
+ | standardFunction
+ | setFunction
+ | collectionFunction
+ | collectionExpression
+ | atom
+ ;
+
+caseExpression
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
+@after { enableParameterUsage.pop(); }
+ : caseAbbreviation
+ | caseSpecification
+ ;
+
+caseAbbreviation
+ : nullif_key^ LEFT_PAREN! concatenation COMMA! concatenation RIGHT_PAREN!
+ | coalesce_key^ LEFT_PAREN! concatenation (COMMA! concatenation)* RIGHT_PAREN!
+ ;
+
+caseSpecification
+options{
+backtrack=true;
+} : simpleCase
+ | searchedCase
+ ;
+
+simpleCase
+ : case_key concatenation simpleCaseWhenClause+ elseClause? end_key
+ -> ^(SIMPLE_CASE[$case_key.start, $case_key.text] concatenation simpleCaseWhenClause+ elseClause?)
+ ;
+
+simpleCaseWhenClause
+ : when_key^ concatenation then_key! concatenation
+ ;
+
+elseClause
+ : else_key^ concatenation
+ ;
+
+searchedCase
+ : case_key searchedWhenClause+ elseClause? end_key
+ -> ^(SEARCHED_CASE[$case_key.start, $case_key.text] searchedWhenClause+ elseClause?)
+ ;
+
+searchedWhenClause
+ : when_key^ logicalExpression then_key! concatenation
+ ;
+
+quantifiedExpression
+ : ( some_key^ | exists_key^ | all_key^ | any_key^ )
+ ( collectionExpression
+ | aliasReference
+ | LEFT_PAREN! subQuery RIGHT_PAREN!
+ )
+ ;
+
+standardFunction
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
+@after { enableParameterUsage.pop(); }
+ : castFunction
+ | concatFunction
+ | substringFunction
+ | trimFunction
+ | upperFunction
+ | lowerFunction
+ | lengthFunction
+ | locateFunction
+ | absFunction
+ | sqrtFunction
+ | modFunction
+ | sizeFunction
+ | indexFunction
+ | currentDateFunction
+ | currentTimeFunction
+ | currentTimestampFunction
+ | extractFunction
+ | positionFunction
+ | charLengthFunction
+ | octetLengthFunction
+ | bitLengthFunction
+ ;
+
+castFunction
+ : cast_key^ LEFT_PAREN! concatenation as_key! dataType RIGHT_PAREN!
+ ;
+
+concatFunction
+ : concat_key^ LEFT_PAREN! concatenation ( COMMA! concatenation )+ RIGHT_PAREN!
+ ;
+
+substringFunction
+ : substring_key^ LEFT_PAREN! concatenation COMMA! concatenation ( COMMA! concatenation)? RIGHT_PAREN!
+ ;
+
+trimFunction
+ : trim_key LEFT_PAREN trimOperands RIGHT_PAREN
+ -> ^(trim_key trimOperands)
+ ;
+
+trimOperands
+options{
+k=2;
+}
+@init {boolean hasSecondExpression = false;}
+ : trimSpecification from_key concatenation -> ^(trimSpecification STRING_LITERAL[" "] concatenation)
+ | trimSpecification concatenation from_key concatenation -> ^(trimSpecification concatenation+)
+ | from_key concatenation -> ^(BOTH STRING_LITERAL[" "] concatenation)
+ | cn=concatenation ( from_key concatenation {hasSecondExpression = true;} )?
+ -> {hasSecondExpression}? ^(BOTH concatenation+)
+ -> ^(BOTH STRING_LITERAL[" "] $cn)
+ ;
+
+trimSpecification
+ : leading_key
+ | trailing_key
+ | both_key
+ ;
+
+upperFunction
+ : upper_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
+ ;
+
+lowerFunction
+ : lower_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
+ ;
+
+lengthFunction
+ : length_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
+ ;
+
+locateFunction
+ : locate_key^ LEFT_PAREN! concatenation COMMA! concatenation ( COMMA! concatenation )? RIGHT_PAREN!
+ ;
+
+absFunction
+ : abs_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
+ ;
+
+sqrtFunction
+ : sqrt_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
+ ;
+
+modFunction
+ : mod_key^ LEFT_PAREN! concatenation COMMA! concatenation RIGHT_PAREN!
+ ;
+
+sizeFunction
+ : size_key^ LEFT_PAREN! propertyReference RIGHT_PAREN!
+ ;
+
+indexFunction
+ : index_key^ LEFT_PAREN! aliasReference RIGHT_PAREN!
+ ;
+
+currentDateFunction
+ : current_date_key ( LEFT_PAREN! RIGHT_PAREN! )?
+ ;
+
+currentTimeFunction
+ : current_time_key ( LEFT_PAREN! RIGHT_PAREN! )?
+ ;
+
+currentTimestampFunction
+ : current_timestamp_key ( LEFT_PAREN! RIGHT_PAREN! )?
+ ;
+
+extractFunction
+ : extract_key^ LEFT_PAREN! extractField from_key! concatenation RIGHT_PAREN!
+ ;
+
+extractField
+ : datetimeField
+ | timeZoneField
+ ;
+
+datetimeField
+ : nonSecondDatetimeField
+ | second_key
+ ;
+
+nonSecondDatetimeField
+ : year_key
+ | month_key
+ | day_key
+ | hour_key
+ | minute_key
+ ;
+
+timeZoneField
+ : timezone_hour_key
+ | timezone_minute_key
+ ;
+
+positionFunction
+ : position_key^ LEFT_PAREN! concatenation in_key! concatenation RIGHT_PAREN!
+ ;
+
+charLengthFunction
+ : character_length_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
+ ;
+
+octetLengthFunction
+ : octet_length_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
+ ;
+
+bitLengthFunction
+ : bit_length_key^ LEFT_PAREN! concatenation RIGHT_PAREN!
+ ;
+
+setFunction
+@init { boolean generateOmmitedElement = true; if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
+@after { enableParameterUsage.pop(); }
+ : ( sum_key^ | avg_key^ | max_key^ | min_key^ ) LEFT_PAREN! additiveExpression RIGHT_PAREN!
+ | count_key LEFT_PAREN ( ASTERISK {generateOmmitedElement = false;} | ( ( (distinct_key | all_key) {generateOmmitedElement = false;} )? countFunctionArguments ) ) RIGHT_PAREN
+ -> {generateOmmitedElement}? ^(count_key ASTERISK? ALL countFunctionArguments?)
+ -> ^(count_key ASTERISK? distinct_key? all_key? countFunctionArguments?)
+ ;
+
+countFunctionArguments
+@init { int type = -1;}
+ : propertyReference
+ | collectionExpression
+ | numeric_literal
+ ;
+
+collectionFunction
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
+@after { enableParameterUsage.pop(); }
+ : ( maxelement_key^ | maxindex_key^ | minelement_key^ | minindex_key^ ) LEFT_PAREN! propertyReference RIGHT_PAREN!
+ ;
+
+collectionExpression
+ : (elements_key^|indices_key^) LEFT_PAREN! propertyReference RIGHT_PAREN!
+ ;
+
+atom
+@init { int type = -1;}
+ : identPrimary
+ //TODO if ends with:
+ // .class -> class type
+ // if contains "()" it is a function call
+ // if it is constantReference (using context)
+ // otherwise it will be a generic element to be resolved on the next phase (1st tree walker)
+ -> {type == 0}? ^(DOT_CLASS identPrimary)
+ -> {type == 3}? ^(GENERAL_FUNCTION_CALL identPrimary)
+ -> {type == 4}? ^(JAVA_CONSTANT identPrimary) //-> here will have 2 strutctures element and the constant
+ -> ^(PATH identPrimary)
+ | constant
+ | parameterSpecification { if (enableParameterUsage.peek().equals(Boolean.FALSE)) throw new RecognitionException( ); }
+ //validate using Scopes if it is enabled or not to use parameterSpecification.. if not generate an exception
+ | LEFT_PAREN! ({((validateIdentifierKey("select")|validateIdentifierKey("from")))}?=> subQuery|expressionOrVector) RIGHT_PAREN!
+ ;
+
+parameterSpecification
+@init {boolean isJpaParam = false;}
+ : COLON IDENTIFIER -> NAMED_PARAM[$IDENTIFIER]
+ | PARAM (INTEGER_LITERAL {isJpaParam = true;})?
+ -> {isJpaParam}? JPA_PARAM[$INTEGER_LITERAL]
+ -> PARAM
+ ;
+
+expressionOrVector
+@init {boolean isVectorExp = false;}
+ : expression (vectorExpr {isVectorExp = true;})?
+ -> {isVectorExp}? ^(VECTOR_EXPR expression vectorExpr)
+ -> expression
+ ;
+
+vectorExpr
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
+@after { enableParameterUsage.pop(); }
+ : COMMA! expression (COMMA! expression)*
+ ;
+
+identPrimary
+ : IDENTIFIER
+ ( DOT^ IDENTIFIER
+ | LEFT_SQUARE^ expression RIGHT_SQUARE!
+ | LEFT_SQUARE^ RIGHT_SQUARE!
+ | LEFT_PAREN^ exprList RIGHT_PAREN!
+ )*
+ ;
+
+exprList
+@init { if (state.backtracking == 0) enableParameterUsage.push(Boolean.TRUE); }
+@after { enableParameterUsage.pop(); }
+ : expression? (COMMA! expression)*
+ ;
+
+constant
+ : literal
+ | NULL
+ | TRUE
+ | FALSE
+ ;
+
+literal
+ : numeric_literal
+ | HEX_LITERAL
+ | OCTAL_LITERAL
+ | CHARACTER_LITERAL
+ | STRING_LITERAL
+ ;
+
+numeric_literal
+ : INTEGER_LITERAL
+ | DECIMAL_LITERAL
+ | FLOATING_POINT_LITERAL
+ ;
+
+entityName
+@init { List entityNames = null; }
+ : dotIdentifierPath
+ { entityNames = extractEntityNames($dotIdentifierPath.text); }
+ //here the polimorfic entities should be resolved... to:
+ // 1. to place inside the ENTITY_NAME Token all its possible values, otherwise it would be much difficult to return to the place that should explit the sentence
+ // 2. enable exception geration when not supported (union, insert)
+ -> ENTITY_NAME<EntityNameTree>[$dotIdentifierPath.start, $dotIdentifierPath.text, entityNames]
+ ;
+
+propertyReference
+ : path
+ -> ^(PROPERTY_REFERENCE path)
+ ;
+
+dataType
+ : IDENTIFIER
+ ;
+
+dotIdentifierPath
+ : IDENTIFIER
+ ( DOT^ IDENTIFIER )*
+ ;
+
+path
+ : IDENTIFIER
+ ( DOT^ IDENTIFIER
+ | LEFT_SQUARE^ expression RIGHT_SQUARE!
+ | LEFT_SQUARE^ RIGHT_SQUARE!
+ )*
+ ;
+
+class_key
+ : {(validateIdentifierKey("class"))}?=> id=IDENTIFIER
+ -> CLASS[$id]
+ ;
+
+new_key
+ : {(validateIdentifierKey("new"))}?=> id=IDENTIFIER
+ -> NEW[$id]
+ ;
+
+else_key
+ : {(validateIdentifierKey("else"))}?=> id=IDENTIFIER
+ -> ELSE[$id]
+ ;
+
+object_key
+ : {(validateIdentifierKey("object"))}?=> id=IDENTIFIER
+ ;
+
+case_key
+ : {(validateIdentifierKey("case"))}?=> IDENTIFIER
+ ;
+
+current_date_key
+ : {(validateIdentifierKey("current_date"))}?=> id=IDENTIFIER
+ -> CURRENT_DATE[$id]
+ ;
+
+current_time_key
+ : {(validateIdentifierKey("current_time"))}?=> id=IDENTIFIER
+ -> CURRENT_TIME[$id]
+ ;
+
+current_timestamp_key
+ : {(validateIdentifierKey("current_timestamp"))}?=> id=IDENTIFIER
+ -> CURRENT_TIMESTAMP[$id]
+ ;
+
+timezone_hour_key
+ : {(validateIdentifierKey("timezone_hour"))}?=> id=IDENTIFIER
+ -> TIMEZONE_HOUR[$id]
+ ;
+
+timezone_minute_key
+ : {(validateIdentifierKey("timezone_minute"))}?=> id=IDENTIFIER
+ -> TIMEZONE_MINUTE[$id]
+ ;
+
+character_length_key
+ : {(validateIdentifierKey("character_length") || validateIdentifierKey("char_length"))}?=> id=IDENTIFIER
+ -> CHARACTER_LENGTH[$id]
+ ;
+
+octet_length_key
+ : {(validateIdentifierKey("octet_length"))}?=> id=IDENTIFIER
+ -> OCTET_LENGTH[$id]
+ ;
+
+bit_length_key
+ : {(validateIdentifierKey("bit_length"))}?=> id=IDENTIFIER
+ -> BIT_LENGTH[$id]
+ ;
+
+extract_key
+ : {(validateIdentifierKey("extract"))}?=> id=IDENTIFIER
+ -> EXTRACT[$id]
+ ;
+
+second_key
+ : {(validateIdentifierKey("second"))}?=> id=IDENTIFIER
+ -> SECOND[$id]
+ ;
+
+year_key
+ : {(validateIdentifierKey("year"))}?=> id=IDENTIFIER
+ -> YEAR[$id]
+ ;
+
+month_key
+ : {(validateIdentifierKey("month"))}?=> id=IDENTIFIER
+ -> MONTH[$id]
+ ;
+
+day_key
+ : {(validateIdentifierKey("day"))}?=> id=IDENTIFIER
+ -> DAY[$id]
+ ;
+
+hour_key
+ : {(validateIdentifierKey("hour"))}?=> id=IDENTIFIER
+ -> HOUR[$id]
+ ;
+
+minute_key
+ : {(validateIdentifierKey("minute"))}?=> id=IDENTIFIER
+ -> MINUTE[$id]
+ ;
+
+position_key
+ : {(validateIdentifierKey("position"))}?=> id=IDENTIFIER
+ -> POSITION[$id]
+ ;
+
+sum_key
+ : {(validateIdentifierKey("sum"))}?=> id=IDENTIFIER
+ -> SUM[$id]
+ ;
+
+avg_key
+ : {(validateIdentifierKey("avg"))}?=> id=IDENTIFIER
+ -> AVG[$id]
+ ;
+
+max_key
+ : {(validateIdentifierKey("max"))}?=> id=IDENTIFIER
+ -> MAX[$id]
+ ;
+
+min_key
+ : {(validateIdentifierKey("min"))}?=> id=IDENTIFIER
+ -> MIN[$id]
+ ;
+
+count_key
+ : {(validateIdentifierKey("count"))}?=> id=IDENTIFIER
+ -> COUNT[$id]
+ ;
+
+maxelement_key
+ : {(validateIdentifierKey("maxelement"))}?=> id=IDENTIFIER
+ -> MAXELEMENT[$id]
+ ;
+
+maxindex_key
+ : {(validateIdentifierKey("maxindex"))}?=> id=IDENTIFIER
+ -> MAXINDEX[$id]
+ ;
+
+minelement_key
+ : {(validateIdentifierKey("minelement"))}?=> id=IDENTIFIER
+ -> MINELEMENT[$id]
+ ;
+
+minindex_key
+ : {(validateIdentifierKey("minindex"))}?=> id=IDENTIFIER
+ -> MININDEX[$id]
+ ;
+
+locate_key
+ : {(validateIdentifierKey("locate"))}?=> id=IDENTIFIER
+ -> LOCATE[$id]
+ ;
+
+abs_key
+ : {(validateIdentifierKey("abs"))}?=> id=IDENTIFIER
+ -> ABS[$id]
+ ;
+
+sqrt_key
+ : {(validateIdentifierKey("sqrt"))}?=> id=IDENTIFIER
+ -> SQRT[$id]
+ ;
+
+mod_key
+ : {(validateIdentifierKey("mod"))}?=> id=IDENTIFIER
+ -> MOD[$id]
+ ;
+
+size_key
+ : {(validateIdentifierKey("size"))}?=> id=IDENTIFIER
+ -> SIZE[$id]
+ ;
+
+index_key
+ : {(validateIdentifierKey("index"))}?=> id=IDENTIFIER
+ -> INDEX[$id]
+ ;
+
+leading_key
+ : {(validateIdentifierKey("leading"))}?=> id=IDENTIFIER
+ -> LEADING[$id]
+ ;
+
+trailing_key
+ : {(validateIdentifierKey("trailing"))}?=> id=IDENTIFIER
+ -> TRAILING[$id]
+ ;
+
+upper_key
+ : {(validateIdentifierKey("upper"))}?=> id=IDENTIFIER
+ -> UPPER[$id]
+ ;
+
+lower_key
+ : {(validateIdentifierKey("lower"))}?=> id=IDENTIFIER
+ -> LOWER[$id]
+ ;
+
+length_key
+ : {(validateIdentifierKey("length"))}?=> id=IDENTIFIER
+ -> LENGTH[$id]
+ ;
+
+both_key
+ : {(validateIdentifierKey("both"))}?=> id=IDENTIFIER
+ -> BOTH[$id]
+ ;
+
+trim_key
+ : {(validateIdentifierKey("trim"))}?=> id=IDENTIFIER
+ -> TRIM[$id]
+ ;
+
+substring_key
+ : {(validateIdentifierKey("substring"))}?=> id=IDENTIFIER
+ -> SUBSTRING[$id]
+ ;
+
+concat_key
+ : {(validateIdentifierKey("concat"))}?=> id=IDENTIFIER
+ -> CONCAT[$id]
+ ;
+
+cast_key
+ : {(validateIdentifierKey("cast"))}?=> id=IDENTIFIER
+ -> CAST[$id]
+ ;
+
+any_key
+ : {(validateIdentifierKey("any"))}?=> id=IDENTIFIER
+ -> ANY[$id]
+ ;
+
+exists_key
+ : {(validateIdentifierKey("exists"))}?=> id=IDENTIFIER
+ -> EXISTS[$id]
+ ;
+
+some_key
+ : {(validateIdentifierKey("some"))}?=> id=IDENTIFIER
+ -> SOME[$id]
+ ;
+
+then_key
+ : {(validateIdentifierKey("then"))}?=> id=IDENTIFIER
+ -> THEN[$id]
+ ;
+
+end_key
+ : {(validateIdentifierKey("end"))}?=> id=IDENTIFIER
+ -> END[$id]
+ ;
+
+
+when_key
+ : {(validateIdentifierKey("when"))}?=> id=IDENTIFIER
+ -> WHEN[$id]
+ ;
+
+nullif_key
+ : {(validateIdentifierKey("nullif"))}?=> id=IDENTIFIER
+ -> NULLIF[$id]
+ ;
+
+coalesce_key
+ : {(validateIdentifierKey("coalesce"))}?=> id=IDENTIFIER
+ -> COALESCE[$id]
+ ;
+
+escape_key
+ : {(validateIdentifierKey("escape"))}?=> id=IDENTIFIER
+ -> ESCAPE[$id]
+ ;
+
+like_key
+ : {(validateIdentifierKey("like"))}?=> id=IDENTIFIER
+ -> LIKE[$id]
+ ;
+
+between_key
+ : {(validateIdentifierKey("between"))}?=> id=IDENTIFIER
+ -> BETWEEN[$id]
+ ;
+
+member_of_key
+@init{
+ String text = "";
+} : {(validateIdentifierKey("member") && validateLT(2, "of"))}?=> id=IDENTIFIER IDENTIFIER {text = $text;}
+ -> MEMBER_OF[$id]
+ ;
+
+empty_key
+ : {(validateIdentifierKey("empty"))}?=> id=IDENTIFIER
+ ;
+
+is_key : {(validateIdentifierKey("is"))}?=> id=IDENTIFIER
+ -> IS[$id]
+ ;
+
+or_key : {(validateIdentifierKey("or"))}?=> id=IDENTIFIER
+ -> OR[$id]
+ ;
+
+and_key : {(validateIdentifierKey("and"))}?=> id=IDENTIFIER
+ -> AND[$id]
+ ;
+
+not_key : {(validateIdentifierKey("not"))}?=> id=IDENTIFIER
+ -> NOT[$id]
+ ;
+
+set_key
+ : {(validateIdentifierKey("set"))}?=> id=IDENTIFIER
+ -> SET[$id]
+ ;
+
+versioned_key
+ : {(validateIdentifierKey("versioned"))}?=> id=IDENTIFIER
+ -> VERSIONED[$id]
+ ;
+
+udpate_key
+ : {(validateIdentifierKey("update"))}?=> id=IDENTIFIER
+ -> UPDATE[$id]
+ ;
+
+delete_key
+ : {(validateIdentifierKey("delete"))}?=> id=IDENTIFIER
+ -> DELETE[$id]
+ ;
+
+insert_key
+ : {(validateIdentifierKey("insert"))}?=> id=IDENTIFIER
+ -> INSERT[$id]
+ ;
+
+into_key
+ : {(validateIdentifierKey("into"))}?=> id=IDENTIFIER
+ -> INTO[$id]
+ ;
+
+having_key
+ : {(validateIdentifierKey("having"))}?=> id=IDENTIFIER
+ -> HAVING[$id]
+ ;
+
+with_key
+ : {(validateIdentifierKey("with"))}?=> id=IDENTIFIER
+ -> WITH[$id]
+ ;
+
+on_key
+ : {(validateIdentifierKey("on"))}?=> id=IDENTIFIER
+ -> ON[$id]
+ ;
+
+indices_key
+ : {(validateIdentifierKey("indices"))}?=> id=IDENTIFIER
+ -> INDICES[$id]
+ ;
+
+cross_key
+ : {(validateIdentifierKey("cross"))}?=> id=IDENTIFIER
+ -> CROSS[$id]
+ ;
+
+join_key
+ : {(validateIdentifierKey("join"))}?=> id=IDENTIFIER
+ -> JOIN[$id]
+ ;
+
+inner_key
+ : {(validateIdentifierKey("inner"))}?=> id=IDENTIFIER
+ -> INNER[$id]
+ ;
+
+outer_key
+ : {(validateIdentifierKey("outer"))}?=> id=IDENTIFIER
+ -> OUTER[$id]
+ ;
+
+left_key
+ : {(validateIdentifierKey("left"))}?=> id=IDENTIFIER
+ -> LEFT[$id]
+ ;
+
+right_key
+ : {(validateIdentifierKey("right"))}?=> id=IDENTIFIER
+ -> RIGHT[$id]
+ ;
+
+full_key
+ : {(validateIdentifierKey("full"))}?=> id=IDENTIFIER
+ -> FULL[$id]
+ ;
+
+elements_key
+ : {(validateIdentifierKey("elements"))}?=> id=IDENTIFIER
+ -> ELEMENTS[$id]
+ ;
+
+properties_key
+ : {(validateIdentifierKey("properties"))}?=> id=IDENTIFIER
+ -> PROPERTIES[$id]
+ ;
+
+fetch_key
+ : {(validateIdentifierKey("fetch"))}?=> id=IDENTIFIER
+ -> FETCH[$id]
+ ;
+
+in_key
+ : {(validateIdentifierKey("in"))}?=> id=IDENTIFIER
+ -> IN[$id]
+ ;
+
+as_key
+ : {(validateIdentifierKey("as"))}?=> id=IDENTIFIER
+ -> AS[$id]
+ ;
+
+where_key
+ : {(validateIdentifierKey("where"))}?=> id=IDENTIFIER
+ -> WHERE[$id]
+ ;
+
+select_key
+ : {(validateIdentifierKey("select"))}?=> id=IDENTIFIER
+ -> SELECT[$id]
+ ;
+
+distinct_key
+ : {(validateIdentifierKey("distinct"))}?=> id=IDENTIFIER
+ -> DISTINCT[$id]
+ ;
+
+union_key
+ : {(validateIdentifierKey("union"))}?=> id=IDENTIFIER
+ -> UNION[$id]
+ ;
+
+intersect_key
+ : {(validateIdentifierKey("intersect"))}?=> id=IDENTIFIER
+ -> INTERSECT[$id]
+ ;
+
+except_key
+ : {(validateIdentifierKey("except"))}?=> id=IDENTIFIER
+ -> EXCEPT[$id]
+ ;
+
+all_key
+ : {(validateIdentifierKey("all"))}?=> id=IDENTIFIER
+ -> ALL[$id]
+ ;
+
+ascending_key
+ : {(validateIdentifierKey("ascending") || validateIdentifierKey("asc"))}?=> id=IDENTIFIER
+ -> ASC[$id]
+ ;
+
+descending_key
+ : {(validateIdentifierKey("descending") || validateIdentifierKey("desc"))}?=> id=IDENTIFIER
+ -> DESC[$id]
+ ;
+
+collate_key
+ : {(validateIdentifierKey("collate"))}?=> IDENTIFIER
+ ;
+
+order_by_key
+@init{
+ String text = "";
+} : {(validateIdentifierKey("order") && validateLT(2, "by"))}?=> id=IDENTIFIER IDENTIFIER {text = $text;}
+ -> ORDER_BY[$id]
+ ;
+
+group_by_key
+@init{
+ String text = "";
+} : {(validateIdentifierKey("group") && validateLT(2, "by"))}?=> id=IDENTIFIER IDENTIFIER {text = $text;}
+ -> GROUP_BY[$id]
+ ;
+
+from_key
+ : {(validateIdentifierKey("from"))}?=> id=IDENTIFIER
+ -> FROM[$id]
+ ;
\ No newline at end of file
Property changes on: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQLParser.g
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g 2009-04-23 16:52:44 UTC (rev 16430)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g 2009-04-23 17:38:50 UTC (rev 16431)
@@ -3,7 +3,7 @@
options{
output=AST;
rewrite=true;
- tokenVocab=HQL;
+ tokenVocab=HQLLexer;
ASTLabelType=CommonTree;
TokenLabelType=CommonToken;
}
Modified: core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g
===================================================================
--- core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g 2009-04-23 16:52:44 UTC (rev 16430)
+++ core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g 2009-04-23 17:38:50 UTC (rev 16431)
@@ -3,7 +3,7 @@
options{
output=AST;
rewrite=true;
- tokenVocab=HQL;
+ tokenVocab=HQLLexer;
ASTLabelType=CommonTree;
TokenLabelType=CommonToken;
}
15 years, 7 months
Hibernate SVN: r16430 - core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/path/impl.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-04-23 12:52:44 -0400 (Thu, 23 Apr 2009)
New Revision: 16430
Modified:
core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/path/impl/AbstractPathResolutionStrategy.java
Log:
corrected out-of-date assumption about return from createJoin() in createIndexAccessJoin()
Modified: core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/path/impl/AbstractPathResolutionStrategy.java
===================================================================
--- core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/path/impl/AbstractPathResolutionStrategy.java 2009-04-23 16:31:31 UTC (rev 16429)
+++ core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/path/impl/AbstractPathResolutionStrategy.java 2009-04-23 16:52:44 UTC (rev 16430)
@@ -428,18 +428,18 @@
validateIndexedCollectionReference( lhs, collectionPropertyName );
QueryableCollection collectionPersister = resolveCollectionPersister( lhs, collectionPropertyName );
- HibernateTree join = createJoin( lhs, collectionPersister, null, selector );
+ Table joinedTable = createJoin( lhs, collectionPersister, null, selector );
if ( log.isTraceEnabled() ) {
log.trace(
resolutionContext().getTreePrinter().renderAsString(
- join,
+ joinedTable.getParent(),
"implicit join : " + lhs.getSourceAlias() + "." + collectionPropertyName + "[]"
)
);
}
- return ( Table ) join.getChild( 1 );
+ return joinedTable;
}
/**
15 years, 7 months
Hibernate SVN: r16429 - in core/branches/antlr3: src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse and 9 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-04-23 12:31:31 -0400 (Thu, 23 Apr 2009)
New Revision: 16429
Added:
core/branches/antlr3/src/test/antlr3/
core/branches/antlr3/src/test/antlr3/org/
core/branches/antlr3/src/test/antlr3/org/hibernate/
core/branches/antlr3/src/test/antlr3/org/hibernate/sql/
core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/
core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/
core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/
core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/
core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g
Removed:
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g
Modified:
core/branches/antlr3/pom.xml
Log:
moved TestHQLTreeWalker to src/test/antlr3 + appropriate pom changes
Modified: core/branches/antlr3/pom.xml
===================================================================
--- core/branches/antlr3/pom.xml 2009-04-23 16:28:09 UTC (rev 16428)
+++ core/branches/antlr3/pom.xml 2009-04-23 16:31:31 UTC (rev 16429)
@@ -196,6 +196,18 @@
<goal>gunit</goal>
</goals>
</execution>
+ <execution>
+ <id>test-grammar-processing</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
+ <configuration>
+ <sourceDirectory>${basedir}/src/test/antlr3</sourceDirectory>
+ <outputDirectory>${basedir}/target/generated-test-sources/antlr3</outputDirectory>
+ <libDirectory>${basedir}/target/generated-sources/antlr3</libDirectory>
+ </configuration>
+ </execution>
</executions>
</plugin>
Deleted: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g 2009-04-23 16:28:09 UTC (rev 16428)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g 2009-04-23 16:31:31 UTC (rev 16429)
@@ -1,499 +0,0 @@
-tree grammar TestHQLTreeWalker;
-
-options{
- output=AST;
- rewrite=true;
- tokenVocab=HQL;
- ASTLabelType=CommonTree;
- TokenLabelType=CommonToken;
-}
-
-@header {
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- *
- * Portions of SQL grammar parsing copyright (C) 2003 by Lubos Vnuk. All rights
- * reserved. These portions are distributed under license by Red Hat Middleware
- * LLC and are covered by the above LGPL notice. If you redistribute this material,
- * with or without modification, you must preserve this copyright notice in its
- * entirety.
- */
-package org.hibernate.sql.ast.phase.hql.parse;
-}
-
-filterStatement[String collectionRole]
- : ^(QUERY ^(QUERY_SPEC FILTER
- selectClause? whereClause? ( groupByClause havingClause?)? orderByClause?))
- ;
-
-statement
- : updateStatementSet
- | deleteStatementSet
- | insertStatementSet
- | queryStatementSet
- ;
-
-updateStatementSet
- : updateStatement+
- ;
-
-updateStatement
- : ^(UPDATE entityName ^(SET assignment+) whereClause?)
- ;
-
-assignment
- : ^(EQUALS propertyReference valueExpression)
- | ^(EQUALS VERSIONED_VALUE STRING_LITERAL)
- ;
-
-deleteStatementSet
- : deleteStatement+
- ;
-
-deleteStatement
- : ^(DELETE entityName whereClause?)
- ;
-
-insertStatementSet
- : insertStatement+
- ;
-
-insertStatement
- : ^(INSERT intoClause queryStatementSet)
- ;
-
-intoClause
- : ^(INTO entityName ^(INSERTABILITY_SPEC propertyReference+ ) )
- ;
-
-queryStatementSet
- : queryStatement+
- ;
-
-queryStatement
- : ^(QUERY queryExpression orderByClause?)
- ;
-
-queryExpression
- : ^(UNION ALL? queryExpression queryExpression)
- | ^(INTERSECT ALL? queryExpression queryExpression)
- | ^(EXCEPT ALL? queryExpression queryExpression)
- | querySpec
- ;
-
-querySpec
- : ^(QUERY_SPEC selectFrom whereClause? groupByClause? havingClause?)
- ;
-
-whereClause
- : ^(WHERE searchCondition)
- ;
-
-groupByClause
- : ^(GROUP_BY groupingValue+)
- ;
-
-groupingValue
- : ^(GROUPING_VALUE valueExpression COLLATE?)
- ;
-
-havingClause
- : ^(HAVING searchCondition)
- ;
-
-selectFrom
- : ^(SELECT_FROM fromClause selectClause)
- ;
-
-fromClause
- : ^(FROM persisterSpaces+)
- ;
-
-persisterSpaces
- : ^(PERSISTER_SPACE persisterSpace)
- ;
-
-persisterSpace
- : persisterSpaceRoot joins*
- ;
-
-persisterSpaceRoot
- : ^(ENTITY_PERSISTER_REF entityName PROP_FETCH?)
- ;
-
-joins
- : ^(PROPERTY_JOIN joinType FETCH? ALIAS_NAME PROP_FETCH? (collectionExpression|propertyReference) withClause?)
- | ^(PERSISTER_JOIN joinType persisterSpaceRoot onClause?)
- ;
-
-withClause
- : ^(WITH searchCondition)
- ;
-
-onClause
- : ^(ON searchCondition)
- ;
-
-joinType
- : CROSS
- | INNER
- | (LEFT | RIGHT | FULL) OUTER?
- ;
-
-selectClause
- : ^(SELECT DISTINCT? rootSelectExpression)
- ;
-
-rootSelectExpression
- : ^(SELECT_LIST rootSelectExpression+)
- | ^(SELECT_ITEM rootSelectExpression)
- | ^(DYNAMIC_INSTANTIATION rootSelectExpression+)
- | ^(DYNAMIC_INSTANTIATION_ARG rootSelectExpression)
- | valueExpression ALIAS_NAME?
- ;
-
-orderByClause
- : ^(ORDER_BY sortSpecification+)
- ;
-
-sortSpecification
- : ^(SORT_SPEC valueExpression COLLATE? (ASC|DESC))
- ;
-
-searchCondition
- : ^( OR searchCondition searchCondition )
- | ^( AND searchCondition searchCondition )
- | ^( NOT searchCondition )
- | predicate
- ;
-
-predicate
- : ^( EQUALS rowValueConstructor comparativePredicateValue )
- | ^( NOT_EQUAL rowValueConstructor comparativePredicateValue )
- | ^( LESS rowValueConstructor comparativePredicateValue )
- | ^( LESS_EQUAL rowValueConstructor comparativePredicateValue )
- | ^( GREATER rowValueConstructor comparativePredicateValue )
- | ^( GREATER_EQUAL rowValueConstructor comparativePredicateValue )
- | ^( IS_NULL rowValueConstructor )
- | ^( IS_NOT_NULL rowValueConstructor )
- | ^( LIKE valueExpression valueExpression escapeSpecification? )
- | ^( NOT_LIKE valueExpression valueExpression escapeSpecification? )
- | ^( BETWEEN rowValueConstructor betweenList )
- | ^( NOT_BETWEEN rowValueConstructor betweenList )
- | ^( IN rowValueConstructor inPredicateValue )
- | ^( NOT_IN rowValueConstructor inPredicateValue )
- | ^( MEMBER_OF rowValueConstructor rowValueConstructor )
- | ^( NOT_MEMBER_OF rowValueConstructor rowValueConstructor )
- | ^( IS_EMPTY rowValueConstructor )
- | ^( IS_NOT_EMPTY rowValueConstructor )
- | rowValueConstructor
- ;
-
-betweenList
- : ^( BETWEEN_LIST rowValueConstructor rowValueConstructor )
- ;
-
-comparativePredicateValue
- : rowValueConstructor
- ;
-
-rowValueConstructor
- : valueExpression
- ;
-
-escapeSpecification
- : ^(ESCAPE characterValueExpression)
- ;
-
-inPredicateValue
- : ^(IN_LIST valueExpression+)
- ;
-
-numericValueExpression
- : valueExpression
- ;
-
-characterValueExpression
- : valueExpression
- ;
-
-datetimeValueExpression
- : valueExpression
- ;
-
-valueExpression
- : ^( DOUBLE_PIPE characterValueExpression+ )
- | ^( UNARY_MINUS numericValueExpression )
- | ^( UNARY_PLUS numericValueExpression )
- | ^( PLUS valueExpression valueExpression )
- | ^( MINUS valueExpression valueExpression )
- | ^( ASTERISK numericValueExpression numericValueExpression )
- | ^( SOLIDUS numericValueExpression numericValueExpression )
- | ^( EXISTS rowValueConstructor)
- | ^( SOME valueExpression )
- | ^( ALL valueExpression )
- | ^( ANY valueExpression )
- | ^( VECTOR_EXPR valueExpression+) // or a tuples or ^(AND or IN statement
- | valueExpressionPrimary
- ;
-
-valueExpressionPrimary
- : caseExpression
- | function
- | collectionFunction
- | collectionExpression
- | constant
- | parameter
- | propertyReference
- | ^(SUB_QUERY queryStatementSet)
- | ALIAS_REF //ID COLUMN, full property column list
- | ^(DOT_CLASS identPrimary) // crazy
- | ^(GENERAL_FUNCTION_CALL identPrimary)
- | ^(JAVA_CONSTANT identPrimary) //It will generate at SQL a parameter element (?) -> 'cos we do not need to care about char escaping
- | ^(PATH identPrimary)
- ;
-
-caseExpression
- : ^(NULLIF valueExpression valueExpression)
- | ^(COALESCE valueExpression valueExpression*)
- | ^(SIMPLE_CASE valueExpression simpleCaseWhenClause+ elseClause?)
- | ^(SEARCHED_CASE searchedWhenClause+ elseClause?)
- ;
-
-simpleCaseWhenClause
- : ^(WHEN valueExpression valueExpression)
- ;
-
-searchedWhenClause
- : ^(WHEN searchCondition valueExpression)
- ;
-
-elseClause
- : ^(ELSE valueExpression)
- ;
-
-function
- : standardFunction
- | setFunction
- ;
-
-standardFunction
- : castFunction
- | concatFunction
- | substringFunction
- | trimFunction
- | upperFunction
- | lowerFunction
- | lengthFunction
- | locateFunction
- | absFunction
- | sqrtFunction
- | modFunction
- | sizeFunction
- | indexFunction
- | currentDateFunction
- | currentTimeFunction
- | currentTimestampFunction
- | extractFunction
- | positionFunction
- | charLengthFunction
- | octetLengthFunction
- | bitLengthFunction
- ;
-
-castFunction
- : ^(CAST valueExpression IDENTIFIER)
- ;
-
-concatFunction
- : ^(CONCAT valueExpression+)
- ;
-
-substringFunction
- : ^(SUBSTRING characterValueExpression numericValueExpression numericValueExpression?)
- ;
-
-trimFunction
- : ^(TRIM trimOperands)
- ;
-
-trimOperands
- : ^((LEADING|TRAILING|BOTH) characterValueExpression characterValueExpression)
- ;
-
-upperFunction
- : ^(UPPER characterValueExpression)
- ;
-
-lowerFunction
- : ^(LOWER characterValueExpression)
- ;
-
-lengthFunction
- : ^(LENGTH characterValueExpression)
- ;
-
-locateFunction
- : ^(LOCATE characterValueExpression characterValueExpression numericValueExpression?)
- ;
-
-absFunction
- : ^(ABS numericValueExpression)
- ;
-
-sqrtFunction
- : ^(SQRT numericValueExpression)
- ;
-
-modFunction
- : ^(MOD numericValueExpression numericValueExpression)
- ;
-
-sizeFunction
- : ^(SIZE propertyReference)
- ;
-
-indexFunction
- : ^(INDEX ALIAS_REF)
- ;
-
-currentDateFunction
- : CURRENT_DATE
- ;
-
-currentTimeFunction
- : CURRENT_TIME
- ;
-
-currentTimestampFunction
- : CURRENT_TIMESTAMP
- ;
-
-extractFunction
- : ^(EXTRACT extractField datetimeValueExpression)
- ;
-
-extractField
- : datetimeField
- | timeZoneField
- ;
-
-datetimeField
- : YEAR
- | MONTH
- | DAY
- | HOUR
- | MINUTE
- | SECOND
- ;
-
-timeZoneField
- : TIMEZONE_HOUR
- | TIMEZONE_MINUTE
- ;
-
-positionFunction
- : ^(POSITION characterValueExpression characterValueExpression)
- ;
-
-charLengthFunction
- : ^(CHARACTER_LENGTH characterValueExpression)
- ;
-
-octetLengthFunction
- : ^(OCTET_LENGTH characterValueExpression)
- ;
-
-bitLengthFunction
- : ^(BIT_LENGTH characterValueExpression)
- ;
-
-setFunction
- : ^(SUM numericValueExpression)
- | ^(AVG numericValueExpression)
- | ^(MAX numericValueExpression)
- | ^(MIN numericValueExpression)
- | ^(COUNT (ASTERISK | (DISTINCT|ALL) countFunctionArguments))
- ;
-
-countFunctionArguments
- : collectionExpression
- | propertyReference
- | numeric_literal
- ;
-
-collectionFunction
- : ^((MAXELEMENT|MAXINDEX|MINELEMENT|MININDEX) collectionPropertyReference)
- //it will generate a SELECT MAX (m.column) form Table xxx -> it is realted to Hibernate mappings to Table->Map
- ;
-
-collectionPropertyReference
- : propertyReference
- ;
-
-collectionExpression
- : ^(ELEMENTS propertyReference) //it will generate a SELECT m.column form Table xxx -> it is realted to Hibernate mappings to Table->Map
- | ^(INDICES propertyReference)
- ;
-
-parameter
- : NAMED_PARAM
- | JPA_PARAM
- | PARAM
- ;
-
-constant
- : literal
- | NULL
- | TRUE
- | FALSE
- ;
-
-literal
- : numeric_literal
- | HEX_LITERAL
- | OCTAL_LITERAL
- | CHARACTER_LITERAL
- | STRING_LITERAL
- ;
-
-numeric_literal
- : INTEGER_LITERAL
- | DECIMAL_LITERAL
- | FLOATING_POINT_LITERAL
- ;
-
-entityName
- : ENTITY_NAME ALIAS_NAME
- ;
-
-propertyReference
- : ^(PROPERTY_REFERENCE identPrimary)
- ;
-
-identPrimary
- : IDENTIFIER
- | ^(DOT identPrimary identPrimary )
- | ^(LEFT_SQUARE identPrimary valueExpression* )
- | ^(LEFT_PAREN identPrimary valueExpression* )
- ;
\ No newline at end of file
Copied: core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g (from rev 16425, core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g)
===================================================================
--- core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g (rev 0)
+++ core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g 2009-04-23 16:31:31 UTC (rev 16429)
@@ -0,0 +1,499 @@
+tree grammar TestHQLTreeWalker;
+
+options{
+ output=AST;
+ rewrite=true;
+ tokenVocab=HQL;
+ ASTLabelType=CommonTree;
+ TokenLabelType=CommonToken;
+}
+
+@header {
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ * Portions of SQL grammar parsing copyright (C) 2003 by Lubos Vnuk. All rights
+ * reserved. These portions are distributed under license by Red Hat Middleware
+ * LLC and are covered by the above LGPL notice. If you redistribute this material,
+ * with or without modification, you must preserve this copyright notice in its
+ * entirety.
+ */
+package org.hibernate.sql.ast.phase.hql.parse;
+}
+
+filterStatement[String collectionRole]
+ : ^(QUERY ^(QUERY_SPEC FILTER
+ selectClause? whereClause? ( groupByClause havingClause?)? orderByClause?))
+ ;
+
+statement
+ : updateStatementSet
+ | deleteStatementSet
+ | insertStatementSet
+ | queryStatementSet
+ ;
+
+updateStatementSet
+ : updateStatement+
+ ;
+
+updateStatement
+ : ^(UPDATE entityName ^(SET assignment+) whereClause?)
+ ;
+
+assignment
+ : ^(EQUALS propertyReference valueExpression)
+ | ^(EQUALS VERSIONED_VALUE STRING_LITERAL)
+ ;
+
+deleteStatementSet
+ : deleteStatement+
+ ;
+
+deleteStatement
+ : ^(DELETE entityName whereClause?)
+ ;
+
+insertStatementSet
+ : insertStatement+
+ ;
+
+insertStatement
+ : ^(INSERT intoClause queryStatementSet)
+ ;
+
+intoClause
+ : ^(INTO entityName ^(INSERTABILITY_SPEC propertyReference+ ) )
+ ;
+
+queryStatementSet
+ : queryStatement+
+ ;
+
+queryStatement
+ : ^(QUERY queryExpression orderByClause?)
+ ;
+
+queryExpression
+ : ^(UNION ALL? queryExpression queryExpression)
+ | ^(INTERSECT ALL? queryExpression queryExpression)
+ | ^(EXCEPT ALL? queryExpression queryExpression)
+ | querySpec
+ ;
+
+querySpec
+ : ^(QUERY_SPEC selectFrom whereClause? groupByClause? havingClause?)
+ ;
+
+whereClause
+ : ^(WHERE searchCondition)
+ ;
+
+groupByClause
+ : ^(GROUP_BY groupingValue+)
+ ;
+
+groupingValue
+ : ^(GROUPING_VALUE valueExpression COLLATE?)
+ ;
+
+havingClause
+ : ^(HAVING searchCondition)
+ ;
+
+selectFrom
+ : ^(SELECT_FROM fromClause selectClause)
+ ;
+
+fromClause
+ : ^(FROM persisterSpaces+)
+ ;
+
+persisterSpaces
+ : ^(PERSISTER_SPACE persisterSpace)
+ ;
+
+persisterSpace
+ : persisterSpaceRoot joins*
+ ;
+
+persisterSpaceRoot
+ : ^(ENTITY_PERSISTER_REF entityName PROP_FETCH?)
+ ;
+
+joins
+ : ^(PROPERTY_JOIN joinType FETCH? ALIAS_NAME PROP_FETCH? (collectionExpression|propertyReference) withClause?)
+ | ^(PERSISTER_JOIN joinType persisterSpaceRoot onClause?)
+ ;
+
+withClause
+ : ^(WITH searchCondition)
+ ;
+
+onClause
+ : ^(ON searchCondition)
+ ;
+
+joinType
+ : CROSS
+ | INNER
+ | (LEFT | RIGHT | FULL) OUTER?
+ ;
+
+selectClause
+ : ^(SELECT DISTINCT? rootSelectExpression)
+ ;
+
+rootSelectExpression
+ : ^(SELECT_LIST rootSelectExpression+)
+ | ^(SELECT_ITEM rootSelectExpression)
+ | ^(DYNAMIC_INSTANTIATION rootSelectExpression+)
+ | ^(DYNAMIC_INSTANTIATION_ARG rootSelectExpression)
+ | valueExpression ALIAS_NAME?
+ ;
+
+orderByClause
+ : ^(ORDER_BY sortSpecification+)
+ ;
+
+sortSpecification
+ : ^(SORT_SPEC valueExpression COLLATE? (ASC|DESC))
+ ;
+
+searchCondition
+ : ^( OR searchCondition searchCondition )
+ | ^( AND searchCondition searchCondition )
+ | ^( NOT searchCondition )
+ | predicate
+ ;
+
+predicate
+ : ^( EQUALS rowValueConstructor comparativePredicateValue )
+ | ^( NOT_EQUAL rowValueConstructor comparativePredicateValue )
+ | ^( LESS rowValueConstructor comparativePredicateValue )
+ | ^( LESS_EQUAL rowValueConstructor comparativePredicateValue )
+ | ^( GREATER rowValueConstructor comparativePredicateValue )
+ | ^( GREATER_EQUAL rowValueConstructor comparativePredicateValue )
+ | ^( IS_NULL rowValueConstructor )
+ | ^( IS_NOT_NULL rowValueConstructor )
+ | ^( LIKE valueExpression valueExpression escapeSpecification? )
+ | ^( NOT_LIKE valueExpression valueExpression escapeSpecification? )
+ | ^( BETWEEN rowValueConstructor betweenList )
+ | ^( NOT_BETWEEN rowValueConstructor betweenList )
+ | ^( IN rowValueConstructor inPredicateValue )
+ | ^( NOT_IN rowValueConstructor inPredicateValue )
+ | ^( MEMBER_OF rowValueConstructor rowValueConstructor )
+ | ^( NOT_MEMBER_OF rowValueConstructor rowValueConstructor )
+ | ^( IS_EMPTY rowValueConstructor )
+ | ^( IS_NOT_EMPTY rowValueConstructor )
+ | rowValueConstructor
+ ;
+
+betweenList
+ : ^( BETWEEN_LIST rowValueConstructor rowValueConstructor )
+ ;
+
+comparativePredicateValue
+ : rowValueConstructor
+ ;
+
+rowValueConstructor
+ : valueExpression
+ ;
+
+escapeSpecification
+ : ^(ESCAPE characterValueExpression)
+ ;
+
+inPredicateValue
+ : ^(IN_LIST valueExpression+)
+ ;
+
+numericValueExpression
+ : valueExpression
+ ;
+
+characterValueExpression
+ : valueExpression
+ ;
+
+datetimeValueExpression
+ : valueExpression
+ ;
+
+valueExpression
+ : ^( DOUBLE_PIPE characterValueExpression+ )
+ | ^( UNARY_MINUS numericValueExpression )
+ | ^( UNARY_PLUS numericValueExpression )
+ | ^( PLUS valueExpression valueExpression )
+ | ^( MINUS valueExpression valueExpression )
+ | ^( ASTERISK numericValueExpression numericValueExpression )
+ | ^( SOLIDUS numericValueExpression numericValueExpression )
+ | ^( EXISTS rowValueConstructor)
+ | ^( SOME valueExpression )
+ | ^( ALL valueExpression )
+ | ^( ANY valueExpression )
+ | ^( VECTOR_EXPR valueExpression+) // or a tuples or ^(AND or IN statement
+ | valueExpressionPrimary
+ ;
+
+valueExpressionPrimary
+ : caseExpression
+ | function
+ | collectionFunction
+ | collectionExpression
+ | constant
+ | parameter
+ | propertyReference
+ | ^(SUB_QUERY queryStatementSet)
+ | ALIAS_REF //ID COLUMN, full property column list
+ | ^(DOT_CLASS identPrimary) // crazy
+ | ^(GENERAL_FUNCTION_CALL identPrimary)
+ | ^(JAVA_CONSTANT identPrimary) //It will generate at SQL a parameter element (?) -> 'cos we do not need to care about char escaping
+ | ^(PATH identPrimary)
+ ;
+
+caseExpression
+ : ^(NULLIF valueExpression valueExpression)
+ | ^(COALESCE valueExpression valueExpression*)
+ | ^(SIMPLE_CASE valueExpression simpleCaseWhenClause+ elseClause?)
+ | ^(SEARCHED_CASE searchedWhenClause+ elseClause?)
+ ;
+
+simpleCaseWhenClause
+ : ^(WHEN valueExpression valueExpression)
+ ;
+
+searchedWhenClause
+ : ^(WHEN searchCondition valueExpression)
+ ;
+
+elseClause
+ : ^(ELSE valueExpression)
+ ;
+
+function
+ : standardFunction
+ | setFunction
+ ;
+
+standardFunction
+ : castFunction
+ | concatFunction
+ | substringFunction
+ | trimFunction
+ | upperFunction
+ | lowerFunction
+ | lengthFunction
+ | locateFunction
+ | absFunction
+ | sqrtFunction
+ | modFunction
+ | sizeFunction
+ | indexFunction
+ | currentDateFunction
+ | currentTimeFunction
+ | currentTimestampFunction
+ | extractFunction
+ | positionFunction
+ | charLengthFunction
+ | octetLengthFunction
+ | bitLengthFunction
+ ;
+
+castFunction
+ : ^(CAST valueExpression IDENTIFIER)
+ ;
+
+concatFunction
+ : ^(CONCAT valueExpression+)
+ ;
+
+substringFunction
+ : ^(SUBSTRING characterValueExpression numericValueExpression numericValueExpression?)
+ ;
+
+trimFunction
+ : ^(TRIM trimOperands)
+ ;
+
+trimOperands
+ : ^((LEADING|TRAILING|BOTH) characterValueExpression characterValueExpression)
+ ;
+
+upperFunction
+ : ^(UPPER characterValueExpression)
+ ;
+
+lowerFunction
+ : ^(LOWER characterValueExpression)
+ ;
+
+lengthFunction
+ : ^(LENGTH characterValueExpression)
+ ;
+
+locateFunction
+ : ^(LOCATE characterValueExpression characterValueExpression numericValueExpression?)
+ ;
+
+absFunction
+ : ^(ABS numericValueExpression)
+ ;
+
+sqrtFunction
+ : ^(SQRT numericValueExpression)
+ ;
+
+modFunction
+ : ^(MOD numericValueExpression numericValueExpression)
+ ;
+
+sizeFunction
+ : ^(SIZE propertyReference)
+ ;
+
+indexFunction
+ : ^(INDEX ALIAS_REF)
+ ;
+
+currentDateFunction
+ : CURRENT_DATE
+ ;
+
+currentTimeFunction
+ : CURRENT_TIME
+ ;
+
+currentTimestampFunction
+ : CURRENT_TIMESTAMP
+ ;
+
+extractFunction
+ : ^(EXTRACT extractField datetimeValueExpression)
+ ;
+
+extractField
+ : datetimeField
+ | timeZoneField
+ ;
+
+datetimeField
+ : YEAR
+ | MONTH
+ | DAY
+ | HOUR
+ | MINUTE
+ | SECOND
+ ;
+
+timeZoneField
+ : TIMEZONE_HOUR
+ | TIMEZONE_MINUTE
+ ;
+
+positionFunction
+ : ^(POSITION characterValueExpression characterValueExpression)
+ ;
+
+charLengthFunction
+ : ^(CHARACTER_LENGTH characterValueExpression)
+ ;
+
+octetLengthFunction
+ : ^(OCTET_LENGTH characterValueExpression)
+ ;
+
+bitLengthFunction
+ : ^(BIT_LENGTH characterValueExpression)
+ ;
+
+setFunction
+ : ^(SUM numericValueExpression)
+ | ^(AVG numericValueExpression)
+ | ^(MAX numericValueExpression)
+ | ^(MIN numericValueExpression)
+ | ^(COUNT (ASTERISK | (DISTINCT|ALL) countFunctionArguments))
+ ;
+
+countFunctionArguments
+ : collectionExpression
+ | propertyReference
+ | numeric_literal
+ ;
+
+collectionFunction
+ : ^((MAXELEMENT|MAXINDEX|MINELEMENT|MININDEX) collectionPropertyReference)
+ //it will generate a SELECT MAX (m.column) form Table xxx -> it is realted to Hibernate mappings to Table->Map
+ ;
+
+collectionPropertyReference
+ : propertyReference
+ ;
+
+collectionExpression
+ : ^(ELEMENTS propertyReference) //it will generate a SELECT m.column form Table xxx -> it is realted to Hibernate mappings to Table->Map
+ | ^(INDICES propertyReference)
+ ;
+
+parameter
+ : NAMED_PARAM
+ | JPA_PARAM
+ | PARAM
+ ;
+
+constant
+ : literal
+ | NULL
+ | TRUE
+ | FALSE
+ ;
+
+literal
+ : numeric_literal
+ | HEX_LITERAL
+ | OCTAL_LITERAL
+ | CHARACTER_LITERAL
+ | STRING_LITERAL
+ ;
+
+numeric_literal
+ : INTEGER_LITERAL
+ | DECIMAL_LITERAL
+ | FLOATING_POINT_LITERAL
+ ;
+
+entityName
+ : ENTITY_NAME ALIAS_NAME
+ ;
+
+propertyReference
+ : ^(PROPERTY_REFERENCE identPrimary)
+ ;
+
+identPrimary
+ : IDENTIFIER
+ | ^(DOT identPrimary identPrimary )
+ | ^(LEFT_SQUARE identPrimary valueExpression* )
+ | ^(LEFT_PAREN identPrimary valueExpression* )
+ ;
\ No newline at end of file
Property changes on: core/branches/antlr3/src/test/antlr3/org/hibernate/sql/ast/phase/hql/parse/TestHQLTreeWalker.g
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 7 months
Hibernate SVN: r16428 - core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve.
by hibernate-commits@lists.jboss.org
Author: porcelli
Date: 2009-04-23 12:28:09 -0400 (Thu, 23 Apr 2009)
New Revision: 16428
Added:
core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolver.java
Log:
renambed 2nd phase
Added: core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolver.java
===================================================================
--- core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolver.java (rev 0)
+++ core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolver.java 2009-04-23 16:28:09 UTC (rev 16428)
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import org.antlr.runtime.RecognizerSharedState;
+import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.Tree;
+import org.antlr.runtime.tree.TreeNodeStream;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.persister.entity.Queryable;
+import org.hibernate.sql.ast.alias.DefaultTableAliasGenerator;
+import org.hibernate.sql.ast.alias.TableAliasGenerator;
+import org.hibernate.sql.ast.common.HibernateTree;
+import org.hibernate.sql.ast.common.JoinType;
+import org.hibernate.sql.ast.phase.hql.parse.HQLParser;
+import org.hibernate.sql.ast.phase.hql.resolve.path.PathResolutionStrategy;
+import org.hibernate.sql.ast.phase.hql.resolve.path.PathResolutionStrategyStack;
+import org.hibernate.sql.ast.phase.hql.resolve.path.PathedPropertyReferenceSource;
+import org.hibernate.sql.ast.phase.hql.resolve.path.impl.BasicPathResolutionStrategySupport;
+import org.hibernate.sql.ast.phase.hql.resolve.path.impl.FromClausePathResolutionStrategy;
+import org.hibernate.sql.ast.phase.hql.resolve.path.impl.SelectClausePathResolutionStrategy;
+import org.hibernate.sql.ast.tree.Table;
+import org.hibernate.sql.ast.tree.Table.EntityTableSpace;
+import org.hibernate.sql.ast.util.TreePrinter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HQLResolver extends GeneratedHQLResolver implements
+ ResolutionContext {
+ private static final Logger log = LoggerFactory
+ .getLogger( HQLResolver.class );
+
+ private final SessionFactoryImplementor sessionFactory;
+ private final PersisterSpaceContext persisterSpaceContext;
+ private final DefaultTableAliasGenerator defaultTableAliasGenerator;
+ private final PathResolutionStrategyStack pathResolutionStrategyStack;
+ private final TreePrinter printer;
+
+ private boolean isProcessingFunction = false;
+
+ public HQLResolver( TreeNodeStream input,
+ SessionFactoryImplementor sessionFactory ) {
+ this( input, new RecognizerSharedState(), sessionFactory );
+ }
+
+ public HQLResolver( TreeNodeStream input, RecognizerSharedState state,
+ SessionFactoryImplementor sessionFactory ) {
+ super( input, state );
+ this.sessionFactory = sessionFactory;
+ this.persisterSpaceContext = new RootPersisterSpaceContext();
+ this.defaultTableAliasGenerator = new DefaultTableAliasGenerator(
+ sessionFactory.getDialect() );
+ this.printer = new TreePrinter( HQLParser.class );
+ this.pathResolutionStrategyStack = new PathResolutionStrategyStack();
+ this.pathResolutionStrategyStack
+ .push( new BasicPathResolutionStrategySupport( this ) );
+ }
+
+ protected void registerPersisterSpace( Tree entityName, Tree alias ) {
+ String entityPersisterName = sessionFactory
+ .getImportedClassName( entityName.getText() );
+ Queryable entityPersister = ( Queryable ) sessionFactory
+ .getEntityPersister( entityPersisterName );
+
+ TableAliasGenerator.TableAliasRoot tableAliasRoot = getTableAliasGenerator()
+ .generateSqlAliasRoot( entityPersister, alias.getText() );
+ EntityTableSpace tableSpace = new Table.EntityTableSpace(
+ entityPersister, tableAliasRoot );
+ registerPersisterSpace( tableSpace.getPersisterSpace() );
+ }
+
+ public PersisterSpaceContext getCurrentPersisterSpaceContext() {
+ return persisterSpaceContext;
+ }
+
+ public SessionFactoryImplementor getSessionFactoryImplementor() {
+ return sessionFactory;
+ }
+
+ public TableAliasGenerator getTableAliasGenerator() {
+ return defaultTableAliasGenerator;
+ }
+
+ public TreePrinter getTreePrinter() {
+ return printer;
+ }
+
+ public boolean isCurrentlyProcessingFunction() {
+ return isProcessingFunction;
+ }
+
+ public PathResolutionStrategyStack getPathResolutionStrategyStack() {
+ return pathResolutionStrategyStack;
+ }
+
+ public PathResolutionStrategy getCurrentPathResolutionStrategy() {
+ return pathResolutionStrategyStack.getCurrent();
+ }
+
+ public void registerAssociationFetch( PersisterSpace persisterSpace ) {
+ throw new UnsupportedOperationException( "must be implemented!" );
+ }
+
+ public void registerPropertyFetch( PersisterSpace persisterSpace ) {
+ throw new UnsupportedOperationException( "must be implemented!" );
+ }
+
+ protected void pushFromStrategy( JoinType joinType,
+ Tree assosiationFetchTree, Tree propertyFetchTree, Tree alias ) {
+ boolean assosiationFetch = assosiationFetchTree != null ? true : false;
+ boolean propertyFetch = propertyFetchTree != null ? true : false;
+ pathResolutionStrategyStack.push( new FromClausePathResolutionStrategy(
+ this, joinType, assosiationFetch, propertyFetch, alias
+ .getText() ) );
+ }
+
+ protected void pushSelectStrategy() {
+ pathResolutionStrategyStack
+ .push( new SelectClausePathResolutionStrategy( this ) );
+ }
+
+ protected void popStrategy() {
+ pathResolutionStrategyStack.pop();
+ }
+
+ private void registerPersisterSpace( PersisterSpace persisterSpace ) {
+ persisterSpaceContext.registerPersisterSpace( persisterSpace );
+ }
+
+ protected boolean isUnqualifiedPropertyReference() {
+ return locateOwningPersisterAlias( ( Tree ) input.LT( 1 ) ) != null;
+ }
+
+ protected String locateOwningPersisterAlias( Tree property ) {
+ PersisterSpace persisterReference = getCurrentPersisterSpaceContext()
+ .locatePersisterSpaceExposingProperty( property.getText() );
+ return persisterReference == null ? null : persisterReference
+ .getSourceAlias();
+ }
+
+ protected boolean isPersisterReferenceAlias() {
+ Tree alias = ( Tree ) input.LT( 1 );
+ log.trace( "Checking [" + textOrNull( alias )
+ + "] as persister-ref alias" );
+ return getCurrentPersisterSpaceContext().isContainedAlias(
+ alias.getText() );
+ }
+
+ protected PathedPropertyReferenceSource normalizeUnqualifiedPropertyReference(
+ Tree property ) {
+ return getCurrentPathResolutionStrategy().handleRoot(
+ getCurrentPersisterSpaceContext()
+ .locatePersisterSpaceExposingProperty(
+ property.getText() ) );
+ }
+
+ protected PathedPropertyReferenceSource normalizeUnqualifiedRoot(
+ Tree propertyName ) {
+ log.debug( "normalizing path expression root as unqualified property ["
+ + textOrNull( propertyName ) + "]" );
+ PathedPropertyReferenceSource root = getCurrentPathResolutionStrategy()
+ .handleRoot(
+ getCurrentPersisterSpaceContext()
+ .locatePersisterSpaceExposingProperty(
+ propertyName.getText() ) );
+ return root.handleIntermediatePathPart( propertyName.getText() );
+ }
+
+ protected PathedPropertyReferenceSource normalizeQualifiedRoot( Tree alias ) {
+ log.debug( "normalizing path expression root as alias ["
+ + alias.getText() + "]" );
+ return getCurrentPathResolutionStrategy().handleRoot(
+ getCurrentPersisterSpaceContext().locatePersisterSpaceByAlias(
+ alias.getText() ) );
+ }
+
+ protected Tree normalizePropertyPathTerminus(
+ PathedPropertyReferenceSource source, Tree propertyNameNode ) {
+ log.trace( "normalizing terminal path expression ["
+ + textOrNull( propertyNameNode ) + "]" );
+ return getCurrentPathResolutionStrategy().handleTerminalPathPart(
+ source, propertyNameNode.getText() );
+ }
+
+ protected PathedPropertyReferenceSource normalizePropertyPathIntermediary(
+ PathedPropertyReferenceSource source, Tree propertyName ) {
+ log.trace( "normalizing intermediate path expression ["
+ + textOrNull( propertyName ) + "]" );
+ return getCurrentPathResolutionStrategy().handleIntermediatePathPart(
+ ( PathedPropertyReferenceSource ) source,
+ propertyName.getText() );
+ }
+
+ protected PathedPropertyReferenceSource normalizeUnqualifiedPropertyReferenceSource(
+ Tree propertyName ) {
+ return getCurrentPathResolutionStrategy().handleRoot(
+ getCurrentPersisterSpaceContext()
+ .locatePersisterSpaceExposingProperty(
+ propertyName.getText() ) );
+ }
+
+ protected void normalizeIntermediateIndexOperation(
+ PathedPropertyReferenceSource propertyReferenceSource,
+ Tree collectionProperty, Tree selector ) {
+ throw new UnsupportedOperationException(
+ "must be implemented!: normalizeIntermediateIndexOperation" );
+ }
+
+ protected void normalizeTerminalIndexOperation(
+ PathedPropertyReferenceSource propertyReferenceSource,
+ Tree collectionProperty, Tree selector ) {
+ log.trace( "normalizing terminal index access ["
+ + textOrNull( collectionProperty ) + "]" );
+ PathedPropertyReferenceSource collectionSource = propertyReferenceSource;
+ getCurrentPathResolutionStrategy().handleTerminalIndexAccess(
+ collectionSource, collectionProperty.getText(),
+ new HibernateTree( ( CommonTree ) selector ) );
+ }
+
+ private String textOrNull( Tree tree ) {
+ return tree == null ? null : tree.getText();
+ }
+
+}
\ No newline at end of file
Property changes on: core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolver.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 7 months
Hibernate SVN: r16427 - in core/branches/antlr3/src/main: java/org/hibernate/sql/ast/common and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: porcelli
Date: 2009-04-23 12:12:38 -0400 (Thu, 23 Apr 2009)
New Revision: 16427
Modified:
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g
core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateTree.java
Log:
implementing the indexed properties resolver
Modified: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g 2009-04-23 16:01:18 UTC (rev 16426)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g 2009-04-23 16:12:38 UTC (rev 16427)
@@ -46,8 +46,8 @@
}
@members{
- protected void registerPersisterSpace(CommonTree entityName,
- CommonTree alias) {
+ protected void registerPersisterSpace(Tree entityName,
+ Tree alias) {
throw new UnsupportedOperationException( "must be overridden!" );
}
@@ -55,7 +55,7 @@
throw new UnsupportedOperationException( "must be overridden!" );
}
- protected PathedPropertyReferenceSource normalizeUnqualifiedPropertyReference(CommonTree property) {
+ protected PathedPropertyReferenceSource normalizeUnqualifiedPropertyReference(Tree property) {
throw new UnsupportedOperationException( "must be overridden!" );
}
@@ -63,39 +63,40 @@
throw new UnsupportedOperationException( "must be overridden!" );
}
- protected PathedPropertyReferenceSource normalizeUnqualifiedRoot( CommonTree identifier382 ) {
+ protected PathedPropertyReferenceSource normalizeUnqualifiedRoot( Tree identifier382 ) {
throw new UnsupportedOperationException( "must be overridden!" );
}
- protected PathedPropertyReferenceSource normalizeQualifiedRoot( CommonTree identifier381 ) {
+ protected PathedPropertyReferenceSource normalizeQualifiedRoot( Tree identifier381 ) {
throw new UnsupportedOperationException( "must be overridden!" );
}
- protected PathedPropertyReferenceSource normalizePropertyPathIntermediary( PathedPropertyReferenceSource source, CommonTree propertyName ) {
+ protected PathedPropertyReferenceSource normalizePropertyPathIntermediary( PathedPropertyReferenceSource source, Tree propertyName ) {
throw new UnsupportedOperationException( "must be overridden!" );
}
- protected void normalizeIntermediateIndexOperation( CommonTree commonTree,
- CommonTree commonTree2 ) {
+ protected void normalizeIntermediateIndexOperation( PathedPropertyReferenceSource propertyReferenceSource, Tree collectionProperty,
+ Tree selector ) {
throw new UnsupportedOperationException( "must be overridden!" );
}
+ protected void normalizeTerminalIndexOperation( PathedPropertyReferenceSource propertyReferenceSource, Tree collectionProperty,
+ Tree selector ) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
protected PathedPropertyReferenceSource normalizeUnqualifiedPropertyReferenceSource(
- CommonTree identifier394 ) {
+ Tree identifier394 ) {
throw new UnsupportedOperationException( "must be overridden!" );
}
- protected void normalizeTerminalIndexOperation(CommonTree collectionPath, CommonTree selector) {
+ protected Tree normalizePropertyPathTerminus(PathedPropertyReferenceSource source, Tree propertyNameNode) {
throw new UnsupportedOperationException( "must be overridden!" );
}
- protected Tree normalizePropertyPathTerminus(PathedPropertyReferenceSource source, CommonTree propertyNameNode) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
protected void pushFromStrategy( JoinType joinType,
- CommonTree assosiationFetchTree, CommonTree propertyFetchTree,
- CommonTree alias ) {
+ Tree assosiationFetchTree, Tree propertyFetchTree,
+ Tree alias ) {
throw new UnsupportedOperationException( "must be overridden!" );
}
@@ -595,18 +596,21 @@
intermediateIndexOperation
: ^( LEFT_SQUARE indexOperationSource indexSelector )
- { normalizeIntermediateIndexOperation( $indexOperationSource.tree, $indexSelector.tree ); }
+ { normalizeIntermediateIndexOperation( $indexOperationSource.propertyReferenceSource, $indexOperationSource.collectionProperty, $indexSelector.tree ); }
;
terminalIndexOperation
: ^( LEFT_SQUARE indexOperationSource indexSelector )
- { normalizeTerminalIndexOperation( $indexOperationSource.tree, $indexSelector.tree ); }
+ { normalizeTerminalIndexOperation( $indexOperationSource.propertyReferenceSource, $indexOperationSource.collectionProperty, $indexSelector.tree ); }
;
indexOperationSource returns [PathedPropertyReferenceSource propertyReferenceSource, Tree collectionProperty]
: ^(DOT pathedPropertyReferenceSource IDENTIFIER )
+ { $propertyReferenceSource = $pathedPropertyReferenceSource.propertyReferenceSource;
+ $collectionProperty = $IDENTIFIER; }
| {(isUnqualifiedPropertyReference())}?=> IDENTIFIER
- { $propertyReferenceSource = normalizeUnqualifiedPropertyReferenceSource( $IDENTIFIER ); }
+ { $propertyReferenceSource = normalizeUnqualifiedPropertyReferenceSource( $IDENTIFIER );
+ $collectionProperty = $IDENTIFIER; }
;
indexSelector
Modified: core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateTree.java
===================================================================
--- core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateTree.java 2009-04-23 16:01:18 UTC (rev 16426)
+++ core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateTree.java 2009-04-23 16:12:38 UTC (rev 16427)
@@ -56,6 +56,11 @@
this.token = node.token;
}
+ public HibernateTree(CommonTree node) {
+ super(node);
+ this.token = node.token;
+ }
+
public HibernateTree(Token token) {
super(token);
}
15 years, 7 months
Hibernate SVN: r16426 - annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/immutable.
by hibernate-commits@lists.jboss.org
Author: jcosta(a)redhat.com
Date: 2009-04-23 12:01:18 -0400 (Thu, 23 Apr 2009)
New Revision: 16426
Modified:
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/immutable/ImmutableTest.java
Log:
ANN-790 - Backporting fix
Modified: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/immutable/ImmutableTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/immutable/ImmutableTest.java 2009-04-23 15:27:36 UTC (rev 16425)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/immutable/ImmutableTest.java 2009-04-23 16:01:18 UTC (rev 16426)
@@ -60,6 +60,7 @@
germany = (Country) s.get(Country.class, country.getId());
assertNotNull(germany);
assertEquals("Name should not have changed", "Germany", germany.getName());
+ tx.commit();
s.close();
// // try deletion
15 years, 7 months
Hibernate SVN: r16425 - in core/branches/antlr3/src: main/antlr3/org/hibernate/sql/ast/phase/hql/resolve and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: porcelli
Date: 2009-04-23 11:27:36 -0400 (Thu, 23 Apr 2009)
New Revision: 16425
Added:
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g
Removed:
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolution.g
core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolution.java
Modified:
core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQL.g
core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java
Log:
recent changes on hql parser and treewalker
Modified: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQL.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQL.g 2009-04-23 14:51:55 UTC (rev 16424)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/parse/HQL.g 2009-04-23 15:27:36 UTC (rev 16425)
@@ -475,6 +475,7 @@
-> { generateUpdateStatementTree($udpate_key.tree, $entityName.tree, $aliasClause.tree, $setClause.tree, $whereClause.tree ) }
;
+//TODO: check what is necessary to generate at versioned field
setClause
: set_key assignment (COMMA assignment)*
-> {$updateStatement::generateVersionedField}? ^(set_key assignment+ ^(EQUALS VERSIONED_VALUE STRING_LITERAL))
Deleted: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolution.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolution.g 2009-04-23 14:51:55 UTC (rev 16424)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolution.g 2009-04-23 15:27:36 UTC (rev 16425)
@@ -1,621 +0,0 @@
-tree grammar GeneratedHQLResolution;
-
-options{
- output=AST;
- rewrite=true;
- tokenVocab=HQL;
- ASTLabelType=CommonTree;
- TokenLabelType=CommonToken;
-}
-
-@header {
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- *
- * Portions of SQL grammar parsing copyright (C) 2003 by Lubos Vnuk. All rights
- * reserved. These portions are distributed under license by Red Hat Middleware
- * LLC and are covered by the above LGPL notice. If you redistribute this material,
- * with or without modification, you must preserve this copyright notice in its
- * entirety.
- */
-package org.hibernate.sql.ast.phase.hql.resolve;
-
-import org.antlr.runtime.tree.CommonTree;
-import org.hibernate.sql.ast.common.JoinType;
-import org.hibernate.sql.ast.phase.hql.resolve.path.PathedPropertyReferenceSource;
-}
-
-@members{
- protected void registerPersisterSpace(CommonTree entityName,
- CommonTree alias) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected boolean isUnqualifiedPropertyReference() {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected Tree normalizeUnqualifiedPropertyReference(CommonTree property) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected boolean isPersisterReferenceAlias() {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected PathedPropertyReferenceSource normalizeUnqualifiedRoot( CommonTree identifier382 ) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected PathedPropertyReferenceSource normalizeQualifiedRoot( CommonTree identifier381 ) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected PathedPropertyReferenceSource normalizePropertyPathIntermediary( PathedPropertyReferenceSource source, CommonTree propertyName ) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected void normalizeIntermediateIndexOperation( CommonTree commonTree,
- CommonTree commonTree2 ) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected void normalizeUnqualifiedPropertyReferenceSource(
- CommonTree identifier394 ) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected void normalizeTerminalIndexOperation(CommonTree collectionPath, CommonTree selector) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected void normalizePropertyPathTerminus(PathedPropertyReferenceSource source, CommonTree propertyNameNode) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected void pushFromStrategy( JoinType joinType,
- CommonTree assosiationFetchTree, CommonTree propertyFetchTree,
- CommonTree alias ) {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
- protected void pushSelectStrategy() {
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-
-
- protected void popStrategy(){
- throw new UnsupportedOperationException( "must be overridden!" );
- }
-}
-
-filterStatement[String collectionRole]
- : ^(QUERY ^(QUERY_SPEC FILTER
- selectClause? whereClause? ( groupByClause havingClause?)? orderByClause?))
- ;
-
-statement
- : updateStatementSet
- | deleteStatementSet
- | insertStatementSet
- | queryStatementSet
- ;
-
-updateStatementSet
- : updateStatement+
- ;
-
-updateStatement
- : ^(UPDATE entityName ^(SET assignment+) whereClause?)
- ;
-
-assignment
- : ^(EQUALS propertyReference valueExpression)
- | ^(EQUALS VERSIONED_VALUE STRING_LITERAL)
- ;
-
-deleteStatementSet
- : deleteStatement+
- ;
-
-deleteStatement
- : ^(DELETE entityName whereClause?)
- ;
-
-insertStatementSet
- : insertStatement+
- ;
-
-insertStatement
- : ^(INSERT intoClause queryStatementSet)
- ;
-
-intoClause
- : ^(INTO entityName ^(INSERTABILITY_SPEC propertyReference+ ) )
- ;
-
-queryStatementSet
- : queryStatement+
- ;
-
-queryStatement
- : ^(QUERY queryExpression orderByClause?)
- ;
-
-queryExpression
- : ^(UNION ALL? queryExpression queryExpression)
- | ^(INTERSECT ALL? queryExpression queryExpression)
- | ^(EXCEPT ALL? queryExpression queryExpression)
- | querySpec
- ;
-
-querySpec
- : ^(QUERY_SPEC selectFrom whereClause? groupByClause? havingClause?)
- ;
-
-whereClause
- : ^(WHERE searchCondition)
- ;
-
-groupByClause
- : ^(GROUP_BY groupingValue+)
- ;
-
-groupingValue
- : ^(GROUPING_VALUE valueExpression COLLATE?)
- ;
-
-havingClause
- : ^(HAVING searchCondition)
- ;
-
-selectFrom
- : ^(SELECT_FROM fromClause selectClause)
- ;
-
-fromClause
- : ^(FROM persisterSpaces+)
- ;
-
-persisterSpaces
- : ^(PERSISTER_SPACE persisterSpace)
- ;
-
-persisterSpace
- : persisterSpaceRoot joins*
- ;
-
-persisterSpaceRoot
- : ^(ENTITY_PERSISTER_REF entityName PROP_FETCH?)
- ;
-
-joins
- : ^(PROPERTY_JOIN jt=joinType ft=FETCH? an=ALIAS_NAME pf=PROP_FETCH?
- { pushFromStrategy($jt.joinType, $ft, $pf, $an ); }
- (collectionExpression|propertyReference) withClause?)
- { popStrategy(); }
- | ^(PERSISTER_JOIN joinType persisterSpaceRoot onClause?)
- ;
-
-withClause
- : ^(WITH searchCondition)
- ;
-
-onClause
- : ^(ON searchCondition)
- ;
-
-joinType returns [JoinType joinType]
- : CROSS { $joinType = JoinType.CROSS; }
- | INNER { $joinType = JoinType.INNER; }
- | (LEFT { $joinType = JoinType.LEFT; } | RIGHT { $joinType = JoinType.RIGHT; } | FULL { $joinType = JoinType.FULL; }) OUTER?
- ;
-
-selectClause
-@init { if (state.backtracking == 0) pushSelectStrategy(); }
-@after { popStrategy(); }
- : ^(SELECT DISTINCT? rootSelectExpression)
- ;
-
-rootSelectExpression
- : ^(SELECT_LIST rootSelectExpression+)
- | ^(SELECT_ITEM rootSelectExpression)
- | ^(DYNAMIC_INSTANTIATION rootSelectExpression+)
- | ^(DYNAMIC_INSTANTIATION_ARG rootSelectExpression)
- | valueExpression ALIAS_NAME?
- ;
-
-orderByClause
- : ^(ORDER_BY sortSpecification+)
- ;
-
-sortSpecification
- : ^(SORT_SPEC valueExpression COLLATE? (ASC|DESC))
- ;
-
-searchCondition
- : ^( OR searchCondition searchCondition )
- | ^( AND searchCondition searchCondition )
- | ^( NOT searchCondition )
- | predicate
- ;
-
-predicate
- : ^( EQUALS rowValueConstructor comparativePredicateValue )
- | ^( NOT_EQUAL rowValueConstructor comparativePredicateValue )
- | ^( LESS rowValueConstructor comparativePredicateValue )
- | ^( LESS_EQUAL rowValueConstructor comparativePredicateValue )
- | ^( GREATER rowValueConstructor comparativePredicateValue )
- | ^( GREATER_EQUAL rowValueConstructor comparativePredicateValue )
- | ^( IS_NULL rowValueConstructor )
- | ^( IS_NOT_NULL rowValueConstructor )
- | ^( LIKE valueExpression valueExpression escapeSpecification? )
- | ^( NOT_LIKE valueExpression valueExpression escapeSpecification? )
- | ^( BETWEEN rowValueConstructor betweenList )
- | ^( NOT_BETWEEN rowValueConstructor betweenList )
- | ^( IN rowValueConstructor inPredicateValue )
- | ^( NOT_IN rowValueConstructor inPredicateValue )
- | ^( MEMBER_OF rowValueConstructor rowValueConstructor )
- | ^( NOT_MEMBER_OF rowValueConstructor rowValueConstructor )
- | ^( IS_EMPTY rowValueConstructor )
- | ^( IS_NOT_EMPTY rowValueConstructor )
- | rowValueConstructor
- ;
-
-betweenList
- : ^( BETWEEN_LIST rowValueConstructor rowValueConstructor )
- ;
-
-comparativePredicateValue
- : rowValueConstructor
- ;
-
-rowValueConstructor
- : valueExpression
- ;
-
-escapeSpecification
- : ^(ESCAPE characterValueExpression)
- ;
-
-inPredicateValue
- : ^(IN_LIST valueExpression+)
- ;
-
-numericValueExpression
- : valueExpression
- ;
-
-characterValueExpression
- : valueExpression
- ;
-
-datetimeValueExpression
- : valueExpression
- ;
-
-valueExpression
- : ^( DOUBLE_PIPE characterValueExpression+ )
- | ^( UNARY_MINUS numericValueExpression )
- | ^( UNARY_PLUS numericValueExpression )
- | ^( PLUS valueExpression valueExpression )
- | ^( MINUS valueExpression valueExpression )
- | ^( ASTERISK numericValueExpression numericValueExpression )
- | ^( SOLIDUS numericValueExpression numericValueExpression )
- | ^( EXISTS rowValueConstructor)
- | ^( SOME valueExpression )
- | ^( ALL valueExpression )
- | ^( ANY valueExpression )
- | ^( VECTOR_EXPR valueExpression+) // or a tuples or ^(AND or IN statement
- | valueExpressionPrimary
- ;
-
-valueExpressionPrimary
- : caseExpression
- | function
- | collectionFunction
- | collectionExpression
- | constant
- | parameter
- | propertyReference
- | ^(SUB_QUERY queryStatementSet)
- | ALIAS_REF //ID COLUMN, full property column list
- | ^(DOT_CLASS path) // crazy
- | ^(GENERAL_FUNCTION_CALL path)
- | ^(JAVA_CONSTANT path) //It will generate at SQL a parameter element (?) -> 'cos we do not need to care about char escaping
- | ^(PATH propertyReferencePath)
- ;
-
-caseExpression
- : ^(NULLIF valueExpression valueExpression)
- | ^(COALESCE valueExpression valueExpression*)
- | ^(SIMPLE_CASE valueExpression simpleCaseWhenClause+ elseClause?)
- | ^(SEARCHED_CASE searchedWhenClause+ elseClause?)
- ;
-
-simpleCaseWhenClause
- : ^(WHEN valueExpression valueExpression)
- ;
-
-searchedWhenClause
- : ^(WHEN searchCondition valueExpression)
- ;
-
-elseClause
- : ^(ELSE valueExpression)
- ;
-
-function
- : standardFunction
- | setFunction
- ;
-
-standardFunction
- : castFunction
- | concatFunction
- | substringFunction
- | trimFunction
- | upperFunction
- | lowerFunction
- | lengthFunction
- | locateFunction
- | absFunction
- | sqrtFunction
- | modFunction
- | sizeFunction
- | indexFunction
- | currentDateFunction
- | currentTimeFunction
- | currentTimestampFunction
- | extractFunction
- | positionFunction
- | charLengthFunction
- | octetLengthFunction
- | bitLengthFunction
- ;
-
-castFunction
- : ^(CAST valueExpression IDENTIFIER)
- ;
-
-concatFunction
- : ^(CONCAT valueExpression+)
- ;
-
-substringFunction
- : ^(SUBSTRING characterValueExpression numericValueExpression numericValueExpression?)
- ;
-
-trimFunction
- : ^(TRIM trimOperands)
- ;
-
-trimOperands
- : ^((LEADING|TRAILING|BOTH) characterValueExpression characterValueExpression)
- ;
-
-upperFunction
- : ^(UPPER characterValueExpression)
- ;
-
-lowerFunction
- : ^(LOWER characterValueExpression)
- ;
-
-lengthFunction
- : ^(LENGTH characterValueExpression)
- ;
-
-locateFunction
- : ^(LOCATE characterValueExpression characterValueExpression numericValueExpression?)
- ;
-
-absFunction
- : ^(ABS numericValueExpression)
- ;
-
-sqrtFunction
- : ^(SQRT numericValueExpression)
- ;
-
-modFunction
- : ^(MOD numericValueExpression numericValueExpression)
- ;
-
-sizeFunction
- : ^(SIZE propertyReference)
- ;
-
-indexFunction
- : ^(INDEX ALIAS_REF)
- ;
-
-currentDateFunction
- : CURRENT_DATE
- ;
-
-currentTimeFunction
- : CURRENT_TIME
- ;
-
-currentTimestampFunction
- : CURRENT_TIMESTAMP
- ;
-
-extractFunction
- : ^(EXTRACT extractField datetimeValueExpression)
- ;
-
-extractField
- : datetimeField
- | timeZoneField
- ;
-
-datetimeField
- : YEAR
- | MONTH
- | DAY
- | HOUR
- | MINUTE
- | SECOND
- ;
-
-timeZoneField
- : TIMEZONE_HOUR
- | TIMEZONE_MINUTE
- ;
-
-positionFunction
- : ^(POSITION characterValueExpression characterValueExpression)
- ;
-
-charLengthFunction
- : ^(CHARACTER_LENGTH characterValueExpression)
- ;
-
-octetLengthFunction
- : ^(OCTET_LENGTH characterValueExpression)
- ;
-
-bitLengthFunction
- : ^(BIT_LENGTH characterValueExpression)
- ;
-
-setFunction
- : ^(SUM numericValueExpression)
- | ^(AVG numericValueExpression)
- | ^(MAX numericValueExpression)
- | ^(MIN numericValueExpression)
- | ^(COUNT (ASTERISK | (DISTINCT|ALL) countFunctionArguments))
- ;
-
-countFunctionArguments
- : collectionExpression
- | propertyReference
- | numeric_literal
- ;
-
-collectionFunction
- : ^((MAXELEMENT|MAXINDEX|MINELEMENT|MININDEX) collectionPropertyReference)
- //it will generate a SELECT MAX (m.column) form Table xxx -> it is realted to Hibernate mappings to Table->Map
- ;
-
-collectionPropertyReference
- : propertyReference
- ;
-
-collectionExpression
- : ^(ELEMENTS propertyReference) //it will generate a SELECT m.column form Table xxx -> it is realted to Hibernate mappings to Table->Map
- | ^(INDICES propertyReference)
- ;
-
-parameter
- : NAMED_PARAM
- | JPA_PARAM
- | PARAM
- ;
-
-constant
- : literal
- | NULL
- | TRUE
- | FALSE
- ;
-
-literal
- : numeric_literal
- | HEX_LITERAL
- | OCTAL_LITERAL
- | CHARACTER_LITERAL
- | STRING_LITERAL
- ;
-
-numeric_literal
- : INTEGER_LITERAL
- | DECIMAL_LITERAL
- | FLOATING_POINT_LITERAL
- ;
-
-entityName
- : ENTITY_NAME ALIAS_NAME
- { registerPersisterSpace($ENTITY_NAME, $ALIAS_NAME); }
- ;
-
-propertyReference
- : ^(PROPERTY_REFERENCE propertyReferencePath)
- ;
-
-propertyReferencePath
- : {isUnqualifiedPropertyReference()}? unqualifiedPropertyReference
- | pathedPropertyReference
- | terminalIndexOperation
- ;
-
-unqualifiedPropertyReference
- : IDENTIFIER
- { normalizeUnqualifiedPropertyReference( $IDENTIFIER ); }
- ;
-
-pathedPropertyReference
- : ^(DOT pathedPropertyReferenceSource IDENTIFIER)
- { normalizePropertyPathTerminus( $pathedPropertyReferenceSource.propertyReferenceSource, $IDENTIFIER ); }
- ;
-
-pathedPropertyReferenceSource returns [PathedPropertyReferenceSource propertyReferenceSource]
- : {(isPersisterReferenceAlias())}?=> IDENTIFIER { $propertyReferenceSource = normalizeQualifiedRoot( $IDENTIFIER ); }
- | {(isUnqualifiedPropertyReference())}?=> IDENTIFIER { $propertyReferenceSource = normalizeUnqualifiedRoot( $IDENTIFIER ); }
- | intermediatePathedPropertyReference { $propertyReferenceSource = $intermediatePathedPropertyReference.propertyReferenceSource; }
- | intermediateIndexOperation { $propertyReferenceSource = null; }
- ;
-
-intermediatePathedPropertyReference returns [PathedPropertyReferenceSource propertyReferenceSource]
- : ^(DOT source=pathedPropertyReferenceSource IDENTIFIER )
- { $propertyReferenceSource = normalizePropertyPathIntermediary( $pathedPropertyReferenceSource.propertyReferenceSource, $IDENTIFIER ); }
- ;
-
-intermediateIndexOperation
- : ^( LEFT_SQUARE indexOperationSource indexSelector )
- { normalizeIntermediateIndexOperation( $indexOperationSource.tree, $indexSelector.tree ); }
- ;
-
-indexOperationSource
- : ^(DOT pathedPropertyReferenceSource IDENTIFIER )
- | {(isUnqualifiedPropertyReference())}?=> IDENTIFIER
- { normalizeUnqualifiedPropertyReferenceSource( $IDENTIFIER ); }
- ;
-
-indexSelector
- : valueExpression
- ;
-
-terminalIndexOperation
- : ^( INDEX_OP indexOperationSource indexSelector )
- { normalizeTerminalIndexOperation( $indexOperationSource.tree, $indexSelector.tree ); }
- ;
-
-path
- : IDENTIFIER
- | ^(DOT path path )
- | ^(LEFT_SQUARE path valueExpression* )
- | ^(LEFT_PAREN path valueExpression* )
- ;
Added: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g
===================================================================
--- core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g (rev 0)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g 2009-04-23 15:27:36 UTC (rev 16425)
@@ -0,0 +1,621 @@
+tree grammar GeneratedHQLResolver;
+
+options{
+ output=AST;
+ rewrite=true;
+ tokenVocab=HQL;
+ ASTLabelType=CommonTree;
+ TokenLabelType=CommonToken;
+}
+
+@header {
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ * Portions of SQL grammar parsing copyright (C) 2003 by Lubos Vnuk. All rights
+ * reserved. These portions are distributed under license by Red Hat Middleware
+ * LLC and are covered by the above LGPL notice. If you redistribute this material,
+ * with or without modification, you must preserve this copyright notice in its
+ * entirety.
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import org.antlr.runtime.tree.CommonTree;
+import org.hibernate.sql.ast.common.JoinType;
+import org.hibernate.sql.ast.phase.hql.resolve.path.PathedPropertyReferenceSource;
+}
+
+@members{
+ protected void registerPersisterSpace(CommonTree entityName,
+ CommonTree alias) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected boolean isUnqualifiedPropertyReference() {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected PathedPropertyReferenceSource normalizeUnqualifiedPropertyReference(CommonTree property) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected boolean isPersisterReferenceAlias() {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected PathedPropertyReferenceSource normalizeUnqualifiedRoot( CommonTree identifier382 ) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected PathedPropertyReferenceSource normalizeQualifiedRoot( CommonTree identifier381 ) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected PathedPropertyReferenceSource normalizePropertyPathIntermediary( PathedPropertyReferenceSource source, CommonTree propertyName ) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void normalizeIntermediateIndexOperation( CommonTree commonTree,
+ CommonTree commonTree2 ) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected PathedPropertyReferenceSource normalizeUnqualifiedPropertyReferenceSource(
+ CommonTree identifier394 ) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void normalizeTerminalIndexOperation(CommonTree collectionPath, CommonTree selector) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected Tree normalizePropertyPathTerminus(PathedPropertyReferenceSource source, CommonTree propertyNameNode) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void pushFromStrategy( JoinType joinType,
+ CommonTree assosiationFetchTree, CommonTree propertyFetchTree,
+ CommonTree alias ) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void pushSelectStrategy() {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+
+ protected void popStrategy(){
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+}
+
+filterStatement[String collectionRole]
+ : ^(QUERY ^(QUERY_SPEC FILTER
+ selectClause? whereClause? ( groupByClause havingClause?)? orderByClause?))
+ ;
+
+statement
+ : updateStatementSet
+ | deleteStatementSet
+ | insertStatementSet
+ | queryStatementSet
+ ;
+
+updateStatementSet
+ : updateStatement+
+ ;
+
+updateStatement
+ : ^(UPDATE entityName ^(SET assignment+) whereClause?)
+ ;
+
+assignment
+ : ^(EQUALS propertyReference valueExpression)
+ | ^(EQUALS VERSIONED_VALUE STRING_LITERAL)
+ ;
+
+deleteStatementSet
+ : deleteStatement+
+ ;
+
+deleteStatement
+ : ^(DELETE entityName whereClause?)
+ ;
+
+insertStatementSet
+ : insertStatement+
+ ;
+
+insertStatement
+ : ^(INSERT intoClause queryStatementSet)
+ ;
+
+intoClause
+ : ^(INTO entityName ^(INSERTABILITY_SPEC propertyReference+ ) )
+ ;
+
+queryStatementSet
+ : queryStatement+
+ ;
+
+queryStatement
+ : ^(QUERY queryExpression orderByClause?)
+ ;
+
+queryExpression
+ : ^(UNION ALL? queryExpression queryExpression)
+ | ^(INTERSECT ALL? queryExpression queryExpression)
+ | ^(EXCEPT ALL? queryExpression queryExpression)
+ | querySpec
+ ;
+
+querySpec
+ : ^(QUERY_SPEC selectFrom whereClause? groupByClause? havingClause?)
+ ;
+
+whereClause
+ : ^(WHERE searchCondition)
+ ;
+
+groupByClause
+ : ^(GROUP_BY groupingValue+)
+ ;
+
+groupingValue
+ : ^(GROUPING_VALUE valueExpression COLLATE?)
+ ;
+
+havingClause
+ : ^(HAVING searchCondition)
+ ;
+
+selectFrom
+ : ^(SELECT_FROM fromClause selectClause)
+ ;
+
+fromClause
+ : ^(FROM persisterSpaces+)
+ ;
+
+persisterSpaces
+ : ^(PERSISTER_SPACE persisterSpace)
+ ;
+
+persisterSpace
+ : persisterSpaceRoot joins*
+ ;
+
+persisterSpaceRoot
+ : ^(ENTITY_PERSISTER_REF entityName PROP_FETCH?)
+ ;
+
+joins
+ : ^(PROPERTY_JOIN jt=joinType ft=FETCH? an=ALIAS_NAME pf=PROP_FETCH?
+ { pushFromStrategy($jt.joinType, $ft, $pf, $an ); }
+ (collectionExpression|propertyReference) withClause?)
+ { popStrategy(); }
+ | ^(PERSISTER_JOIN joinType persisterSpaceRoot onClause?)
+ ;
+
+withClause
+ : ^(WITH searchCondition)
+ ;
+
+onClause
+ : ^(ON searchCondition)
+ ;
+
+joinType returns [JoinType joinType]
+ : CROSS { $joinType = JoinType.CROSS; }
+ | INNER { $joinType = JoinType.INNER; }
+ | (LEFT { $joinType = JoinType.LEFT; } | RIGHT { $joinType = JoinType.RIGHT; } | FULL { $joinType = JoinType.FULL; }) OUTER?
+ ;
+
+selectClause
+@init { if (state.backtracking == 0) pushSelectStrategy(); }
+@after { popStrategy(); }
+ : ^(SELECT DISTINCT? rootSelectExpression)
+ ;
+
+rootSelectExpression
+ : ^(SELECT_LIST rootSelectExpression+)
+ | ^(SELECT_ITEM rootSelectExpression)
+ | ^(DYNAMIC_INSTANTIATION rootSelectExpression+)
+ | ^(DYNAMIC_INSTANTIATION_ARG rootSelectExpression)
+ | valueExpression ALIAS_NAME?
+ ;
+
+orderByClause
+ : ^(ORDER_BY sortSpecification+)
+ ;
+
+sortSpecification
+ : ^(SORT_SPEC valueExpression COLLATE? (ASC|DESC))
+ ;
+
+searchCondition
+ : ^( OR searchCondition searchCondition )
+ | ^( AND searchCondition searchCondition )
+ | ^( NOT searchCondition )
+ | predicate
+ ;
+
+predicate
+ : ^( EQUALS rowValueConstructor comparativePredicateValue )
+ | ^( NOT_EQUAL rowValueConstructor comparativePredicateValue )
+ | ^( LESS rowValueConstructor comparativePredicateValue )
+ | ^( LESS_EQUAL rowValueConstructor comparativePredicateValue )
+ | ^( GREATER rowValueConstructor comparativePredicateValue )
+ | ^( GREATER_EQUAL rowValueConstructor comparativePredicateValue )
+ | ^( IS_NULL rowValueConstructor )
+ | ^( IS_NOT_NULL rowValueConstructor )
+ | ^( LIKE valueExpression valueExpression escapeSpecification? )
+ | ^( NOT_LIKE valueExpression valueExpression escapeSpecification? )
+ | ^( BETWEEN rowValueConstructor betweenList )
+ | ^( NOT_BETWEEN rowValueConstructor betweenList )
+ | ^( IN rowValueConstructor inPredicateValue )
+ | ^( NOT_IN rowValueConstructor inPredicateValue )
+ | ^( MEMBER_OF rowValueConstructor rowValueConstructor )
+ | ^( NOT_MEMBER_OF rowValueConstructor rowValueConstructor )
+ | ^( IS_EMPTY rowValueConstructor )
+ | ^( IS_NOT_EMPTY rowValueConstructor )
+ | rowValueConstructor
+ ;
+
+betweenList
+ : ^( BETWEEN_LIST rowValueConstructor rowValueConstructor )
+ ;
+
+comparativePredicateValue
+ : rowValueConstructor
+ ;
+
+rowValueConstructor
+ : valueExpression
+ ;
+
+escapeSpecification
+ : ^(ESCAPE characterValueExpression)
+ ;
+
+inPredicateValue
+ : ^(IN_LIST valueExpression+)
+ ;
+
+numericValueExpression
+ : valueExpression
+ ;
+
+characterValueExpression
+ : valueExpression
+ ;
+
+datetimeValueExpression
+ : valueExpression
+ ;
+
+valueExpression
+ : ^( DOUBLE_PIPE characterValueExpression+ )
+ | ^( UNARY_MINUS numericValueExpression )
+ | ^( UNARY_PLUS numericValueExpression )
+ | ^( PLUS valueExpression valueExpression )
+ | ^( MINUS valueExpression valueExpression )
+ | ^( ASTERISK numericValueExpression numericValueExpression )
+ | ^( SOLIDUS numericValueExpression numericValueExpression )
+ | ^( EXISTS rowValueConstructor)
+ | ^( SOME valueExpression )
+ | ^( ALL valueExpression )
+ | ^( ANY valueExpression )
+ | ^( VECTOR_EXPR valueExpression+) // or a tuples or ^(AND or IN statement
+ | valueExpressionPrimary
+ ;
+
+valueExpressionPrimary
+ : caseExpression
+ | function
+ | collectionFunction
+ | collectionExpression
+ | constant
+ | parameter
+ | propertyReference
+ | ^(SUB_QUERY queryStatementSet)
+ | ALIAS_REF //ID COLUMN, full property column list
+ | ^(DOT_CLASS path) // crazy
+ | ^(GENERAL_FUNCTION_CALL path)
+ | ^(JAVA_CONSTANT path) //It will generate at SQL a parameter element (?) -> 'cos we do not need to care about char escaping
+ | ^(PATH propertyReferencePath)
+ ;
+
+caseExpression
+ : ^(NULLIF valueExpression valueExpression)
+ | ^(COALESCE valueExpression valueExpression*)
+ | ^(SIMPLE_CASE valueExpression simpleCaseWhenClause+ elseClause?)
+ | ^(SEARCHED_CASE searchedWhenClause+ elseClause?)
+ ;
+
+simpleCaseWhenClause
+ : ^(WHEN valueExpression valueExpression)
+ ;
+
+searchedWhenClause
+ : ^(WHEN searchCondition valueExpression)
+ ;
+
+elseClause
+ : ^(ELSE valueExpression)
+ ;
+
+function
+ : standardFunction
+ | setFunction
+ ;
+
+standardFunction
+ : castFunction
+ | concatFunction
+ | substringFunction
+ | trimFunction
+ | upperFunction
+ | lowerFunction
+ | lengthFunction
+ | locateFunction
+ | absFunction
+ | sqrtFunction
+ | modFunction
+ | sizeFunction
+ | indexFunction
+ | currentDateFunction
+ | currentTimeFunction
+ | currentTimestampFunction
+ | extractFunction
+ | positionFunction
+ | charLengthFunction
+ | octetLengthFunction
+ | bitLengthFunction
+ ;
+
+castFunction
+ : ^(CAST valueExpression IDENTIFIER)
+ ;
+
+concatFunction
+ : ^(CONCAT valueExpression+)
+ ;
+
+substringFunction
+ : ^(SUBSTRING characterValueExpression numericValueExpression numericValueExpression?)
+ ;
+
+trimFunction
+ : ^(TRIM trimOperands)
+ ;
+
+trimOperands
+ : ^((LEADING|TRAILING|BOTH) characterValueExpression characterValueExpression)
+ ;
+
+upperFunction
+ : ^(UPPER characterValueExpression)
+ ;
+
+lowerFunction
+ : ^(LOWER characterValueExpression)
+ ;
+
+lengthFunction
+ : ^(LENGTH characterValueExpression)
+ ;
+
+locateFunction
+ : ^(LOCATE characterValueExpression characterValueExpression numericValueExpression?)
+ ;
+
+absFunction
+ : ^(ABS numericValueExpression)
+ ;
+
+sqrtFunction
+ : ^(SQRT numericValueExpression)
+ ;
+
+modFunction
+ : ^(MOD numericValueExpression numericValueExpression)
+ ;
+
+sizeFunction
+ : ^(SIZE propertyReference)
+ ;
+
+indexFunction
+ : ^(INDEX ALIAS_REF)
+ ;
+
+currentDateFunction
+ : CURRENT_DATE
+ ;
+
+currentTimeFunction
+ : CURRENT_TIME
+ ;
+
+currentTimestampFunction
+ : CURRENT_TIMESTAMP
+ ;
+
+extractFunction
+ : ^(EXTRACT extractField datetimeValueExpression)
+ ;
+
+extractField
+ : datetimeField
+ | timeZoneField
+ ;
+
+datetimeField
+ : YEAR
+ | MONTH
+ | DAY
+ | HOUR
+ | MINUTE
+ | SECOND
+ ;
+
+timeZoneField
+ : TIMEZONE_HOUR
+ | TIMEZONE_MINUTE
+ ;
+
+positionFunction
+ : ^(POSITION characterValueExpression characterValueExpression)
+ ;
+
+charLengthFunction
+ : ^(CHARACTER_LENGTH characterValueExpression)
+ ;
+
+octetLengthFunction
+ : ^(OCTET_LENGTH characterValueExpression)
+ ;
+
+bitLengthFunction
+ : ^(BIT_LENGTH characterValueExpression)
+ ;
+
+setFunction
+ : ^(SUM numericValueExpression)
+ | ^(AVG numericValueExpression)
+ | ^(MAX numericValueExpression)
+ | ^(MIN numericValueExpression)
+ | ^(COUNT (ASTERISK | (DISTINCT|ALL) countFunctionArguments))
+ ;
+
+countFunctionArguments
+ : collectionExpression
+ | propertyReference
+ | numeric_literal
+ ;
+
+collectionFunction
+ : ^((MAXELEMENT|MAXINDEX|MINELEMENT|MININDEX) collectionPropertyReference)
+ //it will generate a SELECT MAX (m.column) form Table xxx -> it is realted to Hibernate mappings to Table->Map
+ ;
+
+collectionPropertyReference
+ : propertyReference
+ ;
+
+collectionExpression
+ : ^(ELEMENTS propertyReference) //it will generate a SELECT m.column form Table xxx -> it is realted to Hibernate mappings to Table->Map
+ | ^(INDICES propertyReference)
+ ;
+
+parameter
+ : NAMED_PARAM
+ | JPA_PARAM
+ | PARAM
+ ;
+
+constant
+ : literal
+ | NULL
+ | TRUE
+ | FALSE
+ ;
+
+literal
+ : numeric_literal
+ | HEX_LITERAL
+ | OCTAL_LITERAL
+ | CHARACTER_LITERAL
+ | STRING_LITERAL
+ ;
+
+numeric_literal
+ : INTEGER_LITERAL
+ | DECIMAL_LITERAL
+ | FLOATING_POINT_LITERAL
+ ;
+
+entityName
+ : ENTITY_NAME ALIAS_NAME
+ { registerPersisterSpace($ENTITY_NAME, $ALIAS_NAME); }
+ ;
+
+propertyReference
+ : ^(PROPERTY_REFERENCE propertyReferencePath)
+ ;
+
+propertyReferencePath
+ : {isUnqualifiedPropertyReference()}? unqualifiedPropertyReference
+ | pathedPropertyReference
+ | terminalIndexOperation
+ ;
+
+unqualifiedPropertyReference returns [PathedPropertyReferenceSource propertyReferenceSource]
+ : IDENTIFIER
+ { $propertyReferenceSource = normalizeUnqualifiedPropertyReference( $IDENTIFIER ); }
+ ;
+
+pathedPropertyReference
+ : ^(DOT pathedPropertyReferenceSource IDENTIFIER)
+ { normalizePropertyPathTerminus( $pathedPropertyReferenceSource.propertyReferenceSource, $IDENTIFIER ); }
+ ;
+
+pathedPropertyReferenceSource returns [PathedPropertyReferenceSource propertyReferenceSource]
+ : {(isPersisterReferenceAlias())}?=> IDENTIFIER { $propertyReferenceSource = normalizeQualifiedRoot( $IDENTIFIER ); }
+ | {(isUnqualifiedPropertyReference())}?=> IDENTIFIER { $propertyReferenceSource = normalizeUnqualifiedRoot( $IDENTIFIER ); }
+ | intermediatePathedPropertyReference { $propertyReferenceSource = $intermediatePathedPropertyReference.propertyReferenceSource; }
+ | intermediateIndexOperation { $propertyReferenceSource = null; }
+ ;
+
+intermediatePathedPropertyReference returns [PathedPropertyReferenceSource propertyReferenceSource]
+ : ^(DOT source=pathedPropertyReferenceSource IDENTIFIER )
+ { $propertyReferenceSource = normalizePropertyPathIntermediary( $pathedPropertyReferenceSource.propertyReferenceSource, $IDENTIFIER ); }
+ ;
+
+intermediateIndexOperation
+ : ^( LEFT_SQUARE indexOperationSource indexSelector )
+ { normalizeIntermediateIndexOperation( $indexOperationSource.tree, $indexSelector.tree ); }
+ ;
+
+terminalIndexOperation
+ : ^( LEFT_SQUARE indexOperationSource indexSelector )
+ { normalizeTerminalIndexOperation( $indexOperationSource.tree, $indexSelector.tree ); }
+ ;
+
+indexOperationSource returns [PathedPropertyReferenceSource propertyReferenceSource, Tree collectionProperty]
+ : ^(DOT pathedPropertyReferenceSource IDENTIFIER )
+ | {(isUnqualifiedPropertyReference())}?=> IDENTIFIER
+ { $propertyReferenceSource = normalizeUnqualifiedPropertyReferenceSource( $IDENTIFIER ); }
+ ;
+
+indexSelector
+ : valueExpression
+ ;
+
+path
+ : IDENTIFIER
+ | ^(DOT path path )
+ | ^(LEFT_SQUARE path valueExpression* )
+ | ^(LEFT_PAREN path valueExpression* )
+ ;
Property changes on: core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolver.g
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolution.java
===================================================================
--- core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolution.java 2009-04-23 14:51:55 UTC (rev 16424)
+++ core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolution.java 2009-04-23 15:27:36 UTC (rev 16425)
@@ -1,247 +0,0 @@
-/*
- * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.sql.ast.phase.hql.resolve;
-
-import org.antlr.runtime.RecognizerSharedState;
-import org.antlr.runtime.tree.CommonTree;
-import org.antlr.runtime.tree.Tree;
-import org.antlr.runtime.tree.TreeNodeStream;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.persister.entity.Queryable;
-import org.hibernate.sql.ast.alias.DefaultTableAliasGenerator;
-import org.hibernate.sql.ast.alias.TableAliasGenerator;
-import org.hibernate.sql.ast.common.JoinType;
-import org.hibernate.sql.ast.phase.hql.parse.HQLParser;
-import org.hibernate.sql.ast.phase.hql.resolve.path.PathResolutionStrategy;
-import org.hibernate.sql.ast.phase.hql.resolve.path.PathResolutionStrategyStack;
-import org.hibernate.sql.ast.phase.hql.resolve.path.PathedPropertyReferenceSource;
-import org.hibernate.sql.ast.phase.hql.resolve.path.impl.BasicPathResolutionStrategySupport;
-import org.hibernate.sql.ast.phase.hql.resolve.path.impl.FromClausePathResolutionStrategy;
-import org.hibernate.sql.ast.phase.hql.resolve.path.impl.SelectClausePathResolutionStrategy;
-import org.hibernate.sql.ast.tree.Table;
-import org.hibernate.sql.ast.tree.Table.EntityTableSpace;
-import org.hibernate.sql.ast.util.TreePrinter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HQLResolution extends GeneratedHQLResolution implements
- ResolutionContext {
- private static final Logger log = LoggerFactory
- .getLogger( HQLResolution.class );
-
- private final SessionFactoryImplementor sessionFactory;
- private final PersisterSpaceContext persisterSpaceContext;
- private final DefaultTableAliasGenerator defaultTableAliasGenerator;
- private final PathResolutionStrategyStack pathResolutionStrategyStack;
- private final TreePrinter printer;
-
- private boolean isProcessingFunction = false;
-
- public HQLResolution( TreeNodeStream input,
- SessionFactoryImplementor sessionFactory ) {
- this( input, new RecognizerSharedState(), sessionFactory );
- }
-
- public HQLResolution( TreeNodeStream input, RecognizerSharedState state,
- SessionFactoryImplementor sessionFactory ) {
- super( input, state );
- this.sessionFactory = sessionFactory;
- this.persisterSpaceContext = new RootPersisterSpaceContext();
- this.defaultTableAliasGenerator = new DefaultTableAliasGenerator(
- sessionFactory.getDialect() );
- this.printer = new TreePrinter( HQLParser.class );
- this.pathResolutionStrategyStack = new PathResolutionStrategyStack();
- this.pathResolutionStrategyStack
- .push( new BasicPathResolutionStrategySupport( this ) );
- }
-
- protected void registerPersisterSpace( CommonTree entityName,
- CommonTree alias ) {
- String entityPersisterName = sessionFactory
- .getImportedClassName( entityName.getText() );
- Queryable entityPersister = ( Queryable ) sessionFactory
- .getEntityPersister( entityPersisterName );
-
- TableAliasGenerator.TableAliasRoot tableAliasRoot = getTableAliasGenerator()
- .generateSqlAliasRoot( entityPersister, alias.getText() );
- EntityTableSpace tableSpace = new Table.EntityTableSpace(
- entityPersister, tableAliasRoot );
- registerPersisterSpace( tableSpace.getPersisterSpace() );
- }
-
- public PersisterSpaceContext getCurrentPersisterSpaceContext() {
- return persisterSpaceContext;
- }
-
- public SessionFactoryImplementor getSessionFactoryImplementor() {
- return sessionFactory;
- }
-
- public TableAliasGenerator getTableAliasGenerator() {
- return defaultTableAliasGenerator;
- }
-
- public TreePrinter getTreePrinter() {
- return printer;
- }
-
- public boolean isCurrentlyProcessingFunction() {
- return isProcessingFunction;
- }
-
- public PathResolutionStrategyStack getPathResolutionStrategyStack() {
- return pathResolutionStrategyStack;
- }
-
- public PathResolutionStrategy getCurrentPathResolutionStrategy() {
- return pathResolutionStrategyStack.getCurrent();
- }
-
- public void registerAssociationFetch( PersisterSpace persisterSpace ) {
- // TODO Auto-generated method stub
- persisterSpaceContext.registerPersisterSpace( persisterSpace );
- }
-
- public void registerPropertyFetch( PersisterSpace persisterSpace ) {
- // TODO Auto-generated method stub
- }
-
- protected void pushFromStrategy( JoinType joinType,
- CommonTree assosiationFetchTree, CommonTree propertyFetchTree,
- CommonTree alias ) {
- boolean assosiationFetch = assosiationFetchTree != null ? true : false;
- boolean propertyFetch = propertyFetchTree != null ? true : false;
- pathResolutionStrategyStack.push( new FromClausePathResolutionStrategy(
- this, joinType, assosiationFetch, propertyFetch, alias
- .getText() ) );
- }
-
- protected void pushSelectStrategy() {
- pathResolutionStrategyStack
- .push( new SelectClausePathResolutionStrategy( this ) );
- }
-
- protected void popStrategy() {
- pathResolutionStrategyStack.pop();
- }
-
- protected void registerEntityPersisterSpace( CommonTree entityName,
- CommonTree alias ) {
- // String entityPersisterName = sessionFactory
- // .getImportedClassName( entityName.getText() );
- // EntityPersister entityPersister = sessionFactory
- // .getEntityPersister( entityPersisterName );
- //
- // EntityTableSpace tableSpace = new Table.EntityTableSpace(
- // ( Queryable ) entityPersister, getTableAliasGenerator()
- // .generateSqlAliasRoot( ( Queryable ) entityPersister,
- // alias.getText() ) );
- // registerPersisterSpace( tableSpace.getPersisterSpace() );
- }
-
- private void registerPersisterSpace( PersisterSpace persisterSpace ) {
- persisterSpaceContext.registerPersisterSpace( persisterSpace );
- }
-
- protected boolean isUnqualifiedPropertyReference() {
- return locateOwningPersisterAlias( ( Tree ) input.LT( 1 ) ) != null;
- }
-
- protected String locateOwningPersisterAlias( Tree property ) {
- PersisterSpace persisterReference = getCurrentPersisterSpaceContext()
- .locatePersisterSpaceExposingProperty( property.getText() );
- return persisterReference == null ? null : persisterReference
- .getSourceAlias();
- }
-
- protected boolean isPersisterReferenceAlias() {
- Tree alias = ( Tree ) input.LT( 1 );
- log.trace( "Checking [" + textOrNull( alias )
- + "] as persister-ref alias" );
- return getCurrentPersisterSpaceContext().isContainedAlias(
- alias.getText() );
- }
-
- protected Tree normalizeUnqualifiedPropertyReference( CommonTree property ) {
- // TODO Auto-generated method stub
- return null;
- }
-
- protected PathedPropertyReferenceSource normalizeUnqualifiedRoot(
- CommonTree identifier ) {
- System.out
- .println( "normalizeUnqualifiedRoot: " + identifier.getText() );
- // TODO Auto-generated method stub
- return null;
- }
-
- protected PathedPropertyReferenceSource normalizeQualifiedRoot(
- CommonTree alias ) {
- log.debug( "normalizing path expression root as alias ["
- + alias.getText() + "]" );
-
- return getCurrentPathResolutionStrategy().handleRoot(
- getCurrentPersisterSpaceContext().locatePersisterSpaceByAlias(
- alias.getText() ) );
- }
-
- protected void normalizePropertyPathTerminus(
- PathedPropertyReferenceSource source, CommonTree propertyNameNode ) {
- log.trace( "normalizing terminal path expression ["
- + textOrNull( propertyNameNode ) + "]" );
- getCurrentPathResolutionStrategy().handleTerminalPathPart( source,
- propertyNameNode.getText() );
- }
-
- protected PathedPropertyReferenceSource normalizePropertyPathIntermediary(
- PathedPropertyReferenceSource source, CommonTree propertyName ) {
- log.trace( "normalizing intermediate path expression ["
- + textOrNull( propertyName ) + "]" );
- return getCurrentPathResolutionStrategy().handleIntermediatePathPart(
- ( PathedPropertyReferenceSource ) source,
- propertyName.getText() );
- }
-
- protected void normalizeIntermediateIndexOperation( CommonTree identifier1,
- CommonTree identifier2 ) {
- System.out.println( "normalizeIntermediateIndexOperation: "
- + identifier1.getText() + ":" + identifier2.getText() );
- // TODO Auto-generated method stub
- }
-
- protected void normalizeUnqualifiedPropertyReferenceSource(
- CommonTree identifier ) {
- System.out.println( "normalizeUnqualifiedPropertyReferenceSource: "
- + identifier.getText() );
- // TODO Auto-generated method stub
- }
-
- protected void normalizeTerminalIndexOperation( CommonTree collectionPath,
- CommonTree selector ) {
- // TODO Auto-generated method stub
- }
-
- private String textOrNull( Tree tree ) {
- return tree == null ? null : tree.getText();
- }
-
-}
\ No newline at end of file
Modified: core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java
===================================================================
--- core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java 2009-04-23 14:51:55 UTC (rev 16424)
+++ core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java 2009-04-23 15:27:36 UTC (rev 16425)
@@ -44,7 +44,7 @@
}
public void testBasicSelectStructure() throws Throwable {
- Tree queryTree = normalize( "select a.id from Animal a" );
+ Tree queryTree = normalize( "from Zoo z where mammals['dog'] = ?" );
}
public Tree normalize( String hql ) throws RecognitionException {
@@ -62,7 +62,7 @@
CommonTreeNodeStream nodes = new CommonTreeNodeStream( result );
nodes.setTokenStream( tokens );
- HQLResolution resololution = new HQLResolution( nodes, sessionFactory );
+ HQLResolver resololution = new HQLResolver( nodes, sessionFactory );
System.out.println( resololution.getTreePrinter().renderAsString(
result, "Parser Result" ) );
15 years, 7 months
Hibernate SVN: r16424 - in core/trunk/commons-annotations/src/main/java/org/hibernate/annotations/common: util and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-04-23 10:51:55 -0400 (Thu, 23 Apr 2009)
New Revision: 16424
Modified:
core/trunk/commons-annotations/src/main/java/org/hibernate/annotations/common/reflection/java/JavaReflectionManager.java
core/trunk/commons-annotations/src/main/java/org/hibernate/annotations/common/util/ReflectHelper.java
Log:
Un deprecate reflect helper in commons-annotations and use it in commons annotations code
Modified: core/trunk/commons-annotations/src/main/java/org/hibernate/annotations/common/reflection/java/JavaReflectionManager.java
===================================================================
--- core/trunk/commons-annotations/src/main/java/org/hibernate/annotations/common/reflection/java/JavaReflectionManager.java 2009-04-23 14:51:05 UTC (rev 16423)
+++ core/trunk/commons-annotations/src/main/java/org/hibernate/annotations/common/reflection/java/JavaReflectionManager.java 2009-04-23 14:51:55 UTC (rev 16424)
@@ -44,8 +44,8 @@
import org.hibernate.annotations.common.reflection.java.generics.TypeEnvironmentFactory;
import org.hibernate.annotations.common.reflection.java.generics.TypeSwitch;
import org.hibernate.annotations.common.reflection.java.generics.TypeUtils;
-import org.hibernate.util.ReflectHelper;
import org.hibernate.annotations.common.Version;
+import org.hibernate.annotations.common.util.ReflectHelper;
/**
* The factory for all the objects in this package.
Modified: core/trunk/commons-annotations/src/main/java/org/hibernate/annotations/common/util/ReflectHelper.java
===================================================================
--- core/trunk/commons-annotations/src/main/java/org/hibernate/annotations/common/util/ReflectHelper.java 2009-04-23 14:51:05 UTC (rev 16423)
+++ core/trunk/commons-annotations/src/main/java/org/hibernate/annotations/common/util/ReflectHelper.java 2009-04-23 14:51:55 UTC (rev 16424)
@@ -30,7 +30,6 @@
* Complete duplication of {@link org.hibernate.util.ReflectHelper}.
*
* @author Emmanuel Bernard
- * @deprecated Use {@link org.hibernate.util.ReflectHelper} instead.
*/
public final class ReflectHelper {
public static boolean overridesEquals(Class clazz) {
@@ -42,7 +41,7 @@
}
public static Class classForName(String name) throws ClassNotFoundException {
- return org.hibernate.util.ReflectHelper.classForName( name );
+ return ReflectHelper.classForName( name );
}
public static Class classForName(String name, Class caller) throws ClassNotFoundException {
15 years, 7 months
Hibernate SVN: r16423 - in search/trunk: src/main and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-04-23 10:51:05 -0400 (Thu, 23 Apr 2009)
New Revision: 16423
Removed:
search/trunk/src/main/filters/
search/trunk/src/test/java/org/hibernate/search/test/HANTestCase.java
Modified:
search/trunk/pom.xml
search/trunk/src/test/java/org/hibernate/search/test/SearchTestCase.java
search/trunk/src/test/resources/hibernate.properties
Log:
JBPAPP-1679
Aligned with hibernate.properties from Core and cleaned up the test harness.
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2009-04-23 12:38:22 UTC (rev 16422)
+++ search/trunk/pom.xml 2009-04-23 14:51:05 UTC (rev 16423)
@@ -224,13 +224,12 @@
<artifactId>maven-release-plugin</artifactId>
<configuration>
<releaseProfiles>release</releaseProfiles>
- <goals>package javadoc:javadoc org.jboss.maven.plugins:maven-jdocbook-plugin:2.1.0:resources org.jboss.maven.plugins:maven-jdocbook-plugin:2.1.0:generate assembly:assembly</goals>
+ <goals>package javadoc:javadoc org.jboss.maven.plugins:maven-jdocbook-plugin:2.1.0:resources
+ org.jboss.maven.plugins:maven-jdocbook-plugin:2.1.0:generate assembly:assembly
+ </goals>
</configuration>
</plugin>
</plugins>
- <filters>
- <filter>${filter.file}</filter>
- </filters>
<testResources>
<testResource>
<filtering>true</filtering>
@@ -261,7 +260,12 @@
</dependency>
</dependencies>
<properties>
- <filter.file>src/main/filters/hsqldb.filter</filter.file>
+ <db.dialect>org.hibernate.dialect.HSQLDialect</db.dialect>
+ <jdbc.driver>org.hsqldb.jdbcDriver</jdbc.driver>
+ <jdbc.url>jdbc:hsqldb:.</jdbc.url>
+ <jdbc.user>sa</jdbc.user>
+ <jdbc.pass/>
+ <jdbc.isolation/>
</properties>
</profile>
<profile>
@@ -274,7 +278,12 @@
</dependency>
</dependencies>
<properties>
- <filter.file>src/main/filters/postgresql.filter</filter.file>
+ <db.dialect>org.hibernate.dialect.PostgreSQLDialect</db.dialect>
+ <jdbc.driver>org.postgresql.Driver</jdbc.driver>
+ <jdbc.url>jdbc:postgresql://localhost:5432/hibernate</jdbc.url>
+ <jdbc.user>hibernate</jdbc.user>
+ <jdbc.pass>hibernate</jdbc.pass>
+ <jdbc.isolation/>
</properties>
</profile>
<profile>
@@ -287,7 +296,12 @@
</dependency>
</dependencies>
<properties>
- <filter.file>src/main/filters/mysql.filter</filter.file>
+ <db.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</db.dialect>
+ <jdbc.driver>com.mysql.jdbc.Driver</jdbc.driver>
+ <jdbc.url>jdbc:mysql://localhost/hibernate</jdbc.url>
+ <jdbc.user>hibernate</jdbc.user>
+ <jdbc.pass>hibernate</jdbc.pass>
+ <jdbc.isolation/>
</properties>
</profile>
@@ -328,27 +342,27 @@
<version>1.3.0</version>
<optional>true</optional>
<exclusions>
- <exclusion>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-solrj</artifactId>
- </exclusion>
- <exclusion>
- <groupId>woodstox</groupId>
- <artifactId>wstx-asl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>net.java.dev.stax-utils</groupId>
- <artifactId>stax-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-solrj</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>net.java.dev.stax-utils</groupId>
+ <artifactId>stax-utils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
@@ -434,11 +448,11 @@
</build>
</profile>
</profiles>
-
+
<properties>
<slf4jVersion>1.5.6</slf4jVersion>
<luceneVersion>2.4.1</luceneVersion>
<hibernateVersion>3.5.0-SNAPSHOT</hibernateVersion>
</properties>
-
+
</project>
Deleted: search/trunk/src/test/java/org/hibernate/search/test/HANTestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/HANTestCase.java 2009-04-23 12:38:22 UTC (rev 16422)
+++ search/trunk/src/test/java/org/hibernate/search/test/HANTestCase.java 2009-04-23 14:51:05 UTC (rev 16423)
@@ -1,67 +0,0 @@
-//$Id$
-package org.hibernate.search.test;
-
-import java.io.InputStream;
-
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.Dialect;
-
-/**
- * Originally a copy from Hibernate Annotations.
- *
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- */
-public abstract class HANTestCase extends TestCase {
-
- public HANTestCase() {
- super();
- }
-
- public HANTestCase(String x) {
- super( x );
- }
-
- protected void buildSessionFactory(Class[] classes, String[] packages, String[] xmlFiles) throws Exception {
- if ( getSessions() != null ) {
- getSessions().close();
- }
- try {
- setCfg( new AnnotationConfiguration() );
- configure( cfg );
- if ( recreateSchema() ) {
- cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- }
- for ( String aPackage : packages ) {
- ( ( AnnotationConfiguration ) getCfg() ).addPackage( aPackage );
- }
- for ( Class aClass : classes ) {
- ( ( AnnotationConfiguration ) getCfg() ).addAnnotatedClass( aClass );
- }
- for ( String xmlFile : xmlFiles ) {
- InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
- getCfg().addInputStream( is );
- }
- setDialect( Dialect.getDialect() );
- setSessions( getCfg().buildSessionFactory( /*new TestInterceptor()*/ ) );
- }
- catch ( Exception e ) {
- e.printStackTrace();
- throw e;
- }
- }
-
- protected void setUp() throws Exception {
- if ( getSessions() == null || getSessions().isClosed() || lastTestClass != getClass() ) {
- buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
- lastTestClass = getClass();
- }
- }
-
- protected abstract Class[] getMappings();
-
- protected String[] getAnnotatedPackages() {
- return new String[] { };
- }
-}
Modified: search/trunk/src/test/java/org/hibernate/search/test/SearchTestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/SearchTestCase.java 2009-04-23 12:38:22 UTC (rev 16422)
+++ search/trunk/src/test/java/org/hibernate/search/test/SearchTestCase.java 2009-04-23 14:51:05 UTC (rev 16423)
@@ -2,12 +2,16 @@
package org.hibernate.search.test;
import java.io.File;
+import java.io.InputStream;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.store.Directory;
+import org.slf4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Transaction;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.dialect.Dialect;
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.impl.SessionFactoryImpl;
import org.hibernate.search.Environment;
@@ -16,15 +20,14 @@
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.event.FullTextIndexEventListener;
import org.hibernate.search.store.RAMDirectoryProvider;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.slf4j.Logger;
-
/**
* Base class for Hibernate Search unit tests.
*
* @author Emmanuel Bernard
*/
-public abstract class SearchTestCase extends HANTestCase {
+public abstract class SearchTestCase extends TestCase {
private static final Logger log = org.hibernate.search.util.LoggerFactory.make();
@@ -45,6 +48,11 @@
ensureIndexesAreEmpty();
}
+ protected void tearDown() throws Exception {
+ SchemaExport export = new SchemaExport( cfg );
+ export.drop( false, true );
+ }
+
@SuppressWarnings("unchecked")
protected Directory getDirectory(Class clazz) {
return getLuceneEventListener().getSearchFactoryImplementor().getDirectoryProviders( clazz )[0].getDirectory();
@@ -95,4 +103,39 @@
protected File getBaseIndexDir() {
return indexDir;
}
+
+ protected void buildSessionFactory(Class[] classes, String[] packages, String[] xmlFiles) throws Exception {
+ if ( getSessions() != null ) {
+ getSessions().close();
+ }
+ try {
+ setCfg( new AnnotationConfiguration() );
+ configure( cfg );
+ if ( recreateSchema() ) {
+ cfg.setProperty( org.hibernate.cfg.Environment.HBM2DDL_AUTO, "create-drop" );
+ }
+ for ( String aPackage : packages ) {
+ ( ( AnnotationConfiguration ) getCfg() ).addPackage( aPackage );
+ }
+ for ( Class aClass : classes ) {
+ ( ( AnnotationConfiguration ) getCfg() ).addAnnotatedClass( aClass );
+ }
+ for ( String xmlFile : xmlFiles ) {
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
+ getCfg().addInputStream( is );
+ }
+ setDialect( Dialect.getDialect() );
+ setSessions( getCfg().buildSessionFactory( /*new TestInterceptor()*/ ) );
+ }
+ catch ( Exception e ) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected abstract Class[] getMappings();
+
+ protected String[] getAnnotatedPackages() {
+ return new String[] { };
+ }
}
Modified: search/trunk/src/test/resources/hibernate.properties
===================================================================
--- search/trunk/src/test/resources/hibernate.properties 2009-04-23 12:38:22 UTC (rev 16422)
+++ search/trunk/src/test/resources/hibernate.properties 2009-04-23 14:51:05 UTC (rev 16423)
@@ -1,313 +1,31 @@
-######################
-### Query Language ###
-######################
+################################################################################
+# Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved. #
+# #
+# This copyrighted material is made available to anyone wishing to use, modify,#
+# copy, or redistribute it subject to the terms and conditions of the GNU #
+# Lesser General Public License, v. 2.1. This program is distributed in the #
+# hope that it will be useful, but WITHOUT A WARRANTY; without even the implied#
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# Lesser General Public License for more details. You should have received a #
+# copy of the GNU Lesser General Public License, v.2.1 along with this #
+# distribution; if not, write to the Free Software Foundation, Inc., #
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
+# #
+# Red Hat Author(s): Steve Ebersole #
+################################################################################
+hibernate.dialect ${db.dialect}
+hibernate.connection.driver_class ${jdbc.driver}
+hibernate.connection.url ${jdbc.url}
+hibernate.connection.username ${jdbc.user}
+hibernate.connection.password ${jdbc.pass}
+hibernate.connection.isolation ${jdbc.isolation}
-## define query language constants / function names
+hibernate.connection.pool_size 5
-hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'
-
-
-## select the classic query parser
-
-#hibernate.query.factory_class org.hibernate.hql.classic.ClassicQueryTranslatorFactory
-
+hibernate.show_sql true
hibernate.format_sql true
+hibernate.max_fetch_depth 5
-
-#################
-### Platforms ###
-#################
-
-## JNDI Datasource
-
-#hibernate.connection.datasource jdbc/test
-#hibernate.connection.username db2
-#hibernate.connection.password db2
-
-
-hibernate.dialect @hibernate.dialect@
-hibernate.connection.driver_class @hibernate.connection.driver_class@
-hibernate.connection.username @hibernate.connection.username@
-hibernate.connection.password @hibernate.connection.password@
-hibernate.connection.url @hibernate.connection.url@
-
-
-#################################
-### Hibernate Connection Pool ###
-#################################
-
-hibernate.connection.pool_size 1
-
-
-
-###########################
-### C3P0 Connection Pool###
-###########################
-
-#hibernate.c3p0.max_size 2
-#hibernate.c3p0.min_size 2
-#hibernate.c3p0.timeout 5000
-#hibernate.c3p0.max_statements 100
-#hibernate.c3p0.idle_test_period 3000
-#hibernate.c3p0.acquire_increment 2
-#hibernate.c3p0.validate false
-
-
-
-##############################
-### Proxool Connection Pool###
-##############################
-
-## Properties for external configuration of Proxool
-
-hibernate.proxool.pool_alias pool1
-
-## Only need one of the following
-
-#hibernate.proxool.existing_pool true
-#hibernate.proxool.xml proxool.xml
-#hibernate.proxool.properties proxool.properties
-
-
-
-#################################
-### Plugin ConnectionProvider ###
-#################################
-
-## use a custom ConnectionProvider (if not set, Hibernate will choose a built-in ConnectionProvider using hueristics)
-
-#hibernate.connection.provider_class org.hibernate.connection.DriverManagerConnectionProvider
-#hibernate.connection.provider_class org.hibernate.connection.DatasourceConnectionProvider
-#hibernate.connection.provider_class org.hibernate.connection.C3P0ConnectionProvider
-#hibernate.connection.provider_class org.hibernate.connection.DBCPConnectionProvider
-#hibernate.connection.provider_class org.hibernate.connection.ProxoolConnectionProvider
-
-
-
-#######################
-### Transaction API ###
-#######################
-
-## Enable automatic flush during the JTA beforeCompletion() callback
-## (This setting is relevant with or without the Transaction API)
-
-#hibernate.transaction.flush_before_completion
-
-
-## Enable automatic session close at the end of transaction
-## (This setting is relevant with or without the Transaction API)
-
-#hibernate.transaction.auto_close_session
-
-
-## the Transaction API abstracts application code from the underlying JTA or JDBC transactions
-
-#hibernate.transaction.factory_class org.hibernate.transaction.JTATransactionFactory
-#hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory
-
-
-## to use JTATransactionFactory, Hibernate must be able to locate the UserTransaction in JNDI
-## default is java:comp/UserTransaction
-## you do NOT need this setting if you specify hibernate.transaction.manager_lookup_class
-
-#jta.UserTransaction jta/usertransaction
-#jta.UserTransaction javax.transaction.UserTransaction
-#jta.UserTransaction UserTransaction
-
-
-## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager
-
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.JBossTransactionManagerLookup
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.WeblogicTransactionManagerLookup
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.WebSphereTransactionManagerLookup
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.OrionTransactionManagerLookup
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.ResinTransactionManagerLookup
-
-
-
-##############################
-### Miscellaneous Settings ###
-##############################
-
-## print all generated SQL to the console
-
-#hibernate.show_sql true
-
-
-## add comments to the generated SQL
-
-#hibernate.use_sql_comments true
-
-
-## generate statistics
-
-#hibernate.generate_statistics true
-
-
-## auto schema export
-
-#hibernate.hbm2ddl.auto create-drop
-#hibernate.hbm2ddl.auto create
-#hibernate.hbm2ddl.auto update
-
-
-## specify a default schema and catalog for unqualified tablenames
-
-#hibernate.default_schema test
-#hibernate.default_catalog test
-
-
-## enable ordering of SQL UPDATEs by primary key
-
-hibernate.order_updates true
-
-
-## set the maximum depth of the outer join fetch tree
-
-hibernate.max_fetch_depth 1
-
-
-## set the default batch size for batch fetching
-
-hibernate.default_batch_fetch_size 100
-
-
-## rollback generated identifier values of deleted entities to default values
-
-#hibernate.use_identifer_rollback true
-
-
-## enable CGLIB reflection optimizer (enabled by default)
-
-#hibernate.cglib.use_reflection_optimizer false
-
-
-
-#####################
-### JDBC Settings ###
-#####################
-
-## specify a JDBC isolation level
-
-#hibernate.connection.isolation 4
-
-
-## enable JDBC autocommit (not recommended!)
-
-#hibernate.connection.autocommit true
-
-
-## set the JDBC fetch size
-
-#hibernate.jdbc.fetch_size 25
-
-
-## set the maximum JDBC 2 batch size (a nonzero value enables batching)
-
-#hibernate.jdbc.batch_size 0
-
-
-## enable batch updates even for versioned data
-
-hibernate.jdbc.batch_versioned_data true
-
-
-## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default)
-
-#hibernate.jdbc.use_scrollable_resultset true
-
-
-## use streams when writing binary types to / from JDBC
-
-hibernate.jdbc.use_streams_for_binary true
-
-
-## use JDBC 3 PreparedStatement.getGeneratedKeys() to get the identifier of an inserted row
-
-#hibernate.jdbc.use_get_generated_keys false
-
-
-## choose a custom JDBC batcher
-
-# hibernate.jdbc.factory_class
-
-
-## enable JDBC result set column alias caching
-## (minor performance enhancement for broken JDBC drivers)
-
-# hibernate.jdbc.wrap_result_sets
-
-
-## choose a custom SQL exception converter
-
-#hibernate.jdbc.sql_exception_converter
-
-
-
-##########################
-### Second-level Cache ###
-##########################
-
-## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)
-
-#hibernate.cache.use_minimal_puts true
-
-
-## set a prefix for cache region names
-
hibernate.cache.region_prefix hibernate.test
-
-
-## disable the second-level cache
-
-#hibernate.cache.use_second_level_cache false
-
-
-## enable the query cache
-
-hibernate.cache.use_query_cache true
-
-
-## store the second-level cache entries in a more human-friendly format
-
-#hibernate.cache.use_structured_entries true
-
-
-## choose a cache implementation
-
-#hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.EmptyCacheProvider
hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.TreeCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.OSCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.SwarmCacheProvider
-
-
-## choose a custom query cache implementation
-
-#hibernate.cache.query_cache_factory
-
-
-
-############
-### JNDI ###
-############
-
-## specify a JNDI name for the SessionFactory
-
-#hibernate.session_factory_name hibernate/session_factory
-
-
-## Hibernate uses JNDI to bind a name to a SessionFactory and to look up the JTA UserTransaction;
-## if hibernate.jndi.* are not specified, Hibernate will use the default InitialContext() which
-## is the best approach in an application server
-
-#file system
-#hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory
-#hibernate.jndi.url file:/
-
-#WebSphere
-#hibernate.jndi.class com.ibm.websphere.naming.WsnInitialContextFactory
-#hibernate.jndi.url iiop://localhost:900/
-
15 years, 7 months