Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » min and max (aggregate) don't appear in SQL request(min and max (aggregate) don't appear in SQL request)
min and max (aggregate) don't appear in SQL request [message #1492163] Sat, 29 November 2014 15:56 Go to next message
devware33 . is currently offline devware33 .Friend
Messages: 2
Registered: November 2014
Junior Member
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 15:41 Go to previous message
devware33 . is currently offline devware33 .Friend
Messages: 2
Registered: November 2014
Junior Member

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.
Previous Topic:Can List JPA entity field values be guaranteed to implement java.util.RandomAccess?
Next Topic:Cloning a record in Database using CopyGroup
Goto Forum:
  


Current Time: Sat Feb 24 22:18:04 GMT 2024

Powered by FUDForum. Page generated in 0.02535 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top