Example usage for javax.persistence.criteria CriteriaBuilder lt

List of usage examples for javax.persistence.criteria CriteriaBuilder lt

Introduction

In this page you can find the example usage for javax.persistence.criteria CriteriaBuilder lt.

Prototype

Predicate lt(Expression<? extends Number> x, Number y);

Source Link

Document

Create a predicate for testing whether the first argument is less than the second.

Usage

From source file:org.ow2.proactive.scheduling.api.graphql.fetchers.DatabaseConnectionFetcher.java

protected Predicate createCursorPredicate(CriteriaBuilder criteriaBuilder, Path<? extends Number> taskIdPath,
        Integer after, Integer before) {
    // apply cursors to tasks
    Predicate cursorPredicate = null;

    // after is set
    if (after != null) {
        // remove all elements of tasks before and including afterTask, where
        // afterTask is the task whose cursor is equal to the after argument
        cursorPredicate = criteriaBuilder.gt(taskIdPath, after);
    }//from ww  w . jav  a2 s  .c o m

    // before is set
    if (before != null) {
        // remove all elements of tasks after and including beforeTask, where
        // beforeTask is the task whose cursor is equal to the before argument
        cursorPredicate = criteriaBuilder.lt(taskIdPath, before);
    }

    return cursorPredicate;
}

From source file:com.zero.dao.impl.BaseDaoImpl.java

private void addRestrictions(CriteriaQuery<T> criteriaQuery, List<Filter> filters) {
    if (criteriaQuery == null || filters == null || filters.isEmpty()) {
        return;/*  w  w w.j  av  a2 s  . c  o m*/
    }
    Root<T> root = getRoot(criteriaQuery);
    if (root == null) {
        return;
    }
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    Predicate restrictions = criteriaQuery.getRestriction() != null ? criteriaQuery.getRestriction()
            : criteriaBuilder.conjunction();
    for (Filter filter : filters) {
        if (filter == null || StringUtils.isEmpty(filter.getProperty())) {
            continue;
        }
        if (filter.getOperator() == Operator.eq && filter.getValue() != null) {
            if (filter.getIgnoreCase() != null && filter.getIgnoreCase()
                    && filter.getValue() instanceof String) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.equal(criteriaBuilder.lower(root.<String>get(filter.getProperty())),
                                ((String) filter.getValue()).toLowerCase()));
            } else {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.equal(root.get(filter.getProperty()), filter.getValue()));
            }
        } else if (filter.getOperator() == Operator.ne && filter.getValue() != null) {
            if (filter.getIgnoreCase() != null && filter.getIgnoreCase()
                    && filter.getValue() instanceof String) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.notEqual(criteriaBuilder.lower(root.<String>get(filter.getProperty())),
                                ((String) filter.getValue()).toLowerCase()));
            } else {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.notEqual(root.get(filter.getProperty()), filter.getValue()));
            }
        } else if (filter.getOperator() == Operator.gt && filter.getValue() != null) {
            restrictions = criteriaBuilder.and(restrictions,
                    criteriaBuilder.gt(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
        } else if (filter.getOperator() == Operator.lt && filter.getValue() != null) {
            restrictions = criteriaBuilder.and(restrictions,
                    criteriaBuilder.lt(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
        } else if (filter.getOperator() == Operator.ge && filter.getValue() != null) {
            restrictions = criteriaBuilder.and(restrictions,
                    criteriaBuilder.ge(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
        } else if (filter.getOperator() == Operator.le && filter.getValue() != null) {
            restrictions = criteriaBuilder.and(restrictions,
                    criteriaBuilder.le(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
        } else if (filter.getOperator() == Operator.like && filter.getValue() != null
                && filter.getValue() instanceof String) {
            restrictions = criteriaBuilder.and(restrictions,
                    criteriaBuilder.like(root.<String>get(filter.getProperty()), (String) filter.getValue()));
        } else if (filter.getOperator() == Operator.in && filter.getValue() != null) {
            restrictions = criteriaBuilder.and(restrictions,
                    root.get(filter.getProperty()).in(filter.getValue()));
        } else if (filter.getOperator() == Operator.isNull) {
            restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).isNull());
        } else if (filter.getOperator() == Operator.isNotNull) {
            restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).isNotNull());
        }
    }
    criteriaQuery.where(restrictions);
}

From source file:ca.uhn.fhir.jpa.dao.SearchBuilder.java

private Predicate createPredicateNumeric(CriteriaBuilder builder, IQueryParameterType params,
        ParamPrefixEnum cmpValue, BigDecimal valueValue, final Expression<BigDecimal> path,
        String invalidMessageName, String theValueString) {
    Predicate num;/*  ww  w.  j  a  v  a 2 s . c  o  m*/
    switch (cmpValue) {
    case GREATERTHAN:
        num = builder.gt(path, valueValue);
        break;
    case GREATERTHAN_OR_EQUALS:
        num = builder.ge(path, valueValue);
        break;
    case LESSTHAN:
        num = builder.lt(path, valueValue);
        break;
    case LESSTHAN_OR_EQUALS:
        num = builder.le(path, valueValue);
        break;
    case APPROXIMATE:
    case EQUAL:
    case NOT_EQUAL:
        BigDecimal mul = calculateFuzzAmount(cmpValue, valueValue);
        BigDecimal low = valueValue.subtract(mul, MathContext.DECIMAL64);
        BigDecimal high = valueValue.add(mul, MathContext.DECIMAL64);
        Predicate lowPred;
        Predicate highPred;
        if (cmpValue != ParamPrefixEnum.NOT_EQUAL) {
            lowPred = builder.ge(path.as(BigDecimal.class), low);
            highPred = builder.le(path.as(BigDecimal.class), high);
            num = builder.and(lowPred, highPred);
            ourLog.trace("Searching for {} <= val <= {}", low, high);
        } else {
            // Prefix was "ne", so reverse it!
            lowPred = builder.lt(path.as(BigDecimal.class), low);
            highPred = builder.gt(path.as(BigDecimal.class), high);
            num = builder.or(lowPred, highPred);
        }
        break;
    default:
        String msg = myContext.getLocalizer().getMessage(SearchBuilder.class, invalidMessageName,
                cmpValue.getValue(), params.getValueAsQueryToken(myContext));
        throw new InvalidRequestException(msg);
    }
    return num;
}

From source file:com.zero.dao.impl.BaseDaoImpl.java

private void addRestrictions(CriteriaQuery<T> criteriaQuery, Pageable pageable) {
    if (criteriaQuery == null || pageable == null) {
        return;/* ww  w  .j a v a  2 s.c  om*/
    }
    Root<T> root = getRoot(criteriaQuery);
    if (root == null) {
        return;
    }
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    Predicate restrictions = criteriaQuery.getRestriction() != null ? criteriaQuery.getRestriction()
            : criteriaBuilder.conjunction();
    if (StringUtils.isNotEmpty(pageable.getSearchProperty())
            && StringUtils.isNotEmpty(pageable.getSearchValue())) {
        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder
                .like(root.<String>get(pageable.getSearchProperty()), "%" + pageable.getSearchValue() + "%"));
    }
    if (pageable.getFilters() != null) {
        for (Filter filter : pageable.getFilters()) {
            if (filter == null || StringUtils.isEmpty(filter.getProperty())) {
                continue;
            }
            if (filter.getOperator() == Operator.eq && filter.getValue() != null) {
                if (filter.getIgnoreCase() != null && filter.getIgnoreCase()
                        && filter.getValue() instanceof String) {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.equal(criteriaBuilder.lower(root.<String>get(filter.getProperty())),
                                    ((String) filter.getValue()).toLowerCase()));
                } else {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.equal(root.get(filter.getProperty()), filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.ne && filter.getValue() != null) {
                if (filter.getIgnoreCase() != null && filter.getIgnoreCase()
                        && filter.getValue() instanceof String) {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.notEqual(
                                    criteriaBuilder.lower(root.<String>get(filter.getProperty())),
                                    ((String) filter.getValue()).toLowerCase()));
                } else {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.notEqual(root.get(filter.getProperty()), filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.gt && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.gt(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
            } else if (filter.getOperator() == Operator.lt && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.lt(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
            } else if (filter.getOperator() == Operator.ge && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.ge(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
            } else if (filter.getOperator() == Operator.le && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.le(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
            } else if (filter.getOperator() == Operator.like && filter.getValue() != null
                    && filter.getValue() instanceof String) {
                restrictions = criteriaBuilder.and(restrictions, criteriaBuilder
                        .like(root.<String>get(filter.getProperty()), (String) filter.getValue()));
            } else if (filter.getOperator() == Operator.in && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        root.get(filter.getProperty()).in(filter.getValue()));
            } else if (filter.getOperator() == Operator.isNull) {
                restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).isNull());
            } else if (filter.getOperator() == Operator.isNotNull) {
                restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).isNotNull());
            }
        }
    }
    criteriaQuery.where(restrictions);
}

From source file:ca.uhn.fhir.jpa.dao.BaseFhirResourceDao.java

private Set<Long> addPredicateQuantity(String theParamName, Set<Long> thePids,
        List<? extends IQueryParameterType> theList) {
    if (theList == null || theList.isEmpty()) {
        return thePids;
    }/*from   w  w  w .j a v a2  s.  com*/

    CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
    CriteriaQuery<Long> cq = builder.createQuery(Long.class);
    Root<ResourceIndexedSearchParamQuantity> from = cq.from(ResourceIndexedSearchParamQuantity.class);
    cq.select(from.get("myResourcePid").as(Long.class));

    List<Predicate> codePredicates = new ArrayList<Predicate>();
    for (IQueryParameterType nextOr : theList) {
        IQueryParameterType params = nextOr;

        String systemValue;
        String unitsValue;
        QuantityCompararatorEnum cmpValue;
        BigDecimal valueValue;
        boolean approx = false;

        if (params instanceof BaseQuantityDt) {
            BaseQuantityDt param = (BaseQuantityDt) params;
            systemValue = param.getSystemElement().getValueAsString();
            unitsValue = param.getUnitsElement().getValueAsString();
            cmpValue = QuantityCompararatorEnum.VALUESET_BINDER
                    .fromCodeString(param.getComparatorElement().getValueAsString());
            valueValue = param.getValueElement().getValue();
        } else if (params instanceof QuantityParam) {
            QuantityParam param = (QuantityParam) params;
            systemValue = param.getSystem().getValueAsString();
            unitsValue = param.getUnits();
            cmpValue = param.getComparator();
            valueValue = param.getValue().getValue();
            approx = param.isApproximate();
        } else {
            throw new IllegalArgumentException("Invalid quantity type: " + params.getClass());
        }

        Predicate system = null;
        if (!isBlank(systemValue)) {
            system = builder.equal(from.get("mySystem"), systemValue);
        }

        Predicate code = null;
        if (!isBlank(unitsValue)) {
            code = builder.equal(from.get("myUnits"), unitsValue);
        }

        Predicate num;
        if (cmpValue == null) {
            BigDecimal mul = approx ? new BigDecimal(0.1) : new BigDecimal(0.01);
            BigDecimal low = valueValue.subtract(valueValue.multiply(mul));
            BigDecimal high = valueValue.add(valueValue.multiply(mul));
            Predicate lowPred = builder.gt(from.get("myValue").as(BigDecimal.class), low);
            Predicate highPred = builder.lt(from.get("myValue").as(BigDecimal.class), high);
            num = builder.and(lowPred, highPred);
        } else {
            switch (cmpValue) {
            case GREATERTHAN:
                Expression<Number> path = from.get("myValue");
                num = builder.gt(path, valueValue);
                break;
            case GREATERTHAN_OR_EQUALS:
                path = from.get("myValue");
                num = builder.ge(path, valueValue);
                break;
            case LESSTHAN:
                path = from.get("myValue");
                num = builder.lt(path, valueValue);
                break;
            case LESSTHAN_OR_EQUALS:
                path = from.get("myValue");
                num = builder.le(path, valueValue);
                break;
            default:
                throw new IllegalStateException(cmpValue.getCode());
            }
        }

        if (system == null && code == null) {
            codePredicates.add(num);
        } else if (system == null) {
            Predicate singleCode = builder.and(code, num);
            codePredicates.add(singleCode);
        } else if (code == null) {
            Predicate singleCode = builder.and(system, num);
            codePredicates.add(singleCode);
        } else {
            Predicate singleCode = builder.and(system, code, num);
            codePredicates.add(singleCode);
        }
    }

    Predicate masterCodePredicate = builder.or(codePredicates.toArray(new Predicate[0]));

    Predicate type = builder.equal(from.get("myResourceType"), myResourceName);
    Predicate name = builder.equal(from.get("myParamName"), theParamName);
    if (thePids.size() > 0) {
        Predicate inPids = (from.get("myResourcePid").in(thePids));
        cq.where(builder.and(type, name, masterCodePredicate, inPids));
    } else {
        cq.where(builder.and(type, name, masterCodePredicate));
    }

    TypedQuery<Long> q = myEntityManager.createQuery(cq);
    return new HashSet<Long>(q.getResultList());
}

From source file:com.sammyun.dao.impl.BaseDaoImpl.java

private void addRestrictions(CriteriaQuery<T> criteriaQuery, List<Filter> filters) {
    if (criteriaQuery == null || filters == null || filters.isEmpty()) {
        return;//  w  ww.j  a v a  2 s  .c o  m
    }
    Root<T> root = getRoot(criteriaQuery);
    if (root == null) {
        return;
    }
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();

    Predicate restrictions = criteriaQuery.getRestriction() != null ? criteriaQuery.getRestriction()
            : criteriaBuilder.conjunction();
    for (Filter filter : filters) {
        if (filter == null || StringUtils.isEmpty(filter.getProperty())) {
            continue;
        }

        /**  */
        if (filter.getMold() == Mold.dl || filter.getMold() == Mold.dg) {
            if (filter.getOperator() == Operator.lt && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.lessThan(root.<Date>get(filter.getProperty()),
                                DateUtil.parseDate(filter.getValue().toString())));
            } else if (filter.getOperator() == Operator.gt && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.greaterThan(root.<Date>get(filter.getProperty()),
                                DateUtil.parseDate(filter.getValue().toString())));
            } else if (filter.getOperator() == Operator.le && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.lessThanOrEqualTo(root.<Date>get(filter.getProperty()),
                                DateUtil.parseDate(filter.getValue().toString())));
            } else if (filter.getOperator() == Operator.ge && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.greaterThanOrEqualTo(root.<Date>get(filter.getProperty()),
                                DateUtil.parseDate(filter.getValue().toString())));
            }

        } else {

            if (filter.getOperator() == Operator.eq && filter.getValue() != null) {
                if (filter.getIgnoreCase() != null && filter.getIgnoreCase()
                        && filter.getValue() instanceof String) {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.equal(criteriaBuilder.lower(root.<String>get(filter.getProperty())),
                                    ((String) filter.getValue()).toLowerCase()));
                } else {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.equal(root.get(filter.getProperty()), filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.ne && filter.getValue() != null) {
                if (filter.getIgnoreCase() != null && filter.getIgnoreCase()
                        && filter.getValue() instanceof String) {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.notEqual(
                                    criteriaBuilder.lower(root.<String>get(filter.getProperty())),
                                    ((String) filter.getValue()).toLowerCase()));
                } else {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.notEqual(root.get(filter.getProperty()), filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.gt && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.gt(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));

            } else if (filter.getOperator() == Operator.lt && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.lt(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
            } else if (filter.getOperator() == Operator.ge && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.ge(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
            } else if (filter.getOperator() == Operator.le && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        criteriaBuilder.le(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
            } else if (filter.getOperator() == Operator.like && filter.getValue() != null
                    && filter.getValue() instanceof String) {
                restrictions = criteriaBuilder.and(restrictions, criteriaBuilder
                        .like(root.<String>get(filter.getProperty()), (String) filter.getValue()));
            } else if (filter.getOperator() == Operator.in && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions,
                        root.get(filter.getProperty()).in(filter.getValue()));
            } else if (filter.getOperator() == Operator.isNull) {
                restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).isNull());
            } else if (filter.getOperator() == Operator.isNotNull) {
                restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).isNotNull());
            }
        }
    }
    criteriaQuery.where(restrictions);
}

From source file:com.sammyun.dao.impl.BaseDaoImpl.java

private void addRestrictions(CriteriaQuery<T> criteriaQuery, Pageable pageable) {
    if (criteriaQuery == null || pageable == null) {
        return;//from   www .j  a  v a 2 s .c  o m
    }
    Root<T> root = getRoot(criteriaQuery);
    if (root == null) {
        return;
    }
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    Predicate restrictions = criteriaQuery.getRestriction() != null ? criteriaQuery.getRestriction()
            : criteriaBuilder.conjunction();
    if (StringUtils.isNotEmpty(pageable.getSearchProperty())
            && StringUtils.isNotEmpty(pageable.getSearchValue())) {
        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder
                .like(root.<String>get(pageable.getSearchProperty()), "%" + pageable.getSearchValue() + "%"));
    }
    if (pageable.getFilters() != null) {
        for (Filter filter : pageable.getFilters()) {
            if (filter == null || StringUtils.isEmpty(filter.getProperty())) {
                continue;
            }
            /**  */
            if (filter.getMold() == Mold.dl || filter.getMold() == Mold.dg) {
                if (filter.getOperator() == Operator.lt && filter.getValue() != null) {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.lessThan(root.<Date>get(filter.getProperty()),
                                    DateUtil.parseDate(filter.getValue().toString())));
                } else if (filter.getOperator() == Operator.gt && filter.getValue() != null) {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.greaterThan(root.<Date>get(filter.getProperty()),
                                    DateUtil.parseDate(filter.getValue().toString())));
                } else if (filter.getOperator() == Operator.le && filter.getValue() != null) {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.lessThanOrEqualTo(root.<Date>get(filter.getProperty()),
                                    DateUtil.parseDate(filter.getValue().toString())));
                } else if (filter.getOperator() == Operator.ge && filter.getValue() != null) {
                    restrictions = criteriaBuilder.and(restrictions,
                            criteriaBuilder.greaterThanOrEqualTo(root.<Date>get(filter.getProperty()),
                                    DateUtil.parseDate(filter.getValue().toString())));
                }
            } else {

                if (filter.getOperator() == Operator.eq && filter.getValue() != null) {
                    if (filter.getIgnoreCase() != null && filter.getIgnoreCase()
                            && filter.getValue() instanceof String) {
                        restrictions = criteriaBuilder.and(restrictions,
                                criteriaBuilder.equal(
                                        criteriaBuilder.lower(root.<String>get(filter.getProperty())),
                                        ((String) filter.getValue()).toLowerCase()));
                    } else {
                        restrictions = criteriaBuilder.and(restrictions,
                                criteriaBuilder.equal(root.get(filter.getProperty()), filter.getValue()));
                    }
                } else if (filter.getOperator() == Operator.ne && filter.getValue() != null) {
                    if (filter.getIgnoreCase() != null && filter.getIgnoreCase()
                            && filter.getValue() instanceof String) {
                        restrictions = criteriaBuilder.and(restrictions,
                                criteriaBuilder.notEqual(
                                        criteriaBuilder.lower(root.<String>get(filter.getProperty())),
                                        ((String) filter.getValue()).toLowerCase()));
                    } else {
                        restrictions = criteriaBuilder.and(restrictions,
                                criteriaBuilder.notEqual(root.get(filter.getProperty()), filter.getValue()));
                    }
                } else if (filter.getOperator() == Operator.gt && filter.getValue() != null) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder
                            .gt(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
                } else if (filter.getOperator() == Operator.lt && filter.getValue() != null) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder
                            .lt(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
                } else if (filter.getOperator() == Operator.ge && filter.getValue() != null) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder
                            .ge(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
                } else if (filter.getOperator() == Operator.le && filter.getValue() != null) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder
                            .le(root.<Number>get(filter.getProperty()), (Number) filter.getValue()));
                } else if (filter.getOperator() == Operator.like && filter.getValue() != null
                        && filter.getValue() instanceof String) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder
                            .like(root.<String>get(filter.getProperty()), (String) filter.getValue()));
                } else if (filter.getOperator() == Operator.in && filter.getValue() != null) {
                    restrictions = criteriaBuilder.and(restrictions,
                            root.get(filter.getProperty()).in(filter.getValue()));
                } else if (filter.getOperator() == Operator.isNull) {
                    restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).isNull());
                } else if (filter.getOperator() == Operator.isNotNull) {
                    restrictions = criteriaBuilder.and(restrictions,
                            root.get(filter.getProperty()).isNotNull());
                }
            }
        }
    }
    criteriaQuery.where(restrictions);
}