List<Product> products = productService.getProductListWithPage(productQuery);
今天碰到一个很奇怪的现象,上面的代码查出的信息和数据库中的数据有偏差,查了半天才发现是一个细节写错了
下面是错误的写法
<select id="getProductListWithPage" parameterType="cn.itcast.core.query.product.ProductQuery" resultType="product">

正确的写法

<select id="getProductListWithPage" parameterType="cn.itcast.core.query.product.ProductQuery" resultMap="product">

resultMap没注意写成了resultType,导致数据匹配出现了异常

resultMap=“product”对应下面的配置

<resultMap id="product" type="cn.itcast.core.bean.product.Product">

<result property="id" column="id" />

<result property="no" column="no" />

<result property="name" column="name" />

<result property="weight" column="weight" />

//其余省略

</resultMap>

相关文章:

  • 2021-05-23
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2021-07-25
  • 2022-02-26
猜你喜欢
  • 2021-07-12
  • 2021-07-31
  • 2021-12-14
  • 2021-07-11
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案