This can be achieved without writing a raw request.
Here is a snippet:
QueryBuilder<Person> qb = userDao.queryBuilder(); List<Person> outputPersonList = userDao.queryDeep(" ", null);
It compiles at a low level:
SELECT T."_id",T."NAME",T."COMPANY_ID",T0."_id",T0."NAME" FROM PERSON T LEFT JOIN COMPANY T0 ON T."COMPANY_ID"=T0."_id"
Of course, if the Person model has other relationships, they will all be extracted, so this SQL query will be slow.
However, this basically does what you expect.
source share