@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;
  }
Пример #2
0
  @Override
  public void resetOriginalValues() {
    EntryModelImpl entryModelImpl = this;

    entryModelImpl._originalUserId = entryModelImpl._userId;

    entryModelImpl._setOriginalUserId = false;

    entryModelImpl._originalEmailAddress = entryModelImpl._emailAddress;

    entryModelImpl._columnBitmask = 0;
  }
  protected void cacheUniqueFindersCache(Entry entry) {
    if (entry.isNew()) {
      Object[] args = new Object[] {entry.getUserId(), entry.getEmailAddress()};

      FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_EA, args, Long.valueOf(1));
      FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_EA, args, entry);
    } else {
      EntryModelImpl entryModelImpl = (EntryModelImpl) entry;

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

        FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_EA, args, Long.valueOf(1));
        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_EA, args, 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);
    }
  }