强悍HQL
select order.id, sum(price.amount), count(item)
from Order as order
? ? join order.lineItems as item
? ? join item.product as product,
? ? Catalog as catalog
? ? join catalog.prices as price
where order.paid = false
? ? and order.customer = :customer
? ? and price.product = product
? ? and catalog.effectiveDate < sysdate
? ? and catalog.effectiveDate?
>= all (
? ? ? ? select cat.effectiveDate
? ? ? ? from Catalog as cat
? ? ? ? where cat.effectiveDate < sysdate
? ? )
group by order
having sum(price.amount)?
> :minAmount
order by sum(price.amount) desc