CriteriaBuilder cast function example

It’s quite simple, there is an as method on Expression which allows to do casts:

predicates.add(cb.ge(root.get("customerId").as(Integer.class), (Integer) value));
2 Likes