0

我想为此查询创建等效的 CriteriaQuery : select u from User u where u.name = "John" and u.surname = "Black" and u.middlename = "Small"; 但我对“where”谓词有疑问。谢谢

4

1 回答 1

0

您可以使用:


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);
于 2011-04-19T19:45:31.757 回答