A test case exists here:
A Criteria API query with a doubly-nested subselect results in invalid SQL being generated.
JPA model class snippet:
Note missing root in the subselect.
Here's the full exception & trace from the test case:
After investigation, both this ticket and share the same solution. So I updated to include testing cases for both. One stone two birds!
Glad to hear there is actually only one underlying bug. Thanks!
After investigation, it is decided a separate PR will be created for this ticket for it has different root cause and solution.
PR created at: