srvacbwilliams wrote:
results = query.iterate();
if (results == null)
log.debug("Found no results");
else
log.debug("Found something");
session.close();
Once again, this code doen't tell you there is no result to your request !
When using query.iterate(), an iterator is returned.
Code:
int nbr = 0;
while (results.hasNext()) {
results.next();
nbr++;
}
log.debug("Nb of result=" + nbr);
will do the work.
Be careful, iterate() doesn't load object until they are really used. If you manipulate results after session.close() it will fails.
And Once again, query.list() (same as session.find) is generally more appropriate.
Have a look at javadoc of session and query.