I have a HQL query:
query = select item.itemNumber from items item where item.stock>0 and item.price<100.00
I like to parse this query and convert it to a tree structure:
AST queryTree = parse(query);
what I like to iterate over nodes, change some values ββand convert the tree back to string representation:
Iterator<ASTNode> it = queryTree.nodeIterator();
while(it.hasNext())
{
ASTNode node = it.next();
System.out.println( node.text() + "->" + node.value() );
}
query = queryTree.toString();
it would be nice if the parse method selected Exceptions in case of violation of the HQL grammar, but this was not necessary. Does anyone know how to do this? Are there any API methods suggested by hibernation to perform this task?
Thank,
Chris source
share