@Override
  public Boolean execute(OnlineSectioningServer server, OnlineSectioningHelper helper) {
    for (Long offeringId : getOfferingIds()) {
      helper
          .getAction()
          .addOther(
              OnlineSectioningLog.Entity.newBuilder()
                  .setUniqueId(offeringId)
                  .setType(OnlineSectioningLog.Entity.EntityType.OFFERING));

      List<Long> studentIds =
          (List<Long>)
              helper
                  .getHibSession()
                  .createQuery(
                      "select distinct cr.courseDemand.student.uniqueId from CourseRequest cr "
                          + "where cr.courseOffering.instructionalOffering.uniqueId = :offeringId")
                  .setLong("offeringId", offeringId)
                  .list();
      studentIds.addAll(
          helper
              .getHibSession()
              .createQuery(
                  "select distinct e.student.uniqueId from StudentClassEnrollment e "
                      + "where e.courseOffering.instructionalOffering.uniqueId = :offeringId and e.courseRequest is null")
              .setLong("offeringId", offeringId)
              .list());
      /*
      List<Long> studentIds = (List<Long>)helper.getHibSession().createQuery(
      		"select distinct s.uniqueId from Student s " +
      		"left outer join s.classEnrollments e " +
      		"left outer join s.courseDemands d left outer join d.courseRequests r left outer join r.courseOffering co " +
      		"where e.courseOffering.instructionalOffering.uniqueId = :offeringId or " +
      		"co.instructionalOffering.uniqueId = :offeringId").setLong("offeringId", offeringId).list();
      */

      Lock lock = server.lockOffering(offeringId, studentIds, name());
      try {
        helper.beginTransaction();
        try {
          reloadOffering(server, helper, offeringId);

          helper.commitTransaction();
        } catch (Exception e) {
          helper.rollbackTransaction();
          if (e instanceof SectioningException) throw (SectioningException) e;
          throw new SectioningException(MSG.exceptionUnknown(e.getMessage()), e);
        }
      } finally {
        lock.release();
      }
    }
    return true;
  }
  @Override
  public Boolean execute(OnlineSectioningServer server, OnlineSectioningHelper helper) {
    StudentSectioningStatus status =
        (hasStatus()
            ? (StudentSectioningStatus)
                helper
                    .getHibSession()
                    .createQuery("from StudentSectioningStatus where reference = :ref")
                    .setString("ref", getStatus())
                    .uniqueResult()
            : null);
    for (Long studentId : getStudentIds()) {
      Lock lock = server.lockStudent(studentId, null, name());
      try {
        XStudent student = server.getStudent(studentId);
        helper.beginTransaction();
        try {
          Student dbStudent = StudentDAO.getInstance().get(studentId, helper.getHibSession());
          if (student != null && dbStudent != null) {

            OnlineSectioningLog.Action.Builder action =
                helper.addAction(this, server.getAcademicSession());
            action.setStudent(
                OnlineSectioningLog.Entity.newBuilder()
                    .setUniqueId(student.getStudentId())
                    .setExternalId(student.getExternalId())
                    .setName(student.getName()));
            if (status != null) {
              action.addOther(
                  OnlineSectioningLog.Entity.newBuilder()
                      .setUniqueId(status.getUniqueId())
                      .setName(status.getLabel())
                      .setExternalId(status.getReference())
                      .setType(OnlineSectioningLog.Entity.EntityType.OTHER));
            }

            student.setStatus(getStatus());
            dbStudent.setSectioningStatus(status);
            helper.getHibSession().saveOrUpdate(dbStudent);
            server.update(student, false);
          }
          helper.commitTransaction();
        } catch (Exception e) {
          helper.rollbackTransaction();
          if (e instanceof SectioningException) throw (SectioningException) e;
          throw new SectioningException(MSG.exceptionUnknown(e.getMessage()), e);
        }

      } finally {
        lock.release();
      }
    }
    return true;
  }