Julian Reschke schrieb am 26.02.2018 um 10:13:
> On 2018-02-25 10:24, Ronald Appelfelder wrote:
>> ...
>> With variant 1 I get a compiler error:
>>
>> cannot find symbol
>> symbol: method getTotalSize()
>> location: variable result of type javax.jcr.query.QueryResult
>>
>> With variant 2 I get a runtime error:
>>
>> java.lang.ClassCastException: \
>> org.apache.jackrabbit.core.query.lucene.SingleColumnQueryResult \
>> cannot be cast to org.apache.jackrabbit.api.query.JackrabbitQueryResult
>>
>> I have also tried other casting variants, but all my attempts result in a
>> ClassCastException.
>>
>> Is there anyone out there who can enlighten me?
>> ...
> Well, SingleColumnQueryResult doesn't implement JackrabbitQueryResult - not
> sure
> why or whether it should.
Of course. How could I have miss that?
I was hoping that using JackrabbitQueryResult would be the fastest way to get
both, the total number of results (for pagination) and the dataset defined by
limit and offset with a single query.
> In general, you should not rely on extensions, so do something like
>
> if(x instanceof JackrabbitQueryResult) {
> y = ((JackrabbitQueryResult)x).getTotalSize();
> } else {
> // do something else
> }
Yes.
Thanks a lot.
Ronald Appelfelder