Condition spanTraceIdCondition(SelectOffsetStep<? extends Record> traceIdQuery) { if (hasTraceIdHigh && strictTraceId) { Result<? extends Record> result = traceIdQuery.fetch(); List<Row2<Long, Long>> traceIds = new ArrayList<>(result.size()); for (Record r : result) { traceIds.add(row(r.get(ZIPKIN_SPANS.TRACE_ID_HIGH), r.get(ZIPKIN_SPANS.TRACE_ID))); } return row(ZIPKIN_SPANS.TRACE_ID_HIGH, ZIPKIN_SPANS.TRACE_ID).in(traceIds); } else { List<Long> traceIds = traceIdQuery.fetch(ZIPKIN_SPANS.TRACE_ID); return ZIPKIN_SPANS.TRACE_ID.in(traceIds); } }
@Override public RESP_R withConnection(final Connection conn) throws SQLException { return DSL.using(conn, dialect, settings) .selectFrom(responsesTable) .where(DSL.field(KB_PAYMENT_ID).equal(kbPaymentId.toString())) .and(DSL.field(TRANSACTION_TYPE).equal(TransactionType.AUTHORIZE.toString())) .and(DSL.field(KB_TENANT_ID).equal(kbTenantId.toString())) .orderBy(DSL.field(recordIdFieldName).desc()) .limit(1) .fetchOne(); } });
.and(runAfterCondition(resourceType)) .limit(resourceType == null ? BATCH.get() : 1) .fetchInto(new RecordHandler<Record6<Long, String, String, String, Long, Integer>>() { @Override public void next(Record6<Long, String, String, String, Long, Integer> record) {
private Query limitIfPageable(SelectLimitStep<? extends Record> limitStep, Pageable pageable, Sort sort) { if (pageable == null || isCountQuery()) { return limitStep; } else if (sort == null) { return limitStep.limit(pageable.getPageSize()); } return limitStep.limit(pageable.getPageSize()).offset(pageable.getOffset()); }
.where(conditions) .limit(daoFilter.getLimitOrInfinity()) .fetchLazy(getFetchSize()); Set<int[]> pages = new HashSet<int[]>(); for (Record record : result) {
private Query limitIfPageable(SelectLimitStep<? extends Record> limitStep, Pageable pageable, Sort sort) { if (pageable == null || isCountQuery()) { return limitStep; } else if (sort == null) { return limitStep.limit(pageable.getPageSize()); } else { return limitStep.limit(pageable.getPageSize()).offset(pageable.getOffset()); } }
where(conditions). limit(daoFilter.getLimitOrInfinity()). fetchLazy(getFetchSize()); Set<LocalId> ids = new HashSet<LocalId>(); for (Record2<Short, Long> record : result) {
@Override public <R extends Record> R fetchAny(Table<R> table) { return Utils.filterOne(selectFrom(table).limit(1).fetch()); }
@Override public List<? extends InstanceLink> findBadInstanceLinks(int count) { return create().select(INSTANCE_LINK.fields()) .from(INSTANCE_LINK) .join(INSTANCE) .on(INSTANCE.ID.eq(INSTANCE_LINK.TARGET_INSTANCE_ID)) .where(INSTANCE.STATE.eq(CommonStatesConstants.PURGED)) .limit(count) .fetchInto(InstanceLinkRecord.class); }
@Override public Account getAccountByUuid(String uuid) { return create() .selectFrom(ACCOUNT) .where(ACCOUNT.UUID.eq(uuid) .and(ACCOUNT.STATE.in(getActiveStates()))) .orderBy(ACCOUNT.ID.asc()).limit(1).fetchOne(); }
/** * Creates the query for the given {@link org.springframework.data.domain.Sort}. * * @param pageable the pageable * @return the query */ private OSQLQuery<T> getQuery(Pageable pageable) { DSLContext context = DSL.using(SQLDialect.MYSQL); SelectJoinStep<? extends Record> joinStep = context.select().from(domainClass.getSimpleName()); Sort sort = pageable.getSort(); SelectLimitStep<? extends Record> limitStep = sort == null ? joinStep : joinStep.orderBy(QueryUtils.toOrders(sort)); Query query = pageable == null ? limitStep : limitStep.limit(pageable.getPageSize()).offset(pageable.getOffset()); return new OSQLSynchQuery<T>(query.getSQL(ParamType.INLINED)); } }
@Override public Iterable<UniversalLink> get(DaoFilter daoFilter) throws DaoException { DSLContext context = getJooq(); try { Collection<Condition> conditions = new ArrayList<Condition>(); if (daoFilter.getSourceIds() != null) { conditions.add(Tables.UNIVERSAL_LINK.UNIV_SOURCE_ID.in(daoFilter.getSourceIds())); } if (daoFilter.getDestIds() != null) { conditions.add(Tables.UNIVERSAL_LINK.UNIV_DEST_ID.in(daoFilter.getDestIds())); } if (daoFilter.isRedirect() != null) { conditions.add(Tables.UNIVERSAL_LINK.ALGORITHM_ID.eq(algorithmId)); } Cursor<Record> result = context.select(). from(Tables.UNIVERSAL_LINK). where(conditions). limit(daoFilter.getLimitOrInfinity()). fetchLazy(getFetchSize()); return buildUniversalLinksIterable(result, context); } catch (RuntimeException e) { freeJooq(context); throw e; } }
@Override public <R extends Record> R fetchAny(Table<R> table, Condition condition) { return Utils.filterOne(selectFrom(table).where(condition).limit(1).fetch()); }
.orderBy(SCHEDULED_UPGRADE.PRIORITY.desc(), SCHEDULED_UPGRADE.CREATED.asc()) .limit(max * 4) .fetchInto(ScheduledUpgradeRecord.class);
@Override public Account getAdminAccount() { return create() .selectFrom(ACCOUNT) .where(ACCOUNT.STATE.in(getActiveStates()) .and(ACCOUNT.KIND.eq(AccountConstants.ADMIN_KIND))) .orderBy(ACCOUNT.ID.asc()).limit(1).fetchOne(); }
/** * Creates the query for the given {@link org.springframework.data.domain.Sort}. * * @param pageable the pageable * @return the query */ private OSQLQuery<T> getQuery(Pageable pageable) { DSLContext context = DSL.using(SQLDialect.MYSQL); SelectJoinStep<? extends Record> joinStep = context.select().from(domainClass.getSimpleName()); Sort sort = pageable.getSort(); SelectLimitStep<? extends Record> limitStep = sort == null ? joinStep : joinStep.orderBy(QueryUtils.toOrders(sort)); Query query = pageable == null ? limitStep : limitStep.limit(pageable.getPageSize()).offset(pageable.getOffset()); return new OSQLSynchQuery<>(query.getSQL(ParamType.INLINED)); } }
/** * Generally this method should not be used. * @param daoFilter a set of filters to limit the search * @return * @throws DaoException */ @Override public Iterable<Redirect> get(DaoFilter daoFilter) throws DaoException { DSLContext context = getJooq(); try { Collection<Condition> conditions = new ArrayList<Condition>(); if (daoFilter.getLangIds() != null) { conditions.add(Tables.REDIRECT.LANG_ID.in(daoFilter.getLangIds())); } Cursor<Record> result = context.select(). from(Tables.REDIRECT). where(conditions). limit(daoFilter.getLimitOrInfinity()). fetchLazy(getFetchSize()); return new SimpleSqlDaoIterable<Redirect>(result, context) { @Override public Redirect transform(Record r) { return buildRedirect(r); } }; } catch (RuntimeException e) { freeJooq(context); throw e; } }
.and(WIKIDATA_ENTITY_LABELS.ENTITY_ID.eq(id)) .limit(1) .fetch(); if (result.size() >= 1) { return result.get(0).value1();
protected List<? extends ConfigItemStatus> stackOutOfSyncItems() { return create() .select(CONFIG_ITEM_STATUS.fields()) .from(CONFIG_ITEM_STATUS) .join(STACK) .on(STACK.ID.eq(CONFIG_ITEM_STATUS.STACK_ID)) .where(CONFIG_ITEM_STATUS.REQUESTED_VERSION.ne(CONFIG_ITEM_STATUS.APPLIED_VERSION) .and(STACK.REMOVED.isNull())) .limit(BATCH_SIZE.get()) .fetchInto(ConfigItemStatusRecord.class); }
.where(ACCOUNT.STATE.in(accountDao.getAccountActiveStates()) .and(ACCOUNT.KIND.eq(AccountConstants.ADMIN_KIND))) .orderBy(ACCOUNT.ID.asc()).limit(1).fetchOne();