buf.append(')');
}
public Object visit(ASTEJBQL node, Object data) {
Node selectNode = node.jjtGetChild(0);
Node fromNode = node.jjtGetChild(1);
Node whereNode = null;
Node orderByNode = null;
Node limitNode = null;
for (int childNode = 2; childNode < node.jjtGetNumChildren(); childNode++) {
Node temp = node.jjtGetChild(childNode);
if (temp instanceof ASTWhere) {
whereNode = temp;
} else if (temp instanceof ASTOrderBy) {
orderByNode = temp;
} else if (temp instanceof ASTLimitOffset) {
limitNode = temp;
}
}
// translate select and add it to the buffer
StringBuffer select = new StringBuffer();
selectNode.jjtAccept(this, select);
// conditional term paths from the where clause are treated separately from those
// in select, from and order by.
// TODO come up with a nicer treatment implementation.
Set selectJoinPaths = new HashSet(ctermJoinPaths);
Map selectCollectionMemberJoinPaths = new HashMap(ctermCollectionMemberJoinPaths);
Map selectLeftJoinPaths = new HashMap(ctermLeftJoinPaths);
// translate where and save results to append later
StringBuffer where = new StringBuffer();
if (whereNode != null) {
whereNode.jjtAccept(this, where);
}
// reassign conditional term paths and add paths from order by and from to select paths
ctermJoinPaths = selectJoinPaths;
ctermCollectionMemberJoinPaths = selectCollectionMemberJoinPaths;
ctermLeftJoinPaths = selectLeftJoinPaths;
// translate order by and save results to append later
StringBuffer orderBy = new StringBuffer();
if (orderByNode != null) {
orderByNode.jjtAccept(this, orderBy);
// hack alert - this should use the visitor approach
for (int i = 0; i < orderByNode.jjtGetNumChildren(); i++) {
Node orderByPath = orderByNode.jjtGetChild(i);
ASTPath path = (ASTPath) orderByPath.jjtGetChild(0);
if (!isSelected(path)) {
select.append(SQLUtil.COMMA);
path.jjtAccept(this, select);
}
}