1Z0-898 · Question #63
Which one of the following queries selects the customer whose order has the highest total price?
The correct answer is D. CriteriaBuilder cb =. Incorrect: Not a, not b, not C: use .from not .correlate. CriteriaBuilder qb = em.getCriteriaBuilder(); CriteriaQuery<Number> cq = qb.createQuery(Number.class); Root<Event> root = cq.from(Event.class); cq.select(qb.max(root.get("dateProcessed")))…
Question
Which one of the following queries selects the customer whose order has the highest total price?
Options
- ACriteriaBuilder cb = ...
- BCriteriaBuilder cb = ...
- CCriteriaBuilder cb = ...
- DCriteriaBuilder cb = ...
How the community answered
(48 responses)- A6% (3)
- B13% (6)
- C2% (1)
- D79% (38)
Explanation
Incorrect: Not a, not b, not C: use .from not .correlate. CriteriaBuilder qb = em.getCriteriaBuilder(); CriteriaQuery<Number> cq = qb.createQuery(Number.class); Root<Event> root = cq.from(Event.class); cq.select(qb.max(root.get("dateProcessed"))); cq.where(qb.equal(Event.get("org"), qb.parameter(MyOrgType.class, "myOrg"))); em.createQuery(cq).setParameter("myOrg", myOrg).getSingleResult(); max(Expression<N> x) Create an aggregate expression applying the numerical max operation.
Topics
Community Discussion
No community discussion yet for this question.