Join with subquery in Querydsl SQL 4.x

223 views
Skip to first unread message

Balázs Zsoldos

unread,
Jul 27, 2016, 9:21:03 AM7/27/16
to Querydsl
Hi,

Last night I could not find out how to use SQLQuery.join(SubQueryExpression, Path) function. The SubQuery would have results with several columns that would be used in the main query. What should be the generic type of the Path parameter?

A simple example like the following would be great in the documentation.:

SELECT userSubQuery.userName, userSubQuery.age
  FROM company
  INNER JOIN (SELECT companyId, userName, age FROM user) AS userSubQuery ON userSubQuery.companyId = company.companyId

The statement above is only an example. I know that it could be simplified to avoid subquery.

I could not answer the following questions by evaluating the QueryDSL API:

 - What should be the generic type of the Path when multiple columns are used from the SubQuery?
 - How should be the Path instance created?
 - How can I use the columns in the main query?

Thanks,
Balazs
Reply all
Reply to author
Forward
0 new messages