title: JPA QueryDSL exists and count
body: <p>I'm trying to got these SQL-Statement to a QueryDSL call.</p>
  
  <pre><code>   select t.asd_id, count(*) as count from asset_object t 
       left join asset_data ad on (t.asd_id = ad.asd_id)
       where
         exists (select * from assetobject_parents p 
                 where t.aso_id = p.aso_id and p.ctd_id = 1)
       group by t.asd_id
       order by count(*) desc, t.asd_id asc
  </code></pre>
  
  <p>Can anyone give me a hint or a solution?</p>
  
  <p>Here is my Domain (extract):</p>
  
  <pre><code>@Entity
  public class AssetObject {
  
      @Id
      @Column(name = "ASO_ID")
      private Long asoId;
  
  
      @ManyToMany
      @OrderColumn(name = "ASP_ORDER")
      @JoinTable(name = "ASSETOBJECT_PARENTS", joinColumns = { @JoinColumn(name = "ASO_ID", referencedColumnName="ASO_ID") }, inverseJoinColumns = { @JoinColumn(name = "CTD_ID", referencedColumnName="CTD_ID") })
      private List&lt;CategoryData&gt; parents = new ArrayList&lt;CategoryData&gt;();
  
  }
  
  @Entity
  public class CategoryData {
  
      @Id
      @Column(name = "CTD_ID")
      private Long ctdId;
  
  }
  
  
  @Entity
  @Table(name = "ASSET_DATA")
  public class AssetData {
  
      @Id
      @Column(name = "ASD_ID")
      private Long asdId;
  
      @ManyToMany
      @JoinTable(name = "ASSETDATA_CATEGORYDATA", joinColumns = { @JoinColumn(name = "ASD_ID", referencedColumnName="ASD_ID") }, inverseJoinColumns = { @JoinColumn(name = "CTD_ID", referencedColumnName="CTD_ID") })
      private List&lt;CategoryData&gt; categoryDataList = new ArrayList&lt;CategoryData&gt;();
  
  }
  </code></pre>
  
  <p>Hope this helps a little bit more. I think the main point is that it's not possible to access join-tables with querydsl.</p>