在Mybatis多条件查询中:

1.参数如果是多条件,则需要将将添加到Map集合中进行传入。

2.就是将其参数用有序数字进行代替。

Mybatis单个String类型参数传递

mysql文如下,传入参数为‘parentCategoryId’,运行报错为:There is no getter for property named 'parentCategoryId' in 'class java.lang.String

<select id="selectCategoryList"  parameterType="java.lang.String" resultType="MstCategoryBean">

SELECT         category_id             AS  categoryId,          category_name           AS  categoryName,          view_orderby            AS  viewOrderby      FROM          mst_category      WHERE          del_flg =0      <if test="parentCategoryId!=null  and parentCategoryId!=''">      and          parent_category_id = #{parentCategoryId}      </if>  </select>

发现不能将参数设为bean里的名称,如果传入类型为String类型,则参数需统一修改为[_parameter],修改后的sql语句如下(不管你的参数是什么,都要改成"_parameter"

<select id="selectCategoryList" parametertype="java.lang.String" resulttype="MstCategoryBean">

SELECT              category_id             AS  categoryId,              category_name           AS  categoryName,              view_orderby            AS  viewOrderby          FROM              mst_category          WHERE              del_flg =0                    and             parent_category_id = #{_parameter}

</select>

Mybatis多条件查询的更多相关文章

  1. mybatis 按照条件查询

    mybatis 按照条件查询 @Autowired private StudentMapper studentMapper; @Override public Map getStudentList(i ...

  2. MyBatis参数条件查询传入的值为0时的判断

    MyBatis条件查询对字段判断是否为空一般为: <if test="testValue!=null and testValue != ''"> and test_va ...

  3. SSM整合 mybatis多条件查询与分页

    多条件查询与分页: 通过页面的houseName.floorage获取值传到前端视图(HouseSearchVO)实体类中的houseName,floorage建立houseSearchVO对象. 通 ...

  4. Mybatis实现条件查询(三)

    1. 准备 请先完成Mybatis基本配置(一)的基本内容 2. 疑问 我们再Mybatis基本配置(一)中实现了按照商品ID进行查询商品信息,可是在实际应用中却很少出现根据ID来查询商品的情况.因为 ...

  5. mybatis if条件查询 及<号的问题

    摘录自:http://flt95.blog.163.com/blog/static/12736128920136185841551/ <if test="p=='1'"> ...

  6. mybatis中条件查询大于等于和小于等于写法

    原符号 < <= > >= & ' "替换符号 < <= > >= & &apos; " createDat ...

  7. SSM-MyBatis-13:Mybatis中多条件查询

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 实体类 public class Book { private Integer bookID; private ...

  8. mybatis按datetime条件查询,参数为时间戳时

    mybatis按datetime条件查询,参数为时间戳时,如果数据库为2018-1-1 20:22:10, 你的时间戳也为2018-1-1 20:22:10,但却没找到数据.可能是时差导致的.百度修正 ...

  9. Mybatis中动态SQL多条件查询

    Mybatis中动态SQL多条件查询 mybatis中用于实现动态SQL的元素有: if:用if实现条件的选择,用于定义where的字句的条件. choose(when otherwise)相当于Ja ...

随机推荐

  1. linux 标准输入输出

    文件描述符是一个简单的正整数,用以标明每一个被进程所打开的文件和socket.最前面的三个文件描述符(0,1,2)分别与标准输入(stdin),标准输出(stdout)和标准错误(stderr)对应 ...

  2. CSS媒体查询,CSS根据不同的分辨率显示不同的样式

    在写自适应网页的时候,我们需要网页有几种显示方式,我们可以用CSS实现这个功能 使用CSS提供的媒体查询,我们可以根据屏幕分辨率来使用相应的CSS样式 @media screen and (max-w ...

  3. JavaScript表单验证实例

    1. 长度限制<script>function test(){if(document.a.b.value.length>50){alert("不能超过50个字符!" ...

  4. MySQL作业

    创建作业事件 MONTH STARTS '2015-01-01 05:30:01' ON COMPLETION NOT PRESERVE ENABLE DO CALL sp_moveLoginReco ...

  5. 原始ajax发起请求并反馈

    在用户登陆的时候,离开用户.密码输入框即进行验证:ajax发起请求进行验证的: login.jsp代码: <%@ page language="java" contentTy ...

  6. mysql 增加用户

    mysql 增加用户 3.增加用户: (注意:和上面不同,下面的因为是MYSQL环境中的命令,所以后面都带一个分号作为命令结束符) 格式:grant select on 数据库.* to 用户名@登录 ...

  7. C开源hash项目uthash

    uthash 是C的比较优秀的开源代码,它实现了常见的hash操作函数,例如查找.插入.删除等.该套开源代码采用宏的方式实现hash函数的相关功能,支持C语言的任意数据结构最为key值,甚至可以采用多 ...

  8. ajaxSubmit中option的参数

    var options = { target: '#output1', // target element(s) to be updated with server response beforeSu ...

  9. js替换字符串中全部“-”

    alert("2014-03-22".replace('-','')); alert("2014-03-22".replace(/-/g,'')); 第一个运行 ...

  10. [SQL]向3个表插入数据的存储过程 和 C# 代码

    public int UpdateQty(string strPartID, int iQty, int iUpdateQty, string strBarCode, string strCreate ...