nerdexam
Oracle

1Z0-860 · Question #144

A User entity is in a one-to-many relationship with a Book entity. In other words, a developer can reach the collection of books that a User instance myUser has by using the path…

The correct answer is A. SELECT u FROM User u WHERE SIZE(u.books) = 2 C. SELECT u FROM User u WHERE(SELECT COUNT(b) FROM u.books b) = 2. See the full explanation below for the reasoning.

Question

A User entity is in a one-to-many relationship with a Book entity. In other words, a developer can reach the collection of books that a User instance myUser has by using the path expression"myUser.books". A developer wants to write a Java Persistence query that returns all users that have only two books. Which two are valid queries that return this information? (Choose two.)

Options

  • ASELECT u FROM User u WHERE SIZE(u.books) = 2
  • BSELECT u FROM User u WHERE COUNT(u. books) = 2
  • CSELECT u FROM User u WHERE(SELECT COUNT(b) FROM u.books b) = 2
  • DSELECT u FROM User u WHERE (SELECT SIZE(b) FROM u.booksb)= 2

How the community answered

(31 responses)
  • A
    71% (22)
  • B
    10% (3)
  • D
    19% (6)

Community Discussion

No community discussion yet for this question.

Full 1Z0-860 Practice