/**
   * Returns the bar with the primary key or returns <code>null</code> if it could not be found.
   *
   * @param primaryKey the primary key of the bar
   * @return the bar, or <code>null</code> if a bar with the primary key could not be found
   */
  @Override
  public Bar fetchByPrimaryKey(Serializable primaryKey) {
    Bar bar =
        (Bar)
            EntityCacheUtil.getResult(BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey);

    if (bar == _nullBar) {
      return null;
    }

    if (bar == null) {
      Session session = null;

      try {
        session = openSession();

        bar = (Bar) session.get(BarImpl.class, primaryKey);

        if (bar != null) {
          cacheResult(bar);
        } else {
          EntityCacheUtil.putResult(
              BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey, _nullBar);
        }
      } catch (Exception e) {
        EntityCacheUtil.removeResult(BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return bar;
  }
  /**
   * Returns the foo with the primary key or returns <code>null</code> if it could not be found.
   *
   * @param primaryKey the primary key of the foo
   * @return the foo, or <code>null</code> if a foo with the primary key could not be found
   */
  @Override
  public Foo fetchByPrimaryKey(Serializable primaryKey) {
    Foo foo =
        (Foo)
            EntityCacheUtil.getResult(FooModelImpl.ENTITY_CACHE_ENABLED, FooImpl.class, primaryKey);

    if (foo == _nullFoo) {
      return null;
    }

    if (foo == null) {
      Session session = null;

      try {
        session = openSession();

        foo = (Foo) session.get(FooImpl.class, primaryKey);

        if (foo != null) {
          cacheResult(foo);
        } else {
          EntityCacheUtil.putResult(
              FooModelImpl.ENTITY_CACHE_ENABLED, FooImpl.class, primaryKey, _nullFoo);
        }
      } catch (Exception e) {
        EntityCacheUtil.removeResult(FooModelImpl.ENTITY_CACHE_ENABLED, FooImpl.class, primaryKey);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return foo;
  }
  @Override
  public SocialEquityHistory updateImpl(
      com.liferay.portlet.social.model.SocialEquityHistory socialEquityHistory, boolean merge)
      throws SystemException {
    socialEquityHistory = toUnwrappedModel(socialEquityHistory);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, socialEquityHistory, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.putResult(
        SocialEquityHistoryModelImpl.ENTITY_CACHE_ENABLED,
        SocialEquityHistoryImpl.class,
        socialEquityHistory.getPrimaryKey(),
        socialEquityHistory);

    return socialEquityHistory;
  }
  /**
   * Caches the bar in the entity cache if it is enabled.
   *
   * @param bar the bar
   */
  @Override
  public void cacheResult(Bar bar) {
    EntityCacheUtil.putResult(
        BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, bar.getPrimaryKey(), bar);

    bar.resetOriginalValues();
  }
  /**
   * Caches the task in the entity cache if it is enabled.
   *
   * @param task the task
   */
  @Override
  public void cacheResult(Task task) {
    EntityCacheUtil.putResult(
        TaskModelImpl.ENTITY_CACHE_ENABLED, TaskImpl.class, task.getPrimaryKey(), task);

    task.resetOriginalValues();
  }
  /**
   * Caches the asset in the entity cache if it is enabled.
   *
   * @param asset the asset
   */
  @Override
  public void cacheResult(Asset asset) {
    EntityCacheUtil.putResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey(), asset);

    asset.resetOriginalValues();
  }
  @Override
  protected Ticket removeImpl(Ticket ticket) throws SystemException {
    ticket = toUnwrappedModel(ticket);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.delete(session, ticket);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    TicketModelImpl ticketModelImpl = (TicketModelImpl) ticket;

    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_KEY, new Object[] {ticketModelImpl.getKey()});

    EntityCacheUtil.removeResult(
        TicketModelImpl.ENTITY_CACHE_ENABLED, TicketImpl.class, ticket.getPrimaryKey());

    return ticket;
  }
  /**
   * Clears the cache for the h r project.
   *
   * <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(HRProject hrProject) {
    EntityCacheUtil.removeResult(
        HRProjectModelImpl.ENTITY_CACHE_ENABLED, HRProjectImpl.class, hrProject.getPrimaryKey());

    FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, FINDER_ARGS_EMPTY);
  }
  @Override
  public HRProject updateImpl(com.liferay.hr.model.HRProject hrProject, boolean merge)
      throws SystemException {
    hrProject = toUnwrappedModel(hrProject);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, hrProject, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.putResult(
        HRProjectModelImpl.ENTITY_CACHE_ENABLED,
        HRProjectImpl.class,
        hrProject.getPrimaryKey(),
        hrProject);

    return hrProject;
  }
 public void cacheResult(ViewListTitleCompetencies viewListTitleCompetencies) {
   EntityCacheUtil.putResult(
       ViewListTitleCompetenciesModelImpl.ENTITY_CACHE_ENABLED,
       ViewListTitleCompetenciesImpl.class,
       viewListTitleCompetencies.getPrimaryKey(),
       viewListTitleCompetencies);
 }
  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;
  }
  @Override
  protected JIRAChangeItem removeImpl(JIRAChangeItem jiraChangeItem) throws SystemException {
    jiraChangeItem = toUnwrappedModel(jiraChangeItem);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.delete(session, jiraChangeItem);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, FINDER_ARGS_EMPTY);

    EntityCacheUtil.removeResult(
        JIRAChangeItemModelImpl.ENTITY_CACHE_ENABLED,
        JIRAChangeItemImpl.class,
        jiraChangeItem.getPrimaryKey());

    return jiraChangeItem;
  }
  @Override
  public JIRAChangeItem updateImpl(
      com.liferay.socialcoding.model.JIRAChangeItem jiraChangeItem, boolean merge)
      throws SystemException {
    jiraChangeItem = toUnwrappedModel(jiraChangeItem);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, jiraChangeItem, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.putResult(
        JIRAChangeItemModelImpl.ENTITY_CACHE_ENABLED,
        JIRAChangeItemImpl.class,
        jiraChangeItem.getPrimaryKey(),
        jiraChangeItem);

    return jiraChangeItem;
  }
  @Override
  public Faculty updateImpl(
      com.asu.poly.teams.manualSelect.slayer.model.Faculty faculty, boolean merge)
      throws SystemException {
    faculty = toUnwrappedModel(faculty);

    boolean isNew = faculty.isNew();

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, faculty, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    EntityCacheUtil.putResult(
        FacultyModelImpl.ENTITY_CACHE_ENABLED, FacultyImpl.class, faculty.getPrimaryKey(), faculty);

    return faculty;
  }
  @Override
  protected HRUserTimeOff removeImpl(HRUserTimeOff hrUserTimeOff) throws SystemException {
    hrUserTimeOff = toUnwrappedModel(hrUserTimeOff);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.delete(session, hrUserTimeOff);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(
        HRUserTimeOffModelImpl.ENTITY_CACHE_ENABLED,
        HRUserTimeOffImpl.class,
        hrUserTimeOff.getPrimaryKey());

    return hrUserTimeOff;
  }
 /**
  * Clears the cache for the h r user time off.
  *
  * <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(HRUserTimeOff hrUserTimeOff) {
   EntityCacheUtil.removeResult(
       HRUserTimeOffModelImpl.ENTITY_CACHE_ENABLED,
       HRUserTimeOffImpl.class,
       hrUserTimeOff.getPrimaryKey());
 }
  @Override
  public ListType updateImpl(ListType listType) {
    listType = toUnwrappedModel(listType);

    boolean isNew = listType.isNew();

    ListTypeModelImpl listTypeModelImpl = (ListTypeModelImpl) listType;

    Session session = null;

    try {
      session = openSession();

      if (listType.isNew()) {
        session.save(listType);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !ListTypeModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
      if ((listTypeModelImpl.getColumnBitmask()
              & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE.getColumnBitmask())
          != 0) {
        Object[] args = new Object[] {listTypeModelImpl.getOriginalType()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE, args);

        args = new Object[] {listTypeModelImpl.getType()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE, args);
      }
    }

    EntityCacheUtil.putResult(
        ListTypeModelImpl.ENTITY_CACHE_ENABLED,
        ListTypeImpl.class,
        listType.getPrimaryKey(),
        listType,
        false);

    clearUniqueFindersCache(listType);
    cacheUniqueFindersCache(listType);

    listType.resetOriginalValues();

    return listType;
  }
  public ViewListTitleCompetencies updateImpl(
      larion.progate.cds.model.ViewListTitleCompetencies viewListTitleCompetencies, boolean merge)
      throws SystemException {
    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, viewListTitleCompetencies, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

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

    return viewListTitleCompetencies;
  }
  @Override
  public Bar updateImpl(com.liferay.testtransaction.model.Bar bar, boolean merge)
      throws SystemException {
    bar = toUnwrappedModel(bar);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, bar, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.putResult(
        BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, bar.getPrimaryKey(), bar);

    return bar;
  }
  public ViewListTitleCompetencies fetchByPrimaryKey(String id) throws SystemException {
    ViewListTitleCompetencies viewListTitleCompetencies =
        (ViewListTitleCompetencies)
            EntityCacheUtil.getResult(
                ViewListTitleCompetenciesModelImpl.ENTITY_CACHE_ENABLED,
                ViewListTitleCompetenciesImpl.class,
                id,
                this);

    if (viewListTitleCompetencies == null) {
      Session session = null;

      try {
        session = openSession();

        viewListTitleCompetencies =
            (ViewListTitleCompetencies) session.get(ViewListTitleCompetenciesImpl.class, id);
      } catch (Exception e) {
        throw processException(e);
      } finally {
        if (viewListTitleCompetencies != null) {
          cacheResult(viewListTitleCompetencies);
        }

        closeSession(session);
      }
    }

    return viewListTitleCompetencies;
  }
  @Override
  protected HRProject removeImpl(HRProject hrProject) throws SystemException {
    hrProject = toUnwrappedModel(hrProject);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.delete(session, hrProject);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, FINDER_ARGS_EMPTY);

    EntityCacheUtil.removeResult(
        HRProjectModelImpl.ENTITY_CACHE_ENABLED, HRProjectImpl.class, hrProject.getPrimaryKey());

    return hrProject;
  }
  /**
   * Clears the cache for the asset.
   *
   * <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(Asset asset) {
    EntityCacheUtil.removeResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey());

    FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, FINDER_ARGS_EMPTY);
  }
  @Override
  public TraCuuThuTucHanhChinh updateImpl(
      org.oep.cmon.dao.touchscreen.model.TraCuuThuTucHanhChinh traCuuThuTucHanhChinh, boolean merge)
      throws SystemException {
    traCuuThuTucHanhChinh = toUnwrappedModel(traCuuThuTucHanhChinh);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, traCuuThuTucHanhChinh, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    EntityCacheUtil.putResult(
        TraCuuThuTucHanhChinhModelImpl.ENTITY_CACHE_ENABLED,
        TraCuuThuTucHanhChinhImpl.class,
        traCuuThuTucHanhChinh.getPrimaryKey(),
        traCuuThuTucHanhChinh);

    return traCuuThuTucHanhChinh;
  }
  @Override
  public Asset updateImpl(com.liferay.ams.model.Asset asset, boolean merge) throws SystemException {
    asset = toUnwrappedModel(asset);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, asset, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.putResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey(), asset);

    return asset;
  }
  @Override
  public Image updateImpl(com.liferay.portal.model.Image image) throws SystemException {
    image = toUnwrappedModel(image);

    boolean isNew = image.isNew();

    Session session = null;

    try {
      session = openSession();

      if (image.isNew()) {
        session.save(image);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !ImageModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    EntityCacheUtil.putResult(
        ImageModelImpl.ENTITY_CACHE_ENABLED, ImageImpl.class, image.getPrimaryKey(), image);

    return image;
  }
  public DebateItemReference updateImpl(
      com.ext.portlet.debaterevision.model.DebateItemReference debateItemReference, boolean merge)
      throws SystemException {
    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, debateItemReference, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

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

    return debateItemReference;
  }
  @Override
  public iProject updateImpl(com.asu.poly.iProjects.model.iProject iProject, boolean merge)
      throws SystemException {
    iProject = toUnwrappedModel(iProject);

    boolean isNew = iProject.isNew();

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, iProject, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    EntityCacheUtil.putResult(
        iProjectModelImpl.ENTITY_CACHE_ENABLED,
        iProjectImpl.class,
        iProject.getPrimaryKey(),
        iProject);

    return iProject;
  }
  @Override
  protected SocialEquityHistory removeImpl(SocialEquityHistory socialEquityHistory)
      throws SystemException {
    socialEquityHistory = toUnwrappedModel(socialEquityHistory);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.delete(session, socialEquityHistory);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(
        SocialEquityHistoryModelImpl.ENTITY_CACHE_ENABLED,
        SocialEquityHistoryImpl.class,
        socialEquityHistory.getPrimaryKey());

    return socialEquityHistory;
  }
 /**
  * Clears the cache for the social equity history.
  *
  * <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(SocialEquityHistory socialEquityHistory) {
   EntityCacheUtil.removeResult(
       SocialEquityHistoryModelImpl.ENTITY_CACHE_ENABLED,
       SocialEquityHistoryImpl.class,
       socialEquityHistory.getPrimaryKey());
 }
  public DebateItemReference fetchByPrimaryKey(Long debateItemReferencePK) throws SystemException {
    DebateItemReference debateItemReference =
        (DebateItemReference)
            EntityCacheUtil.getResult(
                DebateItemReferenceModelImpl.ENTITY_CACHE_ENABLED,
                DebateItemReferenceImpl.class,
                debateItemReferencePK,
                this);

    if (debateItemReference == null) {
      Session session = null;

      try {
        session = openSession();

        debateItemReference =
            (DebateItemReference) session.get(DebateItemReferenceImpl.class, debateItemReferencePK);
      } catch (Exception e) {
        throw processException(e);
      } finally {
        if (debateItemReference != null) {
          cacheResult(debateItemReference);
        }

        closeSession(session);
      }
    }

    return debateItemReference;
  }