等于:criteriaBuilder.equal

Predicate countryPredicate = criteriaBuilder.equal(root.get(“name”), “小明”);

and 和 or 查询

criteriaBuilder.and(predicates.toArray(Predicate对象,Predicate对象)

criteriaBuilder.or(predicates.toArray(Predicate对象,Predicate对象))

大于:criteriaBuilder.greaterThan

criteriaBuilder.greaterThan(root.get(“name”), 3);

小于:criteriaBuilder.lessThan

大于等于:criteriaBuilder.greaterThanOrEqualTo

小于等于:criteriaBuilder.lessThanOrEqualTo

相似查询:criteriaBuilder.like

Specification spec = (Specification) (root, criteriaQuery, criteriaBuilder) -> {

Predicate p = criteriaBuilder.like(root.get(“name”), “%” + “小明” + “%”);

return p;

};