To map the ORDER BY clause, use the OrderByClauseMapper element in mappings.xml. The OrderByClauseMapper element has two attributes, UseSelectItemIndexes and PushComplexExprs.
Some databases, however, do not. The SELECT clause must contain the expression and the ORDER BY clause must reference the expression by index, for example:
Some databases do not support ORDER BY expressions other than column references. For such databases, an ORDER BY expression that is not a column reference should not be sent to the database. For example, ORDER BY contact_last should be sent to the database, but ORDER BY contact_last || ', ' || contact_first should not.