考虑下面两种不同的扣减库存的方案: 方案1: begin; // 扣减库存 update t_inventory set count=count-5 where id=${id} and count > t_user_account where user_id=123 for update; // 插入订单记录 insert into t_trans; // 扣减库存 update t_inventory set count=count int count = select count from t_inventory for update; if count >= 5: update t_inventory set count=count -5 where id =123 commit else rollback 方案2: begin: int rows = update t_inventory set count=count
R(3), "莫欺少年穷"); tm.put(new R(-5), "天下何人不识君"); tm.put(new R(9), "朋友一生一起走"); // {R[count