nerdexam
Oracle

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…

Criteria API

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)
  • A
    8% (3)
  • B
    79% (30)
  • C
    13% (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

#query root#CriteriaQuery#type-safe query#from clause

Community Discussion

No community discussion yet for this question.

Full 1Z0-898 Practice