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


Java Path.in方法代码示例

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


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

示例1: getPredicateForInClause

import javax.persistence.criteria.Path; //导入方法依赖的package包/类
/**
 * Gets an "in" clause predicate for a list of values. This will take care of breaking the list of values into a group of sub-lists where each sub-list is
 * placed in a separate "in" clause and all "in" clauses are "or"ed together. The size of each sub-list is obtained through an environment configuration.
 *
 * @param builder the criteria builder.
 * @param path the path to the field that is being filtered.
 * @param values the list of values to place in the in clause.
 * @param <T> the type referenced by the path.
 *
 * @return the predicate for the in clause.
 */
protected <T> Predicate getPredicateForInClause(CriteriaBuilder builder, Path<T> path, List<T> values)
{
    // Get the chunk size from the environment and use a default as necessary.
    int inClauseChunkSize = configurationHelper.getProperty(ConfigurationValue.DB_IN_CLAUSE_CHUNK_SIZE, Integer.class);

    // Initializes the returned predicate and the value list size.
    Predicate predicate = null;
    int listSize = values.size();

    // Loop through each chunk of values until we have reached the end of the values.
    for (int i = 0; i < listSize; i += inClauseChunkSize)
    {
        // Get a sub-list for the current chunk of data.
        List<T> valuesSubList = values.subList(i, (listSize > (i + inClauseChunkSize) ? (i + inClauseChunkSize) : listSize));

        // Get an updated predicate which will be the "in" clause of the sub-list on the first loop or the "in" clause of the sub-list "or"ed with the\
        // previous sub-list "in" clause.
        predicate = (predicate == null ? path.in(valuesSubList) : builder.or(predicate, path.in(valuesSubList)));
    }

    // Return the "in" clause predicate.
    return predicate;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:35,代码来源:BaseJpaDaoImpl.java

示例2: toPredicate

import javax.persistence.criteria.Path; //导入方法依赖的package包/类
/**
 * 获取按ID集合进行实体查询的Predicate.
 *
 * @param root 实体类ROOT
 * @param query 条件查询
 * @param cb 查询构建器
 */
@Override
@SuppressWarnings("unchecked")
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) {

  ManagedType type = em.getMetamodel().managedType(entityClass);

  IdentifiableType identifiableType = (IdentifiableType) type;

  Path<?> path = root.get(identifiableType.getId(identifiableType.getIdType().getJavaType()));

  parameter = cb.parameter(Iterable.class);
  return path.in(parameter);
}
 
开发者ID:ibankapp,项目名称:ibankapp-base,代码行数:21,代码来源:ByIdsSpecification.java

示例3: buildPredicate

import javax.persistence.criteria.Path; //导入方法依赖的package包/类
@Override
public Predicate buildPredicate(CriteriaBuilder builder, FieldPathBuilder fieldPathBuilder, From root, String ceilingEntity,
                                String fullPropertyName, Path<Serializable> explicitPath, List<Serializable> directValues) {
    Path<Serializable> path;
    if (explicitPath != null) {
        path = explicitPath;
    } else {
        path = fieldPathBuilder.getPath(root, fullPropertyName, builder);
    }
    return path.in(directValues);
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:12,代码来源:EqPredicateProvider.java

示例4: getPredicate

import javax.persistence.criteria.Path; //导入方法依赖的package包/类
private static Predicate getPredicate(final SetJoin<JpaDistributionSet, JpaDistributionSetTag> tags,
        final Collection<String> tagNames, final Boolean selectDSWithNoTag, final CriteriaBuilder cb) {
    tags.get(JpaDistributionSetTag_.name);
    final Path<String> exp = tags.get(JpaDistributionSetTag_.name);
    if (selectDSWithNoTag != null && selectDSWithNoTag) {
        if (!CollectionUtils.isEmpty(tagNames)) {
            return cb.or(exp.isNull(), exp.in(tagNames));
        } else {
            return exp.isNull();
        }
    } else {
        return exp.in(tagNames);
    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:15,代码来源:DistributionSetSpecification.java

示例5: getPredicate

import javax.persistence.criteria.Path; //导入方法依赖的package包/类
private static Predicate getPredicate(final Root<JpaTarget> targetRoot, final CriteriaBuilder cb,
        final Boolean selectTargetWithNoTag, final String[] tagNames) {
    final SetJoin<JpaTarget, JpaTargetTag> tags = targetRoot.join(JpaTarget_.tags, JoinType.LEFT);
    final Path<String> exp = tags.get(JpaTargetTag_.name);
    if (selectTargetWithNoTag) {
        if (tagNames != null) {
            return cb.or(exp.isNull(), exp.in(tagNames));
        } else {
            return exp.isNull();
        }
    } else {
        return exp.in(tagNames);
    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:15,代码来源:TargetSpecifications.java

示例6: getInPredicate

import javax.persistence.criteria.Path; //导入方法依赖的package包/类
private Predicate getInPredicate(final List<Object> transformedValues, final Path<Object> fieldPath) {
    final List<String> inParams = new ArrayList<>();
    for (final Object param : transformedValues) {
        if (param instanceof String) {
            inParams.add(((String) param).toUpperCase());
        }
    }
    if (!inParams.isEmpty()) {
        return cb.upper(pathOfString(fieldPath)).in(inParams);
    } else {
        return fieldPath.in(transformedValues);

    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:15,代码来源:RSQLUtility.java

示例7: getPredicates

import javax.persistence.criteria.Path; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" }) // TODO: tentar retirar estes warnings
private Predicate[] getPredicates( Root<T> root, List<WhereEntry> wheres ) {
    List<Predicate> predicates = new ArrayList<>();
    Predicate predMaster = null;

    for (WhereEntry whereEntry : wheres) {
        Predicate predicate;

        // --- OPERADOR DE COMPARAÇÃO ---
        Path path = getPath(whereEntry.fieldNames, root);
        switch (whereEntry.comparatorOperator) {
            case EQUAL:
                if ( whereEntry.valueIni == null ) {
                    predicate = criteriaBuilder.isNull(path);
                } else {
                    predicate = criteriaBuilder.equal(path, whereEntry.valueIni);
                }
                break;
            case NOT_EQUAL:
                if ( whereEntry.valueIni == null ) {
                    predicate = criteriaBuilder.isNotNull(path);
                } else {
                    predicate = criteriaBuilder.notEqual(path, whereEntry.valueIni);
                }
                break;
            case GREATER_THAN:
                predicate = criteriaBuilder.greaterThan(path, (Comparable) whereEntry.valueIni);
                break;
            case LESS_THAN:
                predicate = criteriaBuilder.lessThan(path, (Comparable) whereEntry.valueIni);
                break;
            case LIKE:
                predicate = criteriaBuilder.like(path, whereEntry.valueIni.toString());
                break;
            case LIKE_IGNORE_CASE:
                predicate = criteriaBuilder.like( criteriaBuilder.upper(path), whereEntry.valueIni.toString().toUpperCase() );
                break;
            case IN:
                predicate = path.in( (Collection) whereEntry.valueIni);
                break;
            case BETWEEN:
                predicate = criteriaBuilder.between(path, (Comparable) whereEntry.valueIni, (Comparable) whereEntry.valueEnd);
                break;
            default:
                throw new RuntimeException("Tipo de operador de comparação não conhecido: " + whereEntry.comparatorOperator);
        }

        if ( predMaster == null ) {
            predMaster = predicate;
        } else {
            // --- OPERADOR LÓGICO ---
            if ( whereEntry.logicalOperator != null ) {
                switch ( whereEntry.logicalOperator ) {
                    case AND:
                        predMaster = criteriaBuilder.and( predMaster, predicate );
                        break;
                    case OR:
                        predMaster = criteriaBuilder.or( predMaster, predicate );
                        break;
                    default:
                        throw new RuntimeException("Tipo de operador lógico não conhecido: " + whereEntry.comparatorOperator);
                }
            }
        }

    }
    predicates.add( predMaster );

    return predicates.toArray(new Predicate[] {});
}
 
开发者ID:jhonystein,项目名称:Pedidex,代码行数:71,代码来源:JpaCriteriaHelper.java

示例8: toPredicate

import javax.persistence.criteria.Path; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
	Path<?> path = root.get(entityInformation.getIdAttribute());
	parameter = cb.parameter(Iterable.class);
	return path.in(parameter);
}
 
开发者ID:dzinot,项目名称:spring-boot-jpa-data-rest-soft-delete,代码行数:7,代码来源:SoftDeletesRepositoryImpl.java


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