As of now we have seen about simple queries in JPA. This article will deal with introduction to JPA joins.
JPA joins queries are used to retrieve data from more that on entities. When join queries are translated to SQL, then it is likely that joins between entities will produce similar joins between the tables represented by entities.
Joins can occur whenever any of the following conditions are met.
- Two or more range variable declarations are listed in FROM clause and appear in SELECT clause.
- The JOIN operator is used to extend an identification variable using a path expression.
- A path expression anywhere in the query navigates across an association field, to the same or a different entity.
- One or more where conditions compare attributes of different identification variables.
The semantics of jpa joins between entities are the same as SQL joins between tables.
JPA Joins are are categorized into
- Inner joins
- Outer joins
In further articles, we will learn about inner and outer jpa joins.
References for further study :