aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Another Enthuware question doubt regarding JPQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Another Enthuware question doubt regarding JPQL" Watch "Another Enthuware question doubt regarding JPQL" New topic
Author

Another Enthuware question doubt regarding JPQL

Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Hi,

I have some doubts regarding the following question:

Given the following two entites:




Given further that the following data exists in the database:
Student John refers to Presentations P1 and P2
Student Jacob refers to Presentations P3 and P4

Write the sizes of collections returned by the following queries:

1. SELECT p.presenter from Presentation p
Ans: 4
My answer: 4

2. SELECT s from Presentation p INNER JOIN p.presenter s
Ans: 4
My answer: 4

3. SELECT s from Student s INNER JOIN s.presentations p
Ans: 2
My answer: 4

4. SELECT s from Presentation p LEFT JOIN p.presenter s LEFT JOIN FETCH s.presentations
Ans: 4
My answer: 8


I agree with the answer given for the first two statements but not eith the other two.

This is my reasoning:

3. SELECT s from Student s INNER JOIN s.presentations p
Even if only Student instances are returned by the JPQL statement, there is an inner join with Presentations. So, how come only two rows will be returned?
From my point of view, changing the query as "SELECT s, p from Student s INNER JOIN s.presentations p" will make it more obviuos that 4 rows are returned.

4. SELECT s from Presentation p LEFT JOIN p.presenter s LEFT JOIN FETCH s.presentations

In this case we are joining Presentation with Student and again with Presentation. Presentation with Student returns 4 rows and then each one of this 4 rows is joined with Presentation again. Taking into consideration that each Student refers to two Presentations, we should get a result of 8 rows (4 x 2).

Am I correct?

Thanks in advance.


SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Another Enthuware question doubt regarding JPQL