FileDocCategorySizeDatePackage
QueryNode.javaAPI DocHibernate 3.2.53628Thu Jul 14 23:39:42 BST 2005org.hibernate.hql.ast.tree

QueryNode

public class QueryNode extends AbstractRestrictableStatement implements SelectExpression
Defines a top-level AST node representing an HQL select statement.
author
Joshua Davis

Fields Summary
private static final Log
log
private OrderByClause
orderByClause
private String
alias
Constructors Summary
Methods Summary
public java.lang.StringgetAlias()

		return alias;
	
public org.hibernate.type.TypegetDataType()

		return ( (SelectExpression) getSelectClause().getFirstSelectExpression() ).getDataType();
	
public FromElementgetFromElement()

		return null;
	
protected org.apache.commons.logging.LoggetLog()

		return log;
	
public final OrderByClausegetOrderByClause()

		if ( orderByClause == null ) {
			orderByClause = locateOrderByClause();

			// if there is no order by, make one
			if ( orderByClause == null ) {
				log.debug( "getOrderByClause() : Creating a new ORDER BY clause" );
				orderByClause = ( OrderByClause ) ASTUtil.create( getWalker().getASTFactory(), SqlTokenTypes.ORDER, "ORDER" );

				// Find the WHERE; if there is no WHERE, find the FROM...
				AST prevSibling = ASTUtil.findTypeInChildren( this, SqlTokenTypes.WHERE );
				if ( prevSibling == null ) {
					prevSibling = ASTUtil.findTypeInChildren( this, SqlTokenTypes.FROM );
				}

				// Now, inject the newly built ORDER BY into the tree
				orderByClause.setNextSibling( prevSibling.getNextSibling() );
				prevSibling.setNextSibling( orderByClause );
			}
		}
		return orderByClause;
	
public final SelectClausegetSelectClause()
Locate the select clause that is part of this select statement.

Note, that this might return null as derived select clauses (i.e., no select clause at the HQL-level) get generated much later than when we get created; thus it depends upon lifecycle.

return
Our select clause, or null.

		// Due to the complexity in initializing the SelectClause, do not generate one here.
		// If it is not found; simply return null...
		//
		// Also, do not cache since it gets generated well after we are created.
		return ( SelectClause ) ASTUtil.findTypeInChildren( this, SqlTokenTypes.SELECT_CLAUSE );
	
public intgetStatementType()

see
Statement#getStatementType()


	   	 
	   
		return HqlSqlTokenTypes.QUERY;
	
protected intgetWhereClauseParentTokenType()

		return SqlTokenTypes.FROM;
	
public final booleanhasOrderByClause()

		OrderByClause orderByClause = locateOrderByClause();
		return orderByClause != null && orderByClause.getNumberOfChildren() > 0;
	
public booleanisConstructor()

		return false;
	
public booleanisReturnableEntity()

		return false;
	
public booleanisScalar()

		return true;
	
private OrderByClauselocateOrderByClause()

		return ( OrderByClause ) ASTUtil.findTypeInChildren( this, SqlTokenTypes.ORDER );
	
public booleanneedsExecutor()

see
Statement#needsExecutor()

		return false;
	
public voidsetAlias(java.lang.String alias)

		this.alias = alias;
	
public voidsetScalarColumnText(int i)

		ColumnHelper.generateSingleScalarColumn( this, i );