<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.newfiber.modules.inspection.dao.InspectionDetectionEquDao"> <resultMap id="BaseResultMap" type="com.newfiber.modules.inspection.entity.InspectionDetectionEqu"> <id column="id" jdbcType="INTEGER" property="id"/> <result column="template_no" jdbcType="VARCHAR" property="templateNo"/> <result column="template_name" jdbcType="VARCHAR" property="templateName"/> <result column="equ_no" jdbcType="VARCHAR" property="equNo"/> <result column="equ_name" jdbcType="VARCHAR" property="equName"/> <result column="create_datetime" jdbcType="TIMESTAMP" property="createDatetime"/> <result column="item_count" jdbcType="INTEGER" property="itemCount"/> </resultMap> <select id = "selectWithItemCount" resultMap = "BaseResultMap" parameterType="com.newfiber.modules.inspection.entity.InspectionDetectionEqu"> select equ_no, equ_name , (select count(1) from equ_detection_item where equ_detection_item.equ_no = inspection_detection_equ.equ_no) as item_count from inspection_detection_equ where template_no = #{templateNo} </select> </mapper>