Exemple #1
0
  private CounterHolder _obtainIncrement(String counterName, long range, long size)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      Counter counter = (Counter) session.get(CounterImpl.class, counterName, LockMode.UPGRADE);

      long newValue = counter.getCurrentId();

      if (size > newValue) {
        newValue = size;
      }

      long rangeMax = newValue + range;

      counter.setCurrentId(rangeMax);

      CounterHolder counterHolder = new CounterHolder(newValue, rangeMax);

      session.saveOrUpdate(counter);

      session.flush();

      return counterHolder;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  public PmlEdmLevelSend updateImpl(
      com.sgs.portlet.pmllevelsend.model.PmlEdmLevelSend pmlEdmLevelSend, boolean merge)
      throws SystemException {
    Session session = null;

    try {
      session = openSession();

      if (merge) {
        session.merge(pmlEdmLevelSend);
      } else {
        if (pmlEdmLevelSend.isNew()) {
          session.save(pmlEdmLevelSend);
        }
      }

      session.flush();

      pmlEdmLevelSend.setNew(false);

      return pmlEdmLevelSend;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);

      FinderCacheUtil.clearCache(PmlEdmLevelSend.class.getName());
    }
  }
  public SoPhongVanBanNoiBo updateImpl(
      com.sgs.portlet.sovanbannoibo.model.SoPhongVanBanNoiBo soPhongVanBanNoiBo, boolean merge)
      throws SystemException {
    Session session = null;

    try {
      session = openSession();

      if (merge) {
        session.merge(soPhongVanBanNoiBo);
      } else {
        if (soPhongVanBanNoiBo.isNew()) {
          session.save(soPhongVanBanNoiBo);
        }
      }

      session.flush();

      soPhongVanBanNoiBo.setNew(false);

      return soPhongVanBanNoiBo;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);

      FinderCacheUtil.clearCache(SoPhongVanBanNoiBo.class.getName());
    }
  }
  protected ViewListTitleCompetencies removeImpl(
      ViewListTitleCompetencies viewListTitleCompetencies) throws SystemException {
    Session session = null;

    try {
      session = openSession();

      if (viewListTitleCompetencies.isCachedModel() || BatchSessionUtil.isEnabled()) {
        Object staleObject =
            session.get(
                ViewListTitleCompetenciesImpl.class, viewListTitleCompetencies.getPrimaryKeyObj());

        if (staleObject != null) {
          session.evict(staleObject);
        }
      }

      session.delete(viewListTitleCompetencies);

      session.flush();
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(
        ViewListTitleCompetenciesModelImpl.ENTITY_CACHE_ENABLED,
        ViewListTitleCompetenciesImpl.class,
        viewListTitleCompetencies.getPrimaryKey());

    return viewListTitleCompetencies;
  }
  protected DebateItemReference removeImpl(DebateItemReference debateItemReference)
      throws SystemException {
    Session session = null;

    try {
      session = openSession();

      if (debateItemReference.isCachedModel() || BatchSessionUtil.isEnabled()) {
        Object staleObject =
            session.get(DebateItemReferenceImpl.class, debateItemReference.getPrimaryKeyObj());

        if (staleObject != null) {
          session.evict(staleObject);
        }
      }

      session.delete(debateItemReference);

      session.flush();
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(
        DebateItemReferenceModelImpl.ENTITY_CACHE_ENABLED,
        DebateItemReferenceImpl.class,
        debateItemReference.getPrimaryKey());

    return debateItemReference;
  }
  protected ProGateMenuView removeImpl(ProGateMenuView proGateMenuView) throws SystemException {
    Session session = null;

    try {
      session = openSession();

      if (proGateMenuView.isCachedModel() || BatchSessionUtil.isEnabled()) {
        Object staleObject =
            session.get(ProGateMenuViewImpl.class, proGateMenuView.getPrimaryKeyObj());

        if (staleObject != null) {
          session.evict(staleObject);
        }
      }

      session.delete(proGateMenuView);

      session.flush();
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(
        ProGateMenuViewModelImpl.ENTITY_CACHE_ENABLED,
        ProGateMenuViewImpl.class,
        proGateMenuView.getPrimaryKey());

    return proGateMenuView;
  }
  protected void writeTimeHibernate(long time) {
    Session session = _sessionFactory.openSession();

    try {
      Release release = (Release) session.get(ReleaseImpl.class, 1L);

      release.setModifiedDate(new Timestamp(time));

      session.saveOrUpdate(release);

      session.flush();

      session.clear();
    } finally {
      _sessionFactory.closeSession(session);
    }
  }
  protected PmlEdmLevelSend removeImpl(PmlEdmLevelSend pmlEdmLevelSend) throws SystemException {
    Session session = null;

    try {
      session = openSession();

      session.delete(pmlEdmLevelSend);

      session.flush();

      return pmlEdmLevelSend;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);

      FinderCacheUtil.clearCache(PmlEdmLevelSend.class.getName());
    }
  }
  protected LogVanBanNoiBo removeImpl(LogVanBanNoiBo logVanBanNoiBo) throws SystemException {
    Session session = null;

    try {
      session = openSession();

      session.delete(logVanBanNoiBo);

      session.flush();

      return logVanBanNoiBo;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);

      FinderCacheUtil.clearCache(LogVanBanNoiBo.class.getName());
    }
  }
Exemple #10
0
  public void reset(String name) throws SystemException {
    CounterRegister counterRegister = getCounterRegister(name);

    synchronized (counterRegister) {
      Session session = null;

      try {
        session = openSession();

        Counter counter = (Counter) session.get(CounterImpl.class, name);

        session.delete(counter);

        session.flush();
      } catch (ObjectNotFoundException onfe) {
      } catch (Exception e) {
        throw processException(e);
      } finally {
        closeSession(session);
      }

      _counterRegisterMap.remove(name);
    }
  }