001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.LayoutPersistence;
040    import com.liferay.portal.service.persistence.ResourcePersistence;
041    import com.liferay.portal.service.persistence.UserPersistence;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import com.liferay.portlet.documentlibrary.NoSuchFileRankException;
045    import com.liferay.portlet.documentlibrary.model.DLFileRank;
046    import com.liferay.portlet.documentlibrary.model.impl.DLFileRankImpl;
047    import com.liferay.portlet.documentlibrary.model.impl.DLFileRankModelImpl;
048    
049    import java.io.Serializable;
050    
051    import java.util.ArrayList;
052    import java.util.Collections;
053    import java.util.List;
054    
055    /**
056     * The persistence implementation for the document library file rank service.
057     *
058     * <p>
059     * Caching information and settings can be found in <code>portal.properties</code>
060     * </p>
061     *
062     * @author Brian Wing Shun Chan
063     * @see DLFileRankPersistence
064     * @see DLFileRankUtil
065     * @generated
066     */
067    public class DLFileRankPersistenceImpl extends BasePersistenceImpl<DLFileRank>
068            implements DLFileRankPersistence {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link DLFileRankUtil} to access the document library file rank persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
073             */
074            public static final String FINDER_CLASS_NAME_ENTITY = DLFileRankImpl.class.getName();
075            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List1";
077            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List2";
079            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
080                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
081                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
082                            new String[] {
083                                    Long.class.getName(),
084                                    
085                            "java.lang.Integer", "java.lang.Integer",
086                                    "com.liferay.portal.kernel.util.OrderByComparator"
087                            });
088            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
089                    new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
090                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
092                            new String[] { Long.class.getName() },
093                            DLFileRankModelImpl.USERID_COLUMN_BITMASK);
094            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
095                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
097                            new String[] { Long.class.getName() });
098            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID =
099                    new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
100                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
101                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileEntryId",
102                            new String[] {
103                                    Long.class.getName(),
104                                    
105                            "java.lang.Integer", "java.lang.Integer",
106                                    "com.liferay.portal.kernel.util.OrderByComparator"
107                            });
108            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID =
109                    new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
110                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileEntryId",
112                            new String[] { Long.class.getName() },
113                            DLFileRankModelImpl.FILEENTRYID_COLUMN_BITMASK);
114            public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYID = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
115                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
116                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFileEntryId",
117                            new String[] { Long.class.getName() });
118            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
119                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
120                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U",
121                            new String[] {
122                                    Long.class.getName(), Long.class.getName(),
123                                    
124                            "java.lang.Integer", "java.lang.Integer",
125                                    "com.liferay.portal.kernel.util.OrderByComparator"
126                            });
127            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
128                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
130                            new String[] { Long.class.getName(), Long.class.getName() },
131                            DLFileRankModelImpl.GROUPID_COLUMN_BITMASK |
132                            DLFileRankModelImpl.USERID_COLUMN_BITMASK);
133            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
134                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
135                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
136                            new String[] { Long.class.getName(), Long.class.getName() });
137            public static final FinderPath FINDER_PATH_FETCH_BY_C_U_F = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
138                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
139                            FINDER_CLASS_NAME_ENTITY, "fetchByC_U_F",
140                            new String[] {
141                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
142                            },
143                            DLFileRankModelImpl.COMPANYID_COLUMN_BITMASK |
144                            DLFileRankModelImpl.USERID_COLUMN_BITMASK |
145                            DLFileRankModelImpl.FILEENTRYID_COLUMN_BITMASK);
146            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_F = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
147                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
148                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_F",
149                            new String[] {
150                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
151                            });
152            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
153                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
154                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
155            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
156                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
157                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
158            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
159                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
160                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
161    
162            /**
163             * Caches the document library file rank in the entity cache if it is enabled.
164             *
165             * @param dlFileRank the document library file rank
166             */
167            public void cacheResult(DLFileRank dlFileRank) {
168                    EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
169                            DLFileRankImpl.class, dlFileRank.getPrimaryKey(), dlFileRank);
170    
171                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
172                            new Object[] {
173                                    Long.valueOf(dlFileRank.getCompanyId()),
174                                    Long.valueOf(dlFileRank.getUserId()),
175                                    Long.valueOf(dlFileRank.getFileEntryId())
176                            }, dlFileRank);
177    
178                    dlFileRank.resetOriginalValues();
179            }
180    
181            /**
182             * Caches the document library file ranks in the entity cache if it is enabled.
183             *
184             * @param dlFileRanks the document library file ranks
185             */
186            public void cacheResult(List<DLFileRank> dlFileRanks) {
187                    for (DLFileRank dlFileRank : dlFileRanks) {
188                            if (EntityCacheUtil.getResult(
189                                                    DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
190                                                    DLFileRankImpl.class, dlFileRank.getPrimaryKey()) == null) {
191                                    cacheResult(dlFileRank);
192                            }
193                            else {
194                                    dlFileRank.resetOriginalValues();
195                            }
196                    }
197            }
198    
199            /**
200             * Clears the cache for all document library file ranks.
201             *
202             * <p>
203             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
204             * </p>
205             */
206            @Override
207            public void clearCache() {
208                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
209                            CacheRegistryUtil.clear(DLFileRankImpl.class.getName());
210                    }
211    
212                    EntityCacheUtil.clearCache(DLFileRankImpl.class.getName());
213    
214                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
215                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
216                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
217            }
218    
219            /**
220             * Clears the cache for the document library file rank.
221             *
222             * <p>
223             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
224             * </p>
225             */
226            @Override
227            public void clearCache(DLFileRank dlFileRank) {
228                    EntityCacheUtil.removeResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
229                            DLFileRankImpl.class, dlFileRank.getPrimaryKey());
230    
231                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
232                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
233    
234                    clearUniqueFindersCache(dlFileRank);
235            }
236    
237            @Override
238            public void clearCache(List<DLFileRank> dlFileRanks) {
239                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
240                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
241    
242                    for (DLFileRank dlFileRank : dlFileRanks) {
243                            EntityCacheUtil.removeResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
244                                    DLFileRankImpl.class, dlFileRank.getPrimaryKey());
245    
246                            clearUniqueFindersCache(dlFileRank);
247                    }
248            }
249    
250            protected void clearUniqueFindersCache(DLFileRank dlFileRank) {
251                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F,
252                            new Object[] {
253                                    Long.valueOf(dlFileRank.getCompanyId()),
254                                    Long.valueOf(dlFileRank.getUserId()),
255                                    Long.valueOf(dlFileRank.getFileEntryId())
256                            });
257            }
258    
259            /**
260             * Creates a new document library file rank with the primary key. Does not add the document library file rank to the database.
261             *
262             * @param fileRankId the primary key for the new document library file rank
263             * @return the new document library file rank
264             */
265            public DLFileRank create(long fileRankId) {
266                    DLFileRank dlFileRank = new DLFileRankImpl();
267    
268                    dlFileRank.setNew(true);
269                    dlFileRank.setPrimaryKey(fileRankId);
270    
271                    return dlFileRank;
272            }
273    
274            /**
275             * Removes the document library file rank with the primary key from the database. Also notifies the appropriate model listeners.
276             *
277             * @param fileRankId the primary key of the document library file rank
278             * @return the document library file rank that was removed
279             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
280             * @throws SystemException if a system exception occurred
281             */
282            public DLFileRank remove(long fileRankId)
283                    throws NoSuchFileRankException, SystemException {
284                    return remove(Long.valueOf(fileRankId));
285            }
286    
287            /**
288             * Removes the document library file rank with the primary key from the database. Also notifies the appropriate model listeners.
289             *
290             * @param primaryKey the primary key of the document library file rank
291             * @return the document library file rank that was removed
292             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
293             * @throws SystemException if a system exception occurred
294             */
295            @Override
296            public DLFileRank remove(Serializable primaryKey)
297                    throws NoSuchFileRankException, SystemException {
298                    Session session = null;
299    
300                    try {
301                            session = openSession();
302    
303                            DLFileRank dlFileRank = (DLFileRank)session.get(DLFileRankImpl.class,
304                                            primaryKey);
305    
306                            if (dlFileRank == null) {
307                                    if (_log.isWarnEnabled()) {
308                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
309                                    }
310    
311                                    throw new NoSuchFileRankException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
312                                            primaryKey);
313                            }
314    
315                            return remove(dlFileRank);
316                    }
317                    catch (NoSuchFileRankException nsee) {
318                            throw nsee;
319                    }
320                    catch (Exception e) {
321                            throw processException(e);
322                    }
323                    finally {
324                            closeSession(session);
325                    }
326            }
327    
328            @Override
329            protected DLFileRank removeImpl(DLFileRank dlFileRank)
330                    throws SystemException {
331                    dlFileRank = toUnwrappedModel(dlFileRank);
332    
333                    Session session = null;
334    
335                    try {
336                            session = openSession();
337    
338                            BatchSessionUtil.delete(session, dlFileRank);
339                    }
340                    catch (Exception e) {
341                            throw processException(e);
342                    }
343                    finally {
344                            closeSession(session);
345                    }
346    
347                    clearCache(dlFileRank);
348    
349                    return dlFileRank;
350            }
351    
352            @Override
353            public DLFileRank updateImpl(
354                    com.liferay.portlet.documentlibrary.model.DLFileRank dlFileRank,
355                    boolean merge) throws SystemException {
356                    dlFileRank = toUnwrappedModel(dlFileRank);
357    
358                    boolean isNew = dlFileRank.isNew();
359    
360                    DLFileRankModelImpl dlFileRankModelImpl = (DLFileRankModelImpl)dlFileRank;
361    
362                    Session session = null;
363    
364                    try {
365                            session = openSession();
366    
367                            BatchSessionUtil.update(session, dlFileRank, merge);
368    
369                            dlFileRank.setNew(false);
370                    }
371                    catch (Exception e) {
372                            throw processException(e);
373                    }
374                    finally {
375                            closeSession(session);
376                    }
377    
378                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
379    
380                    if (isNew || !DLFileRankModelImpl.COLUMN_BITMASK_ENABLED) {
381                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
382                    }
383                    else {
384                            if ((dlFileRankModelImpl.getColumnBitmask() &
385                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
386                                    Object[] args = new Object[] {
387                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId())
388                                            };
389    
390                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
391                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
392                                            args);
393    
394                                    args = new Object[] {
395                                                    Long.valueOf(dlFileRankModelImpl.getUserId())
396                                            };
397    
398                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
399                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
400                                            args);
401                            }
402    
403                            if ((dlFileRankModelImpl.getColumnBitmask() &
404                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID.getColumnBitmask()) != 0) {
405                                    Object[] args = new Object[] {
406                                                    Long.valueOf(dlFileRankModelImpl.getOriginalFileEntryId())
407                                            };
408    
409                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
410                                            args);
411                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
412                                            args);
413    
414                                    args = new Object[] {
415                                                    Long.valueOf(dlFileRankModelImpl.getFileEntryId())
416                                            };
417    
418                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
419                                            args);
420                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
421                                            args);
422                            }
423    
424                            if ((dlFileRankModelImpl.getColumnBitmask() &
425                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
426                                    Object[] args = new Object[] {
427                                                    Long.valueOf(dlFileRankModelImpl.getOriginalGroupId()),
428                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId())
429                                            };
430    
431                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
432                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
433                                            args);
434    
435                                    args = new Object[] {
436                                                    Long.valueOf(dlFileRankModelImpl.getGroupId()),
437                                                    Long.valueOf(dlFileRankModelImpl.getUserId())
438                                            };
439    
440                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
441                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
442                                            args);
443                            }
444                    }
445    
446                    EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
447                            DLFileRankImpl.class, dlFileRank.getPrimaryKey(), dlFileRank);
448    
449                    if (isNew) {
450                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
451                                    new Object[] {
452                                            Long.valueOf(dlFileRank.getCompanyId()),
453                                            Long.valueOf(dlFileRank.getUserId()),
454                                            Long.valueOf(dlFileRank.getFileEntryId())
455                                    }, dlFileRank);
456                    }
457                    else {
458                            if ((dlFileRankModelImpl.getColumnBitmask() &
459                                            FINDER_PATH_FETCH_BY_C_U_F.getColumnBitmask()) != 0) {
460                                    Object[] args = new Object[] {
461                                                    Long.valueOf(dlFileRankModelImpl.getOriginalCompanyId()),
462                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId()),
463                                                    Long.valueOf(dlFileRankModelImpl.getOriginalFileEntryId())
464                                            };
465    
466                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_F, args);
467                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F, args);
468    
469                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
470                                            new Object[] {
471                                                    Long.valueOf(dlFileRank.getCompanyId()),
472                                                    Long.valueOf(dlFileRank.getUserId()),
473                                                    Long.valueOf(dlFileRank.getFileEntryId())
474                                            }, dlFileRank);
475                            }
476                    }
477    
478                    return dlFileRank;
479            }
480    
481            protected DLFileRank toUnwrappedModel(DLFileRank dlFileRank) {
482                    if (dlFileRank instanceof DLFileRankImpl) {
483                            return dlFileRank;
484                    }
485    
486                    DLFileRankImpl dlFileRankImpl = new DLFileRankImpl();
487    
488                    dlFileRankImpl.setNew(dlFileRank.isNew());
489                    dlFileRankImpl.setPrimaryKey(dlFileRank.getPrimaryKey());
490    
491                    dlFileRankImpl.setFileRankId(dlFileRank.getFileRankId());
492                    dlFileRankImpl.setGroupId(dlFileRank.getGroupId());
493                    dlFileRankImpl.setCompanyId(dlFileRank.getCompanyId());
494                    dlFileRankImpl.setUserId(dlFileRank.getUserId());
495                    dlFileRankImpl.setCreateDate(dlFileRank.getCreateDate());
496                    dlFileRankImpl.setFileEntryId(dlFileRank.getFileEntryId());
497    
498                    return dlFileRankImpl;
499            }
500    
501            /**
502             * Returns the document library file rank with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
503             *
504             * @param primaryKey the primary key of the document library file rank
505             * @return the document library file rank
506             * @throws com.liferay.portal.NoSuchModelException if a document library file rank with the primary key could not be found
507             * @throws SystemException if a system exception occurred
508             */
509            @Override
510            public DLFileRank findByPrimaryKey(Serializable primaryKey)
511                    throws NoSuchModelException, SystemException {
512                    return findByPrimaryKey(((Long)primaryKey).longValue());
513            }
514    
515            /**
516             * Returns the document library file rank with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileRankException} if it could not be found.
517             *
518             * @param fileRankId the primary key of the document library file rank
519             * @return the document library file rank
520             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
521             * @throws SystemException if a system exception occurred
522             */
523            public DLFileRank findByPrimaryKey(long fileRankId)
524                    throws NoSuchFileRankException, SystemException {
525                    DLFileRank dlFileRank = fetchByPrimaryKey(fileRankId);
526    
527                    if (dlFileRank == null) {
528                            if (_log.isWarnEnabled()) {
529                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileRankId);
530                            }
531    
532                            throw new NoSuchFileRankException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
533                                    fileRankId);
534                    }
535    
536                    return dlFileRank;
537            }
538    
539            /**
540             * Returns the document library file rank with the primary key or returns <code>null</code> if it could not be found.
541             *
542             * @param primaryKey the primary key of the document library file rank
543             * @return the document library file rank, or <code>null</code> if a document library file rank with the primary key could not be found
544             * @throws SystemException if a system exception occurred
545             */
546            @Override
547            public DLFileRank fetchByPrimaryKey(Serializable primaryKey)
548                    throws SystemException {
549                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
550            }
551    
552            /**
553             * Returns the document library file rank with the primary key or returns <code>null</code> if it could not be found.
554             *
555             * @param fileRankId the primary key of the document library file rank
556             * @return the document library file rank, or <code>null</code> if a document library file rank with the primary key could not be found
557             * @throws SystemException if a system exception occurred
558             */
559            public DLFileRank fetchByPrimaryKey(long fileRankId)
560                    throws SystemException {
561                    DLFileRank dlFileRank = (DLFileRank)EntityCacheUtil.getResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
562                                    DLFileRankImpl.class, fileRankId);
563    
564                    if (dlFileRank == _nullDLFileRank) {
565                            return null;
566                    }
567    
568                    if (dlFileRank == null) {
569                            Session session = null;
570    
571                            boolean hasException = false;
572    
573                            try {
574                                    session = openSession();
575    
576                                    dlFileRank = (DLFileRank)session.get(DLFileRankImpl.class,
577                                                    Long.valueOf(fileRankId));
578                            }
579                            catch (Exception e) {
580                                    hasException = true;
581    
582                                    throw processException(e);
583                            }
584                            finally {
585                                    if (dlFileRank != null) {
586                                            cacheResult(dlFileRank);
587                                    }
588                                    else if (!hasException) {
589                                            EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
590                                                    DLFileRankImpl.class, fileRankId, _nullDLFileRank);
591                                    }
592    
593                                    closeSession(session);
594                            }
595                    }
596    
597                    return dlFileRank;
598            }
599    
600            /**
601             * Returns all the document library file ranks where userId = &#63;.
602             *
603             * @param userId the user ID
604             * @return the matching document library file ranks
605             * @throws SystemException if a system exception occurred
606             */
607            public List<DLFileRank> findByUserId(long userId) throws SystemException {
608                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
609            }
610    
611            /**
612             * Returns a range of all the document library file ranks where userId = &#63;.
613             *
614             * <p>
615             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
616             * </p>
617             *
618             * @param userId the user ID
619             * @param start the lower bound of the range of document library file ranks
620             * @param end the upper bound of the range of document library file ranks (not inclusive)
621             * @return the range of matching document library file ranks
622             * @throws SystemException if a system exception occurred
623             */
624            public List<DLFileRank> findByUserId(long userId, int start, int end)
625                    throws SystemException {
626                    return findByUserId(userId, start, end, null);
627            }
628    
629            /**
630             * Returns an ordered range of all the document library file ranks where userId = &#63;.
631             *
632             * <p>
633             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
634             * </p>
635             *
636             * @param userId the user ID
637             * @param start the lower bound of the range of document library file ranks
638             * @param end the upper bound of the range of document library file ranks (not inclusive)
639             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
640             * @return the ordered range of matching document library file ranks
641             * @throws SystemException if a system exception occurred
642             */
643            public List<DLFileRank> findByUserId(long userId, int start, int end,
644                    OrderByComparator orderByComparator) throws SystemException {
645                    FinderPath finderPath = null;
646                    Object[] finderArgs = null;
647    
648                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
649                                    (orderByComparator == null)) {
650                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
651                            finderArgs = new Object[] { userId };
652                    }
653                    else {
654                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
655                            finderArgs = new Object[] { userId, start, end, orderByComparator };
656                    }
657    
658                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
659                                    finderArgs, this);
660    
661                    if ((list != null) && !list.isEmpty()) {
662                            for (DLFileRank dlFileRank : list) {
663                                    if ((userId != dlFileRank.getUserId())) {
664                                            list = null;
665    
666                                            break;
667                                    }
668                            }
669                    }
670    
671                    if (list == null) {
672                            StringBundler query = null;
673    
674                            if (orderByComparator != null) {
675                                    query = new StringBundler(3 +
676                                                    (orderByComparator.getOrderByFields().length * 3));
677                            }
678                            else {
679                                    query = new StringBundler(3);
680                            }
681    
682                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
683    
684                            query.append(_FINDER_COLUMN_USERID_USERID_2);
685    
686                            if (orderByComparator != null) {
687                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
688                                            orderByComparator);
689                            }
690    
691                            else {
692                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
693                            }
694    
695                            String sql = query.toString();
696    
697                            Session session = null;
698    
699                            try {
700                                    session = openSession();
701    
702                                    Query q = session.createQuery(sql);
703    
704                                    QueryPos qPos = QueryPos.getInstance(q);
705    
706                                    qPos.add(userId);
707    
708                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
709                                                    end);
710                            }
711                            catch (Exception e) {
712                                    throw processException(e);
713                            }
714                            finally {
715                                    if (list == null) {
716                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
717                                    }
718                                    else {
719                                            cacheResult(list);
720    
721                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
722                                    }
723    
724                                    closeSession(session);
725                            }
726                    }
727    
728                    return list;
729            }
730    
731            /**
732             * Returns the first document library file rank in the ordered set where userId = &#63;.
733             *
734             * <p>
735             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
736             * </p>
737             *
738             * @param userId the user ID
739             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
740             * @return the first matching document library file rank
741             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
742             * @throws SystemException if a system exception occurred
743             */
744            public DLFileRank findByUserId_First(long userId,
745                    OrderByComparator orderByComparator)
746                    throws NoSuchFileRankException, SystemException {
747                    List<DLFileRank> list = findByUserId(userId, 0, 1, orderByComparator);
748    
749                    if (list.isEmpty()) {
750                            StringBundler msg = new StringBundler(4);
751    
752                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
753    
754                            msg.append("userId=");
755                            msg.append(userId);
756    
757                            msg.append(StringPool.CLOSE_CURLY_BRACE);
758    
759                            throw new NoSuchFileRankException(msg.toString());
760                    }
761                    else {
762                            return list.get(0);
763                    }
764            }
765    
766            /**
767             * Returns the last document library file rank in the ordered set where userId = &#63;.
768             *
769             * <p>
770             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
771             * </p>
772             *
773             * @param userId the user ID
774             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
775             * @return the last matching document library file rank
776             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
777             * @throws SystemException if a system exception occurred
778             */
779            public DLFileRank findByUserId_Last(long userId,
780                    OrderByComparator orderByComparator)
781                    throws NoSuchFileRankException, SystemException {
782                    int count = countByUserId(userId);
783    
784                    List<DLFileRank> list = findByUserId(userId, count - 1, count,
785                                    orderByComparator);
786    
787                    if (list.isEmpty()) {
788                            StringBundler msg = new StringBundler(4);
789    
790                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
791    
792                            msg.append("userId=");
793                            msg.append(userId);
794    
795                            msg.append(StringPool.CLOSE_CURLY_BRACE);
796    
797                            throw new NoSuchFileRankException(msg.toString());
798                    }
799                    else {
800                            return list.get(0);
801                    }
802            }
803    
804            /**
805             * Returns the document library file ranks before and after the current document library file rank in the ordered set where userId = &#63;.
806             *
807             * <p>
808             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
809             * </p>
810             *
811             * @param fileRankId the primary key of the current document library file rank
812             * @param userId the user ID
813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
814             * @return the previous, current, and next document library file rank
815             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
816             * @throws SystemException if a system exception occurred
817             */
818            public DLFileRank[] findByUserId_PrevAndNext(long fileRankId, long userId,
819                    OrderByComparator orderByComparator)
820                    throws NoSuchFileRankException, SystemException {
821                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
822    
823                    Session session = null;
824    
825                    try {
826                            session = openSession();
827    
828                            DLFileRank[] array = new DLFileRankImpl[3];
829    
830                            array[0] = getByUserId_PrevAndNext(session, dlFileRank, userId,
831                                            orderByComparator, true);
832    
833                            array[1] = dlFileRank;
834    
835                            array[2] = getByUserId_PrevAndNext(session, dlFileRank, userId,
836                                            orderByComparator, false);
837    
838                            return array;
839                    }
840                    catch (Exception e) {
841                            throw processException(e);
842                    }
843                    finally {
844                            closeSession(session);
845                    }
846            }
847    
848            protected DLFileRank getByUserId_PrevAndNext(Session session,
849                    DLFileRank dlFileRank, long userId,
850                    OrderByComparator orderByComparator, boolean previous) {
851                    StringBundler query = null;
852    
853                    if (orderByComparator != null) {
854                            query = new StringBundler(6 +
855                                            (orderByComparator.getOrderByFields().length * 6));
856                    }
857                    else {
858                            query = new StringBundler(3);
859                    }
860    
861                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
862    
863                    query.append(_FINDER_COLUMN_USERID_USERID_2);
864    
865                    if (orderByComparator != null) {
866                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
867    
868                            if (orderByConditionFields.length > 0) {
869                                    query.append(WHERE_AND);
870                            }
871    
872                            for (int i = 0; i < orderByConditionFields.length; i++) {
873                                    query.append(_ORDER_BY_ENTITY_ALIAS);
874                                    query.append(orderByConditionFields[i]);
875    
876                                    if ((i + 1) < orderByConditionFields.length) {
877                                            if (orderByComparator.isAscending() ^ previous) {
878                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
879                                            }
880                                            else {
881                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
882                                            }
883                                    }
884                                    else {
885                                            if (orderByComparator.isAscending() ^ previous) {
886                                                    query.append(WHERE_GREATER_THAN);
887                                            }
888                                            else {
889                                                    query.append(WHERE_LESSER_THAN);
890                                            }
891                                    }
892                            }
893    
894                            query.append(ORDER_BY_CLAUSE);
895    
896                            String[] orderByFields = orderByComparator.getOrderByFields();
897    
898                            for (int i = 0; i < orderByFields.length; i++) {
899                                    query.append(_ORDER_BY_ENTITY_ALIAS);
900                                    query.append(orderByFields[i]);
901    
902                                    if ((i + 1) < orderByFields.length) {
903                                            if (orderByComparator.isAscending() ^ previous) {
904                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
905                                            }
906                                            else {
907                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
908                                            }
909                                    }
910                                    else {
911                                            if (orderByComparator.isAscending() ^ previous) {
912                                                    query.append(ORDER_BY_ASC);
913                                            }
914                                            else {
915                                                    query.append(ORDER_BY_DESC);
916                                            }
917                                    }
918                            }
919                    }
920    
921                    else {
922                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
923                    }
924    
925                    String sql = query.toString();
926    
927                    Query q = session.createQuery(sql);
928    
929                    q.setFirstResult(0);
930                    q.setMaxResults(2);
931    
932                    QueryPos qPos = QueryPos.getInstance(q);
933    
934                    qPos.add(userId);
935    
936                    if (orderByComparator != null) {
937                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
938    
939                            for (Object value : values) {
940                                    qPos.add(value);
941                            }
942                    }
943    
944                    List<DLFileRank> list = q.list();
945    
946                    if (list.size() == 2) {
947                            return list.get(1);
948                    }
949                    else {
950                            return null;
951                    }
952            }
953    
954            /**
955             * Returns all the document library file ranks where fileEntryId = &#63;.
956             *
957             * @param fileEntryId the file entry ID
958             * @return the matching document library file ranks
959             * @throws SystemException if a system exception occurred
960             */
961            public List<DLFileRank> findByFileEntryId(long fileEntryId)
962                    throws SystemException {
963                    return findByFileEntryId(fileEntryId, QueryUtil.ALL_POS,
964                            QueryUtil.ALL_POS, null);
965            }
966    
967            /**
968             * Returns a range of all the document library file ranks where fileEntryId = &#63;.
969             *
970             * <p>
971             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
972             * </p>
973             *
974             * @param fileEntryId the file entry ID
975             * @param start the lower bound of the range of document library file ranks
976             * @param end the upper bound of the range of document library file ranks (not inclusive)
977             * @return the range of matching document library file ranks
978             * @throws SystemException if a system exception occurred
979             */
980            public List<DLFileRank> findByFileEntryId(long fileEntryId, int start,
981                    int end) throws SystemException {
982                    return findByFileEntryId(fileEntryId, start, end, null);
983            }
984    
985            /**
986             * Returns an ordered range of all the document library file ranks where fileEntryId = &#63;.
987             *
988             * <p>
989             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
990             * </p>
991             *
992             * @param fileEntryId the file entry ID
993             * @param start the lower bound of the range of document library file ranks
994             * @param end the upper bound of the range of document library file ranks (not inclusive)
995             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
996             * @return the ordered range of matching document library file ranks
997             * @throws SystemException if a system exception occurred
998             */
999            public List<DLFileRank> findByFileEntryId(long fileEntryId, int start,
1000                    int end, OrderByComparator orderByComparator) throws SystemException {
1001                    FinderPath finderPath = null;
1002                    Object[] finderArgs = null;
1003    
1004                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1005                                    (orderByComparator == null)) {
1006                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID;
1007                            finderArgs = new Object[] { fileEntryId };
1008                    }
1009                    else {
1010                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID;
1011                            finderArgs = new Object[] { fileEntryId, start, end, orderByComparator };
1012                    }
1013    
1014                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
1015                                    finderArgs, this);
1016    
1017                    if ((list != null) && !list.isEmpty()) {
1018                            for (DLFileRank dlFileRank : list) {
1019                                    if ((fileEntryId != dlFileRank.getFileEntryId())) {
1020                                            list = null;
1021    
1022                                            break;
1023                                    }
1024                            }
1025                    }
1026    
1027                    if (list == null) {
1028                            StringBundler query = null;
1029    
1030                            if (orderByComparator != null) {
1031                                    query = new StringBundler(3 +
1032                                                    (orderByComparator.getOrderByFields().length * 3));
1033                            }
1034                            else {
1035                                    query = new StringBundler(3);
1036                            }
1037    
1038                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
1039    
1040                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1041    
1042                            if (orderByComparator != null) {
1043                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1044                                            orderByComparator);
1045                            }
1046    
1047                            else {
1048                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1049                            }
1050    
1051                            String sql = query.toString();
1052    
1053                            Session session = null;
1054    
1055                            try {
1056                                    session = openSession();
1057    
1058                                    Query q = session.createQuery(sql);
1059    
1060                                    QueryPos qPos = QueryPos.getInstance(q);
1061    
1062                                    qPos.add(fileEntryId);
1063    
1064                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
1065                                                    end);
1066                            }
1067                            catch (Exception e) {
1068                                    throw processException(e);
1069                            }
1070                            finally {
1071                                    if (list == null) {
1072                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1073                                    }
1074                                    else {
1075                                            cacheResult(list);
1076    
1077                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1078                                    }
1079    
1080                                    closeSession(session);
1081                            }
1082                    }
1083    
1084                    return list;
1085            }
1086    
1087            /**
1088             * Returns the first document library file rank in the ordered set where fileEntryId = &#63;.
1089             *
1090             * <p>
1091             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1092             * </p>
1093             *
1094             * @param fileEntryId the file entry ID
1095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1096             * @return the first matching document library file rank
1097             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1098             * @throws SystemException if a system exception occurred
1099             */
1100            public DLFileRank findByFileEntryId_First(long fileEntryId,
1101                    OrderByComparator orderByComparator)
1102                    throws NoSuchFileRankException, SystemException {
1103                    List<DLFileRank> list = findByFileEntryId(fileEntryId, 0, 1,
1104                                    orderByComparator);
1105    
1106                    if (list.isEmpty()) {
1107                            StringBundler msg = new StringBundler(4);
1108    
1109                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1110    
1111                            msg.append("fileEntryId=");
1112                            msg.append(fileEntryId);
1113    
1114                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1115    
1116                            throw new NoSuchFileRankException(msg.toString());
1117                    }
1118                    else {
1119                            return list.get(0);
1120                    }
1121            }
1122    
1123            /**
1124             * Returns the last document library file rank in the ordered set where fileEntryId = &#63;.
1125             *
1126             * <p>
1127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1128             * </p>
1129             *
1130             * @param fileEntryId the file entry ID
1131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1132             * @return the last matching document library file rank
1133             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1134             * @throws SystemException if a system exception occurred
1135             */
1136            public DLFileRank findByFileEntryId_Last(long fileEntryId,
1137                    OrderByComparator orderByComparator)
1138                    throws NoSuchFileRankException, SystemException {
1139                    int count = countByFileEntryId(fileEntryId);
1140    
1141                    List<DLFileRank> list = findByFileEntryId(fileEntryId, count - 1,
1142                                    count, orderByComparator);
1143    
1144                    if (list.isEmpty()) {
1145                            StringBundler msg = new StringBundler(4);
1146    
1147                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1148    
1149                            msg.append("fileEntryId=");
1150                            msg.append(fileEntryId);
1151    
1152                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1153    
1154                            throw new NoSuchFileRankException(msg.toString());
1155                    }
1156                    else {
1157                            return list.get(0);
1158                    }
1159            }
1160    
1161            /**
1162             * Returns the document library file ranks before and after the current document library file rank in the ordered set where fileEntryId = &#63;.
1163             *
1164             * <p>
1165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1166             * </p>
1167             *
1168             * @param fileRankId the primary key of the current document library file rank
1169             * @param fileEntryId the file entry ID
1170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1171             * @return the previous, current, and next document library file rank
1172             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
1173             * @throws SystemException if a system exception occurred
1174             */
1175            public DLFileRank[] findByFileEntryId_PrevAndNext(long fileRankId,
1176                    long fileEntryId, OrderByComparator orderByComparator)
1177                    throws NoSuchFileRankException, SystemException {
1178                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
1179    
1180                    Session session = null;
1181    
1182                    try {
1183                            session = openSession();
1184    
1185                            DLFileRank[] array = new DLFileRankImpl[3];
1186    
1187                            array[0] = getByFileEntryId_PrevAndNext(session, dlFileRank,
1188                                            fileEntryId, orderByComparator, true);
1189    
1190                            array[1] = dlFileRank;
1191    
1192                            array[2] = getByFileEntryId_PrevAndNext(session, dlFileRank,
1193                                            fileEntryId, orderByComparator, false);
1194    
1195                            return array;
1196                    }
1197                    catch (Exception e) {
1198                            throw processException(e);
1199                    }
1200                    finally {
1201                            closeSession(session);
1202                    }
1203            }
1204    
1205            protected DLFileRank getByFileEntryId_PrevAndNext(Session session,
1206                    DLFileRank dlFileRank, long fileEntryId,
1207                    OrderByComparator orderByComparator, boolean previous) {
1208                    StringBundler query = null;
1209    
1210                    if (orderByComparator != null) {
1211                            query = new StringBundler(6 +
1212                                            (orderByComparator.getOrderByFields().length * 6));
1213                    }
1214                    else {
1215                            query = new StringBundler(3);
1216                    }
1217    
1218                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
1219    
1220                    query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1221    
1222                    if (orderByComparator != null) {
1223                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1224    
1225                            if (orderByConditionFields.length > 0) {
1226                                    query.append(WHERE_AND);
1227                            }
1228    
1229                            for (int i = 0; i < orderByConditionFields.length; i++) {
1230                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1231                                    query.append(orderByConditionFields[i]);
1232    
1233                                    if ((i + 1) < orderByConditionFields.length) {
1234                                            if (orderByComparator.isAscending() ^ previous) {
1235                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1236                                            }
1237                                            else {
1238                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1239                                            }
1240                                    }
1241                                    else {
1242                                            if (orderByComparator.isAscending() ^ previous) {
1243                                                    query.append(WHERE_GREATER_THAN);
1244                                            }
1245                                            else {
1246                                                    query.append(WHERE_LESSER_THAN);
1247                                            }
1248                                    }
1249                            }
1250    
1251                            query.append(ORDER_BY_CLAUSE);
1252    
1253                            String[] orderByFields = orderByComparator.getOrderByFields();
1254    
1255                            for (int i = 0; i < orderByFields.length; i++) {
1256                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1257                                    query.append(orderByFields[i]);
1258    
1259                                    if ((i + 1) < orderByFields.length) {
1260                                            if (orderByComparator.isAscending() ^ previous) {
1261                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1262                                            }
1263                                            else {
1264                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1265                                            }
1266                                    }
1267                                    else {
1268                                            if (orderByComparator.isAscending() ^ previous) {
1269                                                    query.append(ORDER_BY_ASC);
1270                                            }
1271                                            else {
1272                                                    query.append(ORDER_BY_DESC);
1273                                            }
1274                                    }
1275                            }
1276                    }
1277    
1278                    else {
1279                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1280                    }
1281    
1282                    String sql = query.toString();
1283    
1284                    Query q = session.createQuery(sql);
1285    
1286                    q.setFirstResult(0);
1287                    q.setMaxResults(2);
1288    
1289                    QueryPos qPos = QueryPos.getInstance(q);
1290    
1291                    qPos.add(fileEntryId);
1292    
1293                    if (orderByComparator != null) {
1294                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
1295    
1296                            for (Object value : values) {
1297                                    qPos.add(value);
1298                            }
1299                    }
1300    
1301                    List<DLFileRank> list = q.list();
1302    
1303                    if (list.size() == 2) {
1304                            return list.get(1);
1305                    }
1306                    else {
1307                            return null;
1308                    }
1309            }
1310    
1311            /**
1312             * Returns all the document library file ranks where groupId = &#63; and userId = &#63;.
1313             *
1314             * @param groupId the group ID
1315             * @param userId the user ID
1316             * @return the matching document library file ranks
1317             * @throws SystemException if a system exception occurred
1318             */
1319            public List<DLFileRank> findByG_U(long groupId, long userId)
1320                    throws SystemException {
1321                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1322                            null);
1323            }
1324    
1325            /**
1326             * Returns a range of all the document library file ranks where groupId = &#63; and userId = &#63;.
1327             *
1328             * <p>
1329             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1330             * </p>
1331             *
1332             * @param groupId the group ID
1333             * @param userId the user ID
1334             * @param start the lower bound of the range of document library file ranks
1335             * @param end the upper bound of the range of document library file ranks (not inclusive)
1336             * @return the range of matching document library file ranks
1337             * @throws SystemException if a system exception occurred
1338             */
1339            public List<DLFileRank> findByG_U(long groupId, long userId, int start,
1340                    int end) throws SystemException {
1341                    return findByG_U(groupId, userId, start, end, null);
1342            }
1343    
1344            /**
1345             * Returns an ordered range of all the document library file ranks where groupId = &#63; and userId = &#63;.
1346             *
1347             * <p>
1348             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1349             * </p>
1350             *
1351             * @param groupId the group ID
1352             * @param userId the user ID
1353             * @param start the lower bound of the range of document library file ranks
1354             * @param end the upper bound of the range of document library file ranks (not inclusive)
1355             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1356             * @return the ordered range of matching document library file ranks
1357             * @throws SystemException if a system exception occurred
1358             */
1359            public List<DLFileRank> findByG_U(long groupId, long userId, int start,
1360                    int end, OrderByComparator orderByComparator) throws SystemException {
1361                    FinderPath finderPath = null;
1362                    Object[] finderArgs = null;
1363    
1364                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1365                                    (orderByComparator == null)) {
1366                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
1367                            finderArgs = new Object[] { groupId, userId };
1368                    }
1369                    else {
1370                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
1371                            finderArgs = new Object[] {
1372                                            groupId, userId,
1373                                            
1374                                            start, end, orderByComparator
1375                                    };
1376                    }
1377    
1378                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
1379                                    finderArgs, this);
1380    
1381                    if ((list != null) && !list.isEmpty()) {
1382                            for (DLFileRank dlFileRank : list) {
1383                                    if ((groupId != dlFileRank.getGroupId()) ||
1384                                                    (userId != dlFileRank.getUserId())) {
1385                                            list = null;
1386    
1387                                            break;
1388                                    }
1389                            }
1390                    }
1391    
1392                    if (list == null) {
1393                            StringBundler query = null;
1394    
1395                            if (orderByComparator != null) {
1396                                    query = new StringBundler(4 +
1397                                                    (orderByComparator.getOrderByFields().length * 3));
1398                            }
1399                            else {
1400                                    query = new StringBundler(4);
1401                            }
1402    
1403                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
1404    
1405                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1406    
1407                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1408    
1409                            if (orderByComparator != null) {
1410                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1411                                            orderByComparator);
1412                            }
1413    
1414                            else {
1415                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1416                            }
1417    
1418                            String sql = query.toString();
1419    
1420                            Session session = null;
1421    
1422                            try {
1423                                    session = openSession();
1424    
1425                                    Query q = session.createQuery(sql);
1426    
1427                                    QueryPos qPos = QueryPos.getInstance(q);
1428    
1429                                    qPos.add(groupId);
1430    
1431                                    qPos.add(userId);
1432    
1433                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
1434                                                    end);
1435                            }
1436                            catch (Exception e) {
1437                                    throw processException(e);
1438                            }
1439                            finally {
1440                                    if (list == null) {
1441                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1442                                    }
1443                                    else {
1444                                            cacheResult(list);
1445    
1446                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1447                                    }
1448    
1449                                    closeSession(session);
1450                            }
1451                    }
1452    
1453                    return list;
1454            }
1455    
1456            /**
1457             * Returns the first document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1458             *
1459             * <p>
1460             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1461             * </p>
1462             *
1463             * @param groupId the group ID
1464             * @param userId the user ID
1465             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1466             * @return the first matching document library file rank
1467             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1468             * @throws SystemException if a system exception occurred
1469             */
1470            public DLFileRank findByG_U_First(long groupId, long userId,
1471                    OrderByComparator orderByComparator)
1472                    throws NoSuchFileRankException, SystemException {
1473                    List<DLFileRank> list = findByG_U(groupId, userId, 0, 1,
1474                                    orderByComparator);
1475    
1476                    if (list.isEmpty()) {
1477                            StringBundler msg = new StringBundler(6);
1478    
1479                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1480    
1481                            msg.append("groupId=");
1482                            msg.append(groupId);
1483    
1484                            msg.append(", userId=");
1485                            msg.append(userId);
1486    
1487                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1488    
1489                            throw new NoSuchFileRankException(msg.toString());
1490                    }
1491                    else {
1492                            return list.get(0);
1493                    }
1494            }
1495    
1496            /**
1497             * Returns the last document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1498             *
1499             * <p>
1500             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1501             * </p>
1502             *
1503             * @param groupId the group ID
1504             * @param userId the user ID
1505             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1506             * @return the last matching document library file rank
1507             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1508             * @throws SystemException if a system exception occurred
1509             */
1510            public DLFileRank findByG_U_Last(long groupId, long userId,
1511                    OrderByComparator orderByComparator)
1512                    throws NoSuchFileRankException, SystemException {
1513                    int count = countByG_U(groupId, userId);
1514    
1515                    List<DLFileRank> list = findByG_U(groupId, userId, count - 1, count,
1516                                    orderByComparator);
1517    
1518                    if (list.isEmpty()) {
1519                            StringBundler msg = new StringBundler(6);
1520    
1521                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1522    
1523                            msg.append("groupId=");
1524                            msg.append(groupId);
1525    
1526                            msg.append(", userId=");
1527                            msg.append(userId);
1528    
1529                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1530    
1531                            throw new NoSuchFileRankException(msg.toString());
1532                    }
1533                    else {
1534                            return list.get(0);
1535                    }
1536            }
1537    
1538            /**
1539             * Returns the document library file ranks before and after the current document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1540             *
1541             * <p>
1542             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1543             * </p>
1544             *
1545             * @param fileRankId the primary key of the current document library file rank
1546             * @param groupId the group ID
1547             * @param userId the user ID
1548             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1549             * @return the previous, current, and next document library file rank
1550             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
1551             * @throws SystemException if a system exception occurred
1552             */
1553            public DLFileRank[] findByG_U_PrevAndNext(long fileRankId, long groupId,
1554                    long userId, OrderByComparator orderByComparator)
1555                    throws NoSuchFileRankException, SystemException {
1556                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
1557    
1558                    Session session = null;
1559    
1560                    try {
1561                            session = openSession();
1562    
1563                            DLFileRank[] array = new DLFileRankImpl[3];
1564    
1565                            array[0] = getByG_U_PrevAndNext(session, dlFileRank, groupId,
1566                                            userId, orderByComparator, true);
1567    
1568                            array[1] = dlFileRank;
1569    
1570                            array[2] = getByG_U_PrevAndNext(session, dlFileRank, groupId,
1571                                            userId, orderByComparator, false);
1572    
1573                            return array;
1574                    }
1575                    catch (Exception e) {
1576                            throw processException(e);
1577                    }
1578                    finally {
1579                            closeSession(session);
1580                    }
1581            }
1582    
1583            protected DLFileRank getByG_U_PrevAndNext(Session session,
1584                    DLFileRank dlFileRank, long groupId, long userId,
1585                    OrderByComparator orderByComparator, boolean previous) {
1586                    StringBundler query = null;
1587    
1588                    if (orderByComparator != null) {
1589                            query = new StringBundler(6 +
1590                                            (orderByComparator.getOrderByFields().length * 6));
1591                    }
1592                    else {
1593                            query = new StringBundler(3);
1594                    }
1595    
1596                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
1597    
1598                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1599    
1600                    query.append(_FINDER_COLUMN_G_U_USERID_2);
1601    
1602                    if (orderByComparator != null) {
1603                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1604    
1605                            if (orderByConditionFields.length > 0) {
1606                                    query.append(WHERE_AND);
1607                            }
1608    
1609                            for (int i = 0; i < orderByConditionFields.length; i++) {
1610                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1611                                    query.append(orderByConditionFields[i]);
1612    
1613                                    if ((i + 1) < orderByConditionFields.length) {
1614                                            if (orderByComparator.isAscending() ^ previous) {
1615                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1616                                            }
1617                                            else {
1618                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1619                                            }
1620                                    }
1621                                    else {
1622                                            if (orderByComparator.isAscending() ^ previous) {
1623                                                    query.append(WHERE_GREATER_THAN);
1624                                            }
1625                                            else {
1626                                                    query.append(WHERE_LESSER_THAN);
1627                                            }
1628                                    }
1629                            }
1630    
1631                            query.append(ORDER_BY_CLAUSE);
1632    
1633                            String[] orderByFields = orderByComparator.getOrderByFields();
1634    
1635                            for (int i = 0; i < orderByFields.length; i++) {
1636                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1637                                    query.append(orderByFields[i]);
1638    
1639                                    if ((i + 1) < orderByFields.length) {
1640                                            if (orderByComparator.isAscending() ^ previous) {
1641                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1642                                            }
1643                                            else {
1644                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1645                                            }
1646                                    }
1647                                    else {
1648                                            if (orderByComparator.isAscending() ^ previous) {
1649                                                    query.append(ORDER_BY_ASC);
1650                                            }
1651                                            else {
1652                                                    query.append(ORDER_BY_DESC);
1653                                            }
1654                                    }
1655                            }
1656                    }
1657    
1658                    else {
1659                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1660                    }
1661    
1662                    String sql = query.toString();
1663    
1664                    Query q = session.createQuery(sql);
1665    
1666                    q.setFirstResult(0);
1667                    q.setMaxResults(2);
1668    
1669                    QueryPos qPos = QueryPos.getInstance(q);
1670    
1671                    qPos.add(groupId);
1672    
1673                    qPos.add(userId);
1674    
1675                    if (orderByComparator != null) {
1676                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
1677    
1678                            for (Object value : values) {
1679                                    qPos.add(value);
1680                            }
1681                    }
1682    
1683                    List<DLFileRank> list = q.list();
1684    
1685                    if (list.size() == 2) {
1686                            return list.get(1);
1687                    }
1688                    else {
1689                            return null;
1690                    }
1691            }
1692    
1693            /**
1694             * Returns the document library file rank where companyId = &#63; and userId = &#63; and fileEntryId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileRankException} if it could not be found.
1695             *
1696             * @param companyId the company ID
1697             * @param userId the user ID
1698             * @param fileEntryId the file entry ID
1699             * @return the matching document library file rank
1700             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1701             * @throws SystemException if a system exception occurred
1702             */
1703            public DLFileRank findByC_U_F(long companyId, long userId, long fileEntryId)
1704                    throws NoSuchFileRankException, SystemException {
1705                    DLFileRank dlFileRank = fetchByC_U_F(companyId, userId, fileEntryId);
1706    
1707                    if (dlFileRank == null) {
1708                            StringBundler msg = new StringBundler(8);
1709    
1710                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1711    
1712                            msg.append("companyId=");
1713                            msg.append(companyId);
1714    
1715                            msg.append(", userId=");
1716                            msg.append(userId);
1717    
1718                            msg.append(", fileEntryId=");
1719                            msg.append(fileEntryId);
1720    
1721                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1722    
1723                            if (_log.isWarnEnabled()) {
1724                                    _log.warn(msg.toString());
1725                            }
1726    
1727                            throw new NoSuchFileRankException(msg.toString());
1728                    }
1729    
1730                    return dlFileRank;
1731            }
1732    
1733            /**
1734             * Returns the document library file rank where companyId = &#63; and userId = &#63; and fileEntryId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1735             *
1736             * @param companyId the company ID
1737             * @param userId the user ID
1738             * @param fileEntryId the file entry ID
1739             * @return the matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1740             * @throws SystemException if a system exception occurred
1741             */
1742            public DLFileRank fetchByC_U_F(long companyId, long userId, long fileEntryId)
1743                    throws SystemException {
1744                    return fetchByC_U_F(companyId, userId, fileEntryId, true);
1745            }
1746    
1747            /**
1748             * Returns the document library file rank where companyId = &#63; and userId = &#63; and fileEntryId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1749             *
1750             * @param companyId the company ID
1751             * @param userId the user ID
1752             * @param fileEntryId the file entry ID
1753             * @param retrieveFromCache whether to use the finder cache
1754             * @return the matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1755             * @throws SystemException if a system exception occurred
1756             */
1757            public DLFileRank fetchByC_U_F(long companyId, long userId,
1758                    long fileEntryId, boolean retrieveFromCache) throws SystemException {
1759                    Object[] finderArgs = new Object[] { companyId, userId, fileEntryId };
1760    
1761                    Object result = null;
1762    
1763                    if (retrieveFromCache) {
1764                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U_F,
1765                                            finderArgs, this);
1766                    }
1767    
1768                    if (result instanceof DLFileRank) {
1769                            DLFileRank dlFileRank = (DLFileRank)result;
1770    
1771                            if ((companyId != dlFileRank.getCompanyId()) ||
1772                                            (userId != dlFileRank.getUserId()) ||
1773                                            (fileEntryId != dlFileRank.getFileEntryId())) {
1774                                    result = null;
1775                            }
1776                    }
1777    
1778                    if (result == null) {
1779                            StringBundler query = new StringBundler(5);
1780    
1781                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
1782    
1783                            query.append(_FINDER_COLUMN_C_U_F_COMPANYID_2);
1784    
1785                            query.append(_FINDER_COLUMN_C_U_F_USERID_2);
1786    
1787                            query.append(_FINDER_COLUMN_C_U_F_FILEENTRYID_2);
1788    
1789                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1790    
1791                            String sql = query.toString();
1792    
1793                            Session session = null;
1794    
1795                            try {
1796                                    session = openSession();
1797    
1798                                    Query q = session.createQuery(sql);
1799    
1800                                    QueryPos qPos = QueryPos.getInstance(q);
1801    
1802                                    qPos.add(companyId);
1803    
1804                                    qPos.add(userId);
1805    
1806                                    qPos.add(fileEntryId);
1807    
1808                                    List<DLFileRank> list = q.list();
1809    
1810                                    result = list;
1811    
1812                                    DLFileRank dlFileRank = null;
1813    
1814                                    if (list.isEmpty()) {
1815                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
1816                                                    finderArgs, list);
1817                                    }
1818                                    else {
1819                                            dlFileRank = list.get(0);
1820    
1821                                            cacheResult(dlFileRank);
1822    
1823                                            if ((dlFileRank.getCompanyId() != companyId) ||
1824                                                            (dlFileRank.getUserId() != userId) ||
1825                                                            (dlFileRank.getFileEntryId() != fileEntryId)) {
1826                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
1827                                                            finderArgs, dlFileRank);
1828                                            }
1829                                    }
1830    
1831                                    return dlFileRank;
1832                            }
1833                            catch (Exception e) {
1834                                    throw processException(e);
1835                            }
1836                            finally {
1837                                    if (result == null) {
1838                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F,
1839                                                    finderArgs);
1840                                    }
1841    
1842                                    closeSession(session);
1843                            }
1844                    }
1845                    else {
1846                            if (result instanceof List<?>) {
1847                                    return null;
1848                            }
1849                            else {
1850                                    return (DLFileRank)result;
1851                            }
1852                    }
1853            }
1854    
1855            /**
1856             * Returns all the document library file ranks.
1857             *
1858             * @return the document library file ranks
1859             * @throws SystemException if a system exception occurred
1860             */
1861            public List<DLFileRank> findAll() throws SystemException {
1862                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1863            }
1864    
1865            /**
1866             * Returns a range of all the document library file ranks.
1867             *
1868             * <p>
1869             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1870             * </p>
1871             *
1872             * @param start the lower bound of the range of document library file ranks
1873             * @param end the upper bound of the range of document library file ranks (not inclusive)
1874             * @return the range of document library file ranks
1875             * @throws SystemException if a system exception occurred
1876             */
1877            public List<DLFileRank> findAll(int start, int end)
1878                    throws SystemException {
1879                    return findAll(start, end, null);
1880            }
1881    
1882            /**
1883             * Returns an ordered range of all the document library file ranks.
1884             *
1885             * <p>
1886             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1887             * </p>
1888             *
1889             * @param start the lower bound of the range of document library file ranks
1890             * @param end the upper bound of the range of document library file ranks (not inclusive)
1891             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1892             * @return the ordered range of document library file ranks
1893             * @throws SystemException if a system exception occurred
1894             */
1895            public List<DLFileRank> findAll(int start, int end,
1896                    OrderByComparator orderByComparator) throws SystemException {
1897                    FinderPath finderPath = null;
1898                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1899    
1900                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1901                                    (orderByComparator == null)) {
1902                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1903                            finderArgs = FINDER_ARGS_EMPTY;
1904                    }
1905                    else {
1906                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1907                            finderArgs = new Object[] { start, end, orderByComparator };
1908                    }
1909    
1910                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
1911                                    finderArgs, this);
1912    
1913                    if (list == null) {
1914                            StringBundler query = null;
1915                            String sql = null;
1916    
1917                            if (orderByComparator != null) {
1918                                    query = new StringBundler(2 +
1919                                                    (orderByComparator.getOrderByFields().length * 3));
1920    
1921                                    query.append(_SQL_SELECT_DLFILERANK);
1922    
1923                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1924                                            orderByComparator);
1925    
1926                                    sql = query.toString();
1927                            }
1928                            else {
1929                                    sql = _SQL_SELECT_DLFILERANK.concat(DLFileRankModelImpl.ORDER_BY_JPQL);
1930                            }
1931    
1932                            Session session = null;
1933    
1934                            try {
1935                                    session = openSession();
1936    
1937                                    Query q = session.createQuery(sql);
1938    
1939                                    if (orderByComparator == null) {
1940                                            list = (List<DLFileRank>)QueryUtil.list(q, getDialect(),
1941                                                            start, end, false);
1942    
1943                                            Collections.sort(list);
1944                                    }
1945                                    else {
1946                                            list = (List<DLFileRank>)QueryUtil.list(q, getDialect(),
1947                                                            start, end);
1948                                    }
1949                            }
1950                            catch (Exception e) {
1951                                    throw processException(e);
1952                            }
1953                            finally {
1954                                    if (list == null) {
1955                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1956                                    }
1957                                    else {
1958                                            cacheResult(list);
1959    
1960                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1961                                    }
1962    
1963                                    closeSession(session);
1964                            }
1965                    }
1966    
1967                    return list;
1968            }
1969    
1970            /**
1971             * Removes all the document library file ranks where userId = &#63; from the database.
1972             *
1973             * @param userId the user ID
1974             * @throws SystemException if a system exception occurred
1975             */
1976            public void removeByUserId(long userId) throws SystemException {
1977                    for (DLFileRank dlFileRank : findByUserId(userId)) {
1978                            remove(dlFileRank);
1979                    }
1980            }
1981    
1982            /**
1983             * Removes all the document library file ranks where fileEntryId = &#63; from the database.
1984             *
1985             * @param fileEntryId the file entry ID
1986             * @throws SystemException if a system exception occurred
1987             */
1988            public void removeByFileEntryId(long fileEntryId) throws SystemException {
1989                    for (DLFileRank dlFileRank : findByFileEntryId(fileEntryId)) {
1990                            remove(dlFileRank);
1991                    }
1992            }
1993    
1994            /**
1995             * Removes all the document library file ranks where groupId = &#63; and userId = &#63; from the database.
1996             *
1997             * @param groupId the group ID
1998             * @param userId the user ID
1999             * @throws SystemException if a system exception occurred
2000             */
2001            public void removeByG_U(long groupId, long userId)
2002                    throws SystemException {
2003                    for (DLFileRank dlFileRank : findByG_U(groupId, userId)) {
2004                            remove(dlFileRank);
2005                    }
2006            }
2007    
2008            /**
2009             * Removes the document library file rank where companyId = &#63; and userId = &#63; and fileEntryId = &#63; from the database.
2010             *
2011             * @param companyId the company ID
2012             * @param userId the user ID
2013             * @param fileEntryId the file entry ID
2014             * @throws SystemException if a system exception occurred
2015             */
2016            public void removeByC_U_F(long companyId, long userId, long fileEntryId)
2017                    throws NoSuchFileRankException, SystemException {
2018                    DLFileRank dlFileRank = findByC_U_F(companyId, userId, fileEntryId);
2019    
2020                    remove(dlFileRank);
2021            }
2022    
2023            /**
2024             * Removes all the document library file ranks from the database.
2025             *
2026             * @throws SystemException if a system exception occurred
2027             */
2028            public void removeAll() throws SystemException {
2029                    for (DLFileRank dlFileRank : findAll()) {
2030                            remove(dlFileRank);
2031                    }
2032            }
2033    
2034            /**
2035             * Returns the number of document library file ranks where userId = &#63;.
2036             *
2037             * @param userId the user ID
2038             * @return the number of matching document library file ranks
2039             * @throws SystemException if a system exception occurred
2040             */
2041            public int countByUserId(long userId) throws SystemException {
2042                    Object[] finderArgs = new Object[] { userId };
2043    
2044                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2045                                    finderArgs, this);
2046    
2047                    if (count == null) {
2048                            StringBundler query = new StringBundler(2);
2049    
2050                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2051    
2052                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2053    
2054                            String sql = query.toString();
2055    
2056                            Session session = null;
2057    
2058                            try {
2059                                    session = openSession();
2060    
2061                                    Query q = session.createQuery(sql);
2062    
2063                                    QueryPos qPos = QueryPos.getInstance(q);
2064    
2065                                    qPos.add(userId);
2066    
2067                                    count = (Long)q.uniqueResult();
2068                            }
2069                            catch (Exception e) {
2070                                    throw processException(e);
2071                            }
2072                            finally {
2073                                    if (count == null) {
2074                                            count = Long.valueOf(0);
2075                                    }
2076    
2077                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2078                                            finderArgs, count);
2079    
2080                                    closeSession(session);
2081                            }
2082                    }
2083    
2084                    return count.intValue();
2085            }
2086    
2087            /**
2088             * Returns the number of document library file ranks where fileEntryId = &#63;.
2089             *
2090             * @param fileEntryId the file entry ID
2091             * @return the number of matching document library file ranks
2092             * @throws SystemException if a system exception occurred
2093             */
2094            public int countByFileEntryId(long fileEntryId) throws SystemException {
2095                    Object[] finderArgs = new Object[] { fileEntryId };
2096    
2097                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2098                                    finderArgs, this);
2099    
2100                    if (count == null) {
2101                            StringBundler query = new StringBundler(2);
2102    
2103                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2104    
2105                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
2106    
2107                            String sql = query.toString();
2108    
2109                            Session session = null;
2110    
2111                            try {
2112                                    session = openSession();
2113    
2114                                    Query q = session.createQuery(sql);
2115    
2116                                    QueryPos qPos = QueryPos.getInstance(q);
2117    
2118                                    qPos.add(fileEntryId);
2119    
2120                                    count = (Long)q.uniqueResult();
2121                            }
2122                            catch (Exception e) {
2123                                    throw processException(e);
2124                            }
2125                            finally {
2126                                    if (count == null) {
2127                                            count = Long.valueOf(0);
2128                                    }
2129    
2130                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2131                                            finderArgs, count);
2132    
2133                                    closeSession(session);
2134                            }
2135                    }
2136    
2137                    return count.intValue();
2138            }
2139    
2140            /**
2141             * Returns the number of document library file ranks where groupId = &#63; and userId = &#63;.
2142             *
2143             * @param groupId the group ID
2144             * @param userId the user ID
2145             * @return the number of matching document library file ranks
2146             * @throws SystemException if a system exception occurred
2147             */
2148            public int countByG_U(long groupId, long userId) throws SystemException {
2149                    Object[] finderArgs = new Object[] { groupId, userId };
2150    
2151                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2152                                    finderArgs, this);
2153    
2154                    if (count == null) {
2155                            StringBundler query = new StringBundler(3);
2156    
2157                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2158    
2159                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2160    
2161                            query.append(_FINDER_COLUMN_G_U_USERID_2);
2162    
2163                            String sql = query.toString();
2164    
2165                            Session session = null;
2166    
2167                            try {
2168                                    session = openSession();
2169    
2170                                    Query q = session.createQuery(sql);
2171    
2172                                    QueryPos qPos = QueryPos.getInstance(q);
2173    
2174                                    qPos.add(groupId);
2175    
2176                                    qPos.add(userId);
2177    
2178                                    count = (Long)q.uniqueResult();
2179                            }
2180                            catch (Exception e) {
2181                                    throw processException(e);
2182                            }
2183                            finally {
2184                                    if (count == null) {
2185                                            count = Long.valueOf(0);
2186                                    }
2187    
2188                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2189                                            count);
2190    
2191                                    closeSession(session);
2192                            }
2193                    }
2194    
2195                    return count.intValue();
2196            }
2197    
2198            /**
2199             * Returns the number of document library file ranks where companyId = &#63; and userId = &#63; and fileEntryId = &#63;.
2200             *
2201             * @param companyId the company ID
2202             * @param userId the user ID
2203             * @param fileEntryId the file entry ID
2204             * @return the number of matching document library file ranks
2205             * @throws SystemException if a system exception occurred
2206             */
2207            public int countByC_U_F(long companyId, long userId, long fileEntryId)
2208                    throws SystemException {
2209                    Object[] finderArgs = new Object[] { companyId, userId, fileEntryId };
2210    
2211                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U_F,
2212                                    finderArgs, this);
2213    
2214                    if (count == null) {
2215                            StringBundler query = new StringBundler(4);
2216    
2217                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2218    
2219                            query.append(_FINDER_COLUMN_C_U_F_COMPANYID_2);
2220    
2221                            query.append(_FINDER_COLUMN_C_U_F_USERID_2);
2222    
2223                            query.append(_FINDER_COLUMN_C_U_F_FILEENTRYID_2);
2224    
2225                            String sql = query.toString();
2226    
2227                            Session session = null;
2228    
2229                            try {
2230                                    session = openSession();
2231    
2232                                    Query q = session.createQuery(sql);
2233    
2234                                    QueryPos qPos = QueryPos.getInstance(q);
2235    
2236                                    qPos.add(companyId);
2237    
2238                                    qPos.add(userId);
2239    
2240                                    qPos.add(fileEntryId);
2241    
2242                                    count = (Long)q.uniqueResult();
2243                            }
2244                            catch (Exception e) {
2245                                    throw processException(e);
2246                            }
2247                            finally {
2248                                    if (count == null) {
2249                                            count = Long.valueOf(0);
2250                                    }
2251    
2252                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_F,
2253                                            finderArgs, count);
2254    
2255                                    closeSession(session);
2256                            }
2257                    }
2258    
2259                    return count.intValue();
2260            }
2261    
2262            /**
2263             * Returns the number of document library file ranks.
2264             *
2265             * @return the number of document library file ranks
2266             * @throws SystemException if a system exception occurred
2267             */
2268            public int countAll() throws SystemException {
2269                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2270                                    FINDER_ARGS_EMPTY, this);
2271    
2272                    if (count == null) {
2273                            Session session = null;
2274    
2275                            try {
2276                                    session = openSession();
2277    
2278                                    Query q = session.createQuery(_SQL_COUNT_DLFILERANK);
2279    
2280                                    count = (Long)q.uniqueResult();
2281                            }
2282                            catch (Exception e) {
2283                                    throw processException(e);
2284                            }
2285                            finally {
2286                                    if (count == null) {
2287                                            count = Long.valueOf(0);
2288                                    }
2289    
2290                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2291                                            FINDER_ARGS_EMPTY, count);
2292    
2293                                    closeSession(session);
2294                            }
2295                    }
2296    
2297                    return count.intValue();
2298            }
2299    
2300            /**
2301             * Initializes the document library file rank persistence.
2302             */
2303            public void afterPropertiesSet() {
2304                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2305                                            com.liferay.portal.util.PropsUtil.get(
2306                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileRank")));
2307    
2308                    if (listenerClassNames.length > 0) {
2309                            try {
2310                                    List<ModelListener<DLFileRank>> listenersList = new ArrayList<ModelListener<DLFileRank>>();
2311    
2312                                    for (String listenerClassName : listenerClassNames) {
2313                                            listenersList.add((ModelListener<DLFileRank>)InstanceFactory.newInstance(
2314                                                            listenerClassName));
2315                                    }
2316    
2317                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2318                            }
2319                            catch (Exception e) {
2320                                    _log.error(e);
2321                            }
2322                    }
2323            }
2324    
2325            public void destroy() {
2326                    EntityCacheUtil.removeCache(DLFileRankImpl.class.getName());
2327                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2328                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2329            }
2330    
2331            @BeanReference(type = DLContentPersistence.class)
2332            protected DLContentPersistence dlContentPersistence;
2333            @BeanReference(type = DLFileEntryPersistence.class)
2334            protected DLFileEntryPersistence dlFileEntryPersistence;
2335            @BeanReference(type = DLFileEntryMetadataPersistence.class)
2336            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
2337            @BeanReference(type = DLFileEntryTypePersistence.class)
2338            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
2339            @BeanReference(type = DLFileRankPersistence.class)
2340            protected DLFileRankPersistence dlFileRankPersistence;
2341            @BeanReference(type = DLFileShortcutPersistence.class)
2342            protected DLFileShortcutPersistence dlFileShortcutPersistence;
2343            @BeanReference(type = DLFileVersionPersistence.class)
2344            protected DLFileVersionPersistence dlFileVersionPersistence;
2345            @BeanReference(type = DLFolderPersistence.class)
2346            protected DLFolderPersistence dlFolderPersistence;
2347            @BeanReference(type = DLSyncPersistence.class)
2348            protected DLSyncPersistence dlSyncPersistence;
2349            @BeanReference(type = LayoutPersistence.class)
2350            protected LayoutPersistence layoutPersistence;
2351            @BeanReference(type = ResourcePersistence.class)
2352            protected ResourcePersistence resourcePersistence;
2353            @BeanReference(type = UserPersistence.class)
2354            protected UserPersistence userPersistence;
2355            private static final String _SQL_SELECT_DLFILERANK = "SELECT dlFileRank FROM DLFileRank dlFileRank";
2356            private static final String _SQL_SELECT_DLFILERANK_WHERE = "SELECT dlFileRank FROM DLFileRank dlFileRank WHERE ";
2357            private static final String _SQL_COUNT_DLFILERANK = "SELECT COUNT(dlFileRank) FROM DLFileRank dlFileRank";
2358            private static final String _SQL_COUNT_DLFILERANK_WHERE = "SELECT COUNT(dlFileRank) FROM DLFileRank dlFileRank WHERE ";
2359            private static final String _FINDER_COLUMN_USERID_USERID_2 = "dlFileRank.userId = ?";
2360            private static final String _FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2 = "dlFileRank.fileEntryId = ?";
2361            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dlFileRank.groupId = ? AND ";
2362            private static final String _FINDER_COLUMN_G_U_USERID_2 = "dlFileRank.userId = ?";
2363            private static final String _FINDER_COLUMN_C_U_F_COMPANYID_2 = "dlFileRank.companyId = ? AND ";
2364            private static final String _FINDER_COLUMN_C_U_F_USERID_2 = "dlFileRank.userId = ? AND ";
2365            private static final String _FINDER_COLUMN_C_U_F_FILEENTRYID_2 = "dlFileRank.fileEntryId = ?";
2366            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileRank.";
2367            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileRank exists with the primary key ";
2368            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileRank exists with the key {";
2369            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2370            private static Log _log = LogFactoryUtil.getLog(DLFileRankPersistenceImpl.class);
2371            private static DLFileRank _nullDLFileRank = new DLFileRankImpl() {
2372                            @Override
2373                            public Object clone() {
2374                                    return this;
2375                            }
2376    
2377                            @Override
2378                            public CacheModel<DLFileRank> toCacheModel() {
2379                                    return _nullDLFileRankCacheModel;
2380                            }
2381                    };
2382    
2383            private static CacheModel<DLFileRank> _nullDLFileRankCacheModel = new CacheModel<DLFileRank>() {
2384                            public DLFileRank toEntityModel() {
2385                                    return _nullDLFileRank;
2386                            }
2387                    };
2388    }