title: Is JPA subquery in FROM clause possible?
body: <p>I'm having a little problem with JPA. Consider this scenario:</p>
  
  <p><strong>Table A (id_a)</strong> | <strong>Table B (id_b, id_a)</strong></p>
  
  <p>What I need is a query like this:</p>
  
  <pre><code>Select a.*, c.quantity from A as a, (Select Count(*) as quantity 
  from B as b where b.id_a = a.id_a) as c;
  </code></pre>
  
  <p>The thing is that I want to use a jpa query and not a native query, something like this:</p>
  
  <pre><code>Select a, c FROM A a, (Select Count(b) FROM B b where a.idA = b.a.idA) c;
  </code></pre>
  
  <p>So then I could iterate from the result (a list of Object[] with a and c in each node) and then assign a.quantity = c;</p>
  
  <p>I repeat, I don't want to use native query, but I found no other way than use redundant data, and add another column to A called Quantity and every time I insert and delete from B, update this column in A.</p>
  
  <p>Please help, I read somewhere that JPA doesn't accept subqueries in Form clause, so, what can I do ?</p>
  
  <p>Thanks a lot !</p>