From: Anton v. S. <an...@ap...> - 2002-06-19 16:25:54
|
> > 3. for advanced usage of queries, provide a Query object with a > > setMaxResults(). This sounds best to me. I don't think it's a bad thing to start "breaking down" the Session interface like this, for the reasons you say: > 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. ...which arises from general good design principles, e.g. small special-purposes interfaces being generally better and more cleanly extensible than large general-purpose interfaces. I took a brief look at ODMG OQL to see whether that had a query-limiting mechanism in the language, but I didn't find it(which doesn't mean it's not there). However, it does seem to me as though this requirement is orthogonal to the business of producing a query, and doesn't necessarily belong in the query language. Putting it in the language might be nice, but that would be icing on the cake, IMO. BTW, I remembered that Microsoft Access uses "SELECT TOP n ...", so we're up to 5 systems that have it in the query language. However, Hibernate is a little different in that it assumes that its clients are always Java code, whereas these other query languages have to deal with being called from all sorts of clients, and can't easily expose a consistent object API to all its possible clients. Hibernate doesn't have that restriction, so it's less important to have a feature like this in the query language itself. Anton |