本文整理了Java中javax.persistence.criteria.Subquery.from()
方法的一些代码示例,展示了Subquery.from()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subquery.from()
方法的具体详情如下:
包路径:javax.persistence.criteria.Subquery
类名称:Subquery
方法名:from
暂无
代码示例来源:origin: kiegroup/jbpm
if( LAST_VARIABLE_LIST.equals(criteria.getListId()) ) {
Subquery<VariableInstanceLog> maxIdSubQuery = query.subquery(VariableInstanceLog.class);
Root from = maxIdSubQuery.from(VariableInstanceLog.class);
maxIdSubQuery.select(builder.max(from.get(VariableInstanceLog_.id)));
maxIdSubQuery.groupBy(
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
Root orderRoot = subquery.from(OrderImpl.class);
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
Root<ResourceTag> subQfrom = subQ.from(ResourceTag.class);
subQ.select(subQfrom.get("myResourceId").as(Long.class));
Root<TagDefinition> defJoinFrom = defJoin.from(TagDefinition.class);
defJoin.select(defJoinFrom.get("myId").as(Long.class));
代码示例来源:origin: jamesagnew/hapi-fhir
Root<ResourceTable> subQfrom = subQ.from(ResourceTable.class);
subQ.select(subQfrom.get("myId").as(Long.class));
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
protected BaseTopicFilterQueryBuilder(final Class<T> clazz, final BaseFieldFilter fieldFilter, final EntityManager entityManager,
final boolean useTopicSubquery) {
super(clazz, fieldFilter, entityManager);
this.useTopicSubquery = useTopicSubquery;
if (useTopicSubquery) {
topicQuery = super.getCriteriaQuery().subquery(Topic.class);
from = topicQuery.from(Topic.class);
} else {
topicQuery = null;
from = null;
}
}
代码示例来源: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: 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 getMatchingLocaleString(final String locale) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<LanguageFile> subquery = getCriteriaQuery().subquery(LanguageFile.class);
final Root<LanguageFile> from = subquery.from(LanguageFile.class);
final Predicate languageFileEqual = criteriaBuilder.equal(getRootPath(), from.get("file"));
final Predicate localeEqual = criteriaBuilder.equal(from.get("locale").get("value"), locale);
subquery.where(criteriaBuilder.and(languageFileEqual, localeEqual));
return criteriaBuilder.exists(subquery);
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
public Predicate getMatchingLocaleString(final String locale) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<LanguageImage> subquery = getCriteriaQuery().subquery(LanguageImage.class);
final Root<LanguageImage> from = subquery.from(LanguageImage.class);
final Predicate languageImageEqual = criteriaBuilder.equal(getRootPath(), from.get("imageFile"));
final Predicate localeEqual = criteriaBuilder.equal(from.get("locale").get("value"), locale);
subquery.where(criteriaBuilder.and(languageImageEqual, localeEqual));
return criteriaBuilder.exists(subquery);
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
@Override
public Predicate getNotMatchingLocaleString(final String locale) {
final CriteriaBuilder criteriaBuilder = getCriteriaBuilder();
final Subquery<LanguageImage> subquery = getCriteriaQuery().subquery(LanguageImage.class);
final Root<LanguageImage> from = subquery.from(LanguageImage.class);
final Predicate languageImageEqual = criteriaBuilder.equal(getRootPath(), from.get("imageFile"));
final Predicate localeEqual = criteriaBuilder.equal(from.get("locale").get("value"), locale);
subquery.where(criteriaBuilder.and(languageImageEqual, localeEqual));
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"), 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 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;
}
内容来源于网络,如有侵权,请联系作者删除!