Esempio n. 1
0
  public void commitTransaction(IObjectScope scope, ICmdbTransaction cmdbTx) {
    idCache.clear();
    aliasCache.clear();

    Session session = null;
    Transaction tx = null;
    Profiler.start("commitTx()");
    try {
      session = getSession(cmdbTx.getSession());
      tx = session.beginTransaction();
      for (ICi item : scope.getDestroyedICis()) {
        session.delete(item);
      }
      for (ICi item : scope.getNewICis()) {
        session.save(item);
      }
      for (ICi item : scope.getModifiedICis()) {
        session.update(item);
      }
      cmdbTx.setEndTs(new Date());
      storeTx(session, cmdbTx); // session.update(cmdbTx);
      tx.commit();

    } catch (HibernateException he) {
      if (tx != null) {
        tx.rollback();
      }
      throw he;
    } finally {
      closeSession(session);

      Profiler.stop("commitTx()");
    }
  }
Esempio n. 2
0
 public List queryCriteria(ISession s, DetachedCriteria detachedCrit, PageInfo info) {
   Session session = getSession(s);
   List result = Collections.EMPTY_LIST;
   try {
     Profiler.start("QueryCriteria():");
     Criteria criteria = detachedCrit.getExecutableCriteria(session);
     criteria.addOrder(Order.asc("alias"));
     if (info != null) {
       if (info.getFirstResult() != null) {
         criteria.setFirstResult(info.getFirstResult());
       }
       if (info.getMaxResult() != null) {
         criteria.setMaxResults(info.getMaxResult());
       }
     }
     result = criteria.list();
   } finally {
     Profiler.stop();
     closeSession(session);
   }
   return (result);
 }