private void removeOrder() {
    int restId = (Integer) request.getSession().getAttribute("restId");

    Session se = HibernateSessionFactory.getSession();
    Orderinfo curOrder = (Orderinfo) se.load(Orderinfo.class, curOrderId);
    Set<Ordercourses> curOrderset = curOrder.getOrdercourseses();
    Transaction trans = se.beginTransaction();
    trans.begin();

    Iterator<Ordercourses> curOrderIt = curOrderset.iterator();
    while (curOrderIt.hasNext()) {
      Ordercourses curOrderCourse = curOrderIt.next();
      if (curOrderCourse.getCourseinfo().getRestaurantinfo().getRestaurantId() == restId)
        se.delete(curOrderCourse);
    }

    if (curOrder.getOrdercourseses() == null || curOrder.getOrdercourseses().isEmpty())
      se.delete(curOrder);

    trans.commit();
    HibernateSessionFactory.closeSession();

    RestOrder.getRestList().remove(listIndex);
  }
  public void validate() {

    if (address.isEmpty()) {
      this.addActionError("请输入地址");
    }

    if (firstName.isEmpty() || lastName.isEmpty()) {
      this.addActionError("请输入姓名");
    }

    if (telephoneNum.isEmpty()) {
      this.addActionError("请输入电话号码");
    }

    if (!isNum(telephoneNum)) {
      this.addActionError("请输入正确电话号码");
    }
    Timestamp datetime;

    System.out.println(demandDate);
    System.out.println(demandTime);

    System.out.println(demandDate.substring(0, 10));
    System.out.println(demandTime.substring(11, 19));
    dt = demandDate.substring(0, 10) + " " + demandTime.substring(11, 19);
    System.out.println(dt);
    datetime = Timestamp.valueOf(dt);

    java.util.Date d = new java.util.Date();
    java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    java.util.Calendar c1 = java.util.Calendar.getInstance();
    java.util.Calendar c2 = java.util.Calendar.getInstance();
    System.out.println("当前系统时间为: " + df.format(d));
    System.out.println("预定时间为" + dt);
    try {
      c1.setTime(df.parse(df.format(d)));
      c2.setTime(df.parse(dt));
    } catch (java.text.ParseException e) {
      System.err.println("格式不正确");
    }
    int result = c1.compareTo(c2);
    if (result >= 0) {
      this.addActionError("请输入正确的时间,时光荏苒,不能倒流");
    }
    Session se = HibernateSessionFactory.getSession();

    Orderinfo curorder = (Orderinfo) se.load(Orderinfo.class, SubmitOrderAction.getOrderID());
    curorder.setAddress(address);
    curorder.setFirstName(firstName);
    curorder.setLastName(lastName);
    curorder.setTelephoneNum(telephoneNum);
    curorder.setState("处理中");
    curorder.setDemandTime(datetime);
    curorder.setOrderTime(Timestamp.valueOf(df.format(d)));

    Criteria crit = se.createCriteria(Ordercourses.class);
    crit.add(Restrictions.eq("orderinfo", curorder));
    List<Ordercourses> os = crit.list();

    Transaction tran = se.beginTransaction();
    se.update(curorder);
    for (Ordercourses o : os) {
      o.setState("处理中");
      se.update(o);
    }
    tran.commit();
    HibernateSessionFactory.closeSession();
  }