本文整理了Java中javax.persistence.criteria.Subquery.select()
方法的一些代码示例,展示了Subquery.select()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subquery.select()
方法的具体详情如下:
包路径:javax.persistence.criteria.Subquery
类名称:Subquery
方法名:select
[英]Specify the item that is to be returned as the subquery result. Replaces the previously specified selection, if any.
[中]指定要作为子查询结果返回的项。替换以前指定的选择(如果有)。
代码示例来源:origin: kiegroup/jbpm
Subquery<VariableInstanceLog> maxIdSubQuery = query.subquery(VariableInstanceLog.class);
Root from = maxIdSubQuery.from(VariableInstanceLog.class);
maxIdSubQuery.select(builder.max(from.get(VariableInstanceLog_.id)));
maxIdSubQuery.groupBy(
from.get(VariableInstanceLog_.variableId),
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
subquery.select(builder.count(orderRoot));
subquery.where(builder.equal(orderRoot.get("customer"),root));
代码示例来源:origin: kiegroup/jbpm
public <R> Predicate createPredicate(QueryCriteria criteria, CriteriaQuery<R> query, CriteriaBuilder builder) {
// subquery and root
Root<TaskImpl> taskRoot = getRoot(query, TaskImpl.class);
Subquery<Long> subQuery = query.subquery(Long.class);
Root<TaskVariableImpl> taskVarRoot = subQuery.from(TaskVariableImpl.class);
subQuery.select(taskVarRoot.get(TaskVariableImpl_.taskId));
// task variable predicate (in subquery)
Predicate taskVariablePredicate = null;
String listId = criteria.getListId();
if( TASK_VARIABLE_COMBINED_ID.equals(listId) ) {
List<QueryCriteria> taskVarSubCriteriaList = criteria.getCriteria();
int size = taskVarSubCriteriaList.size();
Predicate[] taskVarSubPredicates = new Predicate[size];
for( int i = 0; i < size; ++i ) {
taskVarSubPredicates[i] = createSingleTaskVariableCriteriaPredicate(
builder, taskVarRoot, taskVarSubCriteriaList.get(i));
}
taskVariablePredicate = builder.and(taskVarSubPredicates);
} else {
taskVariablePredicate = createSingleTaskVariableCriteriaPredicate(builder, taskVarRoot, criteria);
}
// add predicate to subquery
subQuery.where(taskVariablePredicate);
// create predicate for actual query that references subquery
return taskRoot.get(TaskImpl_.id).in(subQuery);
}
代码示例来源:origin: jamesagnew/hapi-fhir
subQ.select(subQfrom.get("myResourceId").as(Long.class));
defJoin.select(defJoinFrom.get("myId").as(Long.class));
代码示例来源:origin: jamesagnew/hapi-fhir
subQ.select(subQfrom.get("myId").as(Long.class));
代码示例来源:origin: stackoverflow.com
Subquery sq = cb.subquery(SecondEntity.class);
Root<SecondEntity> second= sq.from(SecondEntity.class);
sq.select(cb.count(second));
sq.where(cb.and(cb.equal(second.get("mainEntity"), root), cb.equal(second.get("flag"), 0));
cq.select(cb.construct(CodeSubjectDto.class, root, sq));
代码示例来源:origin: stackoverflow.com
Predicate wantedToBePresentTags = cb.lower(rTag.<String>get("name")).in(cb.parameter(List.class, "tagList"));
Subquery sq = criteriaQuery.subquery(TestExecution.class);
Root sqRoot = sq.from(TestExecution.class);
Join<TestExecution, Tag> sqTag = sqRoot.joinCollection("testExecutionTags").join("tag");
sq.select(sqRoot.get("id"));
sq.where(cb.lower(sqTag.<String>get("name")).in(cb.parameter(List.class, "excludedTagList")));
Predicate excludedTags = cb.not(rExec.get("id").in(sq));
...
criteriaQuery.where(cb.and(wantedToBePresentTags, excludedTags));
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
protected Subquery<TagToPropertyTag> getPropertyTagSubquery(final Integer propertyTagId, final String propertyTagValue) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<TagToPropertyTag> subQuery = getCriteriaQuery().subquery(TagToPropertyTag.class);
final Root<TagToPropertyTag> root = subQuery.from(TagToPropertyTag.class);
subQuery.select(root);
// Create the Condition for the subquery
final Predicate tagIdMatch = criteriaBuilder.equal(getRootPath(), root.get("tag"));
final Predicate propertyTagIdMatch = criteriaBuilder.equal(root.get("propertyTag").get("propertyTagId"), propertyTagId);
final Predicate propertyTagValueMatch = criteriaBuilder.equal(root.get("value"), propertyTagValue);
subQuery.where(criteriaBuilder.and(tagIdMatch, propertyTagIdMatch, propertyTagValueMatch));
return subQuery;
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
protected Subquery<ContentSpecToPropertyTag> getPropertyTagSubquery(Integer propertyTagId, String propertyTagValue) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<ContentSpecToPropertyTag> subQuery = getCriteriaQuery().subquery(ContentSpecToPropertyTag.class);
final Root<ContentSpecToPropertyTag> root = subQuery.from(ContentSpecToPropertyTag.class);
subQuery.select(root);
// Create the Condition for the subquery
final Predicate contentSpecIdMatch = criteriaBuilder.equal(getRootPath(), root.get("contentSpec"));
final Predicate propertyTagIdMatch = criteriaBuilder.equal(root.get("propertyTag").get("propertyTagId"), propertyTagId);
final Predicate propertyTagValueMatch = criteriaBuilder.equal(root.get("value"), propertyTagValue);
subQuery.where(criteriaBuilder.and(contentSpecIdMatch, propertyTagIdMatch, propertyTagValueMatch));
return subQuery;
}
代码示例来源:origin: SAP/olingo-jpa-processor-v4
@SuppressWarnings("unchecked")
protected <T> void createSelectClauseAggregation(final Subquery<T> subQuery, final From<?, ?> from,
final List<JPAOnConditionItem> conditionItems) {
Path<?> p = from;
for (final JPAElement jpaPathElement : conditionItems.get(0).getLeftPath().getPath())
p = p.get(jpaPathElement.getInternalName());
subQuery.select((Expression<T>) p);
}
代码示例来源:origin: xautlx/s2jh4net
@Override
public Predicate toPredicate(Root<Privilege> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
Predicate predicate = buildPredicatesFromFilters(groupFilter, root, query, builder);
Subquery<RoleR2Privilege> sq = query.subquery(RoleR2Privilege.class);
Root<RoleR2Privilege> r2 = sq.from(RoleR2Privilege.class);
sq.where(builder.equal(r2.get("privilege"), root), builder.equal(r2.get("role").get("id"), roleId)).select(r2);
return builder.and(predicate, builder.not(builder.exists(sq)));
}
};
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
protected Subquery<TopicToPropertyTag> getPropertyTagExistsSubquery(final Integer propertyTagId) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<TopicToPropertyTag> subQuery = getCriteriaQuery().subquery(TopicToPropertyTag.class);
final Root<TopicToPropertyTag> root = subQuery.from(TopicToPropertyTag.class);
subQuery.select(root);
// Create the Condition for the subquery
final Predicate topicIdMatch = criteriaBuilder.equal(getRootPath(), root.get("topic"));
final Predicate propertyTagIdMatch = criteriaBuilder.equal(root.get("propertyTag").get("propertyTagId"), propertyTagId);
subQuery.where(criteriaBuilder.and(topicIdMatch, propertyTagIdMatch));
return subQuery;
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
protected Subquery<ContentSpecToPropertyTag> getPropertyTagExistsSubquery(Integer propertyTagId) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<ContentSpecToPropertyTag> subQuery = getCriteriaQuery().subquery(ContentSpecToPropertyTag.class);
final Root<ContentSpecToPropertyTag> root = subQuery.from(ContentSpecToPropertyTag.class);
subQuery.select(root);
// Create the Condition for the subquery
final Predicate contentSpecIdMatch = criteriaBuilder.equal(getRootPath(), root.get("contentSpec"));
final Predicate propertyTagIdMatch = criteriaBuilder.equal(root.get("propertyTag").get("propertyTagId"), propertyTagId);
subQuery.where(criteriaBuilder.and(contentSpecIdMatch, propertyTagIdMatch));
return subQuery;
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
public Predicate getMatchTagString(final Integer tagId) {
final CriteriaBuilder queryBuilder = getCriteriaBuilder();
final Subquery<TopicToTag> subQuery = getCriteriaQuery().subquery(TopicToTag.class);
final Root<TopicToTag> from = subQuery.from(TopicToTag.class);
final Predicate topic = queryBuilder.equal(from.get("topic"), getRootPath());
final Predicate tag = queryBuilder.equal(from.get("tag").get("tagId"), tagId);
subQuery.select(from);
subQuery.where(queryBuilder.and(topic, tag));
return queryBuilder.exists(subQuery);
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
public Predicate getNotMatchTagString(final Integer tagId) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<ContentSpecToTag> subquery = getCriteriaQuery().subquery(ContentSpecToTag.class);
final Root<ContentSpecToTag> from = subquery.from(ContentSpecToTag.class);
final Predicate contentSpec = criteriaBuilder.equal(from.get("contentSpec").get("contentSpecId"),
getRootPath().get("contentSpecId"));
final Predicate tag = criteriaBuilder.equal(from.get("tag").get("tagId"), tagId);
final Predicate notBookTag = criteriaBuilder.equal(from.get("bookTag"), false);
subquery.select(from);
subquery.where(criteriaBuilder.and(contentSpec, tag, notBookTag));
return criteriaBuilder.not(criteriaBuilder.exists(subquery));
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
public Predicate getMatchTagString(final Integer tagId) {
final CriteriaBuilder queryBuilder = getCriteriaBuilder();
final Subquery<TopicToTag> subQuery = getCriteriaQuery().subquery(TopicToTag.class);
final Root<TopicToTag> from = subQuery.from(TopicToTag.class);
final Predicate topic = queryBuilder.equal(from.get("topic").get("topicId"), translatedTopic.get("topicId"));
final Predicate tag = queryBuilder.equal(from.get("tag").get("tagId"), tagId);
subQuery.select(from);
subQuery.where(queryBuilder.and(topic, tag));
return queryBuilder.exists(subQuery);
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
public Predicate getNotMatchTagString(final Integer tagId) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<TopicToTag> subQuery = getCriteriaQuery().subquery(TopicToTag.class);
final Root<TopicToTag> from = subQuery.from(TopicToTag.class);
final Predicate topic = criteriaBuilder.equal(from.get("topic"), getRootPath());
final Predicate tag = criteriaBuilder.equal(from.get("tag").get("tagId"), tagId);
subQuery.select(from);
subQuery.where(criteriaBuilder.and(topic, tag));
return criteriaBuilder.not(criteriaBuilder.exists(subQuery));
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
protected Subquery<TagToProject> getTagInProjectSubquery(final List<Integer> projectIds) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<TagToProject> subQuery = getCriteriaQuery().subquery(TagToProject.class);
final Root<TagToProject> root = subQuery.from(TagToProject.class);
subQuery.select(root);
// Create the Condition for the subquery
final Predicate tagIdMatch = criteriaBuilder.equal(getRootPath(), root.get("tag"));
final Predicate projectIdMatch = root.get("project").get("projectId").in(projectIds);
subQuery.where(criteriaBuilder.and(tagIdMatch, projectIdMatch));
return subQuery;
}
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
public Predicate getNotMatchTagString(final Integer tagId) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<TopicToTag> subQuery = getCriteriaQuery().subquery(TopicToTag.class);
final Root<TopicToTag> from = subQuery.from(TopicToTag.class);
final Predicate topic = criteriaBuilder.equal(from.get("topic").get("topicId"), translatedTopic.get("topicId"));
final Predicate tag = criteriaBuilder.equal(from.get("tag").get("tagId"), tagId);
subQuery.select(from);
subQuery.where(criteriaBuilder.and(topic, tag));
return criteriaBuilder.not(criteriaBuilder.exists(subQuery));
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
protected Subquery<Integer> getLatestCompleteRevisionSubquery() {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<Integer> subQuery = getCriteriaQuery().subquery(Integer.class);
final Root<TranslatedTopicData> root = subQuery.from(TranslatedTopicData.class);
subQuery.select(criteriaBuilder.max(root.get("translatedTopic").get("topicRevision").as(Integer.class)));
final Predicate topicIdMatch = criteriaBuilder.equal(root.get("translatedTopic").get("topicId"), translatedTopic.get("topicId"));
final Predicate localeMatch = criteriaBuilder.equal(getOriginalRootPath().get("translationLocale"), root.get("translationLocale"));
final Predicate complete = criteriaBuilder.ge(root.get("translationPercentage").as(Integer.class), 100);
subQuery.where(criteriaBuilder.and(topicIdMatch, localeMatch, complete));
subQuery.groupBy(root.get("translatedTopic").get("topicId"));
return subQuery;
}
内容来源于网络,如有侵权,请联系作者删除!