These days I'm reading about JPA. I've learned that it is possible to use explicitor implicit JOIN in JPQL.
Explicit join
em.createQuery(“SELECT b.title, p.name FROM Book b JOIN b.publisher p”).getResultList();
Implicit join
em.createQuery(“SELECT b.title, b.publisher.name FROM Book b”).getResultList();
The source of these examples: link
My question is: Is there any difference in terms of performance between explicit and implict JOIN?
UPDATE
I've read what you've written @MatteoBaldi and @Kayaman, I've done some tests and I want to share the results with you.
I've created two entities: students and course, and I had a manyToOne (many students attend one course). I've used EcpliseLink Implementation of JPA.
Query = select students and dummyFiled from course, scenarios of execution:
- manyToOne (defaultFetch -> eager), implicit JOIN. Result: a single SQL query that does all the work.
- manyToOne (Fetch - > lazy), implicit JOIN. Result: the same SQL query as 1.
- manyToOne (defaultFetch - > eager), explicit JOIN. Result: the same SQL query as 1.
- manyToOne (Fetch - > lazy), explicit JOIN. Result: the same SQL query as 1.
So in my environement of test (EclipseLink,..) I had the same SQL query that was generated from my JPQL queries. So I can say that the performance will be same (ofcourse, I say again in my conditions of tests, I hope that someone can confirm/correct my results and make a general rule.