min and max (aggregate) don't appear in SQL request [message #1492163] |
Sat, 29 November 2014 10:56  |
Eclipse User |
|
|
|
It seems like min and max are not retained by Query: Here is my jpql statement:
Query query = em.createQuery("SELECT po.customerId.customerId, MAX(po.shippingCost),
MIN(po.shippingCost), COUNT(po.orderNum) countligne,
COUNT(DISTINCT po.productId.productId)\n"
+"FROM PurchaseOrder po WHERE po.customerId.customerId = :Id
GROUP BY` po.customerId.customerId");
And this is eclipselink logging sql:
SELECT t0.CUSTOMER_ID, COUNT(t1.ORDER_NUM), COUNT(DISTINCT(t2.PRODUCT_ID))
FROM CUSTOMER t0, PRODUCT t2, PURCHASE_ORDER t1 WHERE ((t1.CUSTOMER_ID = ?)
AND ((t0.CUSTOMER_ID = t1.CUSTOMER_ID) AND (t2.PRODUCT_ID = t1.PRODUCT_ID)))
GROUP BY t0.CUSTOMER_ID
I am doing wrong ?
Environment: Netbeans 8.0.1, JSF 2.2, Primefaces 5.0, JDK 1.7, eclipseLink 2.5.2
|
|
|
Re: min and max (aggregate) don't appear in SQL request [message #1495876 is a reply to message #1492163] |
Tue, 02 December 2014 10:41  |
Eclipse User |
|
|
|
It seems like count field alias disturb eclipselink, leading to inaccurate result column list:
..., COUNT(po.orderNum) countligne, ...
When I suppress 'countline' alias, every thing works perfectly.
The most strange is the lack of any error, even warning, when aggregation fields are not rendered.
|
|
|
Powered by
FUDForum. Page generated in 0.03716 seconds