当前位置:首页 > 开发 > 编程语言 > mybatis,Ibatis > 正文

ibatis模糊查询sqlmap-mapping-**.xml配置

发表于: 2013-08-13   作者:bijian1013   来源:转载   浏览:
摘要:         正常我们写ibatis的sqlmap-mapping-*.xml文件时,传入的参数都用##标识,如下所示: <resultMap id="personInfo" class="com.bijian.study.dto.PersonDTO"> <res

        正常我们写ibatis的sqlmap-mapping-*.xml文件时,传入的参数都用##标识,如下所示:

<resultMap id="personInfo" class="com.bijian.study.dto.PersonDTO">
	<result property="name" column="person_name"></result>
	<result property="age" column="person_age"></result>
	<result property="sex" column="person_sex"></result>
</resultMap>
<select id="getPersonListByCodeAndName" parameterClass="java.util.Map" resultMap="personInfo">
      SELECT 
	person_name,
     	person_age,
     	person_sex
      FROM person_info
      WHERE person_code = #personCode#
      <isNotEmpty prepend="AND" property="personName">  
  	person_name = #personName#
      </isNotEmpty>
</select>

         但对于like,就不能用##,需用$$。如下所示:

<resultMap id="personInfo" class="com.bijian.study.dto.PersonDTO">
	<result property="name" column="person_name"></result>
	<result property="age" column="person_age"></result>
	<result property="sex" column="person_sex"></result>
</resultMap>
<select id="getPersonListByName" parameterClass="java.lang.String" resultMap="personInfo">
      SELECT 
		person_name,
     		person_age,
     		person_sex
      FROM person_info
      WHERE person_name like '%$brandName$%'
</select>

 

ibatis模糊查询sqlmap-mapping-**.xml配置

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号