Hi Artem,
My take:
1) This looks good
2) Only use the methods that you need now and add methods as they are
needed in the future. For ex if there's no need right now for named
queries we should probably not use it (Of course we should think about
all use cases so that we have a solution should they arise).
3) Why do we still need a QueryPlugin? I don't think it's needed
anymore with the QueryManager. For me the Query Plugin should be
modified to be one of the Query implementation (HQL, XPath - this one
-, JCRSQL, etc).
4) I'd really like that we try to remove any velocity-specific API so
that we have only 1 Java API for all. Maybe we can introduce some
velocity tools to handle the cases where you think it is required.
What would be those cases?
5) Why do we need to write Language.HQL.name() and not Language.HQL?
Thanks
-Vincent
On May 25, 2008, at 5:08 PM, Artem Melentyev wrote:
Hi, devs.
I would like to propose new QueryManager which will deprecate our
store.search(* methods
This proposal is based on Vincent ideas at
http://markmail.org/message/mjgg52coupsmfomg
and QueryManager from JCR v2
QueryManager is designed for low-level querying in Java code.
(QueryPlugin for high-level and velocity)
The main idea is support of multiple languages and easy to add new
languages. This is needed for JCRStore.
Here is interfaces:
public interface QueryManager {
Query createQuery(String statement, String language);
Query getNamedQuery(String qname);
String[] getLanguages();
boolean hasLanguage(String language);
}
public interface Query {
enum Language {
HQL,
XPATH,
JCRSQL
}
<T> List<T> execute();
Query bindValue(String var, Object val);
Query setLimit(int limit);
Query setOffset(int offset);
}
Here is abstract usecase:
QueryManager qm = xwiki.getStore().getQueryManager();
Query q = qm.getNamedQuery("SomeNameOfQuery");
if (q==null && qm.hasLanguage(Query.Language.HQL.name())) {
q = qm.createQuery("from XWikiDocument where author=:var",
Language.HQL.name());
} else if (q==null && qm.hasLanguage(Language.XPATH.name())) {
q = qm.createQuery("/*/*[@author=:var]", Language.XPATH.name());
} else
throw new RuntimeException();
List<XWikiDocument> res = q.setLimit(10).setOffset(10)
.bindValue("var", "Some.Author").execute();
notes:
I'm not sure we need getNamedQuery right now. But it can be useful for
move some complicated queries to store level (to some QueryHolders) or
overriding queries.
Queries are detached from store session. So session isn't opened until
Query#execute().
WDYT?
--
Artem Melentyev
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs