Which query can be used to return the user that holds the book titled "Java"?

A User entity is in a onE. to-many relationship with a Book entity. Assume that a developer has a
function fetchBook(String title) that fetches a Book entity with the given title title. Also assume that
the developer has an entity manager em. Which query can be used to return the user that holds
the book titled “Java”?

A User entity is in a onE. to-many relationship with a Book entity. Assume that a developer has a
function fetchBook(String title) that fetches a Book entity with the given title title. Also assume that
the developer has an entity manager em. Which query can be used to return the user that holds
the book titled “Java”?

A.
em.createQuery(“SELECT u FROM User u where :great IN
u.books.title”).setParameter(“great”,”Java”)

B.
em.createQuery(“SELECT u FROM User u where :great IN
u.books”).setParameter(“great”,fetchBook(“Java”))

C.
em.createQuery(“SELECT u FROM User u where :great MEMBER OF
u.books.title”).setParameter(“great”,”Java”;

D.
em.createQuery(“SELECT u FROM User u where :great MEMBER OF
u.books”).setParameter(“great”,fetchBook(“Java”))

Explanation:



Leave a Reply 0

Your email address will not be published. Required fields are marked *