@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;
  }
  /**
   * Creates a new social equity history with the primary key. Does not add the social equity
   * history to the database.
   *
   * @param equityHistoryId the primary key for the new social equity history
   * @return the new social equity history
   */
  public SocialEquityHistory create(long equityHistoryId) {
    SocialEquityHistory socialEquityHistory = new SocialEquityHistoryImpl();

    socialEquityHistory.setNew(true);
    socialEquityHistory.setPrimaryKey(equityHistoryId);

    return socialEquityHistory;
  }
  /**
   * Caches the social equity history in the entity cache if it is enabled.
   *
   * @param socialEquityHistory the social equity history
   */
  public void cacheResult(SocialEquityHistory socialEquityHistory) {
    EntityCacheUtil.putResult(
        SocialEquityHistoryModelImpl.ENTITY_CACHE_ENABLED,
        SocialEquityHistoryImpl.class,
        socialEquityHistory.getPrimaryKey(),
        socialEquityHistory);

    socialEquityHistory.resetOriginalValues();
  }
 /**
  * Caches the social equity histories in the entity cache if it is enabled.
  *
  * @param socialEquityHistories the social equity histories
  */
 public void cacheResult(List<SocialEquityHistory> socialEquityHistories) {
   for (SocialEquityHistory socialEquityHistory : socialEquityHistories) {
     if (EntityCacheUtil.getResult(
             SocialEquityHistoryModelImpl.ENTITY_CACHE_ENABLED,
             SocialEquityHistoryImpl.class,
             socialEquityHistory.getPrimaryKey(),
             this)
         == null) {
       cacheResult(socialEquityHistory);
     }
   }
 }
  @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());
 }
  protected SocialEquityHistory toUnwrappedModel(SocialEquityHistory socialEquityHistory) {
    if (socialEquityHistory instanceof SocialEquityHistoryImpl) {
      return socialEquityHistory;
    }

    SocialEquityHistoryImpl socialEquityHistoryImpl = new SocialEquityHistoryImpl();

    socialEquityHistoryImpl.setNew(socialEquityHistory.isNew());
    socialEquityHistoryImpl.setPrimaryKey(socialEquityHistory.getPrimaryKey());

    socialEquityHistoryImpl.setEquityHistoryId(socialEquityHistory.getEquityHistoryId());
    socialEquityHistoryImpl.setGroupId(socialEquityHistory.getGroupId());
    socialEquityHistoryImpl.setCompanyId(socialEquityHistory.getCompanyId());
    socialEquityHistoryImpl.setUserId(socialEquityHistory.getUserId());
    socialEquityHistoryImpl.setCreateDate(socialEquityHistory.getCreateDate());
    socialEquityHistoryImpl.setPersonalEquity(socialEquityHistory.getPersonalEquity());

    return socialEquityHistoryImpl;
  }