如何使用CriteriaQuery和EntityManager为此SQL查询创建查询:
SELECT * FROM user WHERE user.login = '?' and user.password = '?'
我试试:
final CriteriaBuilder criteriaBuilder = getEntityManager().getCriteriaBuilder();
final CriteriaQuery<User> criteriaQuery = criteriaBuilder.createQuery(User.class);
Root<User> root = criteriaQuery.from(User.class);
criteriaQuery.select(root);
criteriaQuery.where(criteriaBuilder.gt(root.get("login"), userLogin));
return getEntityManager().createQuery(criteriaQuery).getResultList().get(0);
答案 0 :(得分:0)
这对我来说最终是这样的:
{{1}}