Mybatis的参数parameterType的类型

接口名称


List<Info> findListByNos(List<String> nos);
Info findById(String id);
List<Info> findByEntityWithPagination(Info info, int offset, int count);//分页(第一个是对象,第二个是pageNo,第三个是pageSize)
List<Info> findByMap(Map<String, Object> map);
List<Link> findByEntity(Info info);

xml配置


     <select id="findListByNos" parameterType="list" resultMap="BaseResultMap">
        SELECT 
   		 <include refid="Base_Column_List"/>
   		 FROM INFO
    		WHERE INFO_ID IN
    		<foreach collection="list" index="index" item="item" open="(" close=")" separator=",">
        			#{item}
   		 </foreach>
    		ORDER BY INFO_ID DESC
   	</select>

  <select id="findById" resultMap="BaseResultMap" parameterType="java.lang.String" >
    SELECT 
    <include refid="Base_Column_List" />
     FROM INFO
     WHERE INFO_ID = #{infoId,jdbcType=VARCHAR}
  </select>
 
<select id="findByEntityWithPagination" resultMap="BaseResultMap" >
 SELECT
    <include refid="Base_Column_List" />
    FROM INFO
    <trim prefix="WHERE" suffixOverrides="AND" >
      <if test="param1.infoType != null" >
        INFO_TYPE = #{param1.infoType,jdbcType=VARCHAR} AND
      </if>
      <if test="param1.infoContent != null" >
        INFO_CONTENT = #{param1.infoContent,jdbcType=LONGVARCHAR} AND
      </if>  
    </trim>
     LIMIT #{param2} , #{param3}
  </select>

<select id="findByProperties" parameterType="map" resultMap="BaseResultMap" >
    SELECT 
    <include refid="Base_Column_List" />
    FROM INFO
    <trim prefix="WHERE" suffixOverrides="AND" >
      <if test="_parameter.containsKey('infoType')" >
        INFO_TYPE = #{infoType,jdbcType=VARCHAR} AND
      </if>
      <if test="_parameter.containsKey('infoContent')" >
        INFO_CONTENT = #{infoContent,jdbcType=LONGVARCHAR} AND
      </if>
      <if test="_parameter.containsKey('infoName')" >
        INFO_NAME = #{infoName,jdbcType=VARCHAR} AND
      </if>
    </trim>
    ORDER BY INFO_ID
  </select>
   
   <select id="findByEntity" resultMap="BaseResultMap" parameterType="com.cn.Info" >
    SELECT
    <include refid="Base_Column_List" />
    FROM INFO
    <trim prefix="WHERE" suffixOverrides="AND" >
      <if test="infoType != null" >
        INFO_TYPE = #{infoType,jdbcType=VARCHAR} AND
      </if>
      <if test="infoContent != null" >
        INFO_CONTENT = #{infoContent,jdbcType=LONGVARCHAR} AND
      </if>
    </trim>
  </select>


  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值