jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gadbury <gadb...@googlemail.com>
Subject Jackrabbit 2.0 JCR SQL2 query - odd NodeIterator behaviour
Date Tue, 02 Mar 2010 17:31:17 GMT


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: " +

	while (nodeIterator.hasNext())

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,

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.

View raw message