Methods Summary |
---|
private void | addChild(org.hibernate.hql.ast.tree.FromClause fromClause)
if ( childFromClauses == null ) {
childFromClauses = new HashSet();
}
childFromClauses.add( fromClause );
|
void | addCollectionJoinFromElementByPath(java.lang.String path, FromElement destination)
if ( log.isDebugEnabled() ) {
log.debug( "addCollectionJoinFromElementByPath() : " + path + " -> " + destination );
}
collectionJoinFromElementsByPath.put( path, destination ); // Add the new node to the map so that we don't create it twice.
|
void | addDuplicateAlias(java.lang.String alias, FromElement element)
fromElementByClassAlias.put( alias, element );
|
public FromElement | addFromElement(java.lang.String path, antlr.collections.AST alias)Adds a new from element to the from node.
// The path may be a reference to an alias defined in the parent query.
String classAlias = ( alias == null ) ? null : alias.getText();
checkForDuplicateClassAlias( classAlias );
FromElementFactory factory = new FromElementFactory( this, null, path, classAlias, null, false );
return factory.addFromElement();
|
public void | addImpliedFromElement(FromElement element)
impliedElements.add( element );
|
void | addJoinByPathMap(java.lang.String path, FromElement destination)
if ( log.isDebugEnabled() ) {
log.debug( "addJoinByPathMap() : " + path + " -> " + destination );
}
fromElementsByPath.put( path, destination );
|
private void | checkForDuplicateClassAlias(java.lang.String classAlias)
if ( classAlias != null && fromElementByClassAlias.containsKey( classAlias ) ) {
throw new SemanticException( "Duplicate definition of alias '"
+ classAlias + "'" );
}
|
public boolean | containsClassAlias(java.lang.String alias)Returns true if the from node contains the class alias name.
boolean isAlias = fromElementByClassAlias.containsKey( alias );
if ( !isAlias && getSessionFactoryHelper().isStrictJPAQLComplianceEnabled() ) {
isAlias = findIntendedAliasedFromElementBasedOnCrazyJPARequirements( alias ) != null;
}
return isAlias;
|
public boolean | containsTableAlias(java.lang.String alias)Returns true if the from node contains the table alias name.
return fromElementByTableAlias.keySet().contains( alias );
|
FromElement | findCollectionJoin(java.lang.String path)
return ( FromElement ) collectionJoinFromElementsByPath.get( path );
|
private FromElement | findIntendedAliasedFromElementBasedOnCrazyJPARequirements(java.lang.String specifiedAlias)
Iterator itr = fromElementByClassAlias.entrySet().iterator();
while ( itr.hasNext() ) {
Map.Entry entry = ( Map.Entry ) itr.next();
String alias = ( String ) entry.getKey();
if ( alias.equalsIgnoreCase( specifiedAlias ) ) {
return ( FromElement ) entry.getValue();
}
}
return null;
|
FromElement | findJoinByPath(java.lang.String path)Look for an existing implicit or explicit join by the
given path.
FromElement elem = findJoinByPathLocal( path );
if ( elem == null && parentFromClause != null ) {
elem = parentFromClause.findJoinByPath( path );
}
return elem;
|
FromElement | findJoinByPathLocal(java.lang.String path)
Map joinsByPath = fromElementsByPath;
return ( FromElement ) joinsByPath.get( path );
|
public java.util.List | getCollectionFetches()
return ASTUtil.collectChildren( this, collectionFetchPredicate );
|
public java.lang.String | getDisplayText()
return "FromClause{" +
"level=" + level +
", fromElementCounter=" + fromElementCounter +
", fromElements=" + fromElements.size() +
", fromElementByClassAlias=" + fromElementByClassAlias.keySet() +
", fromElementByTableAlias=" + fromElementByTableAlias.keySet() +
", fromElementsByPath=" + fromElementsByPath.keySet() +
", collectionJoinFromElementsByPath=" + collectionJoinFromElementsByPath.keySet() +
", impliedElements=" + impliedElements +
"}";
|
public java.util.List | getExplicitFromElements()
return ASTUtil.collectChildren( this, explicitFromPredicate );
|
public FromElement | getFromElement(java.lang.String aliasOrClassName)Retreives the from-element represented by the given alias.
FromElement fromElement = ( FromElement ) fromElementByClassAlias.get( aliasOrClassName );
if ( fromElement == null && getSessionFactoryHelper().isStrictJPAQLComplianceEnabled() ) {
fromElement = findIntendedAliasedFromElementBasedOnCrazyJPARequirements( aliasOrClassName );
}
if ( fromElement == null && parentFromClause != null ) {
fromElement = parentFromClause.getFromElement( aliasOrClassName );
}
return fromElement;
|
public FromElement | getFromElement()
// TODO: not sure about this one
// List fromElements = getFromElements();
// if ( fromElements == null || fromElements.isEmpty() ) {
// throw new QueryException( "Unable to locate from element" );
// }
return (FromElement) getFromElements().get(0);
|
public java.util.List | getFromElements()Returns the list of from elements in order.
return ASTUtil.collectChildren( this, fromElementPredicate );
|
public int | getLevel()
return level;
|
public org.hibernate.hql.ast.tree.FromClause | getParentFromClause()
return parentFromClause;
|
public java.util.List | getProjectionList()Returns the list of from elements that will be part of the result set.
return ASTUtil.collectChildren( this, projectionListPredicate );
|
public boolean | hasCollectionFecthes()
return getCollectionFetches().size() > 0;
|
public boolean | isFromElementAlias(java.lang.String possibleAlias)Convenience method to check whether a given token represents a from-element alias.
boolean isAlias = containsClassAlias( possibleAlias );
if ( !isAlias && parentFromClause != null ) {
// try the parent FromClause...
isAlias = parentFromClause.isFromElementAlias( possibleAlias );
}
return isAlias;
|
public boolean | isSubQuery()
// TODO : this is broke for subqueries in statements other than selects...
return parentFromClause != null;
|
public org.hibernate.hql.ast.tree.FromClause | locateChildFromClauseWithJoinByPath(java.lang.String path)
if ( childFromClauses != null && !childFromClauses.isEmpty() ) {
Iterator children = childFromClauses.iterator();
while ( children.hasNext() ) {
FromClause child = ( FromClause ) children.next();
if ( child.findJoinByPathLocal( path ) != null ) {
return child;
}
}
}
return null;
|
public int | nextFromElementCounter()
return fromElementCounter++;
|
public void | promoteJoin(FromElement elem)
if ( log.isDebugEnabled() ) {
log.debug( "Promoting [" + elem + "] to [" + this + "]" );
}
//TODO: implement functionality
// this might be painful to do here, as the "join post processing" for
// the subquery has already been performed (meaning that for
// theta-join dialects, the join conditions have already been moved
// over to the where clause). A "simple" solution here might to
// perform "join post processing" once for the entire query (including
// any subqueries) at one fell swoop
|
void | registerFromElement(FromElement element)
fromElements.add( element );
String classAlias = element.getClassAlias();
if ( classAlias != null ) {
// The HQL class alias refers to the class name.
fromElementByClassAlias.put( classAlias, element );
}
// Associate the table alias with the element.
String tableAlias = element.getTableAlias();
if ( tableAlias != null ) {
fromElementByTableAlias.put( tableAlias, element );
}
|
public void | resolve()
// Make sure that all from elements registered with this FROM clause are actually in the AST.
ASTIterator iter = new ASTIterator( this.getFirstChild() );
Set childrenInTree = new HashSet();
while ( iter.hasNext() ) {
childrenInTree.add( iter.next() );
}
for ( Iterator iterator = fromElements.iterator(); iterator.hasNext(); ) {
FromElement fromElement = ( FromElement ) iterator.next();
if ( !childrenInTree.contains( fromElement ) ) {
throw new IllegalStateException( "Element not in AST: " + fromElement );
}
}
|
public void | setParentFromClause(org.hibernate.hql.ast.tree.FromClause parentFromClause)
this.parentFromClause = parentFromClause;
if ( parentFromClause != null ) {
level = parentFromClause.getLevel() + 1;
parentFromClause.addChild( this );
}
|
public java.lang.String | toString()
return "FromClause{" +
"level=" + level +
"}";
|