mybatis9大练习

mybatis9大练习
文章图片

mybatis9大练习
文章图片



【mybatis9大练习】 mybatis9大练习
文章图片




mybatis9大练习
文章图片




mybatis9大练习
文章图片




mybatis9大练习
文章图片




mybatis9大练习
文章图片






mybatis9大练习
文章图片




mybatis9大练习
文章图片






------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
测试方法有改动!
可借鉴!

@Test //多条件查询方法测试 public void testa(){ SqlSession session = MyBatisUtil.getSession(); StudentInfoDao dao = session.getMapper(StudentInfoDao.class); Map map=new HashMap(); map.put("stuName","z"); map.put("stuAge",20); List list = dao.selectStudentDTJ(map); for (StudentInfo stu:list) { System.out.println(stu.getStuName()); } session.close(); } @Test public void DTJA(){ SqlSession session = MyBatisUtil.getSession(); StudentInfoDao dao = session.getMapper(StudentInfoDao.class); List z = dao.selectStudentDTJA("z", 20); for (StudentInfo info:z) { System.out.println(info.getStuName()); } session.close(); } @Test publicvoid ZN(){ SqlSession session = MyBatisUtil.getSession(); StudentInfoDao dao = session.getMapper(StudentInfoDao.class); StudentInfostu=new StudentInfo(); //stu.setStuName("z"); //stu.setStuAge(20); List list = dao.selectStudentZN(stu); for (StudentInfo s:list) { System.out.println(s.getStuName()); } session.close(); }@Test publicvoid ZN1(){ SqlSession session = MyBatisUtil.getSession(); StudentInfoDao dao = session.getMapper(StudentInfoDao.class); StudentInfostu=new StudentInfo(); stu.setStuName("z"); stu.setStuAge(20); List list = dao.selectStudentZN1(stu); for (StudentInfo s:list) { System.out.println(s.getStuName()); } session.close(); }@Test publicvoid ZNfor(){ SqlSession session = MyBatisUtil.getSession(); StudentInfoDao dao = session.getMapper(StudentInfoDao.class); int [] in={1,5}; List list = dao.selectStudentZNFOR(in); for (StudentInfo s:list) { System.out.println(s.getStuName()); } session.close(); }

    推荐阅读