title: QueryDSL: querying relations and properties
body: <p>I'm using QueryDSL with JPA. </p>
  
  <p>I want to query some properties of an entity, it's like this:</p>
  
  <pre><code>QPost post = QPost.post;
  JPAQuery q = new JPAQuery(em);
  List&lt;Object[]&gt; rows = q.from(post).where(...).list(post.id, post.name);
  </code></pre>
  
  <p>It works fine.</p>
  
  <p>If i want to query a relation property, e.g. comments of a post:</p>
  
  <pre><code>List&lt;Set&lt;Comment&gt;&gt; rows = q.from(post).where(...).list(post.comments);
  </code></pre>
  
  <p>It's also fine.</p>
  
  <p>But when I want to query relation and simple properties together, e.g.</p>
  
  <pre><code>List&lt;Object[]&gt; rows = q.from(post).where(...).list(post.id, post.name, post.comments);
  </code></pre>
  
  <p>Then something went wrong, generiting a bad SQL syntax.</p>
  
  <p>Then I realized that it's not possible to query them together in one SQL statement.</p>
  
  <p>Is it possible that QueryDSL would somehow deal with relations and generate additional queries (just like what hibernate does with lazy relations), and load the results in?</p>
  
  <p>Or should I just query twice, and then merge both result lists?</p>
  
  <p>P.S. what i actually want is each post with its comments' ids. So a function to concat each post's comment ids is better, is this kind of expressin possible?</p>
  
  <pre><code>q.list(post.id, post.name, post.comments.all().id.join())
  </code></pre>
  
  <p>and generate a subquery sql like <code>(select group_concat(c.id) from comments as c inner join post where c.id = post.id)</code></p>