问题一:在MyBatis中注解@Param和ParameterType不能一起用,会报错Parameter 'XXX' not found. Available parameters are [1, 0, param1, param2]

  错例:

public List<Role> findRole(@Param("pageParams") PageParams pageParams, String roleName);
<select id="findRole" parameterType="String" resultType="role">
select id,role_name as roleName,note from t_role
where role_name like concat('%',#{roleName},'%')
</select>

问题二:在MyBatis中,当传入参数为单参数(Integer,String等)时,if标签的test属性中,用参数名判断会报错There is no getter for property..参数为多参数(如POJO类或Map等)就不会有这种问题

  错例:

<select id="findRole" parameterType="String" resultType="role">
select id,role_name as roleName,note from t_role
<where>
<if test="roleName != null and roleName != ''">
role_name like concat('%',#{roleName},'%')
</if>
</where>
</select>

  改正方法:

  1. 在使用roleName时用_parameter代替。(这里有个内置参数问题:引用其他人的博客:mybatis中_parameter使用和常用sql
  2. 使用注解传参。

问题小记(MyBatis传参出现的小问题)的更多相关文章

  1. Mybatis传参方式

    Mybatis传多个参数(三种解决方案) 据我目前接触到的传多个参数的方案有三种. 第一种方案  DAO层的函数方法 ? 1 Public User selectUser(String name,St ...

  2. mybatis传参的几种方式

    1,@Param @参考文章 @Select("select s_id id,s_name name,class_id classid from student where  s_name= ...

  3. mybatis传参总结

    注:文章引用部分 mybatis传递参数总结文章内容 一.单个参数 1.基本数据类型 (1)直接使用 List<ChargeRuleDO> tests(long id); <sele ...

  4. Java Mybatis 传参方式

    一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...

  5. mybatis 传参是 list<string> 的注意事项

    <!--付款 批量 修改账单状态--><update id="editbillpayALL" parameterType="java.util.List ...

  6. mybatis传参问题总结

    一. 传入单个参数 当传入的是单个参数时,方法中的参数名和sql语句中参数名一致即可 List<User> getUser(int id); <select id="get ...

  7. php sql 类似 mybatis 传参

    PHP sql 处理上,没有类似于 java mybatis 的工具,导致进行一些sql 处理时,会有诸多不便, 楼主抽时间写了一个 php 类似 mybatis 的sql 工具,省去了拼装sql 的 ...

  8. Mybatis传参- 被逗号分割的字符串

    String ids = "1,2,3,4,5,6",如ids作为参数传递,查询list返回.mybatis用foreach处理并返回. SELECT * FROM yp_popu ...

  9. mybatis 传参为 Integer 时 ,Mapper 文件 中判断 条件 问题。

    <if test="valiStatus==null || valiStatus=='' || valiStatus==4 "> b.work_permit_card_ ...

随机推荐

  1. css3动画(animation)效果2-旋转的星球

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. react.js学习之路六

    学习react中,我一直认为,总组件里面才有构造函数,但是我才发现我的观点是错误的,构造函数是可以出现在子组件里面的. 今天有一个错误是点击增加/减少input框里面 的数值 我一直在寻找input框 ...

  3. php-fpm 操作命令

    以下内容转自 https://www.cnblogs.com/alibai/p/4070076.html 和 https://blog.csdn.net/wzx19840423/article/det ...

  4. 【CF453D】 Little Pony and Elements of Harmony(FWT)

    题面 传送门 设\(a\)的递推公式为 \[a_i=\sum_ja_jb[count(i\oplus j)]\] 其中\(\oplus\)为异或,\(count(i)\)表示\(i\)的二进制中\(1 ...

  5. MySQL直接导出CSV文件,并解决中文乱码的问题

    需求: 需要导出hr_users 表中的部分字段的数据,以前是用PHP写脚本,然后导出CSV文件. 在MySQL中,它自己就能导出CSV文件 ,只不过是有如下几个问题需要大家解决. 1. 生成文件不成 ...

  6. 2,ThreadGroup 概念以及用法

    当一个任务需要多个子线程去处理业务,这时候不希望这些子线程杂乱无章, 就需要把这些线程统一管理起来,这时候线程组就产生了. ThreadGroup  常用方法讲解 activeCount()   返回 ...

  7. centos7中使用Rsync和inotify同步文件

    一. 环境说明 由于web服务器所提供的网站数据需要保持一致,但当服务器越来越多时,这些主机之间同步网站数据会很麻烦. 解决方案是在后端建立一个数据发布服务器,该服务器作为rsync客户端,通过ino ...

  8. python学习,day3:集合的学习

    集合天生去重,另外集合非常便于两组数字的取交集,并集等计算 # coding=utf-8 # Author: RyAn Bi list_1 =[1,2,3,4,5,6,7] list_1 =set(l ...

  9. Angular material mat-icon 资源参考_Av

    ul,li>ol { margin-bottom: 0 } dt { font-weight: 700 } dd { margin: 0 1.5em 1.5em } img { height: ...

  10. 128th LeetCode Weekly Contest Pairs of Songs With Total Durations Divisible by 60

    In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of s ...