[Mybatis]Cannot convert string '\xAC\xED\x00\x05ur...' from binary to utf8mb3

1,478 阅读1分钟

在使用 Mybatis-Plus 的 Lambda 条件查询时,报出了这个 Cannot convert string '\xAC\xED\x00\x05ur...' from binary to utf8mb3 错误:

UpdateWrapper<ZhCustomer> wrapper = new UpdateWrapper<>();
wrapper.lambda().func(wr -> {
    if (customerCodes.contains("|")) {
        String[] codes = customerCodes.split("\|");
        // 这里不能根据IDE提示转为 (Object) codes
        wr.set(ZhCustomer::getCustomerStatus, status).in(ZhCustomer::getCustomerCode, codes);
    } else {
        wr.set(ZhCustomer::getCustomerStatus, status).eq(ZhCustomer::getCustomerCode, customerCodes);
    }
});

这里需要做一个根据 id 列表查询,但是 in 方法的可变参数类型是 Object,所以 IDEA 提示我把 String 强转为 Object,强转过后就出现了这个错误。后来我不做强转之后就不出现这个错误了。