當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。