From: Gavin_King/Cirrus%<CI...@ci...> - 2002-06-19 08:20:46
|
I just posted the following as a feature request. Its something I would very much like to see just after 1.0 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ It would be very useful to allow the application to limit the size of a query result list. The three obvious ways to do this would be: 1. provide overloaded versions of find() and iterate() that take an int argument 2. allow a LIMIT clause in the query language (like MySQL) 3. for advanced usage of queries, provide a Query object with a setMaxResults(). approach (1) has the disadvantage of causing an explosion of methods on the Session interface - and a further possible explosion if we ever decide to extend this functionality to allowing offsets, fetch sizes, etc.... approach(2) leaves slightly open the question of how to bind a dynamic value to the LIMIT value .... the best way to do this would be with a "?" placeholder that looks just like the JDBC in parameters. Also this approach complexifies the query language which is somewhat undesirable. approach (3) requires a single new prepareQuery() method of the Session interface. However, it also requires a change in the was users think about queries. On the _very_ positive side it allows easy and elegant extension to setting other things like fetch sizes. Incidently, this is the standard model used by persistence layers. Given the preceding discussion, I would be ruling out (1) in favor of (2) or (3) - which are not mutually exclusive, actually. Thoughts? |