Valid 1Z0-898 Dumps shared by ExamDiscuss.com for Helping Passing 1Z0-898 Exam! ExamDiscuss.com now offer the newest 1Z0-898 exam dumps, the ExamDiscuss.com 1Z0-898 exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com 1Z0-898 dumps with Test Engine here:
The developer wants to write a criteria query that will return the number of orders made by customer of each county. Assume that customer is an entity with a unidirectional one-to-many relationship to the Order entity and that Address is an embeddable class, with an attribute country of type String. Which one of the queries below correctly achieves this?
Correct Answer: A
Explanation/Reference: Incorrect: Not B, Not C: Use multiselect, not select. Not D: Use one Join, not two. Use multiselect, count and Group By. multiselect() method is used because we are going to get compound result and not one entity type. Example: CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Object[]> query = cb.createQuery(Object[].class); Root<Department> d = query.from(Department.class); Join<Department,Teacher> teachers = d.join("teachers"); query.multiselect(d.get("name"),cb.count(teachers)).groupBy(d.get("name")); Reference: Criteria group by clause