From: Gavin K. <ga...@ap...> - 2002-09-19 11:23:00
|
Yeah, I knew this would come up.... but I'm not quite sure of exactly how to structure the API. I was thinking along the lines of: Query q = session.createQuery(queryString, collection); or: Filter f = session.createFilter(queryString); f.setCollection(coll); List results = f.list(); where Filter extends Query. But now you've raised another possibility. I don't think I like your suggestion because it changes the way Queries are called. (ie. you go to the session to create the query and then go back to the session again to call it.) The first option is good because it lets us compile the query from the createFilter method (we know exactly which collection role to use) and doesn't require any new interfaces. The second is good because it would let you reuse the same Filter object multiple times for different collections. I am leaning towards the first option. Theres an implementation issue that comes up here: I intend to eventually have the query be compiled from the createQuery() method. That way you recieve any compilation exception from that call and then any execution exception from list() or iterate(). This would also mean I would factor a bunch of code out of SessionImpl and onto QueryImpl (a good thing). Currently, however, the query is compiled on the first call to list() or iterate(). (Note that Hibernate caches compiled queries in a WeakRefHashMap on the session factory.) > > Could you also add a method session.filer(Collection, Query)? > > regards > chris |