public ServiceProduct getServiceProductBySpId(String productId) {
   //        ServiceProduct sp=new ServiceProduct();
   List list = null;
   Session session = getSession();
   try {
     String sql =
         "select sp.csp_id from service_product sp,product p where p.id = sp.product_id and p.MOBILE_PRODUCT = 1";
     Query query = session.createSQLQuery(sql);
     list = query.list();
   } catch (DataAccessResourceFailureException e) {
     logger.error("Hibernate错误:" + e.getMessage());
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   } catch (IllegalStateException e) {
     logger.error("Hibernate错误:" + e.getMessage());
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   } catch (HibernateException e) {
     logger.error("Hibernate错误:" + e.getMessage());
     e.printStackTrace();
   } finally {
     session.close();
   }
   //        return list==null||list.size() == 0?null:list.get(0);
   return null;
 }
示例#2
0
  public List<PlannedNotification> getPlannedNotificationsForCorrespondence() {
    List<PlannedNotification> result;

    SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory");
    Session session = sessionFactory.openSession(sessionFactory.getCurrentSession().connection());
    session.setFlushMode(FlushMode.MANUAL);
    result = new ArrayList<PlannedNotification>();
    try {
      Query query =
          session
              .createQuery(
                  "from PlannedNotification p left join fetch p.userBasedRecipientInternal where p.eventName = :var")
              .setString(
                  "var",
                  NotificationEventTypeEnum.CORRESPONDENCE_CREATED_OR_UPDATED_EVENT.toString());

      result = query.list().subList(0, 1);
    } catch (DataAccessResourceFailureException e) {
      log.error(e.getMessage());
    } catch (IllegalStateException e) {
      e.printStackTrace();
    } catch (HibernateException e) {
      log.error(e.getMessage());
    } catch (Exception e) {
      log.error(e.getMessage());
    } finally {
      session.close();
    }
    return result;
  }
示例#3
0
  /**
   * Gets the planned notifications for the list of sites that are passed in. This method access the
   * db using a new session from the hibernate session factory.
   *
   * @param hcsList the hcs list
   * @return the planned notifications
   */
  public List<PlannedNotification> getPlannedNotificationsForUpdateMasterSubject() {
    List<PlannedNotification> result;

    SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory");
    Session session = sessionFactory.openSession(sessionFactory.getCurrentSession().connection());
    session.setFlushMode(FlushMode.MANUAL);
    result = new ArrayList<PlannedNotification>();
    try {
      Query query =
          session
              .createQuery("from PlannedNotification p where p.eventName = :var")
              .setString("var", NotificationEventTypeEnum.MASTER_SUBJECT_UPDATED_EVENT.toString());

      result = query.list();
    } catch (DataAccessResourceFailureException e) {
      log.error(e.getMessage());
    } catch (IllegalStateException e) {
      e.printStackTrace();
    } catch (HibernateException e) {
      log.error(e.getMessage());
    } catch (Exception e) {
      log.error(e.getMessage());
    } finally {
      session.close();
    }
    return result;
  }
示例#4
0
  /**
   * Gets the planned notifications for the list of sites that are passed in. This method access the
   * db using a new session from the hibernate session factory.
   *
   * @param hcsList the hcs list
   * @return the planned notifications
   */
  public List<PlannedNotification> getPlannedNotifications(List<HealthcareSite> hcsList) {
    List<PlannedNotification> result;
    List<String> nciCodeList = new ArrayList<String>();
    for (HealthcareSite hcs : hcsList) {
      if (hcs != null) {
        nciCodeList.add(hcs.getPrimaryIdentifier());
      }
    }

    SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory");
    Session session = sessionFactory.openSession(sessionFactory.getCurrentSession().connection());
    session.setFlushMode(FlushMode.MANUAL);
    result = new ArrayList<PlannedNotification>();
    try {
      Query query =
          session
              .createQuery(
                  "select p from PlannedNotification p, HealthcareSite o, Identifier i where p = any elements(o.plannedNotificationsInternal) and "
                      + "i = any elements(o.identifiersAssignedToOrganization) and i.primaryIndicator = 'true' and "
                      + "i.value in (:nciCodeList)")
              .setParameterList("nciCodeList", nciCodeList);

      result = query.list();
    } catch (DataAccessResourceFailureException e) {
      log.error(e.getMessage());
    } catch (IllegalStateException e) {
      e.printStackTrace();
    } catch (HibernateException e) {
      log.error(e.getMessage());
    } catch (Exception e) {
      log.error(e.getMessage());
    } finally {
      session.close();
    }
    return result;
  }