南沙建设网站,网上帮人做网站,环保设备网站怎么做,敏感网站用什么浏览器业务代码的方式 (实现的方式#xff0c;书写业务逻辑的java代码实现) ------查询学生所在班级的信息 #xff08;一对一查询#xff09; 1、先把所有学生查询出来#xff08;clazzno#xff09; select* from student 2、拿着clazzno去clazz表中查询班级的信息 select * f…业务代码的方式 (实现的方式书写业务逻辑的java代码实现) ------查询学生所在班级的信息 一对一查询 1、先把所有学生查询出来clazzno select* from student 2、拿着clazzno去clazz表中查询班级的信息 select * from clazz where cno? ------查询班级中所有学生的信息一对多查询 1、查询所有班级的信息clazzno Select * from clazz 2、查询指定班级中的所有学生—List Select * from student where clazzno? 特点 班级和学生之间的关系全部是靠我们书写java业务逻辑代码的方式实现的 最后执行完成SQL语句都执行了N1次数据的查询
接口 ClazzMapper.java
public interface ClazzMapper {//查询指定学生所在班级的信息Clazz selectOne(int clazzno);//查询所有班级信息ListClazz selectAll();
}StudentMapper.java
public interface StudentMapper {//查询所有学生的操作ListStudent selectAll();ListStudent selectMore(int clazzno);
}XML ClazzMapper.xml select idselectOne resultTypeclazzSELECT * from clazz where clazzno#{param1}/selectselect idselectAll resultTypeclazzSELECT * from clazz/selectStudentMappe.xml
select idselectAll resultTypestudentSELECT * from student/selectselect idselectMore resultTypestudentSELECT * from student where clazzno#{param1}/select测试
//查询所有学生所在的班级的信息/* //[A]查询所有学生--clazznoListStudent list stuMapper.selectAll();//[B]拿着clazzno去班级表中查询班级的信息for(Student stu:list){//每一个学生所在班级的编号Integer clazzno stu.getClazzno();Clazz clazz claMapper.selectOne(clazzno);stu.setCla(clazz);System.out.println(stu);}*///查询所有班级中学生的信息//[A]查询所有班级的信息ListClazz claList claMapper.selectAll();//[B]查询班级中对应的学生的信息for(Clazz cla:claList){//班级编号Integer clazzno cla.getClazzno();//指定班级中所有学生的集合ListStudent list stuMapper.selectMore(clazzno);cla.setLi(list);System.out.println(cla);}