当前位置: 首页>>代码示例>>Java>>正文


Java ListJoin类代码示例

本文整理汇总了Java中javax.persistence.criteria.ListJoin的典型用法代码示例。如果您正苦于以下问题:Java ListJoin类的具体用法?Java ListJoin怎么用?Java ListJoin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ListJoin类属于javax.persistence.criteria包,在下文中一共展示了ListJoin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: byKeyword

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
public static Specification<User> byKeyword(String keyword, String role, String active){
    return (Root<User> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {

        List<Predicate> predicates = new ArrayList<>();

        if (StringUtils.hasText(keyword)) {
            predicates.add(
                cb.or(
                    cb.like(root.get(User_.email), "%" + keyword + "%"),
                    cb.like(root.get(User_.username), "%" + keyword + "%")
                ));
        }

        if (StringUtils.hasText(role) && !"ALL".equals(role)) {

            ListJoin<User, String> roleJoin = root.join(User_.roles);
            predicates.add(cb.equal(roleJoin, role));
        }
        if (StringUtils.hasText(active)) {
            predicates.add(cb.equal(root.get(User_.active), Boolean.valueOf(active)));
        }
        return cb.and(predicates.toArray(new Predicate[predicates.size()]));
    };
}
 
开发者ID:hantsy,项目名称:spring-microservice-sample,代码行数:25,代码来源:UserSpecifications.java

示例2: hasEndOfHuntingReportAndFieldsSpeciesIsPermitSpecies

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
public static Specification<HarvestReport> hasEndOfHuntingReportAndFieldsSpeciesIsPermitSpecies(final Long fieldsId) {
    return (root, query, cb) -> {
        final Subquery<Integer> permitQuery = query.subquery(Integer.class);
        final Root<HarvestPermit> permitRoot = permitQuery.from(HarvestPermit.class);

        final ListJoin<HarvestPermit, HarvestPermitSpeciesAmount> speciesAmounts = permitRoot.join(HarvestPermit_.speciesAmounts);
        final Path<GameSpecies> speciesAmountsSpecies = speciesAmounts.get(HarvestPermitSpeciesAmount_.gameSpecies);

        final Subquery<Integer> fieldsQuery = query.subquery(Integer.class);
        final Root<HarvestReportFields> fieldsRoot = fieldsQuery.from(HarvestReportFields.class);

        final Predicate permitSpeciesEqualToFieldsSpecies = cb.and(
                cb.equal(fieldsRoot.get(HarvestReportFields_.id), fieldsId),
                cb.equal(fieldsRoot.get(HarvestReportFields_.species), speciesAmountsSpecies));
        final Predicate fieldsExists = cb.exists(fieldsQuery.select(cb.literal(1)).where(permitSpeciesEqualToFieldsSpecies));

        return cb.exists(permitQuery
                .select(cb.literal(1))
                .where(cb.and(
                        cb.equal(permitRoot.join(HarvestPermit_.endOfHuntingReport), permitQuery.correlate(root)),
                        fieldsExists))
        );
    };
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:25,代码来源:HarvestReportSpecs.java

示例3: findTargetsOfRolloutGroupByRsql

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
@Override
public Page<Target> findTargetsOfRolloutGroupByRsql(final Pageable pageable, final Long rolloutGroupId,
        final String rsqlParam) {

    throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);

    final Specification<JpaTarget> rsqlSpecification = RSQLUtility.parse(rsqlParam, TargetFields.class,
            virtualPropertyReplacer);

    return convertTPage(targetRepository.findAll((root, query, criteriaBuilder) -> {
        final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup);
        return criteriaBuilder.and(rsqlSpecification.toPredicate(root, query, criteriaBuilder),
                criteriaBuilder.equal(
                        rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id),
                        rolloutGroupId));
    }, pageable), pageable);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:18,代码来源:JpaRolloutGroupManagement.java

示例4: findMessagesByActionStatusId

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
@Override
public Page<String> findMessagesByActionStatusId(final Pageable pageable, final Long actionStatusId) {
    final CriteriaBuilder cb = entityManager.getCriteriaBuilder();

    final CriteriaQuery<Long> countMsgQuery = cb.createQuery(Long.class);
    final Root<JpaActionStatus> countMsgQueryFrom = countMsgQuery.distinct(true).from(JpaActionStatus.class);
    final ListJoin<JpaActionStatus, String> cJoin = countMsgQueryFrom.joinList("messages", JoinType.LEFT);
    countMsgQuery.select(cb.count(cJoin))
            .where(cb.equal(countMsgQueryFrom.get(JpaActionStatus_.id), actionStatusId));
    final Long totalCount = entityManager.createQuery(countMsgQuery).getSingleResult();

    final CriteriaQuery<String> msgQuery = cb.createQuery(String.class);
    final Root<JpaActionStatus> as = msgQuery.from(JpaActionStatus.class);
    final ListJoin<JpaActionStatus, String> join = as.joinList("messages", JoinType.LEFT);
    final CriteriaQuery<String> selMsgQuery = msgQuery.select(join);
    selMsgQuery.where(cb.equal(as.get(JpaActionStatus_.id), actionStatusId));

    final List<String> result = entityManager.createQuery(selMsgQuery).setFirstResult(pageable.getOffset())
            .setMaxResults(pageable.getPageSize()).getResultList().stream().collect(Collectors.toList());

    return new PageImpl<>(result, pageable, totalCount);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:23,代码来源:JpaDeploymentManagement.java

示例5: findForPurchaseCustomerPremium

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
public List<Product> findForPurchaseCustomerPremium() {
    // main query on products
    CriteriaQuery<Product> query = em.getCriteriaBuilder().createQuery(Product.class);
    Root<Product> from = query.from(Product.class);
    
    // subquery on product ids
    Subquery<Long> subQuery = query.subquery(Long.class);
    Root<Customer> subFrom = subQuery.from(Customer.class);
    ListJoin<Customer, Purchase> joinPurchase = subFrom.join(Customer_.purchases);
    ListJoin<Purchase, Product> joinProduct = joinPurchase.join(Purchase_.products);
    // Explicitly add to SELECT clause; otherwise, throws Error Code: 30000 SQLSyntaxErrorException
    subQuery.select(joinProduct.get(Product_.id)).distinct(true);
    subQuery.where(em.getCriteriaBuilder().equal(subFrom.get(Customer_.premium), true));
    
    query.select(from);
    query.where(em.getCriteriaBuilder().in(from.get(Product_.id)).value(subQuery));
    return em.createQuery(query).getResultList();
}
 
开发者ID:codebulb,项目名称:JpaQueries,代码行数:19,代码来源:ProductServiceWithCriteria.java

示例6: sumPriceByPurchaseCustomer

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
public Map<Customer, Double> sumPriceByPurchaseCustomer() {
    // Create "tuple" query for use with groupBy; otherwise, throws PersistenceException: Exception [EclipseLink-6051]
    CriteriaQuery<Tuple> query = em.getCriteriaBuilder().createTupleQuery();
    Root<Customer> from = query.from(Customer.class);
    ListJoin<Customer, Purchase> joinPurchase = from.join(Customer_.purchases);
    ListJoin<Purchase, Product> joinProduct = joinPurchase.join(Purchase_.products);
    query.multiselect(from.get(BaseModel_.id), em.getCriteriaBuilder().sum(joinProduct.get(Product_.price)));
    query.groupBy(from.get(BaseModel_.id));
    List<Tuple> results = em.createQuery(query).getResultList();
    
    Map<Customer, Double> ret = new HashMap<>();
    for (Tuple result : results) {
        Object[] arr = result.toArray();
        ret.put(customerService.findById((Long)arr[0]), ((Double)arr[1]));
    }
    return ret;
}
 
开发者ID:codebulb,项目名称:JpaQueries,代码行数:18,代码来源:ProductServiceWithCriteria.java

示例7: getByProviderRequestWithPessimisticWriteLock

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
public Reservation getByProviderRequestWithPessimisticWriteLock(String requesterNsa, String providerNsa, String correlationId) {
  CriteriaBuilder builder = entityManager.getCriteriaBuilder();
  CriteriaQuery<Reservation> query = builder.createQuery(Reservation.class);
  Root<Reservation> root = query.from(Reservation.class);

  ListJoin<Reservation, NsiV2Message> providerRequests = root.join(Reservation_.providerRequests);

  query.where(builder.and(
      builder.equal(providerRequests.get(NsiV2Message_.requesterNsa), requesterNsa),
      builder.equal(providerRequests.get(NsiV2Message_.providerNsa), providerNsa),
      builder.equal(providerRequests.get(NsiV2Message_.correlationId), correlationId),
      builder.equal(providerRequests.get(NsiV2Message_.role), NsiV2Message.Role.REQUESTER),
      builder.equal(providerRequests.get(NsiV2Message_.type), NsiV2Message.Type.REQUEST)));

  return entityManager.createQuery(query).setLockMode(LockModeType.PESSIMISTIC_WRITE).getSingleResult();
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:17,代码来源:ReservationRepoImpl.java

示例8: byService

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
@Override
public QueryFilter<SemanticDescriptor> byService(long serviceId) {
    ListJoin<SemanticDescriptor, DataManipulationService> services = root
            .join(SemanticDescriptor_.describedServices);
    Predicate predicate = criteriaBuilder.equal(services.get(DataManipulationService_.id), serviceId);
    return constructQueryFilter(predicate);
}
 
开发者ID:psnc-dl,项目名称:darceo,代码行数:8,代码来源:SemanticDescriptorFilterFactoryImpl.java

示例9: installedTarget

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
/**
 * @param installedTargetId
 *            the targetID which is installed to a distribution set to
 *            search for.
 * @return the specification to search for a distribution set which is
 *         installed to the given targetId
 */
public static Specification<JpaDistributionSet> installedTarget(final String installedTargetId) {
    return (dsRoot, query, cb) -> {
        final ListJoin<JpaDistributionSet, JpaTarget> installedTargetJoin = dsRoot
                .join(JpaDistributionSet_.installedAtTargets, JoinType.INNER);
        return cb.equal(installedTargetJoin.get(JpaTarget_.controllerId), installedTargetId);
    };
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:15,代码来源:DistributionSetSpecification.java

示例10: assignedTarget

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
/**
 * @param assignedTargetId
 *            the targetID which is assigned to a distribution set to search
 *            for.
 * @return the specification to search for a distribution set which is
 *         assigned to the given targetId
 */
public static Specification<JpaDistributionSet> assignedTarget(final String assignedTargetId) {
    return (dsRoot, query, cb) -> {
        final ListJoin<JpaDistributionSet, JpaTarget> assignedTargetJoin = dsRoot
                .join(JpaDistributionSet_.assignedToTargets, JoinType.INNER);
        return cb.equal(assignedTargetJoin.get(JpaTarget_.controllerId), assignedTargetId);
    };
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:15,代码来源:DistributionSetSpecification.java

示例11: hasNotDistributionSetInActions

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
/**
 * {@link Specification} for retrieving {@link Target}s that don't have the
 * given distribution set in their action history
 *
 * @param distributionSetId
 *            the ID of the distribution set which must not be assigned
 * @return the {@link Target} {@link Specification}
 */
public static Specification<JpaTarget> hasNotDistributionSetInActions(final Long distributionSetId) {
    return (targetRoot, query, cb) -> {
        final ListJoin<JpaTarget, JpaAction> actionsJoin = targetRoot.join(JpaTarget_.actions, JoinType.LEFT);
        actionsJoin.on(cb.equal(actionsJoin.get(JpaAction_.distributionSet).get(JpaDistributionSet_.id),
                distributionSetId));

        return cb.isNull(actionsJoin.get(JpaAction_.id));
    };
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:18,代码来源:TargetSpecifications.java

示例12: isNotInRolloutGroups

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
/**
 * {@link Specification} for retrieving {@link Target}s that are not in the
 * given {@link RolloutGroup}s
 *
 * @param groups
 *            the {@link RolloutGroup}s
 * @return the {@link Target} {@link Specification}
 */
public static Specification<JpaTarget> isNotInRolloutGroups(final Collection<Long> groups) {
    return (targetRoot, query, cb) -> {
        final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot
                .join(JpaTarget_.rolloutTargetGroup, JoinType.LEFT);
        final Predicate inRolloutGroups = rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup)
                .get(JpaRolloutGroup_.id).in(groups);
        rolloutTargetJoin.on(inRolloutGroups);
        return cb.isNull(rolloutTargetJoin.get(RolloutTargetGroup_.target));
    };
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:19,代码来源:TargetSpecifications.java

示例13: hasNoActionInRolloutGroup

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
/**
 * {@link Specification} for retrieving {@link Target}s that have no Action
 * of the {@link RolloutGroup}.
 *
 * @param group
 *            the {@link RolloutGroup}
 * @return the {@link Target} {@link Specification}
 */
public static Specification<JpaTarget> hasNoActionInRolloutGroup(final Long group) {
    return (targetRoot, query, cb) -> {
        final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot
                .join(JpaTarget_.rolloutTargetGroup, JoinType.INNER);
        rolloutTargetJoin.on(
                cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id), group));

        final ListJoin<JpaTarget, JpaAction> actionsJoin = targetRoot.join(JpaTarget_.actions, JoinType.LEFT);
        actionsJoin.on(cb.equal(actionsJoin.get(JpaAction_.rolloutGroup).get(JpaRolloutGroup_.id), group));

        return cb.isNull(actionsJoin.get(JpaAction_.id));
    };
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:22,代码来源:TargetSpecifications.java

示例14: findAllTargetsOfRolloutGroupWithActionStatus

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
@Override
public Page<TargetWithActionStatus> findAllTargetsOfRolloutGroupWithActionStatus(final Pageable pageRequest,
        final Long rolloutGroupId) {
    throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);

    final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
    final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
    final CriteriaQuery<Long> countQuery = cb.createQuery(Long.class);

    final Root<RolloutTargetGroup> targetRoot = query.distinct(true).from(RolloutTargetGroup.class);
    final Join<RolloutTargetGroup, JpaTarget> targetJoin = targetRoot.join(RolloutTargetGroup_.target);
    final ListJoin<RolloutTargetGroup, JpaAction> actionJoin = targetRoot.join(RolloutTargetGroup_.actions,
            JoinType.LEFT);

    final Root<RolloutTargetGroup> countQueryFrom = countQuery.distinct(true).from(RolloutTargetGroup.class);
    countQueryFrom.join(RolloutTargetGroup_.target);
    countQueryFrom.join(RolloutTargetGroup_.actions, JoinType.LEFT);
    countQuery.select(cb.count(countQueryFrom)).where(cb
            .equal(countQueryFrom.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id), rolloutGroupId));
    final Long totalCount = entityManager.createQuery(countQuery).getSingleResult();

    final CriteriaQuery<Object[]> multiselect = query.multiselect(targetJoin, actionJoin.get(JpaAction_.status))
            .where(cb.equal(targetRoot.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id),
                    rolloutGroupId));
    final List<TargetWithActionStatus> targetWithActionStatus = entityManager.createQuery(multiselect)
            .setFirstResult(pageRequest.getOffset()).setMaxResults(pageRequest.getPageSize()).getResultList()
            .stream().map(o -> new TargetWithActionStatus((Target) o[0], (Action.Status) o[1]))
            .collect(Collectors.toList());

    return new PageImpl<>(targetWithActionStatus, pageRequest, totalCount);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:32,代码来源:JpaRolloutGroupManagement.java

示例15: resolveSourceConfigPermissions

import javax.persistence.criteria.ListJoin; //导入依赖的package包/类
@Override
public ResolvedPermissions resolveSourceConfigPermissions(
		AuthorizedUserEntity etlUser, SourceConfigEntity entity) {
	EntityManager entityManager = getEntityManager();
	CriteriaBuilder cb = entityManager.getCriteriaBuilder();
	CriteriaQuery<Tuple> q = 
			cb.createQuery(Tuple.class);
	Root<SourceConfigGroupMembership> groupMembership = q.from(SourceConfigGroupMembership.class);
	q.select(
			cb.tuple(
					cb.greatest(cb.selectCase().when(cb.equal(groupMembership.get(SourceConfigGroupMembership_.groupRead), true), 1).otherwise(0).as(Integer.class)),
					cb.greatest(cb.selectCase().when(cb.equal(groupMembership.get(SourceConfigGroupMembership_.groupWrite), true), 1).otherwise(0).as(Integer.class)),
					cb.greatest(cb.selectCase().when(cb.equal(groupMembership.get(SourceConfigGroupMembership_.groupExecute), true), 1).otherwise(0).as(Integer.class))
			));
	ListJoin<EtlGroup, AuthorizedUserEntity> join = groupMembership.join(SourceConfigGroupMembership_.group).join(EtlGroup_.users);
	q.where(
			cb.and(
					cb.equal(groupMembership.get(SourceConfigGroupMembership_.sourceConfig).get(SourceConfigEntity_.id), entity.getId()), 
					cb.equal(join.get(AuthorizedUserEntity_.id), etlUser.getId())
			)
	);
	q.groupBy(groupMembership.get(SourceConfigGroupMembership_.sourceConfig).get(SourceConfigEntity_.id));
	List<Tuple> resultList = entityManager.createQuery(q).getResultList();
	if (resultList.isEmpty()) {
		return new ResolvedPermissions(false, false, false);
	} else {
		Tuple result = resultList.get(0);
		return new ResolvedPermissions(result.get(0, Integer.class) == 1, result.get(1, Integer.class) == 1, result.get(2, Integer.class) == 1);
	}
}
 
开发者ID:eurekaclinical,项目名称:eureka,代码行数:31,代码来源:JpaEtlGroupDao.java


注:本文中的javax.persistence.criteria.ListJoin类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。