• Dao模式多表联查


    一、查询所有学生记录,包含年级名称

    1.创建实体学生类封装属性

    public class IStudent {

      IGrade grade=new IGrade();


    public IGrade getGrade() {
      return grade;
    }

    public void setGrade(IGrade grade) {
      this.grade = grade;
    }


    private int StudentNo;
    private String loginPwd;
    private String StudentName;
    private int Sex;
    private int GradeId;
    private String phone;
    private String BornDate;
    private String email;
    private String IdentityCard;
    private String address;


    public String getAddress() {
      return address;
    }

    public void setAddress(String address) {
      this.address = address;
    }

    public int getStudentNo() {
      return StudentNo;
    }

    public void setStudentNo(int studentNo) {
      StudentNo = studentNo;
    }
    public String getLoginPwd() {
      return loginPwd;
    }
    public void setLoginPwd(String loginPwd) {
      this.loginPwd = loginPwd;
    }
    public String getStudentName() {
      return StudentName;
    }
    public void setStudentName(String studentName) {
      StudentName = studentName;
    }
    public int getSex() {
      return Sex;
    }
    public void setSex(int sex) {
    Sex = sex;
    }
    public int getGradeId() {
      return GradeId;
    }
    public void setGradeId(int gradeId) {
      GradeId = gradeId;
    }
    public String getPhone() {
      return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public String getBornDate() {
      return BornDate;
    }
    public void setBornDate(String bornDate) {
      BornDate = bornDate;
    }
    public String getEmail() {
      return email;
    }
    public void setEmail(String email) {
      this.email = email;
    }
    public String getIdentityCard() {
      return IdentityCard;
    }
    public void setIdentityCard(String identityCard) {
      IdentityCard = identityCard;
    }



    public IStudent(int studentNo, String loginPwd, String studentName, int sex,
      int gradeId, String phone, String bornDate, String email,
    String identityCard) {

    StudentNo = studentNo;
    this.loginPwd = loginPwd;
    StudentName = studentName;
    Sex = sex;
    GradeId = gradeId;
    this.phone = phone;
    BornDate = bornDate;
    this.email = email;
    IdentityCard = identityCard;
    }
    public IStudent() {

    // TODO Auto-generated constructor stub
    }


    }

    2.创建接口Dao层编写查询学生的方法

       编写查询年级表的方法

    3.创建工具类

    4.实现接口Dao层并继承工具类

    5.测试UI类

    二、查询S1年级下的学生记录

    1.创建Grade表实体类并创建学生实体类集合

    2.在Dao层中编写方法

     3.实现Dao接口

     4.测试UI层

  • 相关阅读:
    软件需求阅读笔记02
    软件需求阅读笔记01
    搜狗输入法
    冲刺周之后感想
    典型用户分析和场景
    四则运算
    学习总结
    2019年春阅读笔记5——对开源的认知
    2019年春阅读笔记4——分布式消息系统的现状、挑战与未来
    2019年春阅读笔记3——数据库集群方案
  • 原文地址:https://www.cnblogs.com/szhhhh/p/10945009.html
Copyright © 2020-2023  润新知