当需要将主查询的参数传递给子查询时可以加虚拟列映射
在sql 里 加上
case when (#{selectTagId} IS NULL) then NULL else #{selectTagId} end as selectTagId
<resultMap type="KlbDocument" id="KlbDocumentResult">
<id property="documentId" column="document_id" />
<result property="docName" column="doc_Name" />
<collection property="tags" javaType="java.util.ArrayList" ofType="KlbDocTag"
select="com.chinaunicom.system.mapper.base.KlbDocumentMapper.selectTagList" column="{documentId=document_id,selectTagId=selectTagId" />
<collection property="roles" javaType="java.util.ArrayList" ofType="KlbDocRole"
select="com.chinaunicom.system.mapper.base.KlbDocumentMapper.selectRoleList" column="{documentId=document_id" />
</resultMap>
SELECT d.*,case when (#{selectTagId} IS NULL) then NULL else #{selectTagId} end as selectTagId
from ........
版权声明:本文为qq_42034205原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。