void showHqlAst(AST hqlAst) { if ( LOG.isDebugEnabled() ) { LOG.debug( TokenPrinters.HQL_TOKEN_PRINTER.showAsString( hqlAst, "--- HQL AST ---" ) ); } }
/** * Returns an array of SelectExpressions gathered from the children of the given parent AST node. * * @return an array of SelectExpressions gathered from the children of the given parent AST node. */ public SelectExpression[] collectSelectExpressions() { // Get the first child to be considered. Sub-classes may do this differently in order to skip nodes that // are not select expressions (e.g. DISTINCT). AST firstChild = getFirstSelectExpression(); ArrayList<SelectExpression> list = new ArrayList<SelectExpression>(); int p = 0; for ( AST n = firstChild; n != null; n = n.getNextSibling() ) { if ( n instanceof SelectExpression ) { list.add( (SelectExpression) n ); } else if ( n instanceof ParameterNode ) { parameterPositions.add( p ); } else { throw new IllegalStateException( "Unexpected AST: " + n.getClass().getName() + " " + TokenPrinters.SQL_TOKEN_PRINTER.showAsString( n, "" ) ); } p++; } return list.toArray( new SelectExpression[list.size()] ); }
private HqlSqlWalker analyze(HqlParser parser, String collectionRole) throws QueryException, RecognitionException { final HqlSqlWalker w = new HqlSqlWalker( this, factory, parser, tokenReplacements, collectionRole ); final AST hqlAst = parser.getAST(); // Transform the tree. w.statement( hqlAst ); if ( LOG.isDebugEnabled() ) { LOG.debug( TokenPrinters.SQL_TOKEN_PRINTER.showAsString( w.getAST(), "--- SQL AST ---" ) ); } w.getParseErrorHandler().throwQueryException(); return w; }
LOG.trace( TokenPrinters.ORDERBY_FRAGMENT_PRINTER.showAsString( parser.getAST(), "--- {order-by fragment} ---" ) );
throw new QueryException( "No data type for node: " + selectExpression.getClass().getName() + " " + TokenPrinters.SQL_TOKEN_PRINTER.showAsString( (AST) selectExpression, "" ) );
private void handleWithFragment(FromElement fromElement, AST hqlWithNode) throws SemanticException { try { withClause( hqlWithNode ); AST hqlSqlWithNode = returnAST; if ( LOG.isDebugEnabled() ) { LOG.debug( "handleWithFragment() : " + getASTPrinter().showAsString( hqlSqlWithNode, "-- with clause --" ) ); } WithClauseVisitor visitor = new WithClauseVisitor( fromElement, queryTranslatorImpl ); NodeTraverser traverser = new NodeTraverser( visitor ); traverser.traverseDepthFirst( hqlSqlWithNode ); SqlGenerator sql = new SqlGenerator( getSessionFactoryHelper().getFactory() ); sql.whereExpr( hqlSqlWithNode.getFirstChild() ); fromElement.setWithClauseFragment( "(" + sql.getSQL() + ")" ); } catch (SemanticException e) { throw e; } catch (InvalidWithClauseException e) { throw e; } catch (Exception e) { throw new SemanticException( e.getMessage() ); } }
LOG.debug( "createFromJoinElement() : " + getASTPrinter().showAsString( fromElement, "-- join tree --" ) );
private static void logAST(AST ast, String message) { if (LOGGER.isDebugEnabled()) { ASTPrinter printer = new ASTPrinter(HqlTokenTypes.class); String astText = printer.showAsString(ast, message); LOGGER.debug(astText); } }
/** * Returns an array of SelectExpressions gathered from the children of the given parent AST node. * * @return an array of SelectExpressions gathered from the children of the given parent AST node. */ public SelectExpression[] collectSelectExpressions() { // Get the first child to be considered. Sub-classes may do this differently in order to skip nodes that // are not select expressions (e.g. DISTINCT). AST firstChild = getFirstSelectExpression(); AST parent = this; ArrayList list = new ArrayList( parent.getNumberOfChildren() ); for ( AST n = firstChild; n != null; n = n.getNextSibling() ) { if ( n instanceof SelectExpression ) { list.add( n ); } else { throw new IllegalStateException( "Unexpected AST: " + n.getClass().getName() + " " + new ASTPrinter( SqlTokenTypes.class ).showAsString( n, "" ) ); } } return ( SelectExpression[] ) list.toArray( new SelectExpression[list.size()] ); }
/** * Returns an array of SelectExpressions gathered from the children of the given parent AST node. * * @return an array of SelectExpressions gathered from the children of the given parent AST node. */ public SelectExpression[] collectSelectExpressions() { // Get the first child to be considered. Sub-classes may do this differently in order to skip nodes that // are not select expressions (e.g. DISTINCT). AST firstChild = getFirstSelectExpression(); AST parent = this; ArrayList list = new ArrayList( parent.getNumberOfChildren() ); for ( AST n = firstChild; n != null; n = n.getNextSibling() ) { if ( n instanceof SelectExpression ) { list.add( n ); } else { throw new IllegalStateException( "Unexpected AST: " + n.getClass().getName() + " " + new ASTPrinter( SqlTokenTypes.class ).showAsString( n, "" ) ); } } return ( SelectExpression[] ) list.toArray( new SelectExpression[list.size()] ); }
void showHqlAst(AST hqlAst) { if ( LOG.isDebugEnabled() ) { ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class ); LOG.debug( printer.showAsString( hqlAst, "--- HQL AST ---" ) ); } }
void showHqlAst(AST hqlAst) { if ( LOG.isDebugEnabled() ) { ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class ); LOG.debug( printer.showAsString( hqlAst, "--- HQL AST ---" ) ); } }
private HqlSqlWalker analyze(HqlParser parser, String collectionRole) throws QueryException, RecognitionException { HqlSqlWalker w = new HqlSqlWalker( this, factory, parser, tokenReplacements, collectionRole ); AST hqlAst = parser.getAST(); // Transform the tree. w.statement( hqlAst ); if ( LOG.isDebugEnabled() ) { ASTPrinter printer = new ASTPrinter( SqlTokenTypes.class ); LOG.debug( printer.showAsString( w.getAST(), "--- SQL AST ---" ) ); } w.getParseErrorHandler().throwQueryException(); return w; }
private HqlSqlWalker analyze(HqlParser parser, String collectionRole) throws QueryException, RecognitionException { HqlSqlWalker w = new HqlSqlWalker( this, factory, parser, tokenReplacements, collectionRole ); AST hqlAst = parser.getAST(); // Transform the tree. w.statement( hqlAst ); if ( LOG.isDebugEnabled() ) { ASTPrinter printer = new ASTPrinter( SqlTokenTypes.class ); LOG.debug( printer.showAsString( w.getAST(), "--- SQL AST ---" ) ); } w.getParseErrorHandler().throwQueryException(); return w; }
LOG.trace( printer.showAsString( parser.getAST(), "--- {order-by fragment} ---" ) );
LOG.trace( printer.showAsString( parser.getAST(), "--- {order-by fragment} ---" ) );
AST hqlSqlWithNode = returnAST; if (LOG.isDebugEnabled()) LOG.debugf("handleWithFragment() : %s", getASTPrinter().showAsString(hqlSqlWithNode, "-- with clause --")); WithClauseVisitor visitor = new WithClauseVisitor( fromElement ); NodeTraverser traverser = new NodeTraverser( visitor );
AST hqlSqlWithNode = returnAST; if (LOG.isDebugEnabled()) LOG.debugf("handleWithFragment() : %s", getASTPrinter().showAsString(hqlSqlWithNode, "-- with clause --")); WithClauseVisitor visitor = new WithClauseVisitor( fromElement ); NodeTraverser traverser = new NodeTraverser( visitor );
getASTPrinter().showAsString(fromElement, "-- join tree --"));
getASTPrinter().showAsString(fromElement, "-- join tree --"));