@Override
public Query getParsedQueryExecutor(Session session, String queryString, Map<String, Object> namedParameters) {
HQLLexer lexed = new HQLLexer( new ANTLRStringStream( queryString ) );
TokenStream tokens = new CommonTokenStream( lexed );
HQLParser parser = new HQLParser( tokens );
try {
//TODO move the following logic into the hibernate-jpql-parser project?
//needs to consider usage of a parsed query plans cache
// parser#statement() is the entry point for evaluation of any kind of statement
HQLParser.statement_return r = parser.statement();
CommonTree tree = (CommonTree) r.getTree();
// To walk the resulting tree we need a treenode stream:
CommonTreeNodeStream treeStream = new CommonTreeNodeStream( tree );
// AST nodes have payloads referring to the tokens from the Lexer:
treeStream.setTokenStream( tokens );