예제 #1
0
  @Override
  public String execute() throws Exception {
    // TODO Auto-generated method stub
    List<UrpTeacher> teacherData;
    List<UrpCollege> collegeData;
    this.result = new ArrayList<HashMap<String, String>>();

    Session session = HibernateSessionFactory.getSession();
    Transaction trans = session.beginTransaction();

    Query teacherQuery = session.createQuery("from UrpTeacher");
    Query collegeQuery = session.createQuery("from UrpCollege");
    teacherData = teacherQuery.list();
    collegeData = collegeQuery.list();
    trans.commit();

    for (UrpCollege college : collegeData) {
      HashMap<String, String> c = new HashMap<String, String>();
      c.put("id", college.getCollegeNo());
      c.put("text", college.getCollegeNo() + "-" + college.getName());
      result.add(c);
    }

    for (UrpTeacher teacher : teacherData) {
      HashMap<String, String> t = new HashMap<String, String>();
      t.put("id", teacher.getTeacherNo());
      t.put("text", teacher.getTeacherNo() + "-" + teacher.getTeacherName());
      t.put("pid", teacher.getCollege().getCollegeNo());
      result.add(t);
    }
    HibernateSessionFactory.closeSession();
    return SUCCESS;
  }
예제 #2
0
  @Override
  public String execute() throws Exception {
    // TODO Auto-generated method stub
    Session session = HibernateSessionFactory.getSession();
    Transaction trans = session.beginTransaction();
    Query query = session.createQuery("from UrpClassroom");
    this.data = query.list();
    this.total = data.size() + "";
    trans.commit();

    HibernateSessionFactory.closeSession();
    return SUCCESS;
  }