Below is my jpa code.
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery();
Root e = cq.from(Student.class);
cq.where(cb.greaterThan(e.get("id"), 3));
Query query = entityManager.createQuery(cq);
List<Student> students = query.getResultList();
I want to get all the students whose id is greater than three. thanks.
I guess you have to define the columns those will be selected from the table.
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Student> cq = cb.createQuery(Student.class);
Root<Student> root = cq.from(Student.class);
cq.where(cb.greaterThan(e.get("id"), 3));
cq.select(root); // Which columns will be selected? Presuming all.
List<Student> studentList = entityManager.createQuery(cq).getResultList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With