I’m implementing a search utility using the Tamino API, and I have some confusion about how to implement paging. I’m retrieving chunks of 20 at a time, but I’m doing it in a servlet, and I’m closing the database connection at the end of each request. How would I go about doing this, as I no longer have the TConnection available: will the TXMLObjectIterator do the right thing if I simply call its “next” method, or is there some other trick to this?
Thanks.
Sorry, if you close the connection, then the cursor is gone and the iterators are invalid.
Can’t you keep the objects alive from request to request. This would be the simplest solution. Everything else gets complicated.
I can preserve it, but there’s generally a performance hit for storing objects in the session. Is there any way to specify a query start point, as could be done in the HTTP API?
No there is no such thing via the API to query and get the cursor prepositioned in the result set.
However, what you can do is issue the query, get the iterator and move the iterator to the desired document. You do this with the iterator’s moveby() method. This will comunicate twice with the Tamino server, but the query is only executed once, because the Tamino Server keeps the result of the query as long as the connection is alive.