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