@Override
  public Entry updateImpl(com.liferay.contacts.model.Entry entry) throws SystemException {
    entry = toUnwrappedModel(entry);

    boolean isNew = entry.isNew();

    EntryModelImpl entryModelImpl = (EntryModelImpl) entry;

    Session session = null;

    try {
      session = openSession();

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

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !EntryModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
      if ((entryModelImpl.getColumnBitmask()
              & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask())
          != 0) {
        Object[] args = new Object[] {entryModelImpl.getOriginalUserId()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID, args);

        args = new Object[] {entryModelImpl.getUserId()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID, args);
      }
    }

    EntityCacheUtil.putResult(
        EntryModelImpl.ENTITY_CACHE_ENABLED, EntryImpl.class, entry.getPrimaryKey(), entry);

    clearUniqueFindersCache(entry);
    cacheUniqueFindersCache(entry);

    return entry;
  }
  protected void clearUniqueFindersCache(Entry entry) {
    EntryModelImpl entryModelImpl = (EntryModelImpl) entry;

    Object[] args = new Object[] {entry.getUserId(), entry.getEmailAddress()};

    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_EA, args);
    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_EA, args);

    if ((entryModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_U_EA.getColumnBitmask()) != 0) {
      args =
          new Object[] {
            entryModelImpl.getOriginalUserId(), entryModelImpl.getOriginalEmailAddress()
          };

      FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_EA, args);
      FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_EA, args);
    }
  }