[hibernate-commits] Hibernate SVN: r16412 - in core/branches/antlr3/src: main/java/org/hibernate/sql/ast/phase/hql/resolve and 1 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Wed Apr 22 17:20:04 EDT 2009
Author: porcelli
Date: 2009-04-22 17:20:04 -0400 (Wed, 22 Apr 2009)
New Revision: 16412
Modified:
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
core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java
Log:
now 2nd pase is using the SelectPathResolutionStrategy
Modified: 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-22 20:18:51 UTC (rev 16411)
+++ core/branches/antlr3/src/main/antlr3/org/hibernate/sql/ast/phase/hql/resolve/GeneratedHQLResolution.g 2009-04-22 21:20:04 UTC (rev 16412)
@@ -48,59 +48,64 @@
@members{
protected void registerPersisterSpace(CommonTree entityName,
CommonTree alias) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected boolean isUnqualifiedPropertyReference() {
- return false;
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected Tree normalizeUnqualifiedPropertyReference(CommonTree property) {
- return null;
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected boolean isPersisterReferenceAlias() {
- return false;
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected PathedPropertyReferenceSource normalizeUnqualifiedRoot( CommonTree identifier382 ) {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected PathedPropertyReferenceSource normalizeQualifiedRoot( CommonTree identifier381 ) {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException( "must be overridden!" );
}
- protected void normalizePropertyPathIntermediary( CommonTree commonTree,
- CommonTree identifier387 ) {
- // TODO Auto-generated method stub
+ protected PathedPropertyReferenceSource normalizePropertyPathIntermediary( PathedPropertyReferenceSource source, CommonTree propertyName ) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void normalizeIntermediateIndexOperation( CommonTree commonTree,
CommonTree commonTree2 ) {
- // TODO Auto-generated method stub
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void normalizeUnqualifiedPropertyReferenceSource(
CommonTree identifier394 ) {
- // TODO Auto-generated method stub
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void normalizeTerminalIndexOperation(CommonTree collectionPath, CommonTree selector) {
- // TODO Auto-generated method stub
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void normalizePropertyPathTerminus(PathedPropertyReferenceSource source, CommonTree propertyNameNode) {
- // TODO Auto-generated method stub
+ 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!" );
}
}
@@ -227,6 +232,8 @@
;
selectClause
+ at init { if (state.backtracking == 0) pushSelectStrategy(); }
+ at after { popStrategy(); }
: ^(SELECT DISTINCT? rootSelectExpression)
;
@@ -336,7 +343,7 @@
| ^(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 path)
+ | ^(PATH propertyReferencePath)
;
caseExpression
@@ -577,13 +584,13 @@
pathedPropertyReferenceSource returns [PathedPropertyReferenceSource propertyReferenceSource]
: {(isPersisterReferenceAlias())}?=> IDENTIFIER { $propertyReferenceSource = normalizeQualifiedRoot( $IDENTIFIER ); }
| {(isUnqualifiedPropertyReference())}?=> IDENTIFIER { $propertyReferenceSource = normalizeUnqualifiedRoot( $IDENTIFIER ); }
- | intermediatePathedPropertyReference
- | intermediateIndexOperation
+ | intermediatePathedPropertyReference { $propertyReferenceSource = $intermediatePathedPropertyReference.propertyReferenceSource; }
+ | intermediateIndexOperation { $propertyReferenceSource = null; }
;
-intermediatePathedPropertyReference
- : ^(DOT pathedPropertyReferenceSource IDENTIFIER )
- { normalizePropertyPathIntermediary( $pathedPropertyReferenceSource.tree, $IDENTIFIER ); }
+intermediatePathedPropertyReference returns [PathedPropertyReferenceSource propertyReferenceSource]
+ : ^(DOT source=pathedPropertyReferenceSource IDENTIFIER )
+ { $propertyReferenceSource = normalizePropertyPathIntermediary( $pathedPropertyReferenceSource.propertyReferenceSource, $IDENTIFIER ); }
;
intermediateIndexOperation
Modified: 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-22 20:18:51 UTC (rev 16411)
+++ core/branches/antlr3/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HQLResolution.java 2009-04-22 21:20:04 UTC (rev 16412)
@@ -36,6 +36,7 @@
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;
@@ -134,6 +135,11 @@
.getText() ) );
}
+ protected void pushSelectStrategy() {
+ pathResolutionStrategyStack
+ .push( new SelectClausePathResolutionStrategy( this ) );
+ }
+
protected void popStrategy() {
pathResolutionStrategyStack.pop();
}
@@ -206,11 +212,13 @@
propertyNameNode.getText() );
}
- protected void normalizePropertyPathIntermediary( CommonTree identifier1,
- CommonTree identifier2 ) {
- System.out.println( "normalizePropertyPathIntermediary: "
- + identifier1.getText() + ":" + identifier2.getText() );
- // TODO Auto-generated method stub
+ 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,
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-22 20:18:51 UTC (rev 16411)
+++ core/branches/antlr3/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/TestHQLResolver.java 2009-04-22 21:20:04 UTC (rev 16412)
@@ -44,7 +44,7 @@
}
public void testBasicSelectStructure() throws Throwable {
- Tree queryTree = normalize( "from Animal as a inner join a.mother" );
+ Tree queryTree = normalize( "select a.id from Animal a" );
}
public Tree normalize( String hql ) throws RecognitionException {
More information about the hibernate-commits
mailing list