Spring事务

@Service
public class UserLoginLogService implements IUserLoginLogService{

    @Autowired
    private UserLoginLogMapper userLoginLogMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void saveLog(UserLoginLog entity) throws Exception{

        userLoginLogMapper.insertUserLoginLog(entity);

        int a = 1/0;

        entity.setNickname("回滚");

        userLoginLogMapper.insertUserLoginLog(entity);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void deleteLog(UserLoginLog log) {

    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public void findLog(UserLoginLog log) {

    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void updateLog(UserLoginLog log) {

    }
}

你可能感兴趣的:(java,面试宝典)