0
我想創建與此查詢等效的CriteriaQuery: 從用戶u中選擇u,其中u.name =「John」和u.surname =「Black」和u.middlename =「Small」; 但我有「where」謂語的問題。 感謝如何動態創建CriteriaQuery
我想創建與此查詢等效的CriteriaQuery: 從用戶u中選擇u,其中u.name =「John」和u.surname =「Black」和u.middlename =「Small」; 但我有「where」謂語的問題。 感謝如何動態創建CriteriaQuery
您可以使用:
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);