在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. [Tex学习]给汉字注音

    \documentclass{article} \usepackage[CJK]{ruby} \usepackage{pinyin} \begin{document} \begin{CJK*}{GBK ...

  2. apache重写规则自动追加查询参数QSA

    看好多大网站上的搜索都是以.html?keyword=手机&page=abc这个样子表现, 如: search_goods.html?q=%BF%D5%C6%F8%BE%BB%BB%AF%C6 ...

  3. 不能向Github提交某一類型的文件

    之前在github上建了6個project,但是其中有一個不能提交jar文件,其他的都可以.後來發現原來在項目中有一個叫.gitignore的文件,其他項目里的都是/bin,但是那個不能提交jar的項 ...

  4. 轻量级的.Net ORM框架介绍

    轻量型 ORM 组件 FluentData 官网https://fluentdata.codeplex.com/ http://www.cnblogs.com/babietongtianta/p/43 ...

  5. linux下安装nginx、pcre、zlib、openssl

    1.安装nginx之前需要安装PCRE库的安装  最新下载地址   ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ tar –zxvf p ...

  6. .net中三种数据类型转换区别((int),Int32.Parse() 和 Convert.toInt32() )

    (typename)valuename,是通用方法: Convert类提供了灵活的类型转换封装: Parse方法,适用于向数字类型的转换. 例如,(int),Int32.Parse() 和 Conve ...

  7. (转) C# textbox 限制输入问题

    原理:e.handled代表这次按键动作是否交由用户自己处理,如果为true代表由用户处理,系统不再过问,这里的应用是拦截,即通知系统我要处理这个数据,但又不处理(丢弃数据),从而实现拦截的效果. 在 ...

  8. image onclick

    onclick="this.src+='?rand='+Math.random();"  style="cursor: pointer; vertical-align: ...

  9. js压缩反压缩

    JavaScript unpacker and beautifier JavaScript Beautifier http://prettydiff.com/?m=beautify&s=htt ...

  10. Spring定时任务配置

    可参照http://gong1208.iteye.com/blog/1773177 的详细配置 <!-- 系统定时任务工厂类 --> <bean id="systemDes ...