/** * 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); }
/** * 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); }
/** * Counts all entities of the specified type. This method is actually a delegate for: <code>count(Class<? * extends Entity>, Query)</code> * * @param type The type of the entities which should be counted. * @return The number of entities of the specified type. */ public <K> int count(Class<? extends RawEntity<K>> type) throws SQLException { return count(type, Query.select()); }
@Override public List<SiteMapping> doInTransaction() { return Arrays.asList(ao.find(SiteMapping.class, Query.select())); } });
/** * Counts all entities of the specified type. This method is actually a delegate for: <code>count(Class<? * extends Entity>, Query)</code> * * @param type The type of the entities which should be counted. * @return The number of entities of the specified type. */ public <K> int count(Class<? extends RawEntity<K>> type) throws SQLException { return count(type, Query.select()); }
/** * Returns all entities of the given type. This actually peers the call to the {@link #find(Class, Query)} method. * * @param type The type of entity to retrieve. * @return An array of all entities which correspond to the given type. */ public <T extends RawEntity<K>, K> T[] find(Class<T> type) throws SQLException { return find(type, Query.select()); }
@Override public Set<String> doInTransaction() { IssueMapping[] mappings = ao.find(IssueMapping.class, Query.select().where(ISSUE_KEY + " IS NOT NULL")); return Sets.newHashSet(Lists.transform(Arrays.asList(mappings), new Function<IssueMapping, String>() { @Override public String apply(IssueMapping input) { return input != null ? input.getIssueKey() : null; } })); } });
public Optional<AddonProperty> getPropertyValue(@Nonnull final String addonKey, @Nonnull final String propertyKey) { AddonPropertyAO[] properties = ao.find(AddonPropertyAO.class, Query.select().where("PLUGIN_KEY = ? AND PROPERTY_KEY = ?", addonKey, propertyKey)); Optional<AddonPropertyAO> option = Optional.ofNullable(Iterables.getFirst(Arrays.asList(properties), null)); return option.flatMap(addonPropertyAO -> Optional.of(AddonPropertyFactory.fromAO(addonPropertyAO))); }
@Override public List<JobMapping> doInTransaction() { return Arrays.asList(ao.find(JobMapping.class, Query.select().where(NAME + " = ?", name))); } });
@Override public IssueMapping[] doInTransaction() { return ao.find(IssueMapping.class, Query.select().where(PORJECT_KEY + " = ?", projectKey)); } });
@Override public IssueMapping[] doInTransaction() { return ao.find(IssueMapping.class, Query.select().where(ISSUE_KEY + " = ?", issueKey)); } });
@Override public BuildMapping doInTransaction() { BuildMapping[] mappings = ao.find(BuildMapping.class, Query.select().where(JOB_ID + " = ? AND " + BUILD_NUMBER + " = ?", jobId, buildNumber)); if (mappings != null && mappings.length == 1) { return mappings[0]; } else { return null; } } });
@Override public List<IssueMapping> doInTransaction() { IssueMapping[] mappings = ao.find(IssueMapping.class, Query.select().where(BUILD_ID + " = ?", build.getId())); return Arrays.asList(mappings); } });
@Override public List<IssueMapping> doInTransaction() { IssueMapping[] mappings = ao.find(IssueMapping.class, Query.select().where(JOB_ID + " = ?", job.getId())); return Arrays.asList(mappings); } });
@Override public Rule getRule(final String name) { final RuleEntity[] ruleEntity = ao.find(RuleEntity.class, Query.select().where("RULE_NAME = ?", name)); Rule ret = null; if (ruleEntity != null && ruleEntity.length == 1) { ret = transformRule(ruleEntity[0]); } return ret; }
@Override public SiteMapping doInTransaction() { SiteMapping[] mappings = ao.find(SiteMapping.class, Query.select().where(SiteMapping.APPLINK_ID + " = ?", applicationId.get())); if (mappings != null && mappings.length == 1) { return mappings[0]; } else { return null; } } });
@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)); }
@Override public SonarServer doInTransaction() { try { return objects.find(SonarServer.class, Query.select().where("NAME = ?", name).limit(1))[0]; } catch (IndexOutOfBoundsException e) { return null; } } });
@Override public JobMapping[] doInTransaction() { return ao.find(JobMapping.class, Query.select() .alias(JobMapping.class, "job") .alias(SiteMapping.class, "site") .from(JobMapping.class) .join(SiteMapping.class, "site.ID = job." + SITE_ID) .where(where.toString())); } });
public WebHookConfiguration[] getEnabledWebHookConfigurations(Repository repo, EventType eventType) { return activeObjects.find(WebHookConfiguration.class, Query.select() .where(COLUMN_REPO_ID + " = ? AND " + COLUMN_ENABLED + " = ? AND " + eventType.getQueryColumn() + " = ?", repo.getId(), true, true) .order(COLUMN_TITLE)); }