当前位置: 代码迷 >> 综合 >> mybatis使用易错点
  详细解决方案

mybatis使用易错点

热度:91   发布时间:2023-09-20 11:37:47.0

1.<sql>片段中 if判断时同时判断null和空串<if test="statusCd !=null and statusCd !=''"></if>

模糊查询<if test="name !=null and name !=''">and name like concat('%',#{name},'%')</if>

判断的时候是==  不是=

mapper.java中传入对像的时候,对象中存入的数组时候,mapper.xml中取值时候通过数组名称取值,类似map通过key取值。

mybatis中mapper.xml中使用resultMap时必须添加type对应的实体bean,否则报错提示:需要属性type 并且必须为元素类型resultMap指定该属性

mapper.xml中传入为list时,保证list不为空,insert into table_name(fied_name) values     否则报错 you have an error in you sql syntax, use near ''

  相关解决方案