Iter.get() giving null

Friday, 6 February 2015 · 4 messages
AK
ankit kumar6 Feb 2015 13:50 #
Hi, I am trying to execute a query in java and trying to fetch the result set using Iter Object. But Iterating through the result set return "null", but when i am executing the same query and getting Result object i am able to see the result set. Why this is happen. Please Help Me.
QueryProcessor pr = new QueryProcessor("let $a := /data/product/*  return
$a ",context);
pr.context(dataset);
Now I am taking Iter object as: Iter itr=pr.iter(); Now, executing itr.get(0) gives me "null", but when i execute it as Result rs = pr.execute() Sytem.out.println("Products ::" + rs) ... it shows the fetch products. But, also itr.next().serialise() also gives me the result.
CG
Christian Grün6 Feb 2015 13:53 #
Quoted text · ankit kumar · 2 lines
> Iter itr=pr.iter(); > Now, executing itr.get(0) gives me "null"
pr.iter().next(); should work.
CG
Christian Grün6 Feb 2015 13:55 #
PS: For more information, please read JavaDoc [1]. It tells: "Returns the specified item, or an arbitrary item if the index is invalid. This method needs to be implemented - and should only be called - if {@link Iter#size()} returns the correct number of results." [1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/iter/Iter.java
Quoted text · Christian Grün · 6 lines
On Fri, Feb 6, 2015 at 1:53 PM, Christian Grün <christian.gruen at gmail.com> wrote: >> Iter itr=pr.iter(); >> Now, executing itr.get(0) gives me "null" > > pr.iter().next(); should work.
AK
ankit kumar6 Feb 2015 14:12 #
Thanks for your prompt reply. It is very helpful.
Quoted text · Christian Grün · 19 lines
On 6 February 2015 at 18:25, Christian Grün <christian.gruen at gmail.com> wrote: > PS: For more information, please read JavaDoc [1]. It tells: "Returns > the specified item, or an arbitrary item if the index is invalid. This > method needs to be implemented - and should only be called - if {@link > Iter#size()} returns the correct number of results." > > [1] > https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/iter/Iter.java > > > > On Fri, Feb 6, 2015 at 1:53 PM, Christian Grün > <christian.gruen at gmail.com> wrote: > >> Iter itr=pr.iter(); > >> Now, executing itr.get(0) gives me "null" > > > > pr.iter().next(); should work. >

⚡Generated with XQuery