protected DLSync toUnwrappedModel(DLSync dlSync) {
    if (dlSync instanceof DLSyncImpl) {
      return dlSync;
    }

    DLSyncImpl dlSyncImpl = new DLSyncImpl();

    dlSyncImpl.setNew(dlSync.isNew());
    dlSyncImpl.setPrimaryKey(dlSync.getPrimaryKey());

    dlSyncImpl.setSyncId(dlSync.getSyncId());
    dlSyncImpl.setCompanyId(dlSync.getCompanyId());
    dlSyncImpl.setCreateDate(dlSync.getCreateDate());
    dlSyncImpl.setModifiedDate(dlSync.getModifiedDate());
    dlSyncImpl.setFileId(dlSync.getFileId());
    dlSyncImpl.setFileUuid(dlSync.getFileUuid());
    dlSyncImpl.setRepositoryId(dlSync.getRepositoryId());
    dlSyncImpl.setParentFolderId(dlSync.getParentFolderId());
    dlSyncImpl.setName(dlSync.getName());
    dlSyncImpl.setDescription(dlSync.getDescription());
    dlSyncImpl.setEvent(dlSync.getEvent());
    dlSyncImpl.setType(dlSync.getType());
    dlSyncImpl.setVersion(dlSync.getVersion());

    return dlSyncImpl;
  }
  /**
   * Caches the d l sync in the entity cache if it is enabled.
   *
   * @param dlSync the d l sync
   */
  public void cacheResult(DLSync dlSync) {
    EntityCacheUtil.putResult(
        DLSyncModelImpl.ENTITY_CACHE_ENABLED, DLSyncImpl.class, dlSync.getPrimaryKey(), dlSync);

    FinderCacheUtil.putResult(
        FINDER_PATH_FETCH_BY_FILEID, new Object[] {dlSync.getFileId()}, dlSync);

    dlSync.resetOriginalValues();
  }
  /**
   * Clears the cache for the d l sync.
   *
   * <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(DLSync dlSync) {
    EntityCacheUtil.removeResult(
        DLSyncModelImpl.ENTITY_CACHE_ENABLED, DLSyncImpl.class, dlSync.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

    clearUniqueFindersCache(dlSync);
  }
 /**
  * Caches the d l syncs in the entity cache if it is enabled.
  *
  * @param dlSyncs the d l syncs
  */
 public void cacheResult(List<DLSync> dlSyncs) {
   for (DLSync dlSync : dlSyncs) {
     if (EntityCacheUtil.getResult(
             DLSyncModelImpl.ENTITY_CACHE_ENABLED, DLSyncImpl.class, dlSync.getPrimaryKey())
         == null) {
       cacheResult(dlSync);
     } else {
       dlSync.resetOriginalValues();
     }
   }
 }
  @Override
  public DLSync updateImpl(com.liferay.portlet.documentlibrary.model.DLSync dlSync)
      throws SystemException {
    dlSync = toUnwrappedModel(dlSync);

    boolean isNew = dlSync.isNew();

    Session session = null;

    try {
      session = openSession();

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

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !DLSyncModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    EntityCacheUtil.putResult(
        DLSyncModelImpl.ENTITY_CACHE_ENABLED, DLSyncImpl.class, dlSync.getPrimaryKey(), dlSync);

    clearUniqueFindersCache(dlSync);
    cacheUniqueFindersCache(dlSync);

    return dlSync;
  }