}
Iterator<Ordering> it = ((SelectQuery) q).getOrderings().iterator();
while (it.hasNext()) {
Ordering ord = it.next();
if (ord.isCaseInsensitive()) {
out.append("UPPER(");
}
Expression exp = ord.getSortSpec();
if (exp.getType() == Expression.OBJ_PATH) {
appendObjPath(exp);
}
else if (exp.getType() == Expression.DB_PATH) {
appendDbPath(exp);
}
else {
throw new CayenneRuntimeException("Unsupported ordering expression: "
+ exp);
}
// Close UPPER() modifier
if (ord.isCaseInsensitive()) {
out.append(")");
}
orderByColumnList.add(out.toString());
// "ASC" is a noop, omit it from the query
if (!ord.isAscending()) {
out.append(" DESC");
}
if (it.hasNext()) {
out.append(", ");