1Z0-898 · Question #60
A developer wants to write a type-safe Criteria API query. Which two of the following statements true about Criteria query roots? (Choose two)
The correct answer is B. The query MUST define a query root only if it navigates to related entities. D. The query may define multiple query roots. For a particular CriteriaQueryobject, the root entity of the query, from which all navigation originates, is called the query root. It is similar to the FROM clause in a JPQL query. D:Criteria queries may have more than one query root. This usually occurs when the query…
Question
A developer wants to write a type-safe Criteria API query. Which two of the following statements true about Criteria query roots? (Choose two)
Options
- AThe query MUST define a query root.
- BThe query MUST define a query root only if it navigates to related entities.
- CThe query MUST NOT define multiple query roots.
- DThe query may define multiple query roots.
How the community answered
(38 responses)- A8% (3)
- B79% (30)
- C13% (5)
Explanation
For a particular CriteriaQueryobject, the root entity of the query, from which all navigation originates, is called the query root. It is similar to the FROM clause in a JPQL query. D:Criteria queries may have more than one query root. This usually occurs when the query navigates from several entities. The following code has two Root instances: CriteriaQuery<Pet> cq = cb.createQuery(Pet.class); Root<Pet> pet1 = cq.from(Pet.class); Root<Pet> pet2 = cq.from(Pet.class);
Topics
Community Discussion
No community discussion yet for this question.