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