Java QueryDSL-子查询别名

Java QueryDSL-子查询别名,java,postgresql,querydsl,Java,Postgresql,Querydsl,所以,我想从我的数据库中获取具有特定数据计数的实体列表。我使用QueryDSL 4.1.3和postgres。我有子查询,它统计每个实体的特定数据。我得到了类似这样的东西,它是有效的: JPAQuery<?> countQuery = from(sideEntity) .join(..).on(..) .. .select(sideEntity.countDistinct); JPAQuery<?> mainQuery = from(mainEntity)

所以,我想从我的数据库中获取具有特定数据计数的实体列表。我使用QueryDSL 4.1.3和postgres。我有子查询,它统计每个实体的特定数据。我得到了类似这样的东西,它是有效的:

JPAQuery<?> countQuery = from(sideEntity)
  .join(..).on(..)
  ..
  .select(sideEntity.countDistinct);

JPAQuery<?> mainQuery = from(mainEntity)
  .innerJoin(..).on(..)
  ..
  .where(..);

return mainQuery(mainEntity, countQuery).fetch();
所以我想知道在queryDSL中是否可以将别名设置为子查询结果,然后按此别名排序

select distinct
  t0.id as a1
  ..
  (select count(distinct (t2.id) from .. where .. ) as countAlias
from .. where ..
group by ..
order by countAlias desc