• mybatis 一对多分页查询数据条数不匹配解决


    mysql find_in_set

    原因

    在项目中,使用mybatis做一对多关联,出现数据条数不匹配的情况,比如要查询10条,由于一对多的关系导致最终得到的数据条数变少。

    解决方案(1)

    <select id="list" parameterType="emro.vo.resource.ResourceConfigDetailSearchVo" resultMap="resourceConfigDetails">
        SELECT
          detail.id id,
          detail.activity_name activityName,
          detail.main_title mainTitle,
          detail.main_title_spec mainTitleSpec,
          detail.sub_title subTitle,
          detail.desc_copy descCopy,
          detail.order_sn orderSn,
          detail.start_time startTime,
          detail.end_time endTime,
          detail.enable enable,
          detail.user_tag userTag,
          detail.pic_num picNum,
          detail.tag tag,
          detail.terminal_type terminalType,
          detail.pop_rate popRate,
          detail.status status,
          detail.create_name createName,
          detail.create_time createTime,
          detail.update_name updateName,
          detail.update_time updateTime,
          item.detail_id detailId,
          item.pc_image pcImage,
          item.pc_jump_url pcJumpUrl,
          item.background_color backgroundColor,
          item.mobile_image mobileImage,
          item.app_jump_url appJumpUrl,
          item.mp_jump_url mpJumpUrl
        FROM
        resource_config_detail detail
        LEFT JOIN resource_config_detail_item item ON detail.id = item.detail_id
        WHERE
        detail.id IN (IFNULL((SELECT temp.id
        FROM (SELECT config_detail.id FROM
        resource_config_detail config_detail
        where config_detail.status='1'
        <include refid="queryTerm"/>
        ORDER BY config_detail.order_sn DESC,config_detail.end_time DESC
        limit #{page},#{rows}) AS temp),''))
      </select>
    

    解决方案(二)

     <id property="id" column="id"/>
     
    <collection property="items"    ofType="com.test..domain.BookDetail"
                       column="id" select="com.test.dao.BookDetailDao.getCheckItemInfo"/>
    
  • 相关阅读:
    线上六个性能问题案例分享
    通达OA 前台任意用户登录漏洞复现
    CVE-2019-11043-Nginx PHP 远程代码执行
    CVE-2019-10758-Mongo-express-远程代码执行
    CVE-2017-7529-Nginx越界读取缓存漏洞
    add_header被覆盖 -配置错误
    目录穿越漏洞 -配置错误
    CRLF注入漏洞 -配置错误
    CVE-2019-12409-Apache Solr JMX服务远程代码执行
    CVE-2017-12149-JBoss 5.x/6.x 反序列化
  • 原文地址:https://www.cnblogs.com/liuyupen/p/14666550.html
Copyright © 2020-2023  润新知