JPQL: Internal registration without duplicate entries

The following is a question that was supposedly part of the official exam from the Sun:

The Reader object is a one-to-many relationship, bidirectional with the Book Object. Two Reader objects are saved, each of which has two books associated with them. For example, reader 1 has book a and book b, while reader 2 has book c and book d. Which query returns a collection of less than four items?
    A. SELECT b.reader FROM Book b
    B. SELECT from an entry b INPUT JOIN b.reader r
    C. SELECT r FROM Reader r INNER JOIN r.books b
    D. SELECT r from book b LEFT JOIN b.reader r LEFT JOIN FETCH r.books

This answer is C, which I believe is incorrect. From what I understand, SQL with an inner join of two tables will be generated by the JPA provider. Therefore, in all cases we get 4 entries. I checked the one-to-many test and duplicates were added.

Who is wrong, me or the sun?

+5
source share
2 answers

Reply from Mike Keith, co-specification EJB 3.0:

There are several duplicate statements in the specification.

  • JOIN FETCH - JOIN, , JOIN ( , ). ( 4.4.5.3 JPA v2.0) , , Employee select.

  • SELECT ( 4.8 JPA 2.0),

" DISTINCT , ."

JPA :

a) , SQL b) c) , , .

+11

C , ToMany . JPA . , , , .

, , . , , . , ( , ).

EclipseLink.

" ", , C "", .

0
source

All Articles