Java Code Examples for javax.persistence.criteria.Path#in()
The following examples show how to use
javax.persistence.criteria.Path#in() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseJpaDaoImpl.java From herd with Apache License 2.0 | 6 votes |
/** * 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; }
Example 2
Source File: JpaQueryUtils.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Use for parsing filter parameter for Object which doesn't extend IdentifiableObject. */ public static Predicate getPredicate( CriteriaBuilder builder, Property property, Path<?> path, String operator, String value ) { switch ( operator ) { case "in" : return path.in( QueryUtils.parseValue( Collection.class, property.getKlass(), value ) ); case "eq" : return builder.equal( path, QueryUtils.parseValue( property.getKlass(), value ) ); default: throw new QueryParserException( "Query operator is not supported : " + operator ); } }
Example 3
Source File: DistributionSetSpecification.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
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); } }
Example 4
Source File: TargetSpecifications.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
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); } }
Example 5
Source File: RSQLUtility.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
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); } }
Example 6
Source File: RSQLUtility.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
private Predicate toNullOrNotInPredicate(final Path<Object> fieldPath, final List<Object> transformedValues, final List<String> outParams) { final Path<String> pathOfString = pathOfString(fieldPath); final Predicate inPredicate = outParams.isEmpty() ? fieldPath.in(transformedValues) : cb.upper(pathOfString).in(outParams); return cb.or(cb.isNull(pathOfString), cb.not(inPredicate)); }
Example 7
Source File: SoftDeletesRepositoryImpl.java From spring-boot-jpa-data-rest-soft-delete with MIT License | 4 votes |
@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); }
Example 8
Source File: In.java From specification-arg-resolver with Apache License 2.0 | 4 votes |
@Override public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { Path<?> path = path(root); Class<?> typeOnPath = path.getJavaType(); return path.in(converter.convert(Arrays.asList(allowedValues), typeOnPath)); }
Example 9
Source File: Condition.java From activejpa with Apache License 2.0 | 4 votes |
@Override Predicate createPredicate(CriteriaBuilder builder, Path path, Expression... parameter) { return path.in(parameter[0]); }
Example 10
Source File: InRestriction.java From base-framework with Apache License 2.0 | 4 votes |
@SuppressWarnings("rawtypes") public Predicate buildRestriction(Path expression, Object[] values,CriteriaBuilder builder) { return expression.in(values); }