项目场景:
mybatis的association标签传多个参数,(传递自定义参数)
这里使用association传递参数 column=”{bankId=id,type=type}”中可以写多个参数
这里的id type是来自于数据库的查询的
题库中需要统计选择题,判断题,多选题的数量
我们需要自定义type类型 这时候发现直接写是不识别的 因为column中的参数来自select id ,type form table这样的
getCount(bankId,type) // 统计题目的数量
<association property="radioCount" javaType="Integer"
column="{bankId=id,type=1}"
select="com.exam.mapper.QuestionMapper.getCount" />
解决方案:
我们可以直接从column中写一个type1 select哪里加上一个type1 这样就可以自定义参数了
select id , 1 type1 form table
<association property="radioCount" javaType="Integer"
column="{bankId=id,type=type1}"
select="com.exam.mapper.QuestionMapper.getCount" />
版权声明:本文为xc979906570原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。