1.mapper.xml可以直接 使用map集合,

  parameterType="java.util.Map"
  resultType="java.util.Map"  

2.mapper.xml的注释必须是 <!--  -->   其他注释将无法识别,sql操作就会发生错误

3. mybatis 映射文件中,if标签判断字符串相等

正确方式:

 1.

  <if test="sex=='Y'.toString()">

    and 1=1 

  </if>

 2.

  <if test = 'sex== "Y"'>

    and 1=1 

  </if>

错误方式:

  <if test="sex=='Y'">

    and 1=1

  </if>

 

注意:因为mybatis会把'Y'解析为字符,java是强类型语言,所以不能这样写。

 

4. #{name} 获取集合中的值的时候需要指定类型;如果是对象入参,就不需要指定类型

  #{endDate,jdbcType=VARCHAR}

 

相关文章:

  • 2021-06-17
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
猜你喜欢
  • 2019-01-06
  • 2021-08-06
  • 2021-07-23
  • 2021-12-03
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案