public void testAggregateExpressionInProjection() {
String jpql = "SELECT SUM(i.price) "
+ "FROM Order o JOIN o.lineItems i JOIN o.customer c "
+ "WHERE c.lastName = 'Smith' AND c.firstName = 'John'";
CriteriaQuery q = cb.createQuery();
Root<Order> o = q.from(Order.class);
Join<Order, LineItem> i = o.join(order_.getList("lineItems",
LineItem.class));
Join<Order, Customer> c = o.join(order_.getSingularAttribute("customer",
Customer.class));
q.where(cb.equal(c.get(customer_.getSingularAttribute("lastName", String.class)), "Smith"),
cb.equal(c.get(customer_.getSingularAttribute("firstName", String.class)), "John"));
q.select(cb.sum(i.get(lineItem_.getSingularAttribute("price", Double.class))));
assertEquivalence(q, jpql);
}