if ("createQuery".equals(method.getName())) {
final QueryObjectModel qom = ServicesRegistry.getInstance().getQueryService().modifyAndOptimizeQuery(
(Source) args[0], (Constraint) args[1], (Ordering[]) args[2], (Column[]) args[3],
underlying, session);
if (provider.isDefault() && qom instanceof JahiaQueryObjectModelImpl) {
JahiaLuceneQueryFactoryImpl lqf = (JahiaLuceneQueryFactoryImpl) ((JahiaQueryObjectModelImpl) qom)
.getLuceneQueryFactory();
lqf.setProvider(provider);
lqf.setJcrSession(session);
}
return Proxy.newProxyInstance(qom.getClass().getClassLoader(), new Class[] { QueryObjectModel.class },
new QOMInvocationHandler(qom, provider));
} else {
try {