Hmmm... The scenario you mention sounds like Query By Example, which would be straightforward. My concern is how can we possibly come up with our own "generic" query and criteria classes for a typical form to do issue a query equivalent to
Code:
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 = :currentCatalog
group by order
having sum(price.amount > :minAmount
order by sum(price.amount) desc
I pulled this example out of the Hibernate docs; our grids will have at least 2 joins each, more typically around 5, and will usually need to select "primary" or other "chosen" children out of the driving entity's many collection properties.
I've looked at the criteria API, and it appears very awkward for anything except Query By Example with forms that simply select a list of a single entity type. There's no way our typical tech-unsavvy customer (or even our own developers) will accept specifying complex queries for their forms with some "generic" equivalent of the NHibernate criteria API :(
I have a hard time seeing anything but a "named queries" approach as scalable/universal. We have enough problems already with past attempts to create "simplified" interfaces that are supposedly sufficient for 90% of cases -- we always end up with a mess of different approaches and workarounds because the simplified interface simply fails to do the job way too often. :?