Factory create = new Factory(connection, dialect); SelectQuery query = create.selectQuery(); query.addFrom(AUTHOR); // Join books only under certain circumstances if (join) { query.addJoin(BOOK, BOOK.AUTHOR_ID.equal(AUTHOR.ID)); } Result<?> result = query.fetch();
protected Object listInternal(SchemaFactory schemaFactory, String type, Map<Object, Object> criteria, ListOptions options, Map<Table<?>, Condition> joins) { Class<?> clz = getClass(schemaFactory, type, criteria, true); if (clz == null) { return null; } /* Use core schema, parent may not be authorized */ type = getObjectManager().getSchemaFactory().getSchemaName(clz); Table<?> table = JooqUtils.getTableFromRecordClass(clz); Sort sort = options == null ? null : options.getSort(); Pagination pagination = options == null ? null : options.getPagination(); Include include = options == null ? null : options.getInclude(); if (table == null) return null; SelectQuery<?> query = create().selectQuery(); addSort(schemaFactory, type, sort, query); MultiTableMapper mapper = addTables(schemaFactory, query, type, table, criteria, include, pagination, joins); addJoins(query, joins); addConditions(schemaFactory, query, type, table, criteria); addLimit(schemaFactory, type, pagination, query); List<?> result = mapper == null ? query.fetch() : query.fetchInto(mapper); addCapabilities(result, schemaFactory.getSchema(clz)); processPaginationResult(result, pagination, mapper); return result; }
public List<ProcessEntry> get(List<PartialProcessKey> processKeys) { try (DSLContext tx = DSL.using(cfg)) { List<UUID> instanceIds = processKeys.stream() .map(PartialProcessKey::getInstanceId) .collect(Collectors.toList()); SelectQuery<Record> query = buildSelect(tx, DEFAULT_INCLUDES); query.addConditions(PROCESS_QUEUE.INSTANCE_ID.in(instanceIds)); return query.fetch(this::toEntry); } }
public List<ProcessEntry> list(UUID parentInstanceId, Set<String> tags) { try (DSLContext tx = DSL.using(cfg)) { SelectQuery<Record> query = buildSelect(tx, DEFAULT_INCLUDES); query.addConditions(PROCESS_QUEUE.PARENT_INSTANCE_ID.eq(parentInstanceId)); filterByTags(query, tags); query.addOrderBy(PROCESS_QUEUE.CREATED_AT.desc()); return query.fetch(this::toEntry); } }
query.addOffset(offset); List<ProcessEntry> processEntries = query.fetch(this::toEntry);