Projections can be used recursively. If you want to include Address information as well, create a projection interface for that and return that interface from the declaration of getAddresses()
On method invocation, the address property of the target instance is obtained and wrapped into a projecting proxy. Spring Data JPA will trigger another query for each Employee to fetch the associated Address entities.
This creates an n+1 select issue, which can cause severe performance issues. We will look at other possible causes of this issue and how to avoid it in future series.
GitHub repo
[email protected]:java-space/springboot.git
Slides
https://drive.google.com/drive/folder...