Mybatis批量查询(一)

为了提高代码的执行效率,我们有时需要采用批量查询的查询方法

批量查询之传入参数–数组

mybatis配置如下:

<select id="queryModelInfoAuditMattersByCode" resultMap="baseMap">
    SELECT "Base_Column_List"/> FROM `ldp_info_trade` WHERE `code` in 
    "array" item="item" open="(" separator="," close=")">
        #{item}
    
  select>

mapper配置如下:

public List queryModelInfoAuditMattersByCode(String[] auditMatterCode);

批量查询之传入参数–集合

mybatis配置如下:

<select id="queryModelInfoAuditMattersByCode" resultMap="baseMap" parameterType="java.util.List">
    SELECT "Base_Column_List"/> FROM `ldp_info_trade` WHERE `code` in 
    "list" item="item" open="(" separator="," close=")">
        #{item}
    
  select>

mapper配置如下:

public List<ModelInfo> queryModelInfoAuditMattersByCode(List<String> codeList);

你可能感兴趣的:(Database)