@Override protected List<SchemaDefinition> getSchemata0() throws SQLException { List<SchemaDefinition> result = new ArrayList<SchemaDefinition>(); // [#1409] Shouldn't select from INFORMATION_SCHEMA.SCHEMATA, as that // would only return schemata of which CURRENT_USER is the owner for (String name : create() .select(PG_NAMESPACE.NSPNAME) .from(PG_NAMESPACE) .orderBy(PG_NAMESPACE.NSPNAME) .fetch(PG_NAMESPACE.NSPNAME)) { result.add(new SchemaDefinition(this, name, "")); } return result; }
public List<Customer> findAll() { return dslContext.select() .from(CUSTOMERS) .orderBy(CUSTOMERS.FIRST_NAME.asc()) .fetchInto(Customer.class); } }
@Override protected List<TableDefinition> getTables0() throws SQLException { List<TableDefinition> result = new ArrayList<TableDefinition>(); for (Record record : create() .select( DB_CLASS.CLASS_NAME) .from(DB_CLASS) .orderBy( DB_CLASS.CLASS_NAME.asc()) .fetch()) { String name = record.get(DB_CLASS.CLASS_NAME); CUBRIDTableDefinition table = new CUBRIDTableDefinition(getSchemata().get(0), name, null); result.add(table); } return result; }
public Timestamp getFirstProcessDate() { return txResult(tx -> tx.select(PROCESS_QUEUE.CREATED_AT) .from(PROCESS_QUEUE) .orderBy(PROCESS_QUEUE.CREATED_AT) .limit(1) .fetchOne(Record1::value1)); }
@Override protected List<SequenceDefinition> getSequences0() throws SQLException { List<SequenceDefinition> result = new ArrayList<SequenceDefinition>(); for (String sequenceName : create() .select(RDB$GENERATORS.RDB$GENERATOR_NAME.trim()) .from(RDB$GENERATORS) .orderBy(1) .fetch(RDB$GENERATORS.RDB$GENERATOR_NAME.trim())) { SchemaDefinition schema = getSchemata().get(0); DataTypeDefinition type = new DefaultDataTypeDefinition( this, schema, FirebirdDataType.BIGINT.getTypeName() ); result.add(new DefaultSequenceDefinition(schema, sequenceName, type )); } return result; }
/** * Creates the query for the given {@link OrientSource} and {@link org.springframework.data.domain.Sort}. * * @param source the source * @param sort the sort * @return the query */ private OSQLQuery<T> getQuery(String source, Sort sort) { Query query = DSL.using(SQLDialect.MYSQL).select().from(source).orderBy(QueryUtils.toOrders(sort)); return new OSQLSynchQuery<>(query.getSQL(ParamType.INLINED)); }
/** * Creates the query for the given {@link OrientSource} and {@link org.springframework.data.domain.Sort}. * * @param source the source * @param sort the sort * @return the query */ private OSQLQuery<T> getQuery(String source, Sort sort) { Query query = DSL.using(SQLDialect.MYSQL).select().from(source).orderBy(QueryUtils.toOrders(sort)); return new OSQLSynchQuery<T>(query.getSQL(ParamType.INLINED)); }
/** * 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)); } }
/** * 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)); } }
public List<OrganizationEntry> list(UUID userId) { try (DSLContext tx = DSL.using(cfg)) { SelectJoinStep<Record5<UUID, String, String, String, String>> q = tx.select(ORGANIZATIONS.ORG_ID, ORGANIZATIONS.ORG_NAME, ORGANIZATIONS.VISIBILITY, ORGANIZATIONS.META.cast(String.class), ORGANIZATIONS.ORG_CFG.cast(String.class)) .from(ORGANIZATIONS); if (userId != null) { SelectConditionStep<Record1<UUID>> teamIds = selectDistinct(USER_TEAMS.TEAM_ID) .from(USER_TEAMS) .where(USER_TEAMS.USER_ID.eq(userId)); SelectConditionStep<Record1<UUID>> orgIds = selectDistinct(TEAMS.ORG_ID) .from(TEAMS) .where(TEAMS.TEAM_ID.in(teamIds)); q.where(ORGANIZATIONS.ORG_ID.in(orgIds)); } return q.orderBy(ORGANIZATIONS.ORG_NAME) .fetch(this::toEntry); } }
return s.orderBy(q.CREATED_AT) .limit(1) .forUpdate()
select(field("pg_get_indexdef({0}, k + 1, true)", String.class, i.INDEXRELID)) .from("generate_subscripts({0}, 1) as k", i.INDKEY) .orderBy(field("k")) ).as("columns"), field("{0}::int[]", Integer[].class, i.INDOPTION).as("asc_or_desc")
public List<SecretEntry> list(UUID orgId, UUID currentUserId, Field<?> sortField, boolean asc) { SelectConditionStep<Record1<UUID>> teamIds = select(TEAMS.TEAM_ID) .from(TEAMS) .where(TEAMS.ORG_ID.eq(orgId)); Condition filterByTeamMember = exists(selectOne().from(USER_TEAMS) .where(USER_TEAMS.USER_ID.eq(currentUserId) .and(USER_TEAMS.TEAM_ID.in(teamIds)))); try (DSLContext tx = DSL.using(cfg)) { SelectJoinStep<Record12<UUID, String, UUID, String, UUID, String, UUID, String, String, String, String, String>> query = selectEntry(tx); if (currentUserId != null) { query.where(or(SECRETS.VISIBILITY.eq(SecretVisibility.PUBLIC.toString()), filterByTeamMember)); } if (orgId != null) { query.where(SECRETS.ORG_ID.eq(orgId)); } if (sortField != null) { query.orderBy(asc ? sortField.asc() : sortField.desc()); } return query.fetch(SecretDao::toEntry); } }
public PolicyRules getRules(DSLContext tx, UUID orgId, UUID projectId, UUID userId) { PolicyEntry entry = getLinked(tx, orgId, projectId, userId); if (entry == null || entry.rules().isEmpty()) { return null; } Result<Record3<String, String, Integer>> rules = tx.withRecursive("children").as( select(POLICIES.POLICY_ID, POLICIES.PARENT_POLICY_ID, POLICIES.POLICY_NAME, POLICIES.RULES, field("1", Integer.class).as("level")).from(POLICIES) .where(POLICIES.POLICY_ID.eq(entry.id())) .unionAll( select(POLICIES.POLICY_ID, POLICIES.PARENT_POLICY_ID, POLICIES.POLICY_NAME, POLICIES.RULES, field("children.level + 1", Integer.class).as("level")).from(POLICIES) .join(name("children")) .on(POLICIES.POLICY_ID.eq( field(name("children", "PARENT_POLICY_ID"), UUID.class))))) .select(POLICIES.as("children").POLICY_NAME, POLICIES.as("children").RULES.cast(String.class), field("level", Integer.class)) .from(name("children")) .orderBy(field("level").desc()) .fetch(); ImmutablePolicyRules.Builder result = ImmutablePolicyRules.builder(); Map<String, Object> mergedRules = new HashMap<>(); for(Record3<String, String, Integer> r : rules) { result.addPolicyNames(r.value1()); mergedRules = ConfigurationUtils.deepMerge(mergedRules, deserialize(r.value2())); } return result .rules(mergedRules) .build(); }
private List<LandingEntry> list(DSLContext tx, UUID orgId, UUID currentUserId) { LandingPage lp = LANDING_PAGE.as("lp"); Projects p = PROJECTS.as("p"); Repositories r = REPOSITORIES.as("r"); Field<String> orgNameField = select(ORGANIZATIONS.ORG_NAME).from(ORGANIZATIONS).where(ORGANIZATIONS.ORG_ID.eq(p.ORG_ID)).asField(); SelectConditionStep<Record1<UUID>> teamIds = select(TEAMS.TEAM_ID) .from(TEAMS) .where(TEAMS.ORG_ID.eq(orgId)); Condition filterByTeamMember = exists(selectOne().from(USER_TEAMS) .where(USER_TEAMS.USER_ID.eq(currentUserId) .and(USER_TEAMS.TEAM_ID.in(teamIds)))); SelectJoinStep<Record9<UUID, UUID, String, UUID, String, String, String, String, byte[]>> q = tx.select(lp.LANDING_PAGE_ID, p.ORG_ID, orgNameField, lp.PROJECT_ID, p.PROJECT_NAME, r.REPO_NAME, lp.NAME, lp.DESCRIPTION, lp.ICON) .from(lp) .innerJoin(p).on(p.PROJECT_ID.eq(lp.PROJECT_ID)) .innerJoin(r).on(r.REPO_ID.eq(lp.REPO_ID)); if (currentUserId != null) { q.where(or(p.VISIBILITY.eq(ProjectVisibility.PUBLIC.toString()), filterByTeamMember)); } return q.orderBy(lp.NAME) .fetch(LandingDao::toEntity); }
q.orderBy(asc ? sortField.asc() : sortField.desc());
.orderBy(1, 2) .fetch()) {
return s.orderBy(pq.CREATED_AT.desc()) .limit(limit) .offset(offset)