@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;
  }
  @Override
  public void resetOriginalValues() {
    ListTypeModelImpl listTypeModelImpl = this;

    listTypeModelImpl._originalType = listTypeModelImpl._type;

    listTypeModelImpl._columnBitmask = 0;
  }
  protected void clearUniqueFindersCache(ListType listType) {
    ListTypeModelImpl listTypeModelImpl = (ListTypeModelImpl) listType;

    Object[] args = new Object[] {listType.getName(), listType.getType()};

    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T, args);
    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T, args);

    if ((listTypeModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_N_T.getColumnBitmask()) != 0) {
      args =
          new Object[] {listTypeModelImpl.getOriginalName(), listTypeModelImpl.getOriginalType()};

      FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T, args);
      FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T, args);
    }
  }
  protected void cacheUniqueFindersCache(ListType listType) {
    if (listType.isNew()) {
      Object[] args = new Object[] {listType.getName(), listType.getType()};

      FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, args, Long.valueOf(1));
      FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T, args, listType);
    } else {
      ListTypeModelImpl listTypeModelImpl = (ListTypeModelImpl) listType;

      if ((listTypeModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_N_T.getColumnBitmask())
          != 0) {
        Object[] args = new Object[] {listType.getName(), listType.getType()};

        FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, args, Long.valueOf(1));
        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T, args, listType);
      }
    }
  }