Hi,

I am having issues with my JCR_SQL2 query results.

        QueryManager qm = jcrSession.getWorkspace().getQueryManager();
        String sql = "select * from [jpg:category]";
        Query query = qm.createQuery(sql, Query.JCR_SQL2); 
        QueryResult queryResult = query.execute();
        NodeIterator nodeIterator = queryResult.getNodes();

        logger.debug(nodeIterator.getSize() + " orders found at path: " +
ordersNodePath);

        while (nodeIterator.hasNext())
        {
                nodeIterator.next();
        }

There are eight nodes of type jpg:category in my repository.  The query
executes and the nodeIterator is assigned.  The logger correctly prints the
size of the nodeIterator as 8.  At this point, before hasNext() / next() is
called, here is the state of some nodeIterator attributes:

nodeIterator.getPosition() == 4
nodeIterator.getSize() == 8
NodeIterator.hasNext() == true

After the first call to nodeIterator.hasNext(), here is the state of the
same attributes:

nodeIterator.getPosition() == 8
nodeIterator.getSize() == 8
NodeIterator.hasNext() == false

The first call to nodeIterator.next() results in a NoSuchElementException
being thrown and the while loop is exited.

Does anyone have any idea about this odd behaviour?

Thanks for your time and kind regards,

James
-- 
View this message in context: 
http://n4.nabble.com/Jackrabbit-2-0-JCR-SQL2-query-odd-NodeIterator-behaviour-tp1575371p1575371.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Reply via email to