• Mybatis多条件查询


    在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>  

  • 相关阅读:
    ZH奶酪:PHP 使用DOMDocument抓取网页
    PHP Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity,
    ZH奶酪:PHP 执行时间Fatal error: Maximum execution time of...
    ZH奶酪:PHP (爬虫)下载图片
    ZH奶酪:PHP的cURL库
    PHP 字符串编码的转换
    PHP http_build_query()方法
    ZH奶酪:使用PHP调用REST API
    PHP全局变量
    HTML页面跳转的5种方式
  • 原文地址:https://www.cnblogs.com/lhfyy/p/4047557.html
Copyright © 2020-2023  润新知