/**
   * Caches the panic button in the entity cache if it is enabled.
   *
   * @param panicButton the panic button
   */
  public void cacheResult(PanicButton panicButton) {
    EntityCacheUtil.putResult(
        PanicButtonModelImpl.ENTITY_CACHE_ENABLED,
        PanicButtonImpl.class,
        panicButton.getPrimaryKey(),
        panicButton);

    panicButton.resetOriginalValues();
  }
  /**
   * Clears the cache for the panic button.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache(PanicButton panicButton) {
    EntityCacheUtil.removeResult(
        PanicButtonModelImpl.ENTITY_CACHE_ENABLED,
        PanicButtonImpl.class,
        panicButton.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }
 /**
  * Caches the panic buttons in the entity cache if it is enabled.
  *
  * @param panicButtons the panic buttons
  */
 public void cacheResult(List<PanicButton> panicButtons) {
   for (PanicButton panicButton : panicButtons) {
     if (EntityCacheUtil.getResult(
             PanicButtonModelImpl.ENTITY_CACHE_ENABLED,
             PanicButtonImpl.class,
             panicButton.getPrimaryKey())
         == null) {
       cacheResult(panicButton);
     } else {
       panicButton.resetOriginalValues();
     }
   }
 }
  @Override
  public PanicButton updateImpl(com.ese.ils.beta.model.PanicButton panicButton, boolean merge)
      throws SystemException {
    panicButton = toUnwrappedModel(panicButton);

    boolean isNew = panicButton.isNew();

    PanicButtonModelImpl panicButtonModelImpl = (PanicButtonModelImpl) panicButton;

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, panicButton, merge);

      panicButton.setNew(false);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !PanicButtonModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
      if ((panicButtonModelImpl.getColumnBitmask()
              & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BYMODULE.getColumnBitmask())
          != 0) {
        Object[] args = new Object[] {Long.valueOf(panicButtonModelImpl.getOriginalModuleId())};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_BYMODULE, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BYMODULE, args);

        args = new Object[] {Long.valueOf(panicButtonModelImpl.getModuleId())};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_BYMODULE, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BYMODULE, args);
      }
    }

    EntityCacheUtil.putResult(
        PanicButtonModelImpl.ENTITY_CACHE_ENABLED,
        PanicButtonImpl.class,
        panicButton.getPrimaryKey(),
        panicButton);

    return panicButton;
  }
  protected PanicButton toUnwrappedModel(PanicButton panicButton) {
    if (panicButton instanceof PanicButtonImpl) {
      return panicButton;
    }

    PanicButtonImpl panicButtonImpl = new PanicButtonImpl();

    panicButtonImpl.setNew(panicButton.isNew());
    panicButtonImpl.setPrimaryKey(panicButton.getPrimaryKey());

    panicButtonImpl.setPanicButtonId(panicButton.getPanicButtonId());
    panicButtonImpl.setUserId(panicButton.getUserId());
    panicButtonImpl.setCreateDate(panicButton.getCreateDate());
    panicButtonImpl.setModuleId(panicButton.getModuleId());
    panicButtonImpl.setSlideId(panicButton.getSlideId());
    panicButtonImpl.setReason(panicButton.getReason());

    return panicButtonImpl;
  }