title: Union All and Sum with JPA CriteriaBuilder
body: <p>I am trying to convert a native SQL query to use the Criteria API in JPA 2.0.  I have found a lot of Criteria API examples on Google, but I am having a really hard time putting all of the pieces together.  I'm hoping that a more experienced person will be able to help me out.  The native query looks like this:</p>
  
  <pre><code>select 
      sum(amount) from firstTable, secondTable 
          where firstTable.id = secondTable.id 
              and amount &lt;&gt; 0 
              and firstTable.id = ?
  union all
  select 
      sum(amount) from firstTable, thirdTable 
          where firstTable.id = thirdTable.id 
              and amount &lt;&gt; 0 
              and firstTable.id = ?
  </code></pre>
  
  <p>The original query result set was returning a List of BigDecimal objects.</p>
  
  <p>Thank you!</p>