The first time I wrote a blog, I wrote down the pits I encountered first. I will continue to improve it later.
collection association query
<resultMap id="resultTestMap" type="resultTest"> <id property="resulttestid" column="resulttestid"/> <result property="knr" column="knr"/> <result property="vin" column="vin"/> <result property="cartype" column="cartype"/> <result property="system" column="system"/> <result property="sysnr" column="sysnr"/> <result property="releasenr" column="releasenr"/> <result property="testplace" column="testplace"/> <result property="asvversion" column="asvversion"/> <result property="odxversion" column="odxversion"/> <result property="result" column="result"/> <result property="testorder" column="testorder"/> <result property="shift" column="shift"/> <result property="testtimestamp" column="testtimestamp"/> <result property="recordtime" column="recordtime"/> <collection property="ptbList" ofType="ptb" column="resulttestid" select="selectPtb"/> </resultMap> <resultMap id="ptbMap" type="ptb"> <result property="ptbno" column="ptbno"/> <result property="ptbtext" column="ptbtext"/> <result property="result" column="result"/> <result property="ptbid" column="ptbid"/> <result property="resulttestid" column="resulttestid"/> </resultMap> <select id="selectPtb" parameterType="java.lang.Integer" resultMap="ptbMap"> SELECT ptbno FROM ptb WHERE resulttestid = #{resulttestid} </select> <select id="selectResultDetail" resultMap="resultTestMap"> SELECT releasenr, cartype, system, sysnr, testplace, result, shift, wine, testtimestamp, resulttestid FROM result_test WHERE knr = '2727791' AND resulttestid = '1' </select> Before the ptbList has been unable to get the value, it took a long time to get it right. I found that there is no problem with the writing method when I checked the information on the Internet. Later, I found that the resulttestid must be queried in selectResultDetail, so that the value can be passed.