title: HQL SUM Query - unexpected token
body: <p>I can execute an HQL as follows:</p>
  
  <pre><code>select order.anticipatedMonetaryTotal.payableAmount.value from OrderType order
  </code></pre>
  
  <p>using a code like:</p>
  
  <pre><code>EntityManager e = this.entityManagerFactory.createEntityManager();
  e.getTransaction().begin();
  result = e.createQuery(query).getResultList();
  </code></pre>
  
  <p>So, I know that the <code>order.anticipatedMonetaryTotal.payableAmount.value</code> is a correct location to fetch values (a list of BigDecimal values).</p>
  
  <p>However, I'm getting a:</p>
  
  <pre><code>line 1:14: unexpected token: order
  antlr.NoViableAltException: unexpected token: order
  </code></pre>
  
  <p>for the following query:</p>
  
  <pre><code>select SUM ( order.anticipatedMonetaryTotal.payableAmount.value) from OrderType order
  </code></pre>
  
  <p>So, what do I miss about the SUM notation? As far as I can see at <a href="https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-aggregation" rel="nofollow noreferrer">https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-aggregation</a>, it is quite straightforward and I cannot see any mistake in my case.</p>