How do I dynamically create CriteriaQuery
I wan开发者_如何学Ct to create equivalent CriteriaQuery to this query : select u from User u where u.name = "John" and u.surname = "Black" and u.middlename = "Small"; but I have problem with "where" predicate. Thanks
You can use:
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery c = ...;
Root root = ...;
Predications name = builder.equal(root.get("name"), name);
Predications surname = ...;
Predications middlename = ...;
c.where(name, surname, middlename);
精彩评论