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; }
protected void cacheUniqueFindersCache(DLSync dlSync) { if (dlSync.isNew()) { Object[] args = new Object[] {dlSync.getFileId()}; FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEID, args, Long.valueOf(1)); FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FILEID, args, dlSync); } else { DLSyncModelImpl dlSyncModelImpl = (DLSyncModelImpl) dlSync; if ((dlSyncModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_FILEID.getColumnBitmask()) != 0) { Object[] args = new Object[] {dlSync.getFileId()}; FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEID, args, Long.valueOf(1)); FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FILEID, args, dlSync); } } }
/** * 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(); }
protected void clearUniqueFindersCache(DLSync dlSync) { DLSyncModelImpl dlSyncModelImpl = (DLSyncModelImpl) dlSync; Object[] args = new Object[] {dlSync.getFileId()}; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEID, args); FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FILEID, args); if ((dlSyncModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_FILEID.getColumnBitmask()) != 0) { args = new Object[] {dlSyncModelImpl.getOriginalFileId()}; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEID, args); FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FILEID, args); } }
/** * Returns the d l sync where fileId = ? or returns <code>null</code> if it could not be * found, optionally using the finder cache. * * @param fileId the file ID * @param retrieveFromCache whether to use the finder cache * @return the matching d l sync, or <code>null</code> if a matching d l sync could not be found * @throws SystemException if a system exception occurred */ public DLSync fetchByFileId(long fileId, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] {fileId}; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_FILEID, finderArgs, this); } if (result instanceof DLSync) { DLSync dlSync = (DLSync) result; if ((fileId != dlSync.getFileId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(3); query.append(_SQL_SELECT_DLSYNC_WHERE); query.append(_FINDER_COLUMN_FILEID_FILEID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(fileId); List<DLSync> list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FILEID, finderArgs, list); } else { DLSync dlSync = list.get(0); result = dlSync; cacheResult(dlSync); if ((dlSync.getFileId() != fileId)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FILEID, finderArgs, dlSync); } } } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FILEID, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (DLSync) result; } }