Hi Carsten

I've actually developed something in this area already. It's basically prepared 
statements for XPATH and SQL queries, using the builder pattern. The solution 
is mature and in use in numerous large commercial deployments.

Here is an example of what using it looks like for XPATH statements (quite the 
same for SQL)

xpath("/jcr:root/content/?/?//*[@jcr:primaryType='cq:Page' and 
jcr:content/@sling:resourceType='?']")
  .setPath(0, "tenant")
  .setPath(1, "en")
  .set(2, "project/templates/articlePage")
  .execute(resourceResolver)

So, there are placeholders with type-safe setters (most notably for paths, 
dates, calendars etc.), simple execution
+ a result that allows fast retrieval of resources, adaptation and pagination, 
with re-usable thread-safe iterators.

If you are interested, I would offer to contribute it to what you are building.

Regards,
Olaf

-----Original Message-----
From: Carsten Ziegeler [mailto:cziege...@apache.org] 
Sent: Mittwoch, 13. Mai 2015 15:24
To: users@sling.apache.org
Subject: Re: Is there a way to limit the results of a query using the Sling API?

I'm currently trying to design a new query API which is not string based 
anymore. It would be much easier to use, safer and in no way require you to 
write complex SQL or Xpath queries

I'll soon have a draft which I'll post here for discussion

Carsten

Am 13.05.15 um 11:55 schrieb Dirk Rudolph:
> There isn’t a way to do this so far but it would be a nice improvement. 
> 
> See https://issues.apache.org/jira/browse/SLING-1873 
> <https://issues.apache.org/jira/browse/SLING-1873>
> 
> Cheers, Dirk
> dirk.rudo...@netcentric.biz <mailto:dirk.rudo...@netcentric.biz> | 
> www.netcentric.biz <http://www.netcentric.biz/>
>> On 13 May 2015, at 11:19, Santiago García Pimentel 
>> <santiago.pimen...@netcentric.biz> wrote:
>>
>> Hello,
>>
>> I wanted to use Sling to find some resources using SQL2 (I would prefer not 
>> to use the JCR api directly). Unfortunately it seems that the use of limit 
>> in the query is not supported, so it seems that my only option is to create 
>> a JCR Query and use query.setLimit(int).
>>
>> Is this correct? I would prefer to use only the Sling API to get these 
>> resources. The ResourceResolver has a findResources() method, but it does 
>> not accept any limit.
>>
>> Greetings.
>> --
>> *Santiago García Pimentel* | Software Engineer Netcentric Ibérica SL 
>> Av. Diagonal 123 -8ª
>> 08005 Barcelona
>> España
>> Skype: santiago.garciapimentel
>> santiago.pimen...@netcentric.biz | www.netcentric.es
> 
> 


-- 
Carsten Ziegeler
Adobe Research Switzerland
cziege...@apache.org

Reply via email to