nerdexam
Oracle

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")))…

Criteria API

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)
  • A
    6% (3)
  • B
    13% (6)
  • C
    2% (1)
  • D
    79% (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

#subquery#aggregate function#max price#CriteriaBuilder

Community Discussion

No community discussion yet for this question.

Full 1Z0-898 Practice