[daisy] COUNT in queries
Bruno Dumon
bruno at outerthought.org
Wed Jul 26 11:38:11 CDT 2006
On Wed, 2006-07-26 at 17:32 +0100, Mark H wrote:
> I came across that problem too - I wanted to select a random document. All I
> could come with was to do a query (in the DocumentApple), like:
>
> public class DocumentApple extends org.outerj.daisy.frontend.DocumentApple{
>
> ...
>
> QueryManager queryManager = repository.getQueryManager();
> SearchResultDocument results=queryManager.performQuery("select
> id,$ProfileButtonX where documentType='Photo'", Locale.getDefault());
> int numDocuments=results.getSearchResult().getRows().sizeOfRowArray();
To make it more efficient, use performQueryReturnKeys(). That way, the
select-part of the query will not need to be evaluated.
>
> viewData.put("numDocuments", numDocuments);
>
> Mark H
BTW, for this usecase you could also do (with Daisy 1.5):
select id where documentType = 'Photo' order by Random() limit 1
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno at outerthought.org bruno at apache.org
More information about the daisy
mailing list