读书人

剽悍HQL

发布时间: 2012-12-26 14:39:29 作者: rapoo

强悍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

读书人网 >编程

热点推荐