selectDistinct = ((ASTSelect) selectNode).distinct || returnType == Set.class || forceDistinct;
// assemble sql
StringBuffer sql = (StringBuffer) data;
if (selectManager.getMetaData().hasRowLocking() && !(selectObject instanceof SelectFunction)) {
JDBCFunctionMappingMetaData rowLockingTemplate = typeMapping.getRowLockingTemplate();
if (rowLockingTemplate == null) {
throw CmpMessages.MESSAGES.rowLockingTemplateNotDefinedFor(typeMapping.getName());
}
boolean distinct = selectDistinct;
Object[] args = new Object[]{
distinct ? SQLUtil.DISTINCT + selectClause : selectClause.toString(),
fromClause,
whereClause == null || whereClause.length() == 0 ? null : whereClause,
orderByClause == null || orderByClause.length() == 0 ? null : orderByClause
};
rowLockingTemplate.getFunctionSql(args, sql);
} else {
sql.append(SQLUtil.SELECT);
if (selectDistinct) {
sql.append(SQLUtil.DISTINCT);
}