From: Gavin_King/Cirrus%<CI...@ci...> - 2002-07-31 12:27:28
|
>Query By Criteria and Query By Example >(Query By example could use Query by criteria internally) > >Here's an example for queryByCriteria >Query query = new Query(); >Query.addBetweenCriteria("age", new Integer(10), new Integer(20)); >Query.addOrderByCriteria("name"); > >QueryByExample: >Customer cust = new Customer(); >cust.setStatus(5); >Collection customers = Session.queryByExample(cust); >(returns all customers with status == 5) > >Do you think this makes sense and is worth implementing? Query by criteria is a standard kind of approach and is the approach used in SmallTalky kinds of solutions that I loosely based Hibernate upon. I'm personally *not* keen on it, it sacrifices much brevity + expressiveness for the sake of looking superficially more object oriented (and a little more compile-time checking). If you think about some of the things you can express in the latest version of Hibernate's query language (subqueries, aggregate functions, some, exists, all, etc....) they are quite difficult to express by composing objects. I am particularly suspicious of the API explosion entailed by something like this. You would need more interfaces for this than Hibernate's whole current API. Query by example: this is really cool and if you want to think about how we could implement it, go ahead.... sorry ... more later ... taxi is here.... |