报错信息:

    1. 021-07-29 16:58:51.245 ERROR 22640 --- [nio-8080-exec-3] c.m.t.c.handler.GlobalExceptionHandler : exception:
    2. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
    3. ### Error querying database. Cause: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    4. ### The error may exist in com/mori/template/dao/mapper/OrdersMapper.java (best guess)
    5. ### The error may involve com.mori.template.dao.mapper.OrdersMapper.selectOne
    6. ### The error occurred while handling results
    7. ### SQL: SELECT order_number FROM orders WHERE deleted=0 AND (order_id = ?)
    8. ### Cause: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

    调用信息:

    1. Orders order = ordersMapper.selectOne(
    2. Wrappers.<Orders>lambdaQuery()
    3. .select(Orders::getOrderNumber)
    4. .eq(Orders::getOrderId, id));

    仅仅是使用了最简单的selectOne都会报错

    原因:
    实体类只使用了@Builder注解,@Builder注解使用后我们必须显示的声明构造方法,或者使用@AllArgsConstructor @NoArgsConstructor来声明构造。
    这个异常正式因为使用MP和lombok不当造成的,mybatis找不到构造方法,无法将查询结果绑定到实体对象上~