org.jooq.OrderField Java Examples

The following examples show how to use org.jooq.OrderField. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryBuilder.java    From FROST-Server with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ResultQuery<Record> buildSelect() {
    gatherData();

    if (queryState.getSqlSelectFields() == null) {
        queryState.setSqlSelectFields(Collections.emptySet());
    }

    DSLContext dslContext = pm.getDslContext();
    SelectSelectStep<Record> selectStep;
    if (queryState.isDistinctRequired()) {
        addOrderPropertiesToSelected();
        selectStep = dslContext.selectDistinct(queryState.getSqlSelectFields());
    } else {
        selectStep = dslContext.select(queryState.getSqlSelectFields());
    }
    SelectConditionStep<Record> whereStep = selectStep.from(queryState.getSqlFrom())
            .where(queryState.getSqlWhere());

    final List<OrderField> sortFields = queryState.getSqlSortFields().getSqlSortFields();
    SelectSeekStepN<Record> orderByStep = whereStep.orderBy(sortFields.toArray(new OrderField[sortFields.size()]));

    int skip = 0;
    int count;
    if (single) {
        count = 2;
    } else if (staQuery != null) {
        count = staQuery.getTopOrDefault() + 1;
        skip = staQuery.getSkip(0);
    } else {
        count = 1;
    }
    SelectWithTiesAfterOffsetStep<Record> limit = orderByStep.limit(skip, count);

    if (forUpdate) {
        return limit.forUpdate();
    }

    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(GENERATED_SQL, limit.getSQL(ParamType.INDEXED));
    }
    return limit;
}
 
Example #2
Source File: Utils.java    From FROST-Server with GNU Lesser General Public License v3.0 4 votes vote down vote up
public List<OrderField> getSqlSortFields() {
    return sqlSortFields;
}
 
Example #3
Source File: GenericVertxDAO.java    From vertx-jooq with MIT License 2 votes vote down vote up
/**
 * Performs an async <code>SELECT</code> using the given condition with specific order.
 * @param condition
 * @param orderFields
 * @return the result type returned for all find-many-values-operations.
 */
public FIND_MANY findManyByCondition(Condition condition, OrderField<?> ... orderFields);