List of usage examples for javax.persistence.criteria CriteriaBuilder mod
Expression<Integer> mod(Integer x, Expression<Integer> y);
From source file:com.ocs.dynamo.dao.query.JpaQueryBuilder.java
/** * Create a modulo predicate/* w w w . ja v a 2 s . co m*/ * * @param builder * @param filter * @return */ @SuppressWarnings({ "rawtypes", "unchecked" }) private static Predicate createModuloPredicate(CriteriaBuilder builder, Root<?> root, Filter filter) { Modulo modulo = (Modulo) filter; if (modulo.getModExpression() != null) { // compare to a literal expression return builder.equal(builder.mod((Expression) getPropertyPath(root, modulo.getPropertyId()), (Expression) getPropertyPath(root, modulo.getModExpression())), modulo.getResult()); } else { // compare to a property return builder.equal(builder.mod((Expression) getPropertyPath(root, modulo.getPropertyId()), modulo.getModValue().intValue()), modulo.getResult()); } }