001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    
384                    else {
385                            if ((dlFileRankModelImpl.getColumnBitmask() &
386                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
387                                    Object[] args = new Object[] {
388                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId())
389                                            };
390    
391                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
392                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
393                                            args);
394    
395                                    args = new Object[] {
396                                                    Long.valueOf(dlFileRankModelImpl.getUserId())
397                                            };
398    
399                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
400                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
401                                            args);
402                            }
403    
404                            if ((dlFileRankModelImpl.getColumnBitmask() &
405                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID.getColumnBitmask()) != 0) {
406                                    Object[] args = new Object[] {
407                                                    Long.valueOf(dlFileRankModelImpl.getOriginalFileEntryId())
408                                            };
409    
410                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
411                                            args);
412                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
413                                            args);
414    
415                                    args = new Object[] {
416                                                    Long.valueOf(dlFileRankModelImpl.getFileEntryId())
417                                            };
418    
419                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
420                                            args);
421                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
422                                            args);
423                            }
424    
425                            if ((dlFileRankModelImpl.getColumnBitmask() &
426                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
427                                    Object[] args = new Object[] {
428                                                    Long.valueOf(dlFileRankModelImpl.getOriginalGroupId()),
429                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId())
430                                            };
431    
432                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
433                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
434                                            args);
435    
436                                    args = new Object[] {
437                                                    Long.valueOf(dlFileRankModelImpl.getGroupId()),
438                                                    Long.valueOf(dlFileRankModelImpl.getUserId())
439                                            };
440    
441                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
442                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
443                                            args);
444                            }
445                    }
446    
447                    EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
448                            DLFileRankImpl.class, dlFileRank.getPrimaryKey(), dlFileRank);
449    
450                    if (isNew) {
451                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
452                                    new Object[] {
453                                            Long.valueOf(dlFileRank.getCompanyId()),
454                                            Long.valueOf(dlFileRank.getUserId()),
455                                            Long.valueOf(dlFileRank.getFileEntryId())
456                                    }, dlFileRank);
457                    }
458                    else {
459                            if ((dlFileRankModelImpl.getColumnBitmask() &
460                                            FINDER_PATH_FETCH_BY_C_U_F.getColumnBitmask()) != 0) {
461                                    Object[] args = new Object[] {
462                                                    Long.valueOf(dlFileRankModelImpl.getOriginalCompanyId()),
463                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId()),
464                                                    Long.valueOf(dlFileRankModelImpl.getOriginalFileEntryId())
465                                            };
466    
467                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_F, args);
468    
469                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F, args);
470    
471                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
472                                            new Object[] {
473                                                    Long.valueOf(dlFileRank.getCompanyId()),
474                                                    Long.valueOf(dlFileRank.getUserId()),
475                                                    Long.valueOf(dlFileRank.getFileEntryId())
476                                            }, dlFileRank);
477                            }
478                    }
479    
480                    return dlFileRank;
481            }
482    
483            protected DLFileRank toUnwrappedModel(DLFileRank dlFileRank) {
484                    if (dlFileRank instanceof DLFileRankImpl) {
485                            return dlFileRank;
486                    }
487    
488                    DLFileRankImpl dlFileRankImpl = new DLFileRankImpl();
489    
490                    dlFileRankImpl.setNew(dlFileRank.isNew());
491                    dlFileRankImpl.setPrimaryKey(dlFileRank.getPrimaryKey());
492    
493                    dlFileRankImpl.setFileRankId(dlFileRank.getFileRankId());
494                    dlFileRankImpl.setGroupId(dlFileRank.getGroupId());
495                    dlFileRankImpl.setCompanyId(dlFileRank.getCompanyId());
496                    dlFileRankImpl.setUserId(dlFileRank.getUserId());
497                    dlFileRankImpl.setCreateDate(dlFileRank.getCreateDate());
498                    dlFileRankImpl.setFileEntryId(dlFileRank.getFileEntryId());
499    
500                    return dlFileRankImpl;
501            }
502    
503            /**
504             * Returns the document library file rank with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
505             *
506             * @param primaryKey the primary key of the document library file rank
507             * @return the document library file rank
508             * @throws com.liferay.portal.NoSuchModelException if a document library file rank with the primary key could not be found
509             * @throws SystemException if a system exception occurred
510             */
511            @Override
512            public DLFileRank findByPrimaryKey(Serializable primaryKey)
513                    throws NoSuchModelException, SystemException {
514                    return findByPrimaryKey(((Long)primaryKey).longValue());
515            }
516    
517            /**
518             * 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.
519             *
520             * @param fileRankId the primary key of the document library file rank
521             * @return the document library file rank
522             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
523             * @throws SystemException if a system exception occurred
524             */
525            public DLFileRank findByPrimaryKey(long fileRankId)
526                    throws NoSuchFileRankException, SystemException {
527                    DLFileRank dlFileRank = fetchByPrimaryKey(fileRankId);
528    
529                    if (dlFileRank == null) {
530                            if (_log.isWarnEnabled()) {
531                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileRankId);
532                            }
533    
534                            throw new NoSuchFileRankException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
535                                    fileRankId);
536                    }
537    
538                    return dlFileRank;
539            }
540    
541            /**
542             * Returns the document library file rank with the primary key or returns <code>null</code> if it could not be found.
543             *
544             * @param primaryKey the primary key of the document library file rank
545             * @return the document library file rank, or <code>null</code> if a document library file rank with the primary key could not be found
546             * @throws SystemException if a system exception occurred
547             */
548            @Override
549            public DLFileRank fetchByPrimaryKey(Serializable primaryKey)
550                    throws SystemException {
551                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
552            }
553    
554            /**
555             * Returns the document library file rank with the primary key or returns <code>null</code> if it could not be found.
556             *
557             * @param fileRankId the primary key of the document library file rank
558             * @return the document library file rank, or <code>null</code> if a document library file rank with the primary key could not be found
559             * @throws SystemException if a system exception occurred
560             */
561            public DLFileRank fetchByPrimaryKey(long fileRankId)
562                    throws SystemException {
563                    DLFileRank dlFileRank = (DLFileRank)EntityCacheUtil.getResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
564                                    DLFileRankImpl.class, fileRankId);
565    
566                    if (dlFileRank == _nullDLFileRank) {
567                            return null;
568                    }
569    
570                    if (dlFileRank == null) {
571                            Session session = null;
572    
573                            boolean hasException = false;
574    
575                            try {
576                                    session = openSession();
577    
578                                    dlFileRank = (DLFileRank)session.get(DLFileRankImpl.class,
579                                                    Long.valueOf(fileRankId));
580                            }
581                            catch (Exception e) {
582                                    hasException = true;
583    
584                                    throw processException(e);
585                            }
586                            finally {
587                                    if (dlFileRank != null) {
588                                            cacheResult(dlFileRank);
589                                    }
590                                    else if (!hasException) {
591                                            EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
592                                                    DLFileRankImpl.class, fileRankId, _nullDLFileRank);
593                                    }
594    
595                                    closeSession(session);
596                            }
597                    }
598    
599                    return dlFileRank;
600            }
601    
602            /**
603             * Returns all the document library file ranks where userId = &#63;.
604             *
605             * @param userId the user ID
606             * @return the matching document library file ranks
607             * @throws SystemException if a system exception occurred
608             */
609            public List<DLFileRank> findByUserId(long userId) throws SystemException {
610                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
611            }
612    
613            /**
614             * Returns a range of all the document library file ranks where userId = &#63;.
615             *
616             * <p>
617             * 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.
618             * </p>
619             *
620             * @param userId the user ID
621             * @param start the lower bound of the range of document library file ranks
622             * @param end the upper bound of the range of document library file ranks (not inclusive)
623             * @return the range of matching document library file ranks
624             * @throws SystemException if a system exception occurred
625             */
626            public List<DLFileRank> findByUserId(long userId, int start, int end)
627                    throws SystemException {
628                    return findByUserId(userId, start, end, null);
629            }
630    
631            /**
632             * Returns an ordered range of all the document library file ranks where userId = &#63;.
633             *
634             * <p>
635             * 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.
636             * </p>
637             *
638             * @param userId the user ID
639             * @param start the lower bound of the range of document library file ranks
640             * @param end the upper bound of the range of document library file ranks (not inclusive)
641             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
642             * @return the ordered range of matching document library file ranks
643             * @throws SystemException if a system exception occurred
644             */
645            public List<DLFileRank> findByUserId(long userId, int start, int end,
646                    OrderByComparator orderByComparator) throws SystemException {
647                    FinderPath finderPath = null;
648                    Object[] finderArgs = null;
649    
650                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
651                                    (orderByComparator == null)) {
652                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
653                            finderArgs = new Object[] { userId };
654                    }
655                    else {
656                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
657                            finderArgs = new Object[] { userId, start, end, orderByComparator };
658                    }
659    
660                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
661                                    finderArgs, this);
662    
663                    if ((list != null) && !list.isEmpty()) {
664                            for (DLFileRank dlFileRank : list) {
665                                    if ((userId != dlFileRank.getUserId())) {
666                                            list = null;
667    
668                                            break;
669                                    }
670                            }
671                    }
672    
673                    if (list == null) {
674                            StringBundler query = null;
675    
676                            if (orderByComparator != null) {
677                                    query = new StringBundler(3 +
678                                                    (orderByComparator.getOrderByFields().length * 3));
679                            }
680                            else {
681                                    query = new StringBundler(3);
682                            }
683    
684                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
685    
686                            query.append(_FINDER_COLUMN_USERID_USERID_2);
687    
688                            if (orderByComparator != null) {
689                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
690                                            orderByComparator);
691                            }
692    
693                            else {
694                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
695                            }
696    
697                            String sql = query.toString();
698    
699                            Session session = null;
700    
701                            try {
702                                    session = openSession();
703    
704                                    Query q = session.createQuery(sql);
705    
706                                    QueryPos qPos = QueryPos.getInstance(q);
707    
708                                    qPos.add(userId);
709    
710                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
711                                                    end);
712                            }
713                            catch (Exception e) {
714                                    throw processException(e);
715                            }
716                            finally {
717                                    if (list == null) {
718                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
719                                    }
720                                    else {
721                                            cacheResult(list);
722    
723                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
724                                    }
725    
726                                    closeSession(session);
727                            }
728                    }
729    
730                    return list;
731            }
732    
733            /**
734             * Returns the first document library file rank in the ordered set where userId = &#63;.
735             *
736             * @param userId the user ID
737             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
738             * @return the first matching document library file rank
739             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
740             * @throws SystemException if a system exception occurred
741             */
742            public DLFileRank findByUserId_First(long userId,
743                    OrderByComparator orderByComparator)
744                    throws NoSuchFileRankException, SystemException {
745                    DLFileRank dlFileRank = fetchByUserId_First(userId, orderByComparator);
746    
747                    if (dlFileRank != null) {
748                            return dlFileRank;
749                    }
750    
751                    StringBundler msg = new StringBundler(4);
752    
753                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
754    
755                    msg.append("userId=");
756                    msg.append(userId);
757    
758                    msg.append(StringPool.CLOSE_CURLY_BRACE);
759    
760                    throw new NoSuchFileRankException(msg.toString());
761            }
762    
763            /**
764             * Returns the first document library file rank in the ordered set where userId = &#63;.
765             *
766             * @param userId the user ID
767             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
768             * @return the first matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
769             * @throws SystemException if a system exception occurred
770             */
771            public DLFileRank fetchByUserId_First(long userId,
772                    OrderByComparator orderByComparator) throws SystemException {
773                    List<DLFileRank> list = findByUserId(userId, 0, 1, orderByComparator);
774    
775                    if (!list.isEmpty()) {
776                            return list.get(0);
777                    }
778    
779                    return null;
780            }
781    
782            /**
783             * Returns the last document library file rank in the ordered set where userId = &#63;.
784             *
785             * @param userId the user ID
786             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
787             * @return the last matching document library file rank
788             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
789             * @throws SystemException if a system exception occurred
790             */
791            public DLFileRank findByUserId_Last(long userId,
792                    OrderByComparator orderByComparator)
793                    throws NoSuchFileRankException, SystemException {
794                    DLFileRank dlFileRank = fetchByUserId_Last(userId, orderByComparator);
795    
796                    if (dlFileRank != null) {
797                            return dlFileRank;
798                    }
799    
800                    StringBundler msg = new StringBundler(4);
801    
802                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
803    
804                    msg.append("userId=");
805                    msg.append(userId);
806    
807                    msg.append(StringPool.CLOSE_CURLY_BRACE);
808    
809                    throw new NoSuchFileRankException(msg.toString());
810            }
811    
812            /**
813             * Returns the last document library file rank in the ordered set where userId = &#63;.
814             *
815             * @param userId the user ID
816             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
817             * @return the last matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
818             * @throws SystemException if a system exception occurred
819             */
820            public DLFileRank fetchByUserId_Last(long userId,
821                    OrderByComparator orderByComparator) throws SystemException {
822                    int count = countByUserId(userId);
823    
824                    List<DLFileRank> list = findByUserId(userId, count - 1, count,
825                                    orderByComparator);
826    
827                    if (!list.isEmpty()) {
828                            return list.get(0);
829                    }
830    
831                    return null;
832            }
833    
834            /**
835             * Returns the document library file ranks before and after the current document library file rank in the ordered set where userId = &#63;.
836             *
837             * @param fileRankId the primary key of the current document library file rank
838             * @param userId the user ID
839             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
840             * @return the previous, current, and next document library file rank
841             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
842             * @throws SystemException if a system exception occurred
843             */
844            public DLFileRank[] findByUserId_PrevAndNext(long fileRankId, long userId,
845                    OrderByComparator orderByComparator)
846                    throws NoSuchFileRankException, SystemException {
847                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
848    
849                    Session session = null;
850    
851                    try {
852                            session = openSession();
853    
854                            DLFileRank[] array = new DLFileRankImpl[3];
855    
856                            array[0] = getByUserId_PrevAndNext(session, dlFileRank, userId,
857                                            orderByComparator, true);
858    
859                            array[1] = dlFileRank;
860    
861                            array[2] = getByUserId_PrevAndNext(session, dlFileRank, userId,
862                                            orderByComparator, false);
863    
864                            return array;
865                    }
866                    catch (Exception e) {
867                            throw processException(e);
868                    }
869                    finally {
870                            closeSession(session);
871                    }
872            }
873    
874            protected DLFileRank getByUserId_PrevAndNext(Session session,
875                    DLFileRank dlFileRank, long userId,
876                    OrderByComparator orderByComparator, boolean previous) {
877                    StringBundler query = null;
878    
879                    if (orderByComparator != null) {
880                            query = new StringBundler(6 +
881                                            (orderByComparator.getOrderByFields().length * 6));
882                    }
883                    else {
884                            query = new StringBundler(3);
885                    }
886    
887                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
888    
889                    query.append(_FINDER_COLUMN_USERID_USERID_2);
890    
891                    if (orderByComparator != null) {
892                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
893    
894                            if (orderByConditionFields.length > 0) {
895                                    query.append(WHERE_AND);
896                            }
897    
898                            for (int i = 0; i < orderByConditionFields.length; i++) {
899                                    query.append(_ORDER_BY_ENTITY_ALIAS);
900                                    query.append(orderByConditionFields[i]);
901    
902                                    if ((i + 1) < orderByConditionFields.length) {
903                                            if (orderByComparator.isAscending() ^ previous) {
904                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
905                                            }
906                                            else {
907                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
908                                            }
909                                    }
910                                    else {
911                                            if (orderByComparator.isAscending() ^ previous) {
912                                                    query.append(WHERE_GREATER_THAN);
913                                            }
914                                            else {
915                                                    query.append(WHERE_LESSER_THAN);
916                                            }
917                                    }
918                            }
919    
920                            query.append(ORDER_BY_CLAUSE);
921    
922                            String[] orderByFields = orderByComparator.getOrderByFields();
923    
924                            for (int i = 0; i < orderByFields.length; i++) {
925                                    query.append(_ORDER_BY_ENTITY_ALIAS);
926                                    query.append(orderByFields[i]);
927    
928                                    if ((i + 1) < orderByFields.length) {
929                                            if (orderByComparator.isAscending() ^ previous) {
930                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
931                                            }
932                                            else {
933                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
934                                            }
935                                    }
936                                    else {
937                                            if (orderByComparator.isAscending() ^ previous) {
938                                                    query.append(ORDER_BY_ASC);
939                                            }
940                                            else {
941                                                    query.append(ORDER_BY_DESC);
942                                            }
943                                    }
944                            }
945                    }
946    
947                    else {
948                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
949                    }
950    
951                    String sql = query.toString();
952    
953                    Query q = session.createQuery(sql);
954    
955                    q.setFirstResult(0);
956                    q.setMaxResults(2);
957    
958                    QueryPos qPos = QueryPos.getInstance(q);
959    
960                    qPos.add(userId);
961    
962                    if (orderByComparator != null) {
963                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
964    
965                            for (Object value : values) {
966                                    qPos.add(value);
967                            }
968                    }
969    
970                    List<DLFileRank> list = q.list();
971    
972                    if (list.size() == 2) {
973                            return list.get(1);
974                    }
975                    else {
976                            return null;
977                    }
978            }
979    
980            /**
981             * Returns all the document library file ranks where fileEntryId = &#63;.
982             *
983             * @param fileEntryId the file entry ID
984             * @return the matching document library file ranks
985             * @throws SystemException if a system exception occurred
986             */
987            public List<DLFileRank> findByFileEntryId(long fileEntryId)
988                    throws SystemException {
989                    return findByFileEntryId(fileEntryId, QueryUtil.ALL_POS,
990                            QueryUtil.ALL_POS, null);
991            }
992    
993            /**
994             * Returns a range of all the document library file ranks where fileEntryId = &#63;.
995             *
996             * <p>
997             * 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.
998             * </p>
999             *
1000             * @param fileEntryId the file entry ID
1001             * @param start the lower bound of the range of document library file ranks
1002             * @param end the upper bound of the range of document library file ranks (not inclusive)
1003             * @return the range of matching document library file ranks
1004             * @throws SystemException if a system exception occurred
1005             */
1006            public List<DLFileRank> findByFileEntryId(long fileEntryId, int start,
1007                    int end) throws SystemException {
1008                    return findByFileEntryId(fileEntryId, start, end, null);
1009            }
1010    
1011            /**
1012             * Returns an ordered range of all the document library file ranks where fileEntryId = &#63;.
1013             *
1014             * <p>
1015             * 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.
1016             * </p>
1017             *
1018             * @param fileEntryId the file entry ID
1019             * @param start the lower bound of the range of document library file ranks
1020             * @param end the upper bound of the range of document library file ranks (not inclusive)
1021             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1022             * @return the ordered range of matching document library file ranks
1023             * @throws SystemException if a system exception occurred
1024             */
1025            public List<DLFileRank> findByFileEntryId(long fileEntryId, int start,
1026                    int end, OrderByComparator orderByComparator) throws SystemException {
1027                    FinderPath finderPath = null;
1028                    Object[] finderArgs = null;
1029    
1030                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1031                                    (orderByComparator == null)) {
1032                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID;
1033                            finderArgs = new Object[] { fileEntryId };
1034                    }
1035                    else {
1036                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID;
1037                            finderArgs = new Object[] { fileEntryId, start, end, orderByComparator };
1038                    }
1039    
1040                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
1041                                    finderArgs, this);
1042    
1043                    if ((list != null) && !list.isEmpty()) {
1044                            for (DLFileRank dlFileRank : list) {
1045                                    if ((fileEntryId != dlFileRank.getFileEntryId())) {
1046                                            list = null;
1047    
1048                                            break;
1049                                    }
1050                            }
1051                    }
1052    
1053                    if (list == null) {
1054                            StringBundler query = null;
1055    
1056                            if (orderByComparator != null) {
1057                                    query = new StringBundler(3 +
1058                                                    (orderByComparator.getOrderByFields().length * 3));
1059                            }
1060                            else {
1061                                    query = new StringBundler(3);
1062                            }
1063    
1064                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
1065    
1066                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1067    
1068                            if (orderByComparator != null) {
1069                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1070                                            orderByComparator);
1071                            }
1072    
1073                            else {
1074                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1075                            }
1076    
1077                            String sql = query.toString();
1078    
1079                            Session session = null;
1080    
1081                            try {
1082                                    session = openSession();
1083    
1084                                    Query q = session.createQuery(sql);
1085    
1086                                    QueryPos qPos = QueryPos.getInstance(q);
1087    
1088                                    qPos.add(fileEntryId);
1089    
1090                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
1091                                                    end);
1092                            }
1093                            catch (Exception e) {
1094                                    throw processException(e);
1095                            }
1096                            finally {
1097                                    if (list == null) {
1098                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1099                                    }
1100                                    else {
1101                                            cacheResult(list);
1102    
1103                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1104                                    }
1105    
1106                                    closeSession(session);
1107                            }
1108                    }
1109    
1110                    return list;
1111            }
1112    
1113            /**
1114             * Returns the first document library file rank in the ordered set where fileEntryId = &#63;.
1115             *
1116             * @param fileEntryId the file entry ID
1117             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1118             * @return the first matching document library file rank
1119             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1120             * @throws SystemException if a system exception occurred
1121             */
1122            public DLFileRank findByFileEntryId_First(long fileEntryId,
1123                    OrderByComparator orderByComparator)
1124                    throws NoSuchFileRankException, SystemException {
1125                    DLFileRank dlFileRank = fetchByFileEntryId_First(fileEntryId,
1126                                    orderByComparator);
1127    
1128                    if (dlFileRank != null) {
1129                            return dlFileRank;
1130                    }
1131    
1132                    StringBundler msg = new StringBundler(4);
1133    
1134                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1135    
1136                    msg.append("fileEntryId=");
1137                    msg.append(fileEntryId);
1138    
1139                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1140    
1141                    throw new NoSuchFileRankException(msg.toString());
1142            }
1143    
1144            /**
1145             * Returns the first document library file rank in the ordered set where fileEntryId = &#63;.
1146             *
1147             * @param fileEntryId the file entry ID
1148             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1149             * @return the first matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1150             * @throws SystemException if a system exception occurred
1151             */
1152            public DLFileRank fetchByFileEntryId_First(long fileEntryId,
1153                    OrderByComparator orderByComparator) throws SystemException {
1154                    List<DLFileRank> list = findByFileEntryId(fileEntryId, 0, 1,
1155                                    orderByComparator);
1156    
1157                    if (!list.isEmpty()) {
1158                            return list.get(0);
1159                    }
1160    
1161                    return null;
1162            }
1163    
1164            /**
1165             * Returns the last document library file rank in the ordered set where fileEntryId = &#63;.
1166             *
1167             * @param fileEntryId the file entry ID
1168             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1169             * @return the last matching document library file rank
1170             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1171             * @throws SystemException if a system exception occurred
1172             */
1173            public DLFileRank findByFileEntryId_Last(long fileEntryId,
1174                    OrderByComparator orderByComparator)
1175                    throws NoSuchFileRankException, SystemException {
1176                    DLFileRank dlFileRank = fetchByFileEntryId_Last(fileEntryId,
1177                                    orderByComparator);
1178    
1179                    if (dlFileRank != null) {
1180                            return dlFileRank;
1181                    }
1182    
1183                    StringBundler msg = new StringBundler(4);
1184    
1185                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1186    
1187                    msg.append("fileEntryId=");
1188                    msg.append(fileEntryId);
1189    
1190                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1191    
1192                    throw new NoSuchFileRankException(msg.toString());
1193            }
1194    
1195            /**
1196             * Returns the last document library file rank in the ordered set where fileEntryId = &#63;.
1197             *
1198             * @param fileEntryId the file entry ID
1199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1200             * @return the last matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1201             * @throws SystemException if a system exception occurred
1202             */
1203            public DLFileRank fetchByFileEntryId_Last(long fileEntryId,
1204                    OrderByComparator orderByComparator) throws SystemException {
1205                    int count = countByFileEntryId(fileEntryId);
1206    
1207                    List<DLFileRank> list = findByFileEntryId(fileEntryId, count - 1,
1208                                    count, orderByComparator);
1209    
1210                    if (!list.isEmpty()) {
1211                            return list.get(0);
1212                    }
1213    
1214                    return null;
1215            }
1216    
1217            /**
1218             * Returns the document library file ranks before and after the current document library file rank in the ordered set where fileEntryId = &#63;.
1219             *
1220             * @param fileRankId the primary key of the current document library file rank
1221             * @param fileEntryId the file entry ID
1222             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1223             * @return the previous, current, and next document library file rank
1224             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
1225             * @throws SystemException if a system exception occurred
1226             */
1227            public DLFileRank[] findByFileEntryId_PrevAndNext(long fileRankId,
1228                    long fileEntryId, OrderByComparator orderByComparator)
1229                    throws NoSuchFileRankException, SystemException {
1230                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
1231    
1232                    Session session = null;
1233    
1234                    try {
1235                            session = openSession();
1236    
1237                            DLFileRank[] array = new DLFileRankImpl[3];
1238    
1239                            array[0] = getByFileEntryId_PrevAndNext(session, dlFileRank,
1240                                            fileEntryId, orderByComparator, true);
1241    
1242                            array[1] = dlFileRank;
1243    
1244                            array[2] = getByFileEntryId_PrevAndNext(session, dlFileRank,
1245                                            fileEntryId, orderByComparator, false);
1246    
1247                            return array;
1248                    }
1249                    catch (Exception e) {
1250                            throw processException(e);
1251                    }
1252                    finally {
1253                            closeSession(session);
1254                    }
1255            }
1256    
1257            protected DLFileRank getByFileEntryId_PrevAndNext(Session session,
1258                    DLFileRank dlFileRank, long fileEntryId,
1259                    OrderByComparator orderByComparator, boolean previous) {
1260                    StringBundler query = null;
1261    
1262                    if (orderByComparator != null) {
1263                            query = new StringBundler(6 +
1264                                            (orderByComparator.getOrderByFields().length * 6));
1265                    }
1266                    else {
1267                            query = new StringBundler(3);
1268                    }
1269    
1270                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
1271    
1272                    query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1273    
1274                    if (orderByComparator != null) {
1275                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1276    
1277                            if (orderByConditionFields.length > 0) {
1278                                    query.append(WHERE_AND);
1279                            }
1280    
1281                            for (int i = 0; i < orderByConditionFields.length; i++) {
1282                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1283                                    query.append(orderByConditionFields[i]);
1284    
1285                                    if ((i + 1) < orderByConditionFields.length) {
1286                                            if (orderByComparator.isAscending() ^ previous) {
1287                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1288                                            }
1289                                            else {
1290                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1291                                            }
1292                                    }
1293                                    else {
1294                                            if (orderByComparator.isAscending() ^ previous) {
1295                                                    query.append(WHERE_GREATER_THAN);
1296                                            }
1297                                            else {
1298                                                    query.append(WHERE_LESSER_THAN);
1299                                            }
1300                                    }
1301                            }
1302    
1303                            query.append(ORDER_BY_CLAUSE);
1304    
1305                            String[] orderByFields = orderByComparator.getOrderByFields();
1306    
1307                            for (int i = 0; i < orderByFields.length; i++) {
1308                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1309                                    query.append(orderByFields[i]);
1310    
1311                                    if ((i + 1) < orderByFields.length) {
1312                                            if (orderByComparator.isAscending() ^ previous) {
1313                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1314                                            }
1315                                            else {
1316                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1317                                            }
1318                                    }
1319                                    else {
1320                                            if (orderByComparator.isAscending() ^ previous) {
1321                                                    query.append(ORDER_BY_ASC);
1322                                            }
1323                                            else {
1324                                                    query.append(ORDER_BY_DESC);
1325                                            }
1326                                    }
1327                            }
1328                    }
1329    
1330                    else {
1331                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1332                    }
1333    
1334                    String sql = query.toString();
1335    
1336                    Query q = session.createQuery(sql);
1337    
1338                    q.setFirstResult(0);
1339                    q.setMaxResults(2);
1340    
1341                    QueryPos qPos = QueryPos.getInstance(q);
1342    
1343                    qPos.add(fileEntryId);
1344    
1345                    if (orderByComparator != null) {
1346                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
1347    
1348                            for (Object value : values) {
1349                                    qPos.add(value);
1350                            }
1351                    }
1352    
1353                    List<DLFileRank> list = q.list();
1354    
1355                    if (list.size() == 2) {
1356                            return list.get(1);
1357                    }
1358                    else {
1359                            return null;
1360                    }
1361            }
1362    
1363            /**
1364             * Returns all the document library file ranks where groupId = &#63; and userId = &#63;.
1365             *
1366             * @param groupId the group ID
1367             * @param userId the user ID
1368             * @return the matching document library file ranks
1369             * @throws SystemException if a system exception occurred
1370             */
1371            public List<DLFileRank> findByG_U(long groupId, long userId)
1372                    throws SystemException {
1373                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1374                            null);
1375            }
1376    
1377            /**
1378             * Returns a range of all the document library file ranks where groupId = &#63; and userId = &#63;.
1379             *
1380             * <p>
1381             * 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.
1382             * </p>
1383             *
1384             * @param groupId the group ID
1385             * @param userId the user ID
1386             * @param start the lower bound of the range of document library file ranks
1387             * @param end the upper bound of the range of document library file ranks (not inclusive)
1388             * @return the range of matching document library file ranks
1389             * @throws SystemException if a system exception occurred
1390             */
1391            public List<DLFileRank> findByG_U(long groupId, long userId, int start,
1392                    int end) throws SystemException {
1393                    return findByG_U(groupId, userId, start, end, null);
1394            }
1395    
1396            /**
1397             * Returns an ordered range of all the document library file ranks where groupId = &#63; and userId = &#63;.
1398             *
1399             * <p>
1400             * 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.
1401             * </p>
1402             *
1403             * @param groupId the group ID
1404             * @param userId the user ID
1405             * @param start the lower bound of the range of document library file ranks
1406             * @param end the upper bound of the range of document library file ranks (not inclusive)
1407             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1408             * @return the ordered range of matching document library file ranks
1409             * @throws SystemException if a system exception occurred
1410             */
1411            public List<DLFileRank> findByG_U(long groupId, long userId, int start,
1412                    int end, OrderByComparator orderByComparator) throws SystemException {
1413                    FinderPath finderPath = null;
1414                    Object[] finderArgs = null;
1415    
1416                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1417                                    (orderByComparator == null)) {
1418                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
1419                            finderArgs = new Object[] { groupId, userId };
1420                    }
1421                    else {
1422                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
1423                            finderArgs = new Object[] {
1424                                            groupId, userId,
1425                                            
1426                                            start, end, orderByComparator
1427                                    };
1428                    }
1429    
1430                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
1431                                    finderArgs, this);
1432    
1433                    if ((list != null) && !list.isEmpty()) {
1434                            for (DLFileRank dlFileRank : list) {
1435                                    if ((groupId != dlFileRank.getGroupId()) ||
1436                                                    (userId != dlFileRank.getUserId())) {
1437                                            list = null;
1438    
1439                                            break;
1440                                    }
1441                            }
1442                    }
1443    
1444                    if (list == null) {
1445                            StringBundler query = null;
1446    
1447                            if (orderByComparator != null) {
1448                                    query = new StringBundler(4 +
1449                                                    (orderByComparator.getOrderByFields().length * 3));
1450                            }
1451                            else {
1452                                    query = new StringBundler(4);
1453                            }
1454    
1455                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
1456    
1457                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1458    
1459                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1460    
1461                            if (orderByComparator != null) {
1462                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1463                                            orderByComparator);
1464                            }
1465    
1466                            else {
1467                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1468                            }
1469    
1470                            String sql = query.toString();
1471    
1472                            Session session = null;
1473    
1474                            try {
1475                                    session = openSession();
1476    
1477                                    Query q = session.createQuery(sql);
1478    
1479                                    QueryPos qPos = QueryPos.getInstance(q);
1480    
1481                                    qPos.add(groupId);
1482    
1483                                    qPos.add(userId);
1484    
1485                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
1486                                                    end);
1487                            }
1488                            catch (Exception e) {
1489                                    throw processException(e);
1490                            }
1491                            finally {
1492                                    if (list == null) {
1493                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1494                                    }
1495                                    else {
1496                                            cacheResult(list);
1497    
1498                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1499                                    }
1500    
1501                                    closeSession(session);
1502                            }
1503                    }
1504    
1505                    return list;
1506            }
1507    
1508            /**
1509             * Returns the first document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1510             *
1511             * @param groupId the group ID
1512             * @param userId the user ID
1513             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1514             * @return the first matching document library file rank
1515             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1516             * @throws SystemException if a system exception occurred
1517             */
1518            public DLFileRank findByG_U_First(long groupId, long userId,
1519                    OrderByComparator orderByComparator)
1520                    throws NoSuchFileRankException, SystemException {
1521                    DLFileRank dlFileRank = fetchByG_U_First(groupId, userId,
1522                                    orderByComparator);
1523    
1524                    if (dlFileRank != null) {
1525                            return dlFileRank;
1526                    }
1527    
1528                    StringBundler msg = new StringBundler(6);
1529    
1530                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1531    
1532                    msg.append("groupId=");
1533                    msg.append(groupId);
1534    
1535                    msg.append(", userId=");
1536                    msg.append(userId);
1537    
1538                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1539    
1540                    throw new NoSuchFileRankException(msg.toString());
1541            }
1542    
1543            /**
1544             * Returns the first document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1545             *
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 first matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1550             * @throws SystemException if a system exception occurred
1551             */
1552            public DLFileRank fetchByG_U_First(long groupId, long userId,
1553                    OrderByComparator orderByComparator) throws SystemException {
1554                    List<DLFileRank> list = findByG_U(groupId, userId, 0, 1,
1555                                    orderByComparator);
1556    
1557                    if (!list.isEmpty()) {
1558                            return list.get(0);
1559                    }
1560    
1561                    return null;
1562            }
1563    
1564            /**
1565             * Returns the last document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1566             *
1567             * @param groupId the group ID
1568             * @param userId the user ID
1569             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1570             * @return the last matching document library file rank
1571             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1572             * @throws SystemException if a system exception occurred
1573             */
1574            public DLFileRank findByG_U_Last(long groupId, long userId,
1575                    OrderByComparator orderByComparator)
1576                    throws NoSuchFileRankException, SystemException {
1577                    DLFileRank dlFileRank = fetchByG_U_Last(groupId, userId,
1578                                    orderByComparator);
1579    
1580                    if (dlFileRank != null) {
1581                            return dlFileRank;
1582                    }
1583    
1584                    StringBundler msg = new StringBundler(6);
1585    
1586                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1587    
1588                    msg.append("groupId=");
1589                    msg.append(groupId);
1590    
1591                    msg.append(", userId=");
1592                    msg.append(userId);
1593    
1594                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1595    
1596                    throw new NoSuchFileRankException(msg.toString());
1597            }
1598    
1599            /**
1600             * Returns the last document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1601             *
1602             * @param groupId the group ID
1603             * @param userId the user ID
1604             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1605             * @return the last matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1606             * @throws SystemException if a system exception occurred
1607             */
1608            public DLFileRank fetchByG_U_Last(long groupId, long userId,
1609                    OrderByComparator orderByComparator) throws SystemException {
1610                    int count = countByG_U(groupId, userId);
1611    
1612                    List<DLFileRank> list = findByG_U(groupId, userId, count - 1, count,
1613                                    orderByComparator);
1614    
1615                    if (!list.isEmpty()) {
1616                            return list.get(0);
1617                    }
1618    
1619                    return null;
1620            }
1621    
1622            /**
1623             * 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;.
1624             *
1625             * @param fileRankId the primary key of the current document library file rank
1626             * @param groupId the group ID
1627             * @param userId the user ID
1628             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1629             * @return the previous, current, and next document library file rank
1630             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
1631             * @throws SystemException if a system exception occurred
1632             */
1633            public DLFileRank[] findByG_U_PrevAndNext(long fileRankId, long groupId,
1634                    long userId, OrderByComparator orderByComparator)
1635                    throws NoSuchFileRankException, SystemException {
1636                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
1637    
1638                    Session session = null;
1639    
1640                    try {
1641                            session = openSession();
1642    
1643                            DLFileRank[] array = new DLFileRankImpl[3];
1644    
1645                            array[0] = getByG_U_PrevAndNext(session, dlFileRank, groupId,
1646                                            userId, orderByComparator, true);
1647    
1648                            array[1] = dlFileRank;
1649    
1650                            array[2] = getByG_U_PrevAndNext(session, dlFileRank, groupId,
1651                                            userId, orderByComparator, false);
1652    
1653                            return array;
1654                    }
1655                    catch (Exception e) {
1656                            throw processException(e);
1657                    }
1658                    finally {
1659                            closeSession(session);
1660                    }
1661            }
1662    
1663            protected DLFileRank getByG_U_PrevAndNext(Session session,
1664                    DLFileRank dlFileRank, long groupId, long userId,
1665                    OrderByComparator orderByComparator, boolean previous) {
1666                    StringBundler query = null;
1667    
1668                    if (orderByComparator != null) {
1669                            query = new StringBundler(6 +
1670                                            (orderByComparator.getOrderByFields().length * 6));
1671                    }
1672                    else {
1673                            query = new StringBundler(3);
1674                    }
1675    
1676                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
1677    
1678                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1679    
1680                    query.append(_FINDER_COLUMN_G_U_USERID_2);
1681    
1682                    if (orderByComparator != null) {
1683                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1684    
1685                            if (orderByConditionFields.length > 0) {
1686                                    query.append(WHERE_AND);
1687                            }
1688    
1689                            for (int i = 0; i < orderByConditionFields.length; i++) {
1690                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1691                                    query.append(orderByConditionFields[i]);
1692    
1693                                    if ((i + 1) < orderByConditionFields.length) {
1694                                            if (orderByComparator.isAscending() ^ previous) {
1695                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1696                                            }
1697                                            else {
1698                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1699                                            }
1700                                    }
1701                                    else {
1702                                            if (orderByComparator.isAscending() ^ previous) {
1703                                                    query.append(WHERE_GREATER_THAN);
1704                                            }
1705                                            else {
1706                                                    query.append(WHERE_LESSER_THAN);
1707                                            }
1708                                    }
1709                            }
1710    
1711                            query.append(ORDER_BY_CLAUSE);
1712    
1713                            String[] orderByFields = orderByComparator.getOrderByFields();
1714    
1715                            for (int i = 0; i < orderByFields.length; i++) {
1716                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1717                                    query.append(orderByFields[i]);
1718    
1719                                    if ((i + 1) < orderByFields.length) {
1720                                            if (orderByComparator.isAscending() ^ previous) {
1721                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1722                                            }
1723                                            else {
1724                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1725                                            }
1726                                    }
1727                                    else {
1728                                            if (orderByComparator.isAscending() ^ previous) {
1729                                                    query.append(ORDER_BY_ASC);
1730                                            }
1731                                            else {
1732                                                    query.append(ORDER_BY_DESC);
1733                                            }
1734                                    }
1735                            }
1736                    }
1737    
1738                    else {
1739                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1740                    }
1741    
1742                    String sql = query.toString();
1743    
1744                    Query q = session.createQuery(sql);
1745    
1746                    q.setFirstResult(0);
1747                    q.setMaxResults(2);
1748    
1749                    QueryPos qPos = QueryPos.getInstance(q);
1750    
1751                    qPos.add(groupId);
1752    
1753                    qPos.add(userId);
1754    
1755                    if (orderByComparator != null) {
1756                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
1757    
1758                            for (Object value : values) {
1759                                    qPos.add(value);
1760                            }
1761                    }
1762    
1763                    List<DLFileRank> list = q.list();
1764    
1765                    if (list.size() == 2) {
1766                            return list.get(1);
1767                    }
1768                    else {
1769                            return null;
1770                    }
1771            }
1772    
1773            /**
1774             * 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.
1775             *
1776             * @param companyId the company ID
1777             * @param userId the user ID
1778             * @param fileEntryId the file entry ID
1779             * @return the matching document library file rank
1780             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1781             * @throws SystemException if a system exception occurred
1782             */
1783            public DLFileRank findByC_U_F(long companyId, long userId, long fileEntryId)
1784                    throws NoSuchFileRankException, SystemException {
1785                    DLFileRank dlFileRank = fetchByC_U_F(companyId, userId, fileEntryId);
1786    
1787                    if (dlFileRank == null) {
1788                            StringBundler msg = new StringBundler(8);
1789    
1790                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1791    
1792                            msg.append("companyId=");
1793                            msg.append(companyId);
1794    
1795                            msg.append(", userId=");
1796                            msg.append(userId);
1797    
1798                            msg.append(", fileEntryId=");
1799                            msg.append(fileEntryId);
1800    
1801                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1802    
1803                            if (_log.isWarnEnabled()) {
1804                                    _log.warn(msg.toString());
1805                            }
1806    
1807                            throw new NoSuchFileRankException(msg.toString());
1808                    }
1809    
1810                    return dlFileRank;
1811            }
1812    
1813            /**
1814             * 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.
1815             *
1816             * @param companyId the company ID
1817             * @param userId the user ID
1818             * @param fileEntryId the file entry ID
1819             * @return the matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1820             * @throws SystemException if a system exception occurred
1821             */
1822            public DLFileRank fetchByC_U_F(long companyId, long userId, long fileEntryId)
1823                    throws SystemException {
1824                    return fetchByC_U_F(companyId, userId, fileEntryId, true);
1825            }
1826    
1827            /**
1828             * 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.
1829             *
1830             * @param companyId the company ID
1831             * @param userId the user ID
1832             * @param fileEntryId the file entry ID
1833             * @param retrieveFromCache whether to use the finder cache
1834             * @return the matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1835             * @throws SystemException if a system exception occurred
1836             */
1837            public DLFileRank fetchByC_U_F(long companyId, long userId,
1838                    long fileEntryId, boolean retrieveFromCache) throws SystemException {
1839                    Object[] finderArgs = new Object[] { companyId, userId, fileEntryId };
1840    
1841                    Object result = null;
1842    
1843                    if (retrieveFromCache) {
1844                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U_F,
1845                                            finderArgs, this);
1846                    }
1847    
1848                    if (result instanceof DLFileRank) {
1849                            DLFileRank dlFileRank = (DLFileRank)result;
1850    
1851                            if ((companyId != dlFileRank.getCompanyId()) ||
1852                                            (userId != dlFileRank.getUserId()) ||
1853                                            (fileEntryId != dlFileRank.getFileEntryId())) {
1854                                    result = null;
1855                            }
1856                    }
1857    
1858                    if (result == null) {
1859                            StringBundler query = new StringBundler(5);
1860    
1861                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
1862    
1863                            query.append(_FINDER_COLUMN_C_U_F_COMPANYID_2);
1864    
1865                            query.append(_FINDER_COLUMN_C_U_F_USERID_2);
1866    
1867                            query.append(_FINDER_COLUMN_C_U_F_FILEENTRYID_2);
1868    
1869                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1870    
1871                            String sql = query.toString();
1872    
1873                            Session session = null;
1874    
1875                            try {
1876                                    session = openSession();
1877    
1878                                    Query q = session.createQuery(sql);
1879    
1880                                    QueryPos qPos = QueryPos.getInstance(q);
1881    
1882                                    qPos.add(companyId);
1883    
1884                                    qPos.add(userId);
1885    
1886                                    qPos.add(fileEntryId);
1887    
1888                                    List<DLFileRank> list = q.list();
1889    
1890                                    result = list;
1891    
1892                                    DLFileRank dlFileRank = null;
1893    
1894                                    if (list.isEmpty()) {
1895                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
1896                                                    finderArgs, list);
1897                                    }
1898                                    else {
1899                                            dlFileRank = list.get(0);
1900    
1901                                            cacheResult(dlFileRank);
1902    
1903                                            if ((dlFileRank.getCompanyId() != companyId) ||
1904                                                            (dlFileRank.getUserId() != userId) ||
1905                                                            (dlFileRank.getFileEntryId() != fileEntryId)) {
1906                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
1907                                                            finderArgs, dlFileRank);
1908                                            }
1909                                    }
1910    
1911                                    return dlFileRank;
1912                            }
1913                            catch (Exception e) {
1914                                    throw processException(e);
1915                            }
1916                            finally {
1917                                    if (result == null) {
1918                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F,
1919                                                    finderArgs);
1920                                    }
1921    
1922                                    closeSession(session);
1923                            }
1924                    }
1925                    else {
1926                            if (result instanceof List<?>) {
1927                                    return null;
1928                            }
1929                            else {
1930                                    return (DLFileRank)result;
1931                            }
1932                    }
1933            }
1934    
1935            /**
1936             * Returns all the document library file ranks.
1937             *
1938             * @return the document library file ranks
1939             * @throws SystemException if a system exception occurred
1940             */
1941            public List<DLFileRank> findAll() throws SystemException {
1942                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1943            }
1944    
1945            /**
1946             * Returns a range of all the document library file ranks.
1947             *
1948             * <p>
1949             * 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.
1950             * </p>
1951             *
1952             * @param start the lower bound of the range of document library file ranks
1953             * @param end the upper bound of the range of document library file ranks (not inclusive)
1954             * @return the range of document library file ranks
1955             * @throws SystemException if a system exception occurred
1956             */
1957            public List<DLFileRank> findAll(int start, int end)
1958                    throws SystemException {
1959                    return findAll(start, end, null);
1960            }
1961    
1962            /**
1963             * Returns an ordered range of all the document library file ranks.
1964             *
1965             * <p>
1966             * 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.
1967             * </p>
1968             *
1969             * @param start the lower bound of the range of document library file ranks
1970             * @param end the upper bound of the range of document library file ranks (not inclusive)
1971             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1972             * @return the ordered range of document library file ranks
1973             * @throws SystemException if a system exception occurred
1974             */
1975            public List<DLFileRank> findAll(int start, int end,
1976                    OrderByComparator orderByComparator) throws SystemException {
1977                    FinderPath finderPath = null;
1978                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1979    
1980                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1981                                    (orderByComparator == null)) {
1982                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1983                            finderArgs = FINDER_ARGS_EMPTY;
1984                    }
1985                    else {
1986                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1987                            finderArgs = new Object[] { start, end, orderByComparator };
1988                    }
1989    
1990                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
1991                                    finderArgs, this);
1992    
1993                    if (list == null) {
1994                            StringBundler query = null;
1995                            String sql = null;
1996    
1997                            if (orderByComparator != null) {
1998                                    query = new StringBundler(2 +
1999                                                    (orderByComparator.getOrderByFields().length * 3));
2000    
2001                                    query.append(_SQL_SELECT_DLFILERANK);
2002    
2003                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2004                                            orderByComparator);
2005    
2006                                    sql = query.toString();
2007                            }
2008                            else {
2009                                    sql = _SQL_SELECT_DLFILERANK.concat(DLFileRankModelImpl.ORDER_BY_JPQL);
2010                            }
2011    
2012                            Session session = null;
2013    
2014                            try {
2015                                    session = openSession();
2016    
2017                                    Query q = session.createQuery(sql);
2018    
2019                                    if (orderByComparator == null) {
2020                                            list = (List<DLFileRank>)QueryUtil.list(q, getDialect(),
2021                                                            start, end, false);
2022    
2023                                            Collections.sort(list);
2024                                    }
2025                                    else {
2026                                            list = (List<DLFileRank>)QueryUtil.list(q, getDialect(),
2027                                                            start, end);
2028                                    }
2029                            }
2030                            catch (Exception e) {
2031                                    throw processException(e);
2032                            }
2033                            finally {
2034                                    if (list == null) {
2035                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2036                                    }
2037                                    else {
2038                                            cacheResult(list);
2039    
2040                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2041                                    }
2042    
2043                                    closeSession(session);
2044                            }
2045                    }
2046    
2047                    return list;
2048            }
2049    
2050            /**
2051             * Removes all the document library file ranks where userId = &#63; from the database.
2052             *
2053             * @param userId the user ID
2054             * @throws SystemException if a system exception occurred
2055             */
2056            public void removeByUserId(long userId) throws SystemException {
2057                    for (DLFileRank dlFileRank : findByUserId(userId)) {
2058                            remove(dlFileRank);
2059                    }
2060            }
2061    
2062            /**
2063             * Removes all the document library file ranks where fileEntryId = &#63; from the database.
2064             *
2065             * @param fileEntryId the file entry ID
2066             * @throws SystemException if a system exception occurred
2067             */
2068            public void removeByFileEntryId(long fileEntryId) throws SystemException {
2069                    for (DLFileRank dlFileRank : findByFileEntryId(fileEntryId)) {
2070                            remove(dlFileRank);
2071                    }
2072            }
2073    
2074            /**
2075             * Removes all the document library file ranks where groupId = &#63; and userId = &#63; from the database.
2076             *
2077             * @param groupId the group ID
2078             * @param userId the user ID
2079             * @throws SystemException if a system exception occurred
2080             */
2081            public void removeByG_U(long groupId, long userId)
2082                    throws SystemException {
2083                    for (DLFileRank dlFileRank : findByG_U(groupId, userId)) {
2084                            remove(dlFileRank);
2085                    }
2086            }
2087    
2088            /**
2089             * Removes the document library file rank where companyId = &#63; and userId = &#63; and fileEntryId = &#63; from the database.
2090             *
2091             * @param companyId the company ID
2092             * @param userId the user ID
2093             * @param fileEntryId the file entry ID
2094             * @return the document library file rank that was removed
2095             * @throws SystemException if a system exception occurred
2096             */
2097            public DLFileRank removeByC_U_F(long companyId, long userId,
2098                    long fileEntryId) throws NoSuchFileRankException, SystemException {
2099                    DLFileRank dlFileRank = findByC_U_F(companyId, userId, fileEntryId);
2100    
2101                    return remove(dlFileRank);
2102            }
2103    
2104            /**
2105             * Removes all the document library file ranks from the database.
2106             *
2107             * @throws SystemException if a system exception occurred
2108             */
2109            public void removeAll() throws SystemException {
2110                    for (DLFileRank dlFileRank : findAll()) {
2111                            remove(dlFileRank);
2112                    }
2113            }
2114    
2115            /**
2116             * Returns the number of document library file ranks where userId = &#63;.
2117             *
2118             * @param userId the user ID
2119             * @return the number of matching document library file ranks
2120             * @throws SystemException if a system exception occurred
2121             */
2122            public int countByUserId(long userId) throws SystemException {
2123                    Object[] finderArgs = new Object[] { userId };
2124    
2125                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2126                                    finderArgs, this);
2127    
2128                    if (count == null) {
2129                            StringBundler query = new StringBundler(2);
2130    
2131                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2132    
2133                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2134    
2135                            String sql = query.toString();
2136    
2137                            Session session = null;
2138    
2139                            try {
2140                                    session = openSession();
2141    
2142                                    Query q = session.createQuery(sql);
2143    
2144                                    QueryPos qPos = QueryPos.getInstance(q);
2145    
2146                                    qPos.add(userId);
2147    
2148                                    count = (Long)q.uniqueResult();
2149                            }
2150                            catch (Exception e) {
2151                                    throw processException(e);
2152                            }
2153                            finally {
2154                                    if (count == null) {
2155                                            count = Long.valueOf(0);
2156                                    }
2157    
2158                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2159                                            finderArgs, count);
2160    
2161                                    closeSession(session);
2162                            }
2163                    }
2164    
2165                    return count.intValue();
2166            }
2167    
2168            /**
2169             * Returns the number of document library file ranks where fileEntryId = &#63;.
2170             *
2171             * @param fileEntryId the file entry ID
2172             * @return the number of matching document library file ranks
2173             * @throws SystemException if a system exception occurred
2174             */
2175            public int countByFileEntryId(long fileEntryId) throws SystemException {
2176                    Object[] finderArgs = new Object[] { fileEntryId };
2177    
2178                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2179                                    finderArgs, this);
2180    
2181                    if (count == null) {
2182                            StringBundler query = new StringBundler(2);
2183    
2184                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2185    
2186                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
2187    
2188                            String sql = query.toString();
2189    
2190                            Session session = null;
2191    
2192                            try {
2193                                    session = openSession();
2194    
2195                                    Query q = session.createQuery(sql);
2196    
2197                                    QueryPos qPos = QueryPos.getInstance(q);
2198    
2199                                    qPos.add(fileEntryId);
2200    
2201                                    count = (Long)q.uniqueResult();
2202                            }
2203                            catch (Exception e) {
2204                                    throw processException(e);
2205                            }
2206                            finally {
2207                                    if (count == null) {
2208                                            count = Long.valueOf(0);
2209                                    }
2210    
2211                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2212                                            finderArgs, count);
2213    
2214                                    closeSession(session);
2215                            }
2216                    }
2217    
2218                    return count.intValue();
2219            }
2220    
2221            /**
2222             * Returns the number of document library file ranks where groupId = &#63; and userId = &#63;.
2223             *
2224             * @param groupId the group ID
2225             * @param userId the user ID
2226             * @return the number of matching document library file ranks
2227             * @throws SystemException if a system exception occurred
2228             */
2229            public int countByG_U(long groupId, long userId) throws SystemException {
2230                    Object[] finderArgs = new Object[] { groupId, userId };
2231    
2232                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2233                                    finderArgs, this);
2234    
2235                    if (count == null) {
2236                            StringBundler query = new StringBundler(3);
2237    
2238                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2239    
2240                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2241    
2242                            query.append(_FINDER_COLUMN_G_U_USERID_2);
2243    
2244                            String sql = query.toString();
2245    
2246                            Session session = null;
2247    
2248                            try {
2249                                    session = openSession();
2250    
2251                                    Query q = session.createQuery(sql);
2252    
2253                                    QueryPos qPos = QueryPos.getInstance(q);
2254    
2255                                    qPos.add(groupId);
2256    
2257                                    qPos.add(userId);
2258    
2259                                    count = (Long)q.uniqueResult();
2260                            }
2261                            catch (Exception e) {
2262                                    throw processException(e);
2263                            }
2264                            finally {
2265                                    if (count == null) {
2266                                            count = Long.valueOf(0);
2267                                    }
2268    
2269                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2270                                            count);
2271    
2272                                    closeSession(session);
2273                            }
2274                    }
2275    
2276                    return count.intValue();
2277            }
2278    
2279            /**
2280             * Returns the number of document library file ranks where companyId = &#63; and userId = &#63; and fileEntryId = &#63;.
2281             *
2282             * @param companyId the company ID
2283             * @param userId the user ID
2284             * @param fileEntryId the file entry ID
2285             * @return the number of matching document library file ranks
2286             * @throws SystemException if a system exception occurred
2287             */
2288            public int countByC_U_F(long companyId, long userId, long fileEntryId)
2289                    throws SystemException {
2290                    Object[] finderArgs = new Object[] { companyId, userId, fileEntryId };
2291    
2292                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U_F,
2293                                    finderArgs, this);
2294    
2295                    if (count == null) {
2296                            StringBundler query = new StringBundler(4);
2297    
2298                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2299    
2300                            query.append(_FINDER_COLUMN_C_U_F_COMPANYID_2);
2301    
2302                            query.append(_FINDER_COLUMN_C_U_F_USERID_2);
2303    
2304                            query.append(_FINDER_COLUMN_C_U_F_FILEENTRYID_2);
2305    
2306                            String sql = query.toString();
2307    
2308                            Session session = null;
2309    
2310                            try {
2311                                    session = openSession();
2312    
2313                                    Query q = session.createQuery(sql);
2314    
2315                                    QueryPos qPos = QueryPos.getInstance(q);
2316    
2317                                    qPos.add(companyId);
2318    
2319                                    qPos.add(userId);
2320    
2321                                    qPos.add(fileEntryId);
2322    
2323                                    count = (Long)q.uniqueResult();
2324                            }
2325                            catch (Exception e) {
2326                                    throw processException(e);
2327                            }
2328                            finally {
2329                                    if (count == null) {
2330                                            count = Long.valueOf(0);
2331                                    }
2332    
2333                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_F,
2334                                            finderArgs, count);
2335    
2336                                    closeSession(session);
2337                            }
2338                    }
2339    
2340                    return count.intValue();
2341            }
2342    
2343            /**
2344             * Returns the number of document library file ranks.
2345             *
2346             * @return the number of document library file ranks
2347             * @throws SystemException if a system exception occurred
2348             */
2349            public int countAll() throws SystemException {
2350                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2351                                    FINDER_ARGS_EMPTY, this);
2352    
2353                    if (count == null) {
2354                            Session session = null;
2355    
2356                            try {
2357                                    session = openSession();
2358    
2359                                    Query q = session.createQuery(_SQL_COUNT_DLFILERANK);
2360    
2361                                    count = (Long)q.uniqueResult();
2362                            }
2363                            catch (Exception e) {
2364                                    throw processException(e);
2365                            }
2366                            finally {
2367                                    if (count == null) {
2368                                            count = Long.valueOf(0);
2369                                    }
2370    
2371                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2372                                            FINDER_ARGS_EMPTY, count);
2373    
2374                                    closeSession(session);
2375                            }
2376                    }
2377    
2378                    return count.intValue();
2379            }
2380    
2381            /**
2382             * Initializes the document library file rank persistence.
2383             */
2384            public void afterPropertiesSet() {
2385                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2386                                            com.liferay.portal.util.PropsUtil.get(
2387                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileRank")));
2388    
2389                    if (listenerClassNames.length > 0) {
2390                            try {
2391                                    List<ModelListener<DLFileRank>> listenersList = new ArrayList<ModelListener<DLFileRank>>();
2392    
2393                                    for (String listenerClassName : listenerClassNames) {
2394                                            listenersList.add((ModelListener<DLFileRank>)InstanceFactory.newInstance(
2395                                                            listenerClassName));
2396                                    }
2397    
2398                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2399                            }
2400                            catch (Exception e) {
2401                                    _log.error(e);
2402                            }
2403                    }
2404            }
2405    
2406            public void destroy() {
2407                    EntityCacheUtil.removeCache(DLFileRankImpl.class.getName());
2408                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2409                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2410            }
2411    
2412            @BeanReference(type = DLContentPersistence.class)
2413            protected DLContentPersistence dlContentPersistence;
2414            @BeanReference(type = DLFileEntryPersistence.class)
2415            protected DLFileEntryPersistence dlFileEntryPersistence;
2416            @BeanReference(type = DLFileEntryMetadataPersistence.class)
2417            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
2418            @BeanReference(type = DLFileEntryTypePersistence.class)
2419            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
2420            @BeanReference(type = DLFileRankPersistence.class)
2421            protected DLFileRankPersistence dlFileRankPersistence;
2422            @BeanReference(type = DLFileShortcutPersistence.class)
2423            protected DLFileShortcutPersistence dlFileShortcutPersistence;
2424            @BeanReference(type = DLFileVersionPersistence.class)
2425            protected DLFileVersionPersistence dlFileVersionPersistence;
2426            @BeanReference(type = DLFolderPersistence.class)
2427            protected DLFolderPersistence dlFolderPersistence;
2428            @BeanReference(type = DLSyncPersistence.class)
2429            protected DLSyncPersistence dlSyncPersistence;
2430            @BeanReference(type = LayoutPersistence.class)
2431            protected LayoutPersistence layoutPersistence;
2432            @BeanReference(type = ResourcePersistence.class)
2433            protected ResourcePersistence resourcePersistence;
2434            @BeanReference(type = UserPersistence.class)
2435            protected UserPersistence userPersistence;
2436            private static final String _SQL_SELECT_DLFILERANK = "SELECT dlFileRank FROM DLFileRank dlFileRank";
2437            private static final String _SQL_SELECT_DLFILERANK_WHERE = "SELECT dlFileRank FROM DLFileRank dlFileRank WHERE ";
2438            private static final String _SQL_COUNT_DLFILERANK = "SELECT COUNT(dlFileRank) FROM DLFileRank dlFileRank";
2439            private static final String _SQL_COUNT_DLFILERANK_WHERE = "SELECT COUNT(dlFileRank) FROM DLFileRank dlFileRank WHERE ";
2440            private static final String _FINDER_COLUMN_USERID_USERID_2 = "dlFileRank.userId = ?";
2441            private static final String _FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2 = "dlFileRank.fileEntryId = ?";
2442            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dlFileRank.groupId = ? AND ";
2443            private static final String _FINDER_COLUMN_G_U_USERID_2 = "dlFileRank.userId = ?";
2444            private static final String _FINDER_COLUMN_C_U_F_COMPANYID_2 = "dlFileRank.companyId = ? AND ";
2445            private static final String _FINDER_COLUMN_C_U_F_USERID_2 = "dlFileRank.userId = ? AND ";
2446            private static final String _FINDER_COLUMN_C_U_F_FILEENTRYID_2 = "dlFileRank.fileEntryId = ?";
2447            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileRank.";
2448            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileRank exists with the primary key ";
2449            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileRank exists with the key {";
2450            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2451            private static Log _log = LogFactoryUtil.getLog(DLFileRankPersistenceImpl.class);
2452            private static DLFileRank _nullDLFileRank = new DLFileRankImpl() {
2453                            @Override
2454                            public Object clone() {
2455                                    return this;
2456                            }
2457    
2458                            @Override
2459                            public CacheModel<DLFileRank> toCacheModel() {
2460                                    return _nullDLFileRankCacheModel;
2461                            }
2462                    };
2463    
2464            private static CacheModel<DLFileRank> _nullDLFileRankCacheModel = new CacheModel<DLFileRank>() {
2465                            public DLFileRank toEntityModel() {
2466                                    return _nullDLFileRank;
2467                            }
2468                    };
2469    }