mybatis传向map参数,map中蕴藏list(输入变量)版权声明

原创
小哥 3年前 (2022-11-11) 阅读数 3 #大杂烩

1.xml中配置:





    
        and type=#{type}
    
    
        and level=#{level}
    
    
    
        and knowledgeType in
        
            #{knowledge}
        
    
    
        ORDER BY RAND() LIMIT #{num}
    

2.Java测试:

// 测试查询ID集合
@Test
public void test3() throws SQLException {
    Map condition = new HashMap();
    condition.put("type", "单选题");
    condition.put("level", 1);
    condition.put("num", 3);
    List konwledges = new ArrayList();
    konwledges.add("安全生产管理知识");
    konwledges.add("电力安全调节系统");
    condition.put("num", 3);
    condition.put("konwledges", konwledges);
    List IDs = questionsCustomMapper.getQuestionsIdsForExamPaper(condition);
    System.out.println(IDs.size());
}

结果:

总结:

map中的list像往常一样,仅在遍历时collection要写出map中的List键值的。这样的:

[当你用心写下每一篇博客后,你会发现它比你用代码来实现函数更充实。!】

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除