QueryDSL and SubQuery with Tuple condition

You can use Expressions.list() to specify more than one column for the in clause:

query.from(child).where(Expressions.list(child.parent, child.revision).in(subquery));

The alternative is to use innerJoin(), as in your original SQL.


In JPA subqueries can appear only in the where part.

Here is my take on your query

select(child).from(child).where(child.revision.eq(
  select(child2.revision.max())
 .from(child2)
 .where(child2.parent.eq(child.parent))
 .groupBy(child2.parent))).fetch()

Expressions.list(ENTITY.year, ENTITY.week).in(//
                    Expressions.list(Expressions.constant(1029), Expressions.constant(1)),
                    Expressions.list(Expressions.constant(1030), Expressions.constant(1)),
                    Expressions.list(Expressions.constant(1031), Expressions.constant(1))

would be what you are looking for, but QueryDSL generates wrong SQL from it:

((p0_.year , p0_.week) in (1029 , 1 , (1030 , 1) , (1031 , 1)))