projections: Spring Data JPA interface, record, nested and dynamic projections with the SQL they generate

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b5sejRr8s3kapmRY2g
This commit is contained in:
2026-11-12 23:51:00 +05:30
co-authored by Claude Sonnet 5.5
parent 7d7d4e872e
commit e3d1b550ae
30 changed files with 710 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
# @Query with aliases, declared as an interface projection
select e1_0.first_name,e1_0.last_name from employee e1_0 where e1_0.salary>?
rows: 6, first getFirstName(): First6
# @Query with a constructor expression (select new ...DepartmentPay)
select d1_0.name,count(e1_0.id),sum(e1_0.salary) from employee e1_0 join department d1_0 on d1_0.id=e1_0.department_id group by d1_0.name order by d1_0.name
DepartmentPay[department=Engineering, headcount=4, totalSalary=218000.00]
DepartmentPay[department=HR, headcount=4, totalSalary=226000.00]
DepartmentPay[department=Sales, headcount=4, totalSalary=222000.00]
# native query with column aliases equal to the getter names
select first_name as firstName, last_name as lastName from employee where salary > ?
rows: 6, first getFirstName(): First6