Author: steve.ebersole(a)jboss.com
Date: 2009-01-06 15:29:32 -0500 (Tue, 06 Jan 2009)
New Revision: 15748
Removed:
core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/resolve.g
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/hql/ast/phase/parse/HqlParser.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/hql/ast/phase/parse/PathCollector.java
Modified:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/CollectionPersisterReference.java
Log:
HHH-2407 : HQL translation rework ->
HHH-3687 : parse (phase1)
HHH-3688 : normalize (phase2)
Deleted: core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/resolve.g
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/resolve.g 2009-01-06 20:11:13 UTC
(rev 15747)
+++ core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/resolve.g 2009-01-06 20:29:32 UTC
(rev 15748)
@@ -1,844 +0,0 @@
-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.hql.ast.phase.parse;
-import antlr.collections.AST;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-}
-
-/**
- * An Antlr tree parser for "resolving" or "normalizing" an HQL
syntax AST. This
- * parser provides the vast majority of the semantic analysis of the HQL AST.
- * <p/>
- * Both "resolving" and "normalizing" here seek a single goal of
building a
- * dis-ambiguated, generic query AST.
- * <p/>
- * The act of resolving is essentially the process of simplifying complex node
- * structures into atomic components based on contextual information (aka, the
- * current parser state). The main thrust of this process is breaking down
- * dot-structures (a series of DOT INDET pairs) into <ul>
- * <li>a series of "implicit" join structures injected into the from
clause tree</li>
- * <li>a simple structure representing the "meaning" of the
"leaf" of said dot-structure</li>
- * </ul>
- * <p/>
- * The act of normalizing essentially refers to the process of dis-ambiguating
- * node structures based on their context and creating a unified AST
- * representation for different ways to express the same "idea". An example of
this
- * is normalizing implicit join dot-structures into a structure akin to its explicit
- * join corollary.
- *
- * @author Joshua Davis
- * @author Steve Ebersole
- */
-class GeneratedHqlResolver extends TreeParser;
-
-options {
- importVocab=HqlParse;
- exportVocab=HqlResolve;
- buildAST=true;
-}
-
-tokens {
- PROPERTY_REF;
- ENTITY_PERSISTER_REF;
- COLLECTION_PERSISTER_REF;
- PERSISTER_ALIAS_REF;
- BOGUS;
-
-// SELECT_CLAUSE;
-}
-
-
-// -- Declarations --
-{
- private static Logger log = LoggerFactory.getLogger( GeneratedHqlResolver.class );
-
- private int ordinalParamCount = 0;
-
- protected boolean isPersisterReferenceAlias(AST alias) {
- return false;
- }
-
- protected AST resolveAlias(AST alias) {
- return alias;
- }
-
- protected boolean isUnqualifiedPropertyReference(AST property) {
- return false;
- }
-
- protected AST buildUnqualifiedPropertyReference(AST propertyNameNode) {
- return propertyNameNode;
- }
-
- protected AST resolvePropertyPathTerminus(AST source, AST propertyNameNode) {
- return propertyNameNode;
- }
-
- protected AST resolvePropertyPathIntermediary(AST source, AST propertyNameNode) {
- return propertyNameNode;
- }
-
- protected void validateIndexOperationOperands(AST collectionPropertyRef, AST
selector) {
- }
-
- protected AST resolveQualifiedRoot(AST alias) {
- return null;
- }
-
- protected AST resolveUnqualifiedRoot(AST alias) {
- return null;
- }
-
- protected AST resolveIndexedRoot(AST alias) {
- return null;
- }
-
-
- // Statement node BEGIN/END handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected void pushStatement(AST statementNode) {
- }
-
- protected void popStatement() {
- }
-
-
- // property-path context pushing/popping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected void pushFromClausePropertyPathContext(AST joinType, AST fetch, AST alias, AST
propertyFetch) {
- }
-
- protected void popFromClausePropertyPathContext() {
- }
-
- protected void pushOnFragmentPropertyPathContext(AST rhsPersisterReference) {
- }
-
- protected void popOnFragmentPropertyPathContext() {
- }
-
- protected void pushWithFragmentPropertyPathContext(AST rhsPersisterReference) {
- }
-
- protected void popWithFragmentPropertyPathContext() {
- }
-
- protected void pushSelectClausePropertyPathContext() {
- }
-
- protected void popSelectClausePropertyPathContext() {
- }
-
-
- // persister reference handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected AST buildEntityPersisterReference(AST entityName, AST alias, AST
propertyFetch) {
- return entityName;
- }
-
- protected AST buildAdHocJoinNode(AST persisterReference, AST joinType, AST withFragment)
{
- return persisterReference;
- }
-
- protected void applyWithFragment(AST withFragment) {
- }
-
-
- // parameter handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- private AST generateNamedParameter(AST delim, AST name) throws SemanticException {
- // use the source delim node to properly transfer line/column number information :(
- AST param = #( delim );
- param.setType( NAMED_PARAM );
- param.setText( name.getText() );
- return param;
- }
-
- private AST generateOrdinalParameter(AST source) throws SemanticException {
- // use the source node to properly transfer line/column number information :(
- AST param = #( source );
- param.setType( ORDINAL_PARAM );
- param.setText( Integer.toString( ordinalParamCount++ ) );
- return param;
- }
-
- protected void injectSelectAlias( AST selectExpression, AST alias) {
- }
-
- protected void registerSelectExpression(AST selectExpression) {
- }
-
- protected AST handleSelectedPropertyRef(AST propertyRef) {
- return propertyRef;
- }
-}
-
-// Statement rules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-/**
- * The main grammar rule
- */
-statement :
- updateStatement
- | deleteStatement
- | insertStatement
- | selectStatement
-;
-
-
-// <tt>UPDATE</tt> statement
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-/**
- * Recognize an <tt>UPDATE</tt> statement
- */
-updateStatement :
- #(
- UPDATE { pushStatement( #updateStatement ); }
- (VERSIONED)?
- ENTITY_NAME (ALIAS)?
- setClause
- (whereClause)? { popStatement(); }
- )
-;
-
-setClause :
- #( SET (assignment)+ )
-;
-
-assignment :
- #( ASSIGNMENT_OP assignmentField newValue )
-;
-
-assignmentField :
- propertyReference
-;
-
-newValue :
- valueExpression
-;
-
-
-
-// <tt>DELETE</tt> statement
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-/**
- * Recognize an HQL <tt>DELETE</tt> statement
- */
-deleteStatement :
- #(
- DELETE { pushStatement( #deleteStatement ); }
- ENTITY_NAME (ALIAS)?
- (whereClause)? { popStatement(); }
- )
-;
-
-
-// <tt>INSERT</tt> statement
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-/**
- * Recognize an HQL <tt>INSERT</tt> statement
- */
-insertStatement :
- #(
- INSERT { pushStatement( #insertStatement ); }
- intoClause
- queryExpression { popStatement(); }
- )
-;
-
-intoClause :
- #( INTO ENTITY_NAME insertabilitySpecification )
-;
-
-insertabilitySpecification :
- #( INSERTABILITY_SPEC (insertablePropertySpecification)+ )
-;
-
-/**
- * The property being inserted into.
- */
-insertablePropertySpecification :
- IDENT
-;
-
-
-// <tt>SELECT</tt> statement rules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-/**
- * Recognize an HQL <tt>SELECT</tt> statement.
- * <p/>
- * This corresponds most closely to the <cursor specification> rule in ISO/ANSI
SQL...
- */
-selectStatement :
- #( QUERY queryExpression orderByClause )
-;
-
-orderByClause :
- #( ORDER (sortSpecification)+ )
-;
-
-sortSpecification :
- #( SORT_SPEC sortKey (collationSpecification)? (orderingSpecification)? )
-;
-
-sortKey :
- // todo : do we want to explicitly limit these?
- valueExpression
-;
-
-collationSpecification :
- COLLATE
-;
-
-orderingSpecification :
- ORDER_SPEC
-;
-
-queryExpression :
- #(
- QUERY { pushStatement( #queryExpression ); }
- querySpec ( ( UNION | INTERSECT | EXCEPT ) (ALL)? querySpec )* {
popStatement( #queryExpression ); }
- )
-;
-
-subquery :
- queryExpression
-;
-
-querySpec :
- selectFrom ( whereClause )? ( groupByClause ( havingClause )? )?
-;
-
-
-selectFrom! :
- #( SELECT_FROM fromClause (selectClause)? )
-;
-
-fromClause :
- #( FROM (persisterSpace)+ )
-;
-
-persisterSpace :
- #( PERSISTER_SPACE entityPersisterReference ( qualifiedJoin | crossJoin )* )
-;
-
-entityPersisterReference! :
- en:ENTITY_NAME (a:ALIAS)? (pf:PROP_FETCH)? {
- #entityPersisterReference = buildEntityPersisterReference( en, a, pf );
- }
-;
-
-crossJoin :
- #( JOIN CROSS entityPersisterReference )
-;
-
-qualifiedJoin :
- #(
- j:JOIN (jt:nonCrossJoinType)? (
- e:entityPersisterReference (on:onFragment[#e])? {
- buildAdHocJoinNode( #e, #jt, #on );
- if ( on != null ) {
- popOnFragmentPropertyPathContext();
- }
- }
- | (f:FETCH)? (a:ALIAS)? (pf:PROP_FETCH)? { pushFromClausePropertyPathContext(
jt, #f, #a, #pf ); } prop:propertyRef (with:withFragment[#prop])? {
- popFromClausePropertyPathContext();
- }
- )
- )
-;
-
-nonCrossJoinType :
- ( (LEFT | RIGHT) (OUTER)? )
- | INNER
- ;
-
-onFragment[ AST rhsPersisterReference ]
- : #( o:ON { pushOnFragmentPropertyPathContext( rhsPersisterReference ); } le:logicalExpr
) {
- #onFragment = #( o, le );
- }
- ;
-
-withFragment[ AST rhsPropertyReference ]
- : #( w:WITH { pushWithFragmentPropertyPathContext( rhsPropertyReference ); }
le:logicalExpr ) {
- #withFragment = #( w, le );
- applyWithFragment( #withFragment );
- popWithFragmentPropertyPathContext();
- }
- ;
-
-
-
-
-
-
-
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-// The statement sub-rules
-
-selectStatement :
- query ( ( m:MINUS | u:UNION ) (a:ALL)? query )*
-;
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-
-query
- : #(QUERY { pushStatement( #query ); }
- // The first phase places the FROM first to make processing the SELECT simpler.
- #( SELECT_FROM fromClause (selectClause)? )
- (whereClause)?
- (groupClause)?
- (orderClause)? {
- popStatement();
- }
- )
- ;
-
-selectClause
- : #( SELECT { pushSelectClausePropertyPathContext(); } ( d:DISTINCT )? x:selectExprList
) {
- #selectClause = #([SELECT_CLAUSE,"{select clause}"], #d, #x);
- popSelectClausePropertyPathContext();
- }
- ;
-
-selectExprList
- : ( selectExprValue )+
- ;
-
-selectExprValue
- : ( selectExpr | aliasedSelectExpr ) {
- registerSelectExpression( #selectExprValue );
- }
- ;
-
-aliasedSelectExpr
- : #( AS se:selectExpr i:identifier! ) {
- injectSelectAlias( #se, #i );
- #aliasedSelectExpr = #se;
- }
- ;
-
-// TODO : the old grammar had both literal and constant available as select expressions,
but that is probably not valid; it is certainly not valid for non-subqueries
-selectExpr
- : (persisterReferenceAliasCheck) => persisterRefRef
- | pr:propertyRef { #selectExpr = handleSelectedPropertyRef( #pr ); }
- | arithmeticExpr
- | count
- | literal
- | constant
- ;
-
-persisterRefRef!
- : alias:IDENT {
- #persisterRefRef = #( [ PERSISTER_REF_REF, alias.getText() ] );
- }
- ;
-
-count
- : #(COUNT ( DISTINCT | ALL )? ( propertyRef | literal | ROW_STAR ) )
- ;
-
-fromClause
- : #( f:FROM rootFromElement ( explicitJoin | rootFromElement )* )
- ;
-
-rootFromElement!
- : #( RANGE e:entityPersisterReference ) {
- #rootFromElement = #e;
- }
- ;
-
-entityPersisterReference!
- : en:ENTITY_NAME (a:ALIAS)? (pf:PROP_FETCH)? {
- #entityPersisterReference = buildEntityPersisterReference( en, a, pf );
- }
- ;
-
-explicitJoin!
- : #(
- j:JOIN (jt:joinType)?
- (
- e:entityPersisterReference (on:onFragment[#e])? {
- buildAdHocJoinNode( #e, #jt, #on );
- if ( on != null ) {
- popOnFragmentPropertyPathContext();
- }
- }
- | (f:FETCH)? (a:ALIAS)? (pf:PROP_FETCH)? { pushFromClausePropertyPathContext( jt, #f,
#a, #pf ); } prop:propertyRef (with:withFragment[#prop])? {
- popFromClausePropertyPathContext();
- }
- )
- )
- ;
-
-
-///////////////////////////////////////////////////////////////////////////////
-// propertyRef related rules...
-//
-
-/**
- * The top level property ref recognition rule.
- */
-propertyRef
- : (unqualifiedPropertyRefCheck) => unqualifiedPropertyRef
- | implicitJoin
- | indexOperation
- ;
-
-/**
- * A rule utilizing a validating semantic predicate to contextually
- * ensure that we have unqualified property reference. Generally
- * used from within syntactic predicates to disambiguate the match path
- *
- * see {@link #implicitJoinSource} for example
- */
-unqualifiedPropertyRefCheck!
- : prop:IDENT { isUnqualifiedPropertyReference( prop ) }?
- ;
-
-/**
- * AST construction rule for building AST relating to *known*
- * unqualified property references. Do not call this rule unless
- * you know for certain (ala, have verified via the unqualifiedPropertyRefCheck
- * rule or similiar) that the next token is an IDENT representing an
- * unqualified property reference.
- */
-unqualifiedPropertyRef!
- : prop:IDENT {
- #unqualifiedPropertyRef = buildUnqualifiedPropertyReference( prop );
- }
- ;
-
-/**
- * A rule utilizing a validating semantic predicate to contextually
- * ensure that we have an alias for a persister reference previously
- * encountered and processed. Generally used from within syntactic
- * predicates to disambiguate the path.
- */
-persisterReferenceAliasCheck!
- : alias:IDENT { isPersisterReferenceAlias( alias ) }?
- ;
-
-/**
- * AST construction rule for building AST relating to *known*
- * persister reference aliases. Do not call this rule unless
- * you know for certain (ala, have verified via the persisterReferenceAliasCheck
- * rule or similiar) that the next token is an IDENT representing an
- * alias for a persister reference
- */
-persisterReferenceAlias!
- : alias:IDENT {
- #persisterReferenceAlias = resolveAlias( alias );
- }
- ;
-
-/**
- * Perhaps better named as 'complex property ref' or 'pathed property
ref' i.e.
- * Anyway, the basic idea is (DOT <source> IDENT)
- */
-implicitJoin!
- : #( d:DOT source:implicitJoinSource prop:IDENT) {
- #implicitJoin = resolvePropertyPathTerminus( #source, #prop );
- }
- ;
-
-intermediateImplicitJoin!
- : #( d:DOT source:implicitJoinSource prop:IDENT) {
- #intermediateImplicitJoin = resolvePropertyPathIntermediary( #source, #prop );
- }
- ;
-
-/**
- * The output of the implicitJoinSource rule is a {@link
org.hibernate.sql.ast.phase.resolve.patg.PropertyPathPart}
- * reference which is a tokenized and encoded representation of the current path
expression
- * resolution state.
- */
-implicitJoinSource
- : (persisterReferenceAliasCheck) => a:IDENT { #implicitJoinSource =
resolveQualifiedRoot( #a ); }
- | (unqualifiedPropertyRefCheck) => pr:IDENT { #implicitJoinSource =
resolveUnqualifiedRoot( #pr ); }
- | intermediateImplicitJoin
- | i:indexOperation { #implicitJoinSource = resolveIndexedRoot( #i ); }
- ;
-
-indexOperation
- : #( i:INDEX_OP coll:propertyRef selector:indexSelector ) {
- validateIndexOperationOperands( #coll, #selector );
- }
- ;
-
-indexSelector
- : constant
- | parameter
- | arithmeticExpr
- | collectionFunctionCall
- ;
-
-//
-// <end> propertyRef related rules...
-///////////////////////////////////////////////////////////////////////////////
-
-collectionFunctionCall
- : #( METHOD_CALL pathAsIdent ( #(EXPR_LIST alias ) )? )
- ;
-
-alias!
- : i:identifier {
- #alias = resolveAlias( i );
- }
- ;
-
-joinType
- : ( (LEFT | RIGHT) (OUTER)? )
- | FULL
- | INNER
- ;
-
-onFragment[ AST rhsPersisterReference ]
- : #( o:ON { pushOnFragmentPropertyPathContext( rhsPersisterReference ); } le:logicalExpr
) {
- #onFragment = #( o, le );
- }
- ;
-
-withFragment[ AST rhsPropertyReference ]
- : #( w:WITH { pushWithFragmentPropertyPathContext( rhsPropertyReference ); }
le:logicalExpr ) {
- #withFragment = #( w, le );
- applyWithFragment( #withFragment );
- popWithFragmentPropertyPathContext();
- }
- ;
-
-
-intoClause
- : #(i:INTO (subtree)* )
- ;
-
-whereClause
- : #(WHERE logicalExpr )
- ;
-
-groupClause
- : #(GROUP (subtree)* )
- ;
-
-orderClause
- : #(ORDER (subtree)* )
- ;
-
-
-logicalExpr
- : #(AND logicalExpr logicalExpr)
- | #(OR logicalExpr logicalExpr)
- | #(NOT logicalExpr)
- | comparisonExpr
- ;
-
-comparisonExpr
- :
- ( #(EQ exprOrSubquery exprOrSubquery)
- | #(NE exprOrSubquery exprOrSubquery)
- | #(LT exprOrSubquery exprOrSubquery)
- | #(GT exprOrSubquery exprOrSubquery)
- | #(LE exprOrSubquery exprOrSubquery)
- | #(GE exprOrSubquery exprOrSubquery)
- | #(LIKE exprOrSubquery expr ( #(ESCAPE expr) )? )
- | #(NOT_LIKE exprOrSubquery expr ( #(ESCAPE expr) )? )
- | #(BETWEEN exprOrSubquery exprOrSubquery exprOrSubquery)
- | #(NOT_BETWEEN exprOrSubquery exprOrSubquery exprOrSubquery)
- | #(IN exprOrSubquery inRhs )
- | #(NOT_IN exprOrSubquery inRhs )
- | #(IS_NULL exprOrSubquery)
- | #(IS_NOT_NULL exprOrSubquery)
- | #(EXISTS ( expr | collectionFunctionOrSubselect ) )
- )
- ;
-
-inRhs
- : #(IN_LIST ( collectionFunctionOrSubselect | ( (expr)* ) ) )
- ;
-
-exprOrSubquery
- : expr
- | query
- | #(ANY collectionFunctionOrSubselect)
- | #(ALL collectionFunctionOrSubselect)
- | #(SOME collectionFunctionOrSubselect)
- ;
-
-collectionFunctionOrSubselect
- : collectionFunction
- | query
- ;
-
-collectionFunction
- : #( ELEMENTS propertyRef )
- | #( INDICES propertyRef )
- ;
-
-aggregateExpr
- : expr
- | collectionFunction
- ;
-
-expr
- : addrExpr
- | #( VECTOR_EXPR (expr)* )
- | constant
- | arithmeticExpr
- | functionCall // Function call, not in the SELECT clause.
- | parameter
- | count // Count, not in the SELECT clause.
- ;
-
-arithmeticExpr
- : #(PLUS expr expr)
- | #(MINUS expr expr)
- | #(DIV expr expr)
- | #(STAR expr expr)
- | #(UNARY_MINUS expr)
- | caseExpr
- ;
-
-caseExpr
- : #(CASE (#(WHEN logicalExpr expr))+ (#(ELSE expr))?)
- | #(CASE2 expr (#(WHEN expr expr))+ (#(ELSE expr))?)
- ;
-
-//addrExpr
-// : propertyRef
-// | #(INDEX_OP addrExprLhs expr)
-// ;
-
-addrExpr
- : propertyRef
- ;
-
-addrExprLhs
- : addrExpr
- ;
-
-constant
- : NULL
- | TRUE
- | FALSE
- | javaConstant
- ;
-
-javaConstant
- : JAVA_CONSTANT
- ;
-
-literal
- : NUM_INT
- | NUM_LONG
- | NUM_FLOAT
- | NUM_DOUBLE
- | QUOTED_STRING
- ;
-
-parameter!
- : #( c:COLON (c2:COLON)? i:identifier ) {
- if ( c2 != null ) {
- // allows escaping the colon...
- String text = ":" + i.getText();
- #parameter = #( [IDENT, text] );
- }
- else {
- #parameter = generateNamedParameter( c, i );
- }
- }
- | #( p:PARAM (n:NUM_INT)? ) {
- if ( n != null ) {
- // An ejb3-style "positional parameter", which we handle internally as a
named-parameter
- #parameter = generateNamedParameter( p, n );
- }
- else {
- #parameter = generateOrdinalParameter( p );
- }
- }
- ;
-
-functionCall
- : #(METHOD_CALL pathAsIdent ( #(EXPR_LIST (expr)* ) )? )
- | #(AGGREGATE aggregateExpr )
- ;
-
-//propertyRef
-// : propertyPath
-// ;
-
-propertyName
- : identifier
- | CLASS
- | ELEMENTS
- | INDICES
- ;
-
-// Matches a path and returns the normalized string for the path (usually
-// fully qualified a class name).
-pathAsString returns [String p] {
- p = "???";
- String x = "?x?";
- }
- : a:identifier { p = a.getText(); }
- | #(DOT x=pathAsString y:identifier) {
- StringBuffer buf = new StringBuffer();
- buf.append(x).append(".").append(y.getText());
- p = buf.toString();
- }
- ;
-
-// Returns a path as a single identifier node.
-pathAsIdent {
- String text = "?text?";
- }
- : text=pathAsString {
- #pathAsIdent = #([IDENT,text]);
- }
- ;
-
-identifier
- : (IDENT | WEIRD_IDENT)
- ;
-
-// General subtree. Matches anything, copies the tree verbatim.
-subtree
- : #(. (subtree)*)
- ;
Deleted:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/hql/ast/phase/parse/HqlParser.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/hql/ast/phase/parse/HqlParser.java 2009-01-06
20:11:13 UTC (rev 15747)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/hql/ast/phase/parse/HqlParser.java 2009-01-06
20:29:32 UTC (rev 15748)
@@ -1,623 +0,0 @@
-/*
- * 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
- */
-package org.hibernate.hql.ast.phase.parse;
-
-import org.hibernate.sql.ast.util.ASTUtil;
-import org.hibernate.sql.ast.util.ASTPrinter;
-import org.hibernate.sql.ast.util.ErrorCounter;
-import org.hibernate.sql.ast.util.ParseErrorHandler;
-import org.hibernate.QueryException;
-import org.hibernate.MappingException;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.sql.ast.common.CommonHibernateLexer;
-import org.hibernate.sql.ast.common.TokenImpl;
-import org.hibernate.sql.ast.common.Node;
-import org.hibernate.util.ReflectHelper;
-import org.hibernate.util.StringHelper;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.StringReader;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-import antlr.collections.AST;
-import antlr.RecognitionException;
-import antlr.TokenStreamException;
-import antlr.Token;
-import antlr.ASTPair;
-import antlr.MismatchedTokenException;
-import antlr.SemanticException;
-import antlr.ASTFactory;
-
-/**
- * The parser used by Hibernate to generate an AST given an input
- * HQL string (a "stream parser"). The produced AST is then used
- * (and mutated) by later phases/parsers to apply semantic resolution;
- * this parser, however, is all about syntax resolution.
- *
- * @author Steve Ebersole
- */
-public class HqlParser extends GeneratedHqlParser {
- private static final Logger log = LoggerFactory.getLogger( HqlParser.class );
-
- private final Context context;
- private final ParseErrorHandler parseErrorHandler = new ErrorCounter();
- private final ASTPrinter printer = new ASTPrinter( HqlParseTokenTypes.class );
- private int traceDepth = 0;
-
- public static interface Context {
- /**
- * Does this name represent an entity name?
- *
- * @param name The name to check
- * @return True if the name represents an entioty name; false otherwise.
- */
- public boolean isEntityName(String name);
-
- /**
- * Get the import "replacement" name for the given name (e.g., 'User'
-> 'com.acme.User'). <tt>null</tt>
- * indicates an unrecognized name.
- *
- * @param name The name for which to locate the imported name.
- * @return The corresponding imported name, or null.
- */
- public String getImportedName(String name);
-
- /**
- * Does the given name represent a registered function name?
- *
- * @param name The name to check
- * @return True if the name matches a registered function name; false otherwise.
- */
- public boolean isRegisteredFunctionName(String name);
- }
-
- public HqlParser(String hql, Context context) {
- super( new CommonHibernateLexer( new StringReader( hql ) ) );
- this.context = context;
- super.setASTFactory( new ASTFactoryImpl() );
- }
-
- public HqlParser(String hql, final SessionFactoryImplementor sessionFactoryImplementor)
{
- this(
- hql,
- new Context() {
- public boolean isEntityName(String name) {
- return findEntityPersisterByName( name ) != null;
- }
-
- public String getImportedName(String name) {
- return sessionFactoryImplementor.getImportedClassName( name );
- }
-
- public boolean isRegisteredFunctionName(String name) {
- return sessionFactoryImplementor.getDialect().getFunctions().get( name ) != null;
- }
-
- private EntityPersister findEntityPersisterByName(String name) throws
MappingException {
- try {
- return sessionFactoryImplementor.getEntityPersister( name );
- }
- catch ( MappingException ignore ) {
- // unable to locate it using this name
- }
-
- // If that didn't work, try using the 'import' name.
- String importedClassName = sessionFactoryImplementor.getImportedClassName( name );
- if ( importedClassName == null ) {
- return null;
- }
- return sessionFactoryImplementor.getEntityPersister( importedClassName );
- }
- }
- );
- }
-
-
- // overrides of Antlr infastructure methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public void reportError(RecognitionException e) {
- parseErrorHandler.reportError( e );
- }
-
- public void reportError(String s) {
- parseErrorHandler.reportError( s );
- }
-
- public void reportWarning(String s) {
- parseErrorHandler.reportWarning( s );
- }
-
- public ParseErrorHandler getParseErrorHandler() {
- return parseErrorHandler;
- }
-
- static public void panic() {
- //overriden to avoid System.exit
- throw new QueryException( "Parser: panic" );
- }
-
- public void setASTFactory(ASTFactory astFactory) {
- throw new UnsupportedOperationException( "not allowed!" );
- }
-
-
-// various AST output methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public void traceIn(String s) throws TokenStreamException {
- if ( inputState.guessing > 0 ) {
- return;
- }
- String prefix = StringHelper.repeat( "-", (traceDepth++ * 2) ) +
"->";
- trace( prefix + s );
- }
-
- public void traceOut(String s) throws TokenStreamException {
- if ( inputState.guessing > 0 ) {
- return;
- }
- String prefix = "<-" + StringHelper.repeat( "-", (--traceDepth *
2) );
- trace( prefix + s );
- }
-
- private void trace(String msg) {
- System.out.println( msg );
-// log.trace( msg );
- }
-
- public void dumpAst(AST ast) {
- dumpAst( ast, "DUMP" );
- }
-
- public void dumpAst(AST ast, String header) {
- log.info( printer.showAsString( ast, header ) );
- }
-
- public void showAst(AST ast, PrintStream out) {
- showAst( ast, new PrintWriter( out ) );
- }
-
- private void showAst(AST ast, PrintWriter pw) {
- printer.showAst( ast, pw );
- }
-
-
- // overrides of grammar semantic actions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public String extractPath(AST tree) {
- try {
- return PathCollector.getPath( tree );
- }
- catch ( Throwable t ) {
- return tree.getText();
- }
- }
-
- public boolean isRegisteredFunction(AST tree) {
- return context.isRegisteredFunctionName( extractPath( tree ) );
- }
-
- public boolean isJavaConstant(String path) {
- try {
- log.debug( "Testing path [" + path + "] as potential java
constant" );
- Object value = ReflectHelper.getConstantValueStrictly( path );
- log.debug( "Resolved path to java constant [" + value + "]" );
- return true;
- }
- catch( Throwable t ) {
- log.debug( "Path did not resolve to java constant : " + t );
- return false;
- }
- }
-
- public String resolveEntityName(String name) {
- return context.getImportedName( name );
- }
-
- public String resolveDynamicInstantiationPojoName(AST name) throws SemanticException {
- String path = extractPath( name );
- if ( "list".equals( path ) || "map".equals( path ) ) {
- return path;
- }
- else {
- String importedName = context.getImportedName( path );
- try {
- Class importedClass = ReflectHelper.classForName( importedName );
- return importedClass.getName();
- }
- catch ( ClassNotFoundException e ) {
- throw new SemanticException( "Unable to locate dynamic instantiation class
[" + importedName + "]" );
- }
- }
- }
-
- protected AST processEqualityExpression(AST x) {
- if ( x == null ) {
- log.warn( "processEqualityExpression() : No expression to process!" );
- return null;
- }
-
- int type = x.getType();
- if ( log.isTraceEnabled() ) {
- log.trace( "processEqualityExpression() -> type : {}, name : {}",
Integer.toString( type ), ASTUtil.getTokenTypeName( HqlParseTokenTypes.class, type ) );
- }
- if ( type == EQUALS_OP || type == NOT_EQUALS_OP || type == SQL_NOT_EQUALS_OP ) {
- boolean negated = ( type != EQUALS_OP );
- if ( x.getNumberOfChildren() == 2 ) {
- AST a = x.getFirstChild();
- AST b = a.getNextSibling();
- // (EQ NULL b) => (IS_NULL b)
- if ( a.getType() == NULL && b.getType() != NULL ) {
- return createIsNullParent( b, negated );
- }
- // (EQ a NULL) => (IS_NULL a)
- else if ( b.getType() == NULL && a.getType() != NULL ) {
- return createIsNullParent( a, negated );
- }
- else if ( b.getType() == EMPTY ) {
- return processIsEmpty( a, negated );
- }
- else {
- return x;
- }
- }
- else {
- return x;
- }
- }
- else {
- return x;
- }
- }
-
- private AST createIsNullParent(AST node, boolean negated) {
- node.setNextSibling( null );
- int type = negated ? IS_NOT_NULL : IS_NULL;
- String text = negated ? "is not null" : "is null";
- return ASTUtil.createParent( astFactory, type, text, node );
- }
-
- protected AST processMemberOf(AST path, AST notNode) {
- AST inNode = notNode == null ? astFactory.create( IN, "in" ) :
astFactory.create( NOT_IN, "not in" );
- AST subqueryNode = createSubquery( path );
- AST inListNode = ASTUtil.createParent( astFactory, IN_LIST, "in-list",
subqueryNode );
- inNode.addChild( inListNode );
- return inNode;
- }
-
- private AST createSubquery(AST subquerySource) {
-// AST ast = ASTUtil.createParent( astFactory, RANGE, "RANGE", node );
-// todo : what is the type of 'node'?
- log.debug(
- "Generating subquery; incoming node type = {}; incoming node = [{}]",
- printer.getTokenTypeName( subquerySource.getType() ),
- subquerySource
- );
- AST fromNode = ASTUtil.createParent( astFactory, FROM, "from", subquerySource
);
- AST selectFromNode = ASTUtil.createParent( astFactory, SELECT_FROM,
"SELECT_FROM", fromNode );
- return ASTUtil.createParent( astFactory, QUERY, "QUERY", selectFromNode );
- }
-
- protected AST processIsEmpty(AST collection, AST notToken) {
- return processIsEmpty( collection, notToken != null );
- }
-
- private AST processIsEmpty(AST node, boolean negated) {
- node.setNextSibling( null );
- AST ast = createSubquery( node );
- ast = ASTUtil.createParent( astFactory, EXISTS, "exists", ast );
- // Add NOT if it's negated.
- if ( negated ) {
- ast = ASTUtil.createParent( astFactory, NOT, "not", ast );
- }
- return ast;
- }
- public AST negateNode(AST x) {
- //TODO: switch statements are always evil! We already had bugs because
- // of forgotten token types. Use polymorphism for this!
- switch ( x.getType() ) {
- case OR:
- x.setType(AND);
- x.setText("{and}");
- negateNode( x.getFirstChild() );
- negateNode( x.getFirstChild().getNextSibling() );
- return x;
- case AND:
- x.setType(OR);
- x.setText("{or}");
- negateNode( x.getFirstChild() );
- negateNode( x.getFirstChild().getNextSibling() );
- return x;
- case EQUALS_OP:
- x.setType( NOT_EQUALS_OP );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (EQ a b) ) => (NE a b)
- case NOT_EQUALS_OP:
- x.setType( EQUALS_OP );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (NE a b) ) => (EQ a b)
- case GREATER_THAN_OP:
- x.setType( LESS_THAN_OR_EQUALS_OP );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (GT a b) ) => (LE a b)
- case LESS_THAN_OP:
- x.setType( GREATER_THAN_OR_EQUALS_OP );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (LT a b) ) => (GE a b)
- case GREATER_THAN_OR_EQUALS_OP:
- x.setType( LESS_THAN_OP );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (GE a b) ) => (LT a b)
- case LESS_THAN_OR_EQUALS_OP:
- x.setType( GREATER_THAN_OP );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (LE a b) ) => (GT a b)
- case LIKE:
- x.setType( NOT_LIKE );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (LIKE a b) ) => (NOT_LIKE a b)
- case NOT_LIKE:
- x.setType( LIKE );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (NOT_LIKE a b) ) => (LIKE a b)
- case IN:
- x.setType( NOT_IN );
- x.setText( "{not}" + x.getText() );
- return x;
- case NOT_IN:
- x.setType( IN );
- x.setText( "{not}" + x.getText() );
- return x;
- case IS_NULL:
- x.setType( IS_NOT_NULL );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (IS_NULL a b) ) => (IS_NOT_NULL a b)
- case IS_NOT_NULL:
- x.setType( IS_NULL );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (IS_NOT_NULL a b) ) => (IS_NULL a b)
- case BETWEEN:
- x.setType( NOT_BETWEEN );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (BETWEEN a b) ) => (NOT_BETWEEN a b)
- case NOT_BETWEEN:
- x.setType( BETWEEN );
- x.setText( "{not}" + x.getText() );
- return x; // (NOT (NOT_BETWEEN a b) ) => (BETWEEN a b)
- case NOT:
- return x.getFirstChild(); // (NOT (NOT x) ) => (x)
- default:
- return super.negateNode( x ); // Just add a 'not' parent.
- }
- }
-
- protected void transferTrackingInfo(AST source, AST target) {
- if ( target instanceof Node ) {
- ( ( Node ) target ).transferTrackingInfo( source );
- }
- else {
- super.transferTrackingInfo( source, target );
- }
- }
-
- /**
- * Overrides the base behavior to retry keywords as identifiers.
- *
- * @param token The token.
- * @param ex The recognition exception.
- * @return AST - The new AST.
- * @throws antlr.RecognitionException if the substitution was not possible.
- * @throws antlr.TokenStreamException if the substitution was not possible.
- */
- public AST handleIdentifierError(Token token, RecognitionException ex) throws
RecognitionException, TokenStreamException {
- // If the token can tell us if it could be an identifier...
- if ( token instanceof TokenImpl ) {
- TokenImpl hqlToken = ( TokenImpl ) token;
- // ... and the token could be an identifer and the error is
- // a mismatched token error ...
- if ( hqlToken.isPossibleIdentifier() && ex instanceof MismatchedTokenException
) {
- MismatchedTokenException mte = ( MismatchedTokenException ) ex;
- // ... and the expected token type was an identifier, then:
- if ( mte.expecting == IDENT ) {
- // Use the token as an identifier.
- reportWarning(
- "Keyword '"+ token.getText()
- + "' is being interpreted as an identifier due to: "
- + mte.getMessage()
- );
- // Add the token to the AST.
- ASTPair currentAST = new ASTPair();
-// token.setType( WEIRD_IDENT );
- token.setType( IDENT );
- astFactory.addASTChild( currentAST, astFactory.create( token ) );
- consume();
- return currentAST.root;
- }
- }
- }
- return super.handleIdentifierError( token, ex );
- }
-
- public void handleDotIdent() throws TokenStreamException {
- // This handles HHH-354, where there is a strange property name in a where
clause.
- // If the lookahead contains a DOT then something that isn't an IDENT...
- handleDotIdent( 1 );
- }
-
- protected int handleDotIdent(int offset) throws TokenStreamException {
- while ( LA( offset ) == DOT ) {
- switch ( LA( offset+1 ) ) {
- case IDENT:
- case CLASS:
- break; // break the case statement, not the loop...
- default:
- convertPossibleIdentifier( ( TokenImpl ) LT( offset+1 ) );
- }
- offset += 2;
- }
- return offset;
- }
-
- protected void weakKeywords() throws TokenStreamException {
- switch ( LA( 1 ) ) {
- case ORDER:
- case GROUP:
- // Case 1: Multi token keywords GROUP BY and ORDER BY
- // The next token ( LT(2) ) should be 'by'... otherwise, this is just an
ident.
- if ( LA( 2 ) != BY ) {
- convertPossibleIdentifier( ( TokenImpl ) LT(1) );
- }
- break;
- case IDENT:
- break;
- default :
- if ( LA(0) == FROM && LA(2) == DOT ) {
- convertPossibleIdentifier( ( TokenImpl ) LT(1) );
- }
- }
- }
-
- protected void unequivocalKeywordAsIdentifier() throws TokenStreamException {
- if ( LA(1) == IDENT ) {
- return;
- }
- convertPossibleIdentifier( ( TokenImpl ) LT(1) );
- }
-
- protected void potentialUpdatePersisterAlias() throws TokenStreamException {
- switch( LA(1) ) {
- case AS:
- // alias rule will handle this...
- case SET:
- // SET marks the beginning of the UPDATE's SET-clause
- break;
- default:
- convertPossibleIdentifier( ( TokenImpl ) LT(1) );
- }
- }
-
- protected void potentialDeletePersisterAlias() throws TokenStreamException {
- switch( LA(1) ) {
- case AS:
- // alias rule will handle this...
- case WHERE:
- break;
- default:
- convertPossibleIdentifier( ( TokenImpl ) LT(1) );
- }
- }
-
- protected void prepareForPersisterReferenceRoot() throws TokenStreamException {
- if ( LA(1) == IN ) {
- return;
- }
-
- unequivocalKeywordAsIdentifier();
-
- if ( LA(1) == IDENT && LA(2) == IN ) {
- return;
- }
-
- prepareForBasicEntityPersisterReference();
- }
-
- protected void prepareForCrossJoinElements() throws TokenStreamException {
- unequivocalKeywordAsIdentifier();
- prepareForBasicEntityPersisterReference();
- }
-
- protected void prepareForBasicEntityPersisterReference() throws TokenStreamException {
- int offset = handleDotIdent( 2 );
- int next = LA(offset);
- switch ( next ) {
- case AS: {
- // the next token would need to be the persister alias
- convertPossibleIdentifier( (TokenImpl) LT(offset+1) );
- break;
- }
- case IDENT : {
- // nothing to do
- break;
- }
- case WHERE:
- case COMMA:
- case ON:
- case WITH:
- case JOIN:
- case RIGHT:
- case LEFT:
- case CROSS: {
- // single token structural elements indicating that the next thing could not be an
alias
- break;
- }
- case UNION:
- case INTERSECT:
- case EXCEPT: {
- int nextNext = LA(offset+1);
- if ( nextNext == SELECT || nextNext == FROM ) {
- break;
- }
- else if ( nextNext == ALL ) {
- int nextNextNext = LA(offset+2);
- if ( nextNextNext == SELECT || nextNextNext == FROM ) {
- break;
- }
- }
- convertPossibleIdentifier( ( TokenImpl ) LT(offset) );
- break;
- }
- case GROUP:
- case ORDER:
- if ( LA(offset+1) != BY ) {
- convertPossibleIdentifier( ( TokenImpl ) LT(offset) );
- }
- break;
- case FETCH:
- if ( ! ( LA(offset+1) == ALL && LA(offset+2) == PROPERTIES ) ) {
- // not sure sure I like allowing 'fetch' as an indentifier
- log.warn( "interpretting [fetch] keyword as alias; consider using differen
alias" );
- convertPossibleIdentifier( ( TokenImpl ) LT(offset) );
- }
- break;
- default:
- convertPossibleIdentifier( ( TokenImpl ) LT(offset) );
- break;
- }
- }
-
- protected void prepareForQualifiedJoinElements() throws TokenStreamException {
- unequivocalKeywordAsIdentifier();
- prepareForBasicEntityPersisterReference();
- }
-
- protected void convertPossibleIdentifier(TokenImpl token) {
- if ( token.isPossibleIdentifier() ) {
- token.setType( IDENT );
- log.debug( "Converting keyword-to-identifier [{}]; [id={}]", token, new
Integer(System.identityHashCode( token ) ) );
- }
- }
-}
Deleted:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/hql/ast/phase/parse/PathCollector.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/hql/ast/phase/parse/PathCollector.java 2009-01-06
20:11:13 UTC (rev 15747)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/hql/ast/phase/parse/PathCollector.java 2009-01-06
20:29:32 UTC (rev 15748)
@@ -1,74 +0,0 @@
-/*
- * 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
- */
-package org.hibernate.hql.ast.phase.parse;
-
-import org.hibernate.sql.ast.util.NodeTraverser;
-
-import antlr.collections.AST;
-
-/**
- * Utilizes a NodeTraverser in order to collect a path from
- * a (expecting dot-structure) an AST.
- *
- * @author Steve Ebersole
- */
-public class PathCollector implements NodeTraverser.VisitationStrategy,
HqlParseTokenTypes {
- private String path = "";
-
- private PathCollector() {
- }
-
- public void visit(AST node) {
- if ( node.getType() == DOT ) {
- path += '.';
- }
- else if ( "$".equals( node.getText() ) ) {
- // allowable for treating java constants
- path += '$';
- }
- else {
- path += node.getText();
- }
- }
-
- public static String getPath(AST dotStructure) {
- if ( dotStructure.getType() == IDENT ) {
- return dotStructure.getText();
- }
-
- return extractText( dotStructure );
- }
-
- private static String extractText(AST node) {
- AST lhs = node.getFirstChild();
- AST rhs = lhs.getNextSibling();
-
- if ( lhs.getType() == IDENT ) {
- return lhs.getText() + node.getText() + rhs.getText();
- }
- else {
- return extractText( lhs ) + node.getText() + rhs.getText();
- }
- }
-}
Modified:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/CollectionPersisterReference.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/CollectionPersisterReference.java 2009-01-06
20:11:13 UTC (rev 15747)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/CollectionPersisterReference.java 2009-01-06
20:29:32 UTC (rev 15748)
@@ -31,7 +31,6 @@
import org.hibernate.type.EntityType;
import org.hibernate.type.ComponentType;
import org.hibernate.persister.collection.QueryableCollection;
-import org.hibernate.persister.collection.CollectionPropertyMapping;
import org.hibernate.persister.entity.Queryable;
/**
@@ -39,11 +38,9 @@
*
* @author Steve Ebersole
*/
-public class CollectionPersisterReference extends AbstractPersisterReference
- implements NormalizationContextAwareNode, DisplayableNode {
+public class CollectionPersisterReference extends AbstractPersisterReference implements
PersisterReference, NormalizationContextAwareNode, DisplayableNode {
private NormalizationContext resolutionContext;
private transient QueryableCollection persister;
- private transient CollectionPropertyMapping propertyMapping;
/**
* Retrieve the collection "role" identifying the underlying {@link
org.hibernate.persister.collection.CollectionPersister}
@@ -123,7 +120,7 @@
this.resolutionContext = resolutionContext;
}
- private final SessionFactoryImplementor getSessionFactory() {
+ private SessionFactoryImplementor getSessionFactory() {
if ( resolutionContext == null ) {
throw new AssertionFailure( "resolution context was null on attempt to retrieve
session factory reference" );
}