/**
   * Caches the web d a v props in the entity cache if it is enabled.
   *
   * @param webDAVProps the web d a v props
   */
  @Override
  public void cacheResult(WebDAVProps webDAVProps) {
    entityCache.putResult(
        WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
        WebDAVPropsImpl.class,
        webDAVProps.getPrimaryKey(),
        webDAVProps);

    finderCache.putResult(
        FINDER_PATH_FETCH_BY_C_C,
        new Object[] {webDAVProps.getClassNameId(), webDAVProps.getClassPK()},
        webDAVProps);

    webDAVProps.resetOriginalValues();
  }
  protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) {
    if (webDAVProps instanceof WebDAVPropsImpl) {
      return webDAVProps;
    }

    WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();

    webDAVPropsImpl.setNew(webDAVProps.isNew());
    webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey());

    webDAVPropsImpl.setMvccVersion(webDAVProps.getMvccVersion());
    webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId());
    webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId());
    webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate());
    webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate());
    webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId());
    webDAVPropsImpl.setClassPK(webDAVProps.getClassPK());
    webDAVPropsImpl.setProps(webDAVProps.getProps());

    return webDAVPropsImpl;
  }
  /**
   * Returns the web d a v props where classNameId = &#63; and classPK = &#63; or returns <code>null
   * </code> if it could not be found, optionally using the finder cache.
   *
   * @param classNameId the class name ID
   * @param classPK the class p k
   * @param retrieveFromCache whether to retrieve from the finder cache
   * @return the matching web d a v props, or <code>null</code> if a matching web d a v props could
   *     not be found
   */
  @Override
  public WebDAVProps fetchByC_C(long classNameId, long classPK, boolean retrieveFromCache) {
    Object[] finderArgs = new Object[] {classNameId, classPK};

    Object result = null;

    if (retrieveFromCache) {
      result = finderCache.getResult(FINDER_PATH_FETCH_BY_C_C, finderArgs, this);
    }

    if (result instanceof WebDAVProps) {
      WebDAVProps webDAVProps = (WebDAVProps) result;

      if ((classNameId != webDAVProps.getClassNameId()) || (classPK != webDAVProps.getClassPK())) {
        result = null;
      }
    }

    if (result == null) {
      StringBundler query = new StringBundler(4);

      query.append(_SQL_SELECT_WEBDAVPROPS_WHERE);

      query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);

      query.append(_FINDER_COLUMN_C_C_CLASSPK_2);

      String sql = query.toString();

      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(sql);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(classNameId);

        qPos.add(classPK);

        List<WebDAVProps> list = q.list();

        if (list.isEmpty()) {
          finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, finderArgs, list);
        } else {
          WebDAVProps webDAVProps = list.get(0);

          result = webDAVProps;

          cacheResult(webDAVProps);

          if ((webDAVProps.getClassNameId() != classNameId)
              || (webDAVProps.getClassPK() != classPK)) {
            finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, finderArgs, webDAVProps);
          }
        }
      } catch (Exception e) {
        finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, finderArgs);

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

    if (result instanceof List<?>) {
      return null;
    } else {
      return (WebDAVProps) result;
    }
  }