public void takeOrder(String currentUser){ String sql = "select * from customer where take_status is null limit 30"; List<Customer> customerList = customerDao.findUnTakeCustomer(sql); for(Customer cust : customerList){ if(cust.getEntryId > 3){ cust.setTakeStatus(1); update(cust); Sd sd = new Sd(); sd.setUser(currentUser); sd.setCust(cust); sd.setTakeTime(new Date()); sdDao.save(sd); } }}如上例代码,两个用户同时操作,查询出来的customerList可能包含相同的记录,下边遍历,根据entryId的值,进行更新和插入操作。这样就会出现两个用户重复更新一个customer,并且插入到SD表中两条记录。如何避免这种重复的操作?
添加回答
举报
0/150
提交
取消