public Object visit(ASTSelect select, Object data) {
StringBuffer sql = (StringBuffer) data;
final Node child0 = select.jjtGetChild(0);
final ASTPath path;
if (child0 instanceof ASTPath) {
path = (ASTPath) child0;
if (path.isCMPField()) {
// set the select object
JDBCFieldBridge selectField = (JDBCFieldBridge) path.getCMPField();
selectManager = selectField.getManager();
selectObject = selectField;
setTypeFactory(selectManager.getJDBCTypeFactory());
// todo inner or left?
//addLeftJoinPath(path);
addInnerJoinPath(path);
String alias = aliasManager.getAlias(path.getPath(path.size() - 2));
SQLUtil.getColumnNamesClause(selectField, alias, sql);
} else {
JDBCAbstractEntityBridge selectEntity = (JDBCAbstractEntityBridge) path.getEntity();
selectManager = selectEntity.getManager();
selectObject = selectEntity;
setTypeFactory(selectEntity.getManager().getJDBCTypeFactory());
final String alias = aliasManager.getAlias(path.getPath());
if (select.distinct) {
SQLUtil.getSearchableColumnNamesClause(selectEntity.getTableFields(), alias, sql);
} else {
SQLUtil.getColumnNamesClause(selectEntity.getTableFields(), alias, sql);
}
/*
if(readAhead.isOnFind())
{
String eagerLoadGroupName = readAhead.getEagerLoadGroup();
boolean[] loadGroupMask = selectEntity.getLoadGroupMask(eagerLoadGroupName);
SQLUtil.appendColumnNamesClause(
selectEntity.getTableFields(),
loadGroupMask,
alias,
sql
);
}
*/
addLeftJoinPath(path);
}
} else {
// the function should take a path expresion as a parameter
path = getPathFromChildren(child0);
if (path == null) {
throw new IllegalStateException("The function in SELECT clause does not contain a path expression.");
}
if (path.isCMPField()) {
JDBCFieldBridge selectField = (JDBCFieldBridge) path.getCMPField();
selectManager = selectField.getManager();
setTypeFactory(selectManager.getJDBCTypeFactory());
if (selectField.getJDBCType().hasMapper())
this.functionJDBCType = selectField.getJDBCType();
} else if (path.isCMRField()) {
JDBCFieldBridge cmrField = (JDBCFieldBridge) path.getCMRField();
selectManager = cmrField.getManager();
setTypeFactory(selectManager.getJDBCTypeFactory());
addLeftJoinPath(path);
} else {
final JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge) path.getEntity();
selectManager = entity.getManager();
setTypeFactory(selectManager.getJDBCTypeFactory());
addLeftJoinPath(path);
}