开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜