MyBatis框架中的select

select中查询一条数据,和查询多条数据

查询一条的方法值限于查询一条,但是查询多条的方法既可以查询多条,也可以查询一条。

查询一条:

Article a = (Article) session.selectOne("aa.bb.cc.findById", 75)

查询一条或多条如果后面输入多个参数,则将参数放到集合里

Map<String, Integer> m = new HashMap<String, Integer>();
        m.put("offset",0);
        m.put("pagesize", 10);
        List<Article> a = (List<Article>)session.selectList("aa.bb.cc.list",m );
        
        Iterator<Article> it = a.iterator();
        while(it.hasNext()){
            Article aa = it.next();
            System.out.println(aa.getAsource()+" "+aa.getContent()+" "+aa.getId());
        }

猜你喜欢

转载自blog.csdn.net/zxl1148377834/article/details/81872637