use of org.hibernate.hql.internal.ast.util.NodeTraverser in project hibernate-orm by hibernate.
the class QueryTranslatorImpl method parse.
private HqlParser parse(boolean filter) throws TokenStreamException, RecognitionException {
// Parse the query string into an HQL AST.
final HqlParser parser = HqlParser.getInstance(hql);
parser.setFilter(filter);
LOG.debugf("parse() - HQL: %s", hql);
parser.statement();
final AST hqlAst = parser.getAST();
final NodeTraverser walker = new NodeTraverser(new JavaConstantConverter(factory));
walker.traverseDepthFirst(hqlAst);
showHqlAst(hqlAst);
parser.getParseErrorHandler().throwQueryException();
return parser;
}
use of org.hibernate.hql.internal.ast.util.NodeTraverser in project hibernate-orm by hibernate.
the class HqlSqlWalker method handleWithFragment.
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());
}
}
Aggregations