Skip to main content

Join Queries & DTO Projection

Learn Join Queries & DTO Projection (Spring Data JPA, Spring Boot) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Two-Table Join Operation Business requirement: you have two tables and want to fetch data from both. In that case we go with the join approach. Problem statement: design the REST API to return this response, built from two tables: empDept • empDeptDesc • empName • empEmail • empAddress Table structure Notice that the five fields we want come from both tables and match neither entity. That is what a DTO is for: a class shaped like the answer rather than like a table.

More lessons in Spring Data JPA