Search in sources :

Example 1 with OrderByClause

use of org.dbflute.cbean.sqlclause.orderby.OrderByClause in project dbflute-core by dbflute.

the class AbstractSqlClause method getOrderByClause.

// ===================================================================================
// OrderBy Clause
// ==============
// Clause Parts
public String getOrderByClause() {
    reflectClauseLazilyIfExists();
    final OrderByClause orderBy = getOrderBy();
    String orderByClause = null;
    if (hasUnionQuery()) {
        final Map<String, String> selectClauseRealColumnAliasMap = getSelectClauseRealColumnAliasMap();
        if (selectClauseRealColumnAliasMap.isEmpty()) {
            String msg = "The selectClauseColumnAliasMap should not be empty when union query exists.";
            throw new IllegalStateException(msg);
        }
        orderByClause = orderBy.getOrderByClause(selectClauseRealColumnAliasMap);
    } else {
        orderByClause = orderBy.getOrderByClause();
    }
    if (orderByClause != null && orderByClause.trim().length() > 0) {
        return ln() + " " + orderByClause;
    } else {
        return orderByClause;
    }
}
Also used : OrderByClause(org.dbflute.cbean.sqlclause.orderby.OrderByClause)

Example 2 with OrderByClause

use of org.dbflute.cbean.sqlclause.orderby.OrderByClause in project dbflute-core by dbflute.

the class AbstractBehaviorReadable method helpSelectCursorCheckingOrderByPK.

protected void helpSelectCursorCheckingOrderByPK(CB cb, CursorSelectOption option) {
    if (option.isOrderByPK()) {
        final OrderByClause orderByClause = cb.getOrderByComponent();
        final OrderByElement orderByFirstElement = orderByClause.getOrderByFirstElement();
        if (orderByFirstElement == null || !orderByFirstElement.getColumnInfo().isPrimary()) {
            String msg = "The cursor select by paging needs order by primary key: " + cb.asTableDbName();
            throw new IllegalConditionBeanOperationException(msg);
        }
    }
}
Also used : OrderByClause(org.dbflute.cbean.sqlclause.orderby.OrderByClause) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) OrderByElement(org.dbflute.cbean.sqlclause.orderby.OrderByElement)

Aggregations

OrderByClause (org.dbflute.cbean.sqlclause.orderby.OrderByClause)2 OrderByElement (org.dbflute.cbean.sqlclause.orderby.OrderByElement)1 IllegalConditionBeanOperationException (org.dbflute.exception.IllegalConditionBeanOperationException)1