0
我想自己控制hibernate事務,所以我可以在任何時候回滾。我調用一個線程來做生意,但沒有等待它完成工作並更新數據庫。此更新僅在方法結束時可用,但我想在每個for循環中提交更改,因此我需要控制hibernate事務。用戶休眠的春天用戶交易
我的示例代碼如下:
for(BaseFileprocess fileProcess : unprocessedFiles) {
BaseFileprocessfunctype functionType = fileProcessFunctionTypeService.findBySerno(fileProcess.getFunctioncodeserno());
if(functionType != null) {
taskExecutor.execute(new ServiceCallThread(functionType.getFunctionname(), fileProcess.getSerno(), fileProcess.getFilename()));
fileProcess.setStatu("1");
fileProcessService.update(fileProcess);//I need commit here
}
else {
System.out.println("There is no defined Function Type");
}
}
什麼建議嗎?
這段代碼並不真正有趣,我們需要看看冬眠工作的位。 – skaffman 2009-07-22 07:51:43