在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. python(6)时间戳和北京时间互转,输出当前的时间和推到七天前的日期

    项目发展的需要:(包含时间函数)time datetime 时间戳和北京时间互转 import time import datetime s = '2015-04-17 11:25:30' d = d ...

  2. 微信支付开发若干问题总结,API搞死人(谢谢ζั͡ޓއއއ๓http://www.thinkphp.cn/code/1620.html)血淋淋的教训,第二次栽这里了

    近日,我研究了微信支付的API,我是用简化版的API,首先简述一下流程: 1.通过APP_ID,APP_SCRECT获取网页授权码code, 2.利用code获取用户openid/userinfo 3 ...

  3. Windows 32 程序设计

    C语言版 开发语言:C语言 开发工具:Visual Studio 2015 目      标:使用C语言,直接调用Windows API,创建Windows程序. 参考图书:<Windows程序 ...

  4. addSubView需要注意的几个点

    addSubview: Adds a view to the end of the receiver’s list of subviews. 译:增加一个视图到接收者的子视图列表中. - (void) ...

  5. [Java] 过滤流BufferedInputStream和BufferedOutputStream

    package test.stream; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import ...

  6. [ActionScript 3.0] AS3 绘制正四面体(线条)

    package { import flash.display.MovieClip; import flash.display.Sprite; import flash.events.Event; im ...

  7. 防止重复发送 Ajax 请求

    作者:长天之云链接:http://www.zhihu.com/question/19805411/answer/15465427来源:知乎 不推荐用外部变量锁定或修改按钮状态的方式,因为那样比较难: ...

  8. 【Python】迭代器、生成器、yield单线程异步并发实现详解

    转自http://blog.itpub.net/29018063/viewspace-2079767 大家在学习python开发时可能经常对迭代器.生成器.yield关键字用法有所疑惑,在这篇文章将从 ...

  9. Node.js异常处理

    var log4js = require('log4js'); log4js.configure({ appenders: [ { type: 'console' }, { type: 'file', ...

  10. Hive分布式的数据仓库

    1.hive介绍 hive是一个数据仓库的解决方案,它的数据存储依赖于HDFS,数据结算依赖于MR,也就是说,hive就是一个在数据仓库的服务,它只需要安装到一台普通的PC上即可,仅仅对外提供SQL服 ...