我想在下面的代码片段本地化错误:org.hibernate.ObjectNotFoundException在查询迭代
Query bookLogs = session.createQuery("FROM BookLog log");
for (Iterator it = bookLogs.iterate(); it.hasNext();) {
BookLog bookLog = (BookLog) it.next();
bookNo = bookLog.getNo();
...
session.delete(bookLog);
session.flush();
}
以下异常在bookLog.getNo很少发生():
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [de.store.Books.BookLog#2343]
我想在删除数据库条目时会发生冲突,而迭代器不会通过调用它来调整它.remove()。
BookLog没有引用任何表格,其映射也相应简单。
为什么你要投入迭代器对象来预订?相反,您可以尝试BookLog bookLog =(BookLog)it.next(); – Ramesh 2015-04-01 12:27:15
抱歉,小错字。 – user3639982 2015-04-01 13:02:27
是否因为你试图去除那些不在那里的东西?我想它会返回NULL – ha9u63ar 2015-04-01 13:07:49