if (query.getSortOrder() == WorkflowExpressionQuery.SORT_ASC) { sel.append(" ASC");
if (query.getOrderBy() != 0) {  String fName = fieldName(query.getOrderBy());  if (log.isDebugEnabled()) { log.debug("Found fieldName as: " + fName); }  sel.append(fName);   String current = sel.toString();       String entry = current.substring(0, current.indexOf(columnName)) + columnName + ") , " + fName + " "; entry += current.substring(current.indexOf(columnName) + columnName.length() + 1);  sel = new StringBuffer(entry);  if (query.getSortOrder() == WorkflowExpressionQuery.SORT_ASC) { sel.append(" ASC"); } else { sel.append(" DESC"); }  if (log.isDebugEnabled()) { log.debug("Finalized query: " + sel.toString()); }
    public List query(WorkflowExpressionQuery query) throws StoreException {        Expression expression = query.getExpression();        StringBuffer sel = new StringBuffer();        List values = new ArrayList();        String columnName = null;        if (expression.isNested()) {            columnName = buildNested((NestedExpression) expression, sel, values);        } else {            columnName = buildSimple((FieldExpression) expression, sel, values);        }        if (query.getSortOrder() != WorkflowExpressionQuery.SORT_NONE) {            sel.append(" ORDER BY ");            sel.append(fieldName(query.getOrderBy()));            if (query.getSortOrder() == WorkflowExpressionQuery.SORT_ASC) {                sel.append(" ASC");            } else {                sel.append(" DESC");            }        }        List results = doExpressionQuery(sel.toString(), columnName, values);        return results;    }