Java Code Examples for javax.persistence.criteria.CriteriaBuilder.conjunction()

The following are Jave code examples for showing how to use conjunction() of the javax.persistence.criteria.CriteriaBuilder class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: cloud   File: ByRangeSpecification.java   Source Code and License Vote up 7 votes
@Override
public  Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
    List<Predicate> predicates = newArrayList();

    for (Range<T> range : ranges) {
        if (range.isSet()) {
            Predicate rangePredicate = buildRangePredicate(range, root, builder);

            if (rangePredicate != null) {
                if (!range.isIncludeNullSet() || range.getIncludeNull() == FALSE) {
                    predicates.add(rangePredicate);
                } else {
                    predicates.add(builder.or(rangePredicate, builder.isNull(root.get(range.getField()))));
                }
            }

            if (TRUE == range.getIncludeNull()) {
                predicates.add(builder.isNull(root.get(range.getField())));
            } else if (FALSE == range.getIncludeNull()) {
                predicates.add(builder.isNotNull(root.get(range.getField())));
            }
        }
    }
    return predicates.isEmpty() ? builder.conjunction() : builder.and(toArray(predicates, Predicate.class));
}
 
Example 2
Project: plumdo-stock   File: Criteria.java   Source Code and License Vote up 5 votes
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,  
        CriteriaBuilder builder) {  
    if (!criterions.isEmpty()) {  
        List<Predicate> predicates = new ArrayList<Predicate>();  
        for(Criterion c : criterions){  
            predicates.add(c.toPredicate(root, query,builder));  
        }  
        // 将所有条件用 and 联合起来  
        if (predicates.size() > 0) {  
            return builder.and(predicates.toArray(new Predicate[predicates.size()]));  
        }  
    }  
    return builder.conjunction();  
}
 
Example 3
Project: plumdo-work   File: Criteria.java   Source Code and License Vote up 5 votes
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,  
        CriteriaBuilder builder) {  
    if (!criterions.isEmpty()) {  
        List<Predicate> predicates = new ArrayList<Predicate>();  
        for(Criterion c : criterions){  
            predicates.add(c.toPredicate(root, query,builder));  
        }  
        // 将所有条件用 and 联合起来  
        if (predicates.size() > 0) {  
            return builder.and(predicates.toArray(new Predicate[predicates.size()]));  
        }  
    }  
    return builder.conjunction();  
}
 
Example 4
Project: bootstrap   File: DynamicSpecification.java   Source Code and License Vote up 5 votes
/**
 * Create a predicate group.
 */
private Predicate getGroupPredicate(final UiFilter group, final Root<U> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
	// Build the predicates
	final java.util.List<Predicate> predicates = getPredicates(group, root, query, cb);

	// Build the specification
	if (predicates.isEmpty()) {
		return cb.conjunction();
	}
	final Predicate[] filteredPredicates = predicates.toArray(new Predicate[predicates.size()]);
	if (group.getGroupOp() == FilterOperator.AND) {
		return cb.and(filteredPredicates);
	}
	return cb.or(filteredPredicates);
}
 
Example 5
Project: datatable-java   File: DatatableSpecification.java   Source Code and License Vote up 5 votes
/**
 * {@inheritDoc}
 */
@Override
public Predicate toPredicate(final Root<T> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    Predicate predicate = cb.conjunction();
    predicate = getPredicateColonnes(root, query, cb, predicate);
    predicate = getPredicateGlobalSearch(root, query, cb, predicate);
    return predicate;
}
 
Example 6
Project: sctalk   File: SearchCriteria.java   Source Code and License Vote up 5 votes
@Override
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
    if (!criterions.isEmpty()) {
        List<Predicate> predicates = new ArrayList<Predicate>();
        for (Criterion c : criterions) {
            predicates.add(c.toPredicate(root, query, builder));
        }
        // 将所有条件用 and 联合起来
        if (predicates.size() > 0) {
            return builder.and(predicates.toArray(new Predicate[predicates.size()]));
        }
    }
    return builder.conjunction();
}