iterator hasnext () retorna true mas next () lança NoSuchElementException

Quando depurei meu código, descobri quehasNext() método deIterator retornoutrue, mas onext() método lançou NoSuchElementException.

Abaixo está o meu código:

 Collection<TradeStock> restBuy=em.createQuery("select t from TradeStock ...t.getResultList();

if(!restBuy.isEmpty())
{
    Iterator itrest=restBuy.iterator();
    while(itrest.hasNext())
    {
        TradeStock ts=(TradeStock)itrest.next();
        x+=ts.getTradeExecutedQuantity();
    }
}

O que estou errado?

questionAnswers(2)

yourAnswerToTheQuestion