1Z0-898 · Question #19
The developer wants to write a portable criteria query that will order the orders made by customer James Brown according to increasing quantity. Which one of the below queries correctly accomplishes…
The correct answer is B. CriteriaBuilder cb=. Incorrect: Not A: Missing select statement. Not C: select statement should not be put last.Not D: Do not use two orderBy. Note:ORDER BY in Criteria Queries The CriteriaQuery interface provides methods for setting the ORDER BY clause. For example, the following JPQL query: ORDER…
Question
The developer wants to write a portable criteria query that will order the orders made by customer James Brown according to increasing quantity. Which one of the below queries correctly accomplishes that task?
Options
- ACriteriaBuilder cb= . . .
- BCriteriaBuilder cb= . . .
- CCriteriaBuilder cb= . . .
- DCriteriaBuilder cb= . . .
How the community answered
(26 responses)- A4% (1)
- B85% (22)
- C4% (1)
- D8% (2)
Explanation
Incorrect: Not A: Missing select statement. Not C: select statement should not be put last.Not D: Do not use two orderBy. Note:ORDER BY in Criteria Queries The CriteriaQuery interface provides methods for setting the ORDER BY clause. For example, the following JPQL query: ORDER BY c.currency, c.population DESC can be built using the criteria query API as follows: CriteriaQuery<Country> q = cb.createQuery(Country.class); Root<Country> c = q.from(Country.class); q.orderBy(cb.asc(c.get("currency")), cb.desc(c.get("population")));
Topics
Community Discussion
No community discussion yet for this question.