我在使用hibernate的批處理事務中使用session.clear()時收到以下錯誤。org.hibernate.HibernateException:在Hibernate搜索中進行索引時出錯(事務完成前)
org.hibernate.HibernateException: Error while indexing in Hibernate Search (before transaction completion)
我用下面的代碼
try {
for (TimeSheetEntity timeSheet : timeSheets) {
timeSheet.setActive(false);
try {
session.update(timeSheet);
count++;
if (count % 250 == 0 || totalCount == count) {
System.out.println(count);
session.flush();
session.clear();
}
} catch (HibernateException ex) {
logger.error(ArchiveImpl.class.getName(), ExceptionUtils.getStackTrace(ex) + "[" + timeSheet.getId() + "] ");
} catch (Exception ex) {
logger.error(ArchiveImpl.class.getName(), ExceptionUtils.getStackTrace(ex) + "[" + timeSheet.getId() + "] ");
}
}
sessionManager.commit();
} catch (HibernateException ex) {
System.out.println(ex);
logger.error(ArchiveImpl.class.getName(), ExceptionUtils.getStackTrace(ex));
sessionManager.abort();
} finally {
}
現在,如果我刪除session.clear();一切工作,因爲它假設。任何想法,爲什麼我不能在我的批處理事務中使用hibernate搜索清除?
準確地說,我正在尋找的答案,非常感謝。 – 2015-03-03 13:30:00