@Override public List<JobMapping> doInTransaction() { Query query = Query.select(); if (includeDeleted) { query.where(SITE_ID + " = ?", siteId); } else { query.where(SITE_ID + " = ? AND " + DELETED + " = ?", siteId, Boolean.FALSE); } query.order(NAME); return Arrays.asList(ao.find(JobMapping.class, query)); } });
return ao.executeInTransaction(() -> { requireNonNull(search, "search"); Query query = Query.select("ID"); List<String> whereJoinedByAnd = new ArrayList<>(); List<Object> params = new ArrayList<>(); query.where(String.join(" AND ", whereJoinedByAnd), params.toArray()); query.limit(search.getLimit()); query.offset(search.getOffset()); query.distinct(); query.order("ID ASC"); .collect(Collectors.joining(",")); Query inQuery = Query.select(); AO_ALIAS_NAMES.forEach(inQuery::alias); return ao.find(AoWebhook.class, inQuery.where(getTableName(AoWebhook.class) + ".ID IN (" + idParams + ")", ids.toArray()));
@Override public Option<AOHipChatLink> getLinkByUrlAndGroup(String apiUrl, int groupId) { final Query query = Query.select() .from(AOHipChatLink.class) .where("GROUP_ID = ? and API_URL = ?", groupId, apiUrl ); final AOHipChatLink[] links = ao.find(AOHipChatLink.class, query); return first(ImmutableList.copyOf(links)); }
/** * Create a {@link Query} which will select the primary key field of the entity. * * @return non-null Query */ public static Query select() { return select(PRIMARY_KEY_FIELD); }
/** * <p>Optimised read for large datasets. This method will stream all rows for the given type to the given * callback.</p> * * <p>Please see {@link #stream(Class, Query, EntityStreamCallback)} for details / limitations. * * @param type The type of the entities to retrieve. * @param streamCallback The receiver of the data, will be passed one entity per returned row */ public <T extends RawEntity<K>, K> void stream(Class<T> type, EntityStreamCallback<T, K> streamCallback) throws SQLException { final EntityInfo<T, K> entityInfo = resolveEntityInfo(type); final Set<String> valueFields = getValueFieldsNames(entityInfo, nameConverters.getFieldNameConverter()); final Query query = Query.select(); query.setFields(valueFields.toArray(new String[valueFields.size()])); stream(type, query, streamCallback); }
@Override public Set<BuildMapping> doInTransaction() { return newHashSet(ao.find(BuildMapping.class, query.limit(maxResults))); } }), buildMappingToBuildFunction));
/** * Create a {@link Query} and set the field list in the {@code SELECT} clause. * * @param fields The fields to select, as comma-delimited field names. Spaces are OK. Must not contain {@code "*"}. * @return non-null Query * @throws java.lang.IllegalArgumentException if fields contains {@code "*"} */ public static Query select(String fields) { return new Query(QueryType.SELECT, fields); }
/** * Create a {@link Query} which will select the primary key field of the entity. * * @return non-null Query */ public static Query select() { return select(PRIMARY_KEY_FIELD); }
/** * <p>Optimised read for large datasets. This method will stream all rows for the given type to the given * callback.</p> * * <p>Please see {@link #stream(Class, Query, EntityStreamCallback)} for details / limitations. * * @param type The type of the entities to retrieve. * @param streamCallback The receiver of the data, will be passed one entity per returned row */ public <T extends RawEntity<K>, K> void stream(Class<T> type, EntityStreamCallback<T, K> streamCallback) throws SQLException { final EntityInfo<T, K> entityInfo = resolveEntityInfo(type); final Set<String> valueFields = getValueFieldsNames(entityInfo, nameConverters.getFieldNameConverter()); final Query query = Query.select(); query.setFields(valueFields.toArray(new String[valueFields.size()])); stream(type, query, streamCallback); }
@Override public List<IssueMapping> doInTransaction() { return Arrays.asList(ao.find(IssueMapping.class, query.limit(maxResults))); } });
/** * Create a {@link Query} and set the field list in the {@code SELECT} clause. * * @param fields The fields to select, as comma-delimited field names. Spaces are OK. Must not contain {@code "*"}. * @return non-null Query * @throws java.lang.IllegalArgumentException if fields contains {@code "*"} */ public static Query select(String fields) { return new Query(QueryType.SELECT, fields); }