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

The following are Jave code examples for showing how to use disjunction() 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: datatable-java   File:   Source Code and License Vote up 6 votes
private Predicate getPredicateGlobalSearch(final Root<T> root, final CriteriaQuery<?> query, final CriteriaBuilder cb,
    Predicate predicate) {
    // check whether a global filter value exists
    final String globalFilterValue = input.getSearch().getValue();
    if (globalFilterValue != null && globalFilterValue.trim().length() > 0) {
        LOGGER.fine("filtre global: {"+ globalFilterValue+"}");

        Predicate matchOneColumnPredicate = cb.disjunction();
        // add a 'WHERE .. LIKE' clause on each searchable column
        for (final DatatableColumn column : input.getColumns()) {
            if (column.getSearchable()) {
                LOGGER.log(Level.FINE, "filtre global pour colonne: {}", column);
                final Expression<String> expression = DatatableHelper.getExpression(root, column.getData(), String.class);

                matchOneColumnPredicate = cb.or(matchOneColumnPredicate,
          , getLikeFilterValue(globalFilterValue), ESCAPE_CHAR));
        predicate = cb.and(predicate, matchOneColumnPredicate);
    return predicate;