Example usage for javax.persistence.criteria Expression in

List of usage examples for javax.persistence.criteria Expression in

Introduction

In this page you can find the example usage for javax.persistence.criteria Expression in.

Prototype

Predicate in(Expression<Collection<?>> values);

Source Link

Document

Create a predicate to test whether the expression is a member of the collection.

Usage

From source file:org.niord.core.db.CriteriaHelper.java

/**
 * If values is defined, matches the attribute with any of the values.
 * If values is undefined (null or empty) this predicate yields false.
 *
 * @param attr the attribute// w  ww.  j  av a  2s.com
 * @param values the values to match
 */
public <V> CriteriaHelper<T> in(Expression<V> attr, Collection<V> values) {
    if (values != null && values.size() > 0) {
        where.add(attr.in(values));
    } else {
        where.add(cb.disjunction()); // Always false
    }
    return this;
}