001    /**
002     * Copyright (c) 2000-2011 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.tasks.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.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.ModelListener;
037    import com.liferay.portal.service.persistence.BatchSessionUtil;
038    import com.liferay.portal.service.persistence.ResourcePersistence;
039    import com.liferay.portal.service.persistence.UserPersistence;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
043    import com.liferay.portlet.tasks.NoSuchReviewException;
044    import com.liferay.portlet.tasks.model.TasksReview;
045    import com.liferay.portlet.tasks.model.impl.TasksReviewImpl;
046    import com.liferay.portlet.tasks.model.impl.TasksReviewModelImpl;
047    
048    import java.io.Serializable;
049    
050    import java.util.ArrayList;
051    import java.util.Collections;
052    import java.util.List;
053    
054    /**
055     * The persistence implementation for the tasks review service.
056     *
057     * <p>
058     * Never modify or reference this class directly. Always use {@link TasksReviewUtil} to access the tasks review persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
059     * </p>
060     *
061     * <p>
062     * Caching information and settings can be found in <code>portal.properties</code>
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see TasksReviewPersistence
067     * @see TasksReviewUtil
068     * @generated
069     */
070    public class TasksReviewPersistenceImpl extends BasePersistenceImpl<TasksReview>
071            implements TasksReviewPersistence {
072            public static final String FINDER_CLASS_NAME_ENTITY = TasksReviewImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
074                    ".List";
075            public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
076                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
077                            "findByUserId",
078                            new String[] {
079                                    Long.class.getName(),
080                                    
081                            "java.lang.Integer", "java.lang.Integer",
082                                    "com.liferay.portal.kernel.util.OrderByComparator"
083                            });
084            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
085                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
086                            "countByUserId", new String[] { Long.class.getName() });
087            public static final FinderPath FINDER_PATH_FIND_BY_PROPOSALID = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
088                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
089                            "findByProposalId",
090                            new String[] {
091                                    Long.class.getName(),
092                                    
093                            "java.lang.Integer", "java.lang.Integer",
094                                    "com.liferay.portal.kernel.util.OrderByComparator"
095                            });
096            public static final FinderPath FINDER_PATH_COUNT_BY_PROPOSALID = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
097                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
098                            "countByProposalId", new String[] { Long.class.getName() });
099            public static final FinderPath FINDER_PATH_FETCH_BY_U_P = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
100                            TasksReviewModelImpl.FINDER_CACHE_ENABLED,
101                            FINDER_CLASS_NAME_ENTITY, "fetchByU_P",
102                            new String[] { Long.class.getName(), Long.class.getName() });
103            public static final FinderPath FINDER_PATH_COUNT_BY_U_P = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
104                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105                            "countByU_P",
106                            new String[] { Long.class.getName(), Long.class.getName() });
107            public static final FinderPath FINDER_PATH_FIND_BY_P_S = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
108                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
109                            "findByP_S",
110                            new String[] {
111                                    Long.class.getName(), Integer.class.getName(),
112                                    
113                            "java.lang.Integer", "java.lang.Integer",
114                                    "com.liferay.portal.kernel.util.OrderByComparator"
115                            });
116            public static final FinderPath FINDER_PATH_COUNT_BY_P_S = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
117                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
118                            "countByP_S",
119                            new String[] { Long.class.getName(), Integer.class.getName() });
120            public static final FinderPath FINDER_PATH_FIND_BY_P_S_C = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
121                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
122                            "findByP_S_C",
123                            new String[] {
124                                    Long.class.getName(), Integer.class.getName(),
125                                    Boolean.class.getName(),
126                                    
127                            "java.lang.Integer", "java.lang.Integer",
128                                    "com.liferay.portal.kernel.util.OrderByComparator"
129                            });
130            public static final FinderPath FINDER_PATH_COUNT_BY_P_S_C = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
131                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
132                            "countByP_S_C",
133                            new String[] {
134                                    Long.class.getName(), Integer.class.getName(),
135                                    Boolean.class.getName()
136                            });
137            public static final FinderPath FINDER_PATH_FIND_BY_P_S_C_R = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
138                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
139                            "findByP_S_C_R",
140                            new String[] {
141                                    Long.class.getName(), Integer.class.getName(),
142                                    Boolean.class.getName(), Boolean.class.getName(),
143                                    
144                            "java.lang.Integer", "java.lang.Integer",
145                                    "com.liferay.portal.kernel.util.OrderByComparator"
146                            });
147            public static final FinderPath FINDER_PATH_COUNT_BY_P_S_C_R = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
148                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
149                            "countByP_S_C_R",
150                            new String[] {
151                                    Long.class.getName(), Integer.class.getName(),
152                                    Boolean.class.getName(), Boolean.class.getName()
153                            });
154            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
155                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
156                            "findAll", new String[0]);
157            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
158                            TasksReviewModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
159                            "countAll", new String[0]);
160    
161            /**
162             * Caches the tasks review in the entity cache if it is enabled.
163             *
164             * @param tasksReview the tasks review to cache
165             */
166            public void cacheResult(TasksReview tasksReview) {
167                    EntityCacheUtil.putResult(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
168                            TasksReviewImpl.class, tasksReview.getPrimaryKey(), tasksReview);
169    
170                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_P,
171                            new Object[] {
172                                    new Long(tasksReview.getUserId()),
173                                    new Long(tasksReview.getProposalId())
174                            }, tasksReview);
175            }
176    
177            /**
178             * Caches the tasks reviews in the entity cache if it is enabled.
179             *
180             * @param tasksReviews the tasks reviews to cache
181             */
182            public void cacheResult(List<TasksReview> tasksReviews) {
183                    for (TasksReview tasksReview : tasksReviews) {
184                            if (EntityCacheUtil.getResult(
185                                                    TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
186                                                    TasksReviewImpl.class, tasksReview.getPrimaryKey(), this) == null) {
187                                    cacheResult(tasksReview);
188                            }
189                    }
190            }
191    
192            /**
193             * Clears the cache for all tasks reviews.
194             *
195             * <p>
196             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
197             * </p>
198             */
199            public void clearCache() {
200                    CacheRegistryUtil.clear(TasksReviewImpl.class.getName());
201                    EntityCacheUtil.clearCache(TasksReviewImpl.class.getName());
202                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
203                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
204            }
205    
206            /**
207             * Clears the cache for the tasks review.
208             *
209             * <p>
210             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
211             * </p>
212             */
213            public void clearCache(TasksReview tasksReview) {
214                    EntityCacheUtil.removeResult(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
215                            TasksReviewImpl.class, tasksReview.getPrimaryKey());
216    
217                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_P,
218                            new Object[] {
219                                    new Long(tasksReview.getUserId()),
220                                    new Long(tasksReview.getProposalId())
221                            });
222            }
223    
224            /**
225             * Creates a new tasks review with the primary key. Does not add the tasks review to the database.
226             *
227             * @param reviewId the primary key for the new tasks review
228             * @return the new tasks review
229             */
230            public TasksReview create(long reviewId) {
231                    TasksReview tasksReview = new TasksReviewImpl();
232    
233                    tasksReview.setNew(true);
234                    tasksReview.setPrimaryKey(reviewId);
235    
236                    return tasksReview;
237            }
238    
239            /**
240             * Removes the tasks review with the primary key from the database. Also notifies the appropriate model listeners.
241             *
242             * @param primaryKey the primary key of the tasks review to remove
243             * @return the tasks review that was removed
244             * @throws com.liferay.portal.NoSuchModelException if a tasks review with the primary key could not be found
245             * @throws SystemException if a system exception occurred
246             */
247            public TasksReview remove(Serializable primaryKey)
248                    throws NoSuchModelException, SystemException {
249                    return remove(((Long)primaryKey).longValue());
250            }
251    
252            /**
253             * Removes the tasks review with the primary key from the database. Also notifies the appropriate model listeners.
254             *
255             * @param reviewId the primary key of the tasks review to remove
256             * @return the tasks review that was removed
257             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a tasks review with the primary key could not be found
258             * @throws SystemException if a system exception occurred
259             */
260            public TasksReview remove(long reviewId)
261                    throws NoSuchReviewException, SystemException {
262                    Session session = null;
263    
264                    try {
265                            session = openSession();
266    
267                            TasksReview tasksReview = (TasksReview)session.get(TasksReviewImpl.class,
268                                            new Long(reviewId));
269    
270                            if (tasksReview == null) {
271                                    if (_log.isWarnEnabled()) {
272                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + reviewId);
273                                    }
274    
275                                    throw new NoSuchReviewException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
276                                            reviewId);
277                            }
278    
279                            return remove(tasksReview);
280                    }
281                    catch (NoSuchReviewException nsee) {
282                            throw nsee;
283                    }
284                    catch (Exception e) {
285                            throw processException(e);
286                    }
287                    finally {
288                            closeSession(session);
289                    }
290            }
291    
292            protected TasksReview removeImpl(TasksReview tasksReview)
293                    throws SystemException {
294                    tasksReview = toUnwrappedModel(tasksReview);
295    
296                    Session session = null;
297    
298                    try {
299                            session = openSession();
300    
301                            BatchSessionUtil.delete(session, tasksReview);
302                    }
303                    catch (Exception e) {
304                            throw processException(e);
305                    }
306                    finally {
307                            closeSession(session);
308                    }
309    
310                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
311    
312                    TasksReviewModelImpl tasksReviewModelImpl = (TasksReviewModelImpl)tasksReview;
313    
314                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_P,
315                            new Object[] {
316                                    new Long(tasksReviewModelImpl.getUserId()),
317                                    new Long(tasksReviewModelImpl.getProposalId())
318                            });
319    
320                    EntityCacheUtil.removeResult(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
321                            TasksReviewImpl.class, tasksReview.getPrimaryKey());
322    
323                    return tasksReview;
324            }
325    
326            public TasksReview updateImpl(
327                    com.liferay.portlet.tasks.model.TasksReview tasksReview, boolean merge)
328                    throws SystemException {
329                    tasksReview = toUnwrappedModel(tasksReview);
330    
331                    boolean isNew = tasksReview.isNew();
332    
333                    TasksReviewModelImpl tasksReviewModelImpl = (TasksReviewModelImpl)tasksReview;
334    
335                    Session session = null;
336    
337                    try {
338                            session = openSession();
339    
340                            BatchSessionUtil.update(session, tasksReview, merge);
341    
342                            tasksReview.setNew(false);
343                    }
344                    catch (Exception e) {
345                            throw processException(e);
346                    }
347                    finally {
348                            closeSession(session);
349                    }
350    
351                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
352    
353                    EntityCacheUtil.putResult(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
354                            TasksReviewImpl.class, tasksReview.getPrimaryKey(), tasksReview);
355    
356                    if (!isNew &&
357                                    ((tasksReview.getUserId() != tasksReviewModelImpl.getOriginalUserId()) ||
358                                    (tasksReview.getProposalId() != tasksReviewModelImpl.getOriginalProposalId()))) {
359                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_P,
360                                    new Object[] {
361                                            new Long(tasksReviewModelImpl.getOriginalUserId()),
362                                            new Long(tasksReviewModelImpl.getOriginalProposalId())
363                                    });
364                    }
365    
366                    if (isNew ||
367                                    ((tasksReview.getUserId() != tasksReviewModelImpl.getOriginalUserId()) ||
368                                    (tasksReview.getProposalId() != tasksReviewModelImpl.getOriginalProposalId()))) {
369                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_P,
370                                    new Object[] {
371                                            new Long(tasksReview.getUserId()),
372                                            new Long(tasksReview.getProposalId())
373                                    }, tasksReview);
374                    }
375    
376                    return tasksReview;
377            }
378    
379            protected TasksReview toUnwrappedModel(TasksReview tasksReview) {
380                    if (tasksReview instanceof TasksReviewImpl) {
381                            return tasksReview;
382                    }
383    
384                    TasksReviewImpl tasksReviewImpl = new TasksReviewImpl();
385    
386                    tasksReviewImpl.setNew(tasksReview.isNew());
387                    tasksReviewImpl.setPrimaryKey(tasksReview.getPrimaryKey());
388    
389                    tasksReviewImpl.setReviewId(tasksReview.getReviewId());
390                    tasksReviewImpl.setGroupId(tasksReview.getGroupId());
391                    tasksReviewImpl.setCompanyId(tasksReview.getCompanyId());
392                    tasksReviewImpl.setUserId(tasksReview.getUserId());
393                    tasksReviewImpl.setUserName(tasksReview.getUserName());
394                    tasksReviewImpl.setCreateDate(tasksReview.getCreateDate());
395                    tasksReviewImpl.setModifiedDate(tasksReview.getModifiedDate());
396                    tasksReviewImpl.setProposalId(tasksReview.getProposalId());
397                    tasksReviewImpl.setAssignedByUserId(tasksReview.getAssignedByUserId());
398                    tasksReviewImpl.setAssignedByUserName(tasksReview.getAssignedByUserName());
399                    tasksReviewImpl.setStage(tasksReview.getStage());
400                    tasksReviewImpl.setCompleted(tasksReview.isCompleted());
401                    tasksReviewImpl.setRejected(tasksReview.isRejected());
402    
403                    return tasksReviewImpl;
404            }
405    
406            /**
407             * Finds the tasks review with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
408             *
409             * @param primaryKey the primary key of the tasks review to find
410             * @return the tasks review
411             * @throws com.liferay.portal.NoSuchModelException if a tasks review with the primary key could not be found
412             * @throws SystemException if a system exception occurred
413             */
414            public TasksReview findByPrimaryKey(Serializable primaryKey)
415                    throws NoSuchModelException, SystemException {
416                    return findByPrimaryKey(((Long)primaryKey).longValue());
417            }
418    
419            /**
420             * Finds the tasks review with the primary key or throws a {@link com.liferay.portlet.tasks.NoSuchReviewException} if it could not be found.
421             *
422             * @param reviewId the primary key of the tasks review to find
423             * @return the tasks review
424             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a tasks review with the primary key could not be found
425             * @throws SystemException if a system exception occurred
426             */
427            public TasksReview findByPrimaryKey(long reviewId)
428                    throws NoSuchReviewException, SystemException {
429                    TasksReview tasksReview = fetchByPrimaryKey(reviewId);
430    
431                    if (tasksReview == null) {
432                            if (_log.isWarnEnabled()) {
433                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + reviewId);
434                            }
435    
436                            throw new NoSuchReviewException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
437                                    reviewId);
438                    }
439    
440                    return tasksReview;
441            }
442    
443            /**
444             * Finds the tasks review with the primary key or returns <code>null</code> if it could not be found.
445             *
446             * @param primaryKey the primary key of the tasks review to find
447             * @return the tasks review, or <code>null</code> if a tasks review with the primary key could not be found
448             * @throws SystemException if a system exception occurred
449             */
450            public TasksReview fetchByPrimaryKey(Serializable primaryKey)
451                    throws SystemException {
452                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
453            }
454    
455            /**
456             * Finds the tasks review with the primary key or returns <code>null</code> if it could not be found.
457             *
458             * @param reviewId the primary key of the tasks review to find
459             * @return the tasks review, or <code>null</code> if a tasks review with the primary key could not be found
460             * @throws SystemException if a system exception occurred
461             */
462            public TasksReview fetchByPrimaryKey(long reviewId)
463                    throws SystemException {
464                    TasksReview tasksReview = (TasksReview)EntityCacheUtil.getResult(TasksReviewModelImpl.ENTITY_CACHE_ENABLED,
465                                    TasksReviewImpl.class, reviewId, this);
466    
467                    if (tasksReview == null) {
468                            Session session = null;
469    
470                            try {
471                                    session = openSession();
472    
473                                    tasksReview = (TasksReview)session.get(TasksReviewImpl.class,
474                                                    new Long(reviewId));
475                            }
476                            catch (Exception e) {
477                                    throw processException(e);
478                            }
479                            finally {
480                                    if (tasksReview != null) {
481                                            cacheResult(tasksReview);
482                                    }
483    
484                                    closeSession(session);
485                            }
486                    }
487    
488                    return tasksReview;
489            }
490    
491            /**
492             * Finds all the tasks reviews where userId = &#63;.
493             *
494             * @param userId the user id to search with
495             * @return the matching tasks reviews
496             * @throws SystemException if a system exception occurred
497             */
498            public List<TasksReview> findByUserId(long userId)
499                    throws SystemException {
500                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
501            }
502    
503            /**
504             * Finds a range of all the tasks reviews where userId = &#63;.
505             *
506             * <p>
507             * 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.
508             * </p>
509             *
510             * @param userId the user id to search with
511             * @param start the lower bound of the range of tasks reviews to return
512             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
513             * @return the range of matching tasks reviews
514             * @throws SystemException if a system exception occurred
515             */
516            public List<TasksReview> findByUserId(long userId, int start, int end)
517                    throws SystemException {
518                    return findByUserId(userId, start, end, null);
519            }
520    
521            /**
522             * Finds an ordered range of all the tasks reviews where userId = &#63;.
523             *
524             * <p>
525             * 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.
526             * </p>
527             *
528             * @param userId the user id to search with
529             * @param start the lower bound of the range of tasks reviews to return
530             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
531             * @param orderByComparator the comparator to order the results by
532             * @return the ordered range of matching tasks reviews
533             * @throws SystemException if a system exception occurred
534             */
535            public List<TasksReview> findByUserId(long userId, int start, int end,
536                    OrderByComparator orderByComparator) throws SystemException {
537                    Object[] finderArgs = new Object[] {
538                                    userId,
539                                    
540                                    String.valueOf(start), String.valueOf(end),
541                                    String.valueOf(orderByComparator)
542                            };
543    
544                    List<TasksReview> list = (List<TasksReview>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
545                                    finderArgs, this);
546    
547                    if (list == null) {
548                            StringBundler query = null;
549    
550                            if (orderByComparator != null) {
551                                    query = new StringBundler(3 +
552                                                    (orderByComparator.getOrderByFields().length * 3));
553                            }
554                            else {
555                                    query = new StringBundler(3);
556                            }
557    
558                            query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
559    
560                            query.append(_FINDER_COLUMN_USERID_USERID_2);
561    
562                            if (orderByComparator != null) {
563                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
564                                            orderByComparator);
565                            }
566    
567                            else {
568                                    query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
569                            }
570    
571                            String sql = query.toString();
572    
573                            Session session = null;
574    
575                            try {
576                                    session = openSession();
577    
578                                    Query q = session.createQuery(sql);
579    
580                                    QueryPos qPos = QueryPos.getInstance(q);
581    
582                                    qPos.add(userId);
583    
584                                    list = (List<TasksReview>)QueryUtil.list(q, getDialect(),
585                                                    start, end);
586                            }
587                            catch (Exception e) {
588                                    throw processException(e);
589                            }
590                            finally {
591                                    if (list == null) {
592                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_USERID,
593                                                    finderArgs);
594                                    }
595                                    else {
596                                            cacheResult(list);
597    
598                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
599                                                    finderArgs, list);
600                                    }
601    
602                                    closeSession(session);
603                            }
604                    }
605    
606                    return list;
607            }
608    
609            /**
610             * Finds the first tasks review in the ordered set where userId = &#63;.
611             *
612             * <p>
613             * 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.
614             * </p>
615             *
616             * @param userId the user id to search with
617             * @param orderByComparator the comparator to order the set by
618             * @return the first matching tasks review
619             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
620             * @throws SystemException if a system exception occurred
621             */
622            public TasksReview findByUserId_First(long userId,
623                    OrderByComparator orderByComparator)
624                    throws NoSuchReviewException, SystemException {
625                    List<TasksReview> list = findByUserId(userId, 0, 1, orderByComparator);
626    
627                    if (list.isEmpty()) {
628                            StringBundler msg = new StringBundler(4);
629    
630                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
631    
632                            msg.append("userId=");
633                            msg.append(userId);
634    
635                            msg.append(StringPool.CLOSE_CURLY_BRACE);
636    
637                            throw new NoSuchReviewException(msg.toString());
638                    }
639                    else {
640                            return list.get(0);
641                    }
642            }
643    
644            /**
645             * Finds the last tasks review in the ordered set where userId = &#63;.
646             *
647             * <p>
648             * 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.
649             * </p>
650             *
651             * @param userId the user id to search with
652             * @param orderByComparator the comparator to order the set by
653             * @return the last matching tasks review
654             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
655             * @throws SystemException if a system exception occurred
656             */
657            public TasksReview findByUserId_Last(long userId,
658                    OrderByComparator orderByComparator)
659                    throws NoSuchReviewException, SystemException {
660                    int count = countByUserId(userId);
661    
662                    List<TasksReview> list = findByUserId(userId, count - 1, count,
663                                    orderByComparator);
664    
665                    if (list.isEmpty()) {
666                            StringBundler msg = new StringBundler(4);
667    
668                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
669    
670                            msg.append("userId=");
671                            msg.append(userId);
672    
673                            msg.append(StringPool.CLOSE_CURLY_BRACE);
674    
675                            throw new NoSuchReviewException(msg.toString());
676                    }
677                    else {
678                            return list.get(0);
679                    }
680            }
681    
682            /**
683             * Finds the tasks reviews before and after the current tasks review in the ordered set where userId = &#63;.
684             *
685             * <p>
686             * 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.
687             * </p>
688             *
689             * @param reviewId the primary key of the current tasks review
690             * @param userId the user id to search with
691             * @param orderByComparator the comparator to order the set by
692             * @return the previous, current, and next tasks review
693             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a tasks review with the primary key could not be found
694             * @throws SystemException if a system exception occurred
695             */
696            public TasksReview[] findByUserId_PrevAndNext(long reviewId, long userId,
697                    OrderByComparator orderByComparator)
698                    throws NoSuchReviewException, SystemException {
699                    TasksReview tasksReview = findByPrimaryKey(reviewId);
700    
701                    Session session = null;
702    
703                    try {
704                            session = openSession();
705    
706                            TasksReview[] array = new TasksReviewImpl[3];
707    
708                            array[0] = getByUserId_PrevAndNext(session, tasksReview, userId,
709                                            orderByComparator, true);
710    
711                            array[1] = tasksReview;
712    
713                            array[2] = getByUserId_PrevAndNext(session, tasksReview, userId,
714                                            orderByComparator, false);
715    
716                            return array;
717                    }
718                    catch (Exception e) {
719                            throw processException(e);
720                    }
721                    finally {
722                            closeSession(session);
723                    }
724            }
725    
726            protected TasksReview getByUserId_PrevAndNext(Session session,
727                    TasksReview tasksReview, long userId,
728                    OrderByComparator orderByComparator, boolean previous) {
729                    StringBundler query = null;
730    
731                    if (orderByComparator != null) {
732                            query = new StringBundler(6 +
733                                            (orderByComparator.getOrderByFields().length * 6));
734                    }
735                    else {
736                            query = new StringBundler(3);
737                    }
738    
739                    query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
740    
741                    query.append(_FINDER_COLUMN_USERID_USERID_2);
742    
743                    if (orderByComparator != null) {
744                            String[] orderByFields = orderByComparator.getOrderByFields();
745    
746                            if (orderByFields.length > 0) {
747                                    query.append(WHERE_AND);
748                            }
749    
750                            for (int i = 0; i < orderByFields.length; i++) {
751                                    query.append(_ORDER_BY_ENTITY_ALIAS);
752                                    query.append(orderByFields[i]);
753    
754                                    if ((i + 1) < orderByFields.length) {
755                                            if (orderByComparator.isAscending() ^ previous) {
756                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
757                                            }
758                                            else {
759                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
760                                            }
761                                    }
762                                    else {
763                                            if (orderByComparator.isAscending() ^ previous) {
764                                                    query.append(WHERE_GREATER_THAN);
765                                            }
766                                            else {
767                                                    query.append(WHERE_LESSER_THAN);
768                                            }
769                                    }
770                            }
771    
772                            query.append(ORDER_BY_CLAUSE);
773    
774                            for (int i = 0; i < orderByFields.length; i++) {
775                                    query.append(_ORDER_BY_ENTITY_ALIAS);
776                                    query.append(orderByFields[i]);
777    
778                                    if ((i + 1) < orderByFields.length) {
779                                            if (orderByComparator.isAscending() ^ previous) {
780                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
781                                            }
782                                            else {
783                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
784                                            }
785                                    }
786                                    else {
787                                            if (orderByComparator.isAscending() ^ previous) {
788                                                    query.append(ORDER_BY_ASC);
789                                            }
790                                            else {
791                                                    query.append(ORDER_BY_DESC);
792                                            }
793                                    }
794                            }
795                    }
796    
797                    else {
798                            query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
799                    }
800    
801                    String sql = query.toString();
802    
803                    Query q = session.createQuery(sql);
804    
805                    q.setFirstResult(0);
806                    q.setMaxResults(2);
807    
808                    QueryPos qPos = QueryPos.getInstance(q);
809    
810                    qPos.add(userId);
811    
812                    if (orderByComparator != null) {
813                            Object[] values = orderByComparator.getOrderByValues(tasksReview);
814    
815                            for (Object value : values) {
816                                    qPos.add(value);
817                            }
818                    }
819    
820                    List<TasksReview> list = q.list();
821    
822                    if (list.size() == 2) {
823                            return list.get(1);
824                    }
825                    else {
826                            return null;
827                    }
828            }
829    
830            /**
831             * Finds all the tasks reviews where proposalId = &#63;.
832             *
833             * @param proposalId the proposal id to search with
834             * @return the matching tasks reviews
835             * @throws SystemException if a system exception occurred
836             */
837            public List<TasksReview> findByProposalId(long proposalId)
838                    throws SystemException {
839                    return findByProposalId(proposalId, QueryUtil.ALL_POS,
840                            QueryUtil.ALL_POS, null);
841            }
842    
843            /**
844             * Finds a range of all the tasks reviews where proposalId = &#63;.
845             *
846             * <p>
847             * 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.
848             * </p>
849             *
850             * @param proposalId the proposal id to search with
851             * @param start the lower bound of the range of tasks reviews to return
852             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
853             * @return the range of matching tasks reviews
854             * @throws SystemException if a system exception occurred
855             */
856            public List<TasksReview> findByProposalId(long proposalId, int start,
857                    int end) throws SystemException {
858                    return findByProposalId(proposalId, start, end, null);
859            }
860    
861            /**
862             * Finds an ordered range of all the tasks reviews where proposalId = &#63;.
863             *
864             * <p>
865             * 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.
866             * </p>
867             *
868             * @param proposalId the proposal id to search with
869             * @param start the lower bound of the range of tasks reviews to return
870             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
871             * @param orderByComparator the comparator to order the results by
872             * @return the ordered range of matching tasks reviews
873             * @throws SystemException if a system exception occurred
874             */
875            public List<TasksReview> findByProposalId(long proposalId, int start,
876                    int end, OrderByComparator orderByComparator) throws SystemException {
877                    Object[] finderArgs = new Object[] {
878                                    proposalId,
879                                    
880                                    String.valueOf(start), String.valueOf(end),
881                                    String.valueOf(orderByComparator)
882                            };
883    
884                    List<TasksReview> list = (List<TasksReview>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PROPOSALID,
885                                    finderArgs, this);
886    
887                    if (list == null) {
888                            StringBundler query = null;
889    
890                            if (orderByComparator != null) {
891                                    query = new StringBundler(3 +
892                                                    (orderByComparator.getOrderByFields().length * 3));
893                            }
894                            else {
895                                    query = new StringBundler(3);
896                            }
897    
898                            query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
899    
900                            query.append(_FINDER_COLUMN_PROPOSALID_PROPOSALID_2);
901    
902                            if (orderByComparator != null) {
903                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
904                                            orderByComparator);
905                            }
906    
907                            else {
908                                    query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
909                            }
910    
911                            String sql = query.toString();
912    
913                            Session session = null;
914    
915                            try {
916                                    session = openSession();
917    
918                                    Query q = session.createQuery(sql);
919    
920                                    QueryPos qPos = QueryPos.getInstance(q);
921    
922                                    qPos.add(proposalId);
923    
924                                    list = (List<TasksReview>)QueryUtil.list(q, getDialect(),
925                                                    start, end);
926                            }
927                            catch (Exception e) {
928                                    throw processException(e);
929                            }
930                            finally {
931                                    if (list == null) {
932                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_PROPOSALID,
933                                                    finderArgs);
934                                    }
935                                    else {
936                                            cacheResult(list);
937    
938                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PROPOSALID,
939                                                    finderArgs, list);
940                                    }
941    
942                                    closeSession(session);
943                            }
944                    }
945    
946                    return list;
947            }
948    
949            /**
950             * Finds the first tasks review in the ordered set where proposalId = &#63;.
951             *
952             * <p>
953             * 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.
954             * </p>
955             *
956             * @param proposalId the proposal id to search with
957             * @param orderByComparator the comparator to order the set by
958             * @return the first matching tasks review
959             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
960             * @throws SystemException if a system exception occurred
961             */
962            public TasksReview findByProposalId_First(long proposalId,
963                    OrderByComparator orderByComparator)
964                    throws NoSuchReviewException, SystemException {
965                    List<TasksReview> list = findByProposalId(proposalId, 0, 1,
966                                    orderByComparator);
967    
968                    if (list.isEmpty()) {
969                            StringBundler msg = new StringBundler(4);
970    
971                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
972    
973                            msg.append("proposalId=");
974                            msg.append(proposalId);
975    
976                            msg.append(StringPool.CLOSE_CURLY_BRACE);
977    
978                            throw new NoSuchReviewException(msg.toString());
979                    }
980                    else {
981                            return list.get(0);
982                    }
983            }
984    
985            /**
986             * Finds the last tasks review in the ordered set where proposalId = &#63;.
987             *
988             * <p>
989             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
990             * </p>
991             *
992             * @param proposalId the proposal id to search with
993             * @param orderByComparator the comparator to order the set by
994             * @return the last matching tasks review
995             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
996             * @throws SystemException if a system exception occurred
997             */
998            public TasksReview findByProposalId_Last(long proposalId,
999                    OrderByComparator orderByComparator)
1000                    throws NoSuchReviewException, SystemException {
1001                    int count = countByProposalId(proposalId);
1002    
1003                    List<TasksReview> list = findByProposalId(proposalId, count - 1, count,
1004                                    orderByComparator);
1005    
1006                    if (list.isEmpty()) {
1007                            StringBundler msg = new StringBundler(4);
1008    
1009                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1010    
1011                            msg.append("proposalId=");
1012                            msg.append(proposalId);
1013    
1014                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1015    
1016                            throw new NoSuchReviewException(msg.toString());
1017                    }
1018                    else {
1019                            return list.get(0);
1020                    }
1021            }
1022    
1023            /**
1024             * Finds the tasks reviews before and after the current tasks review in the ordered set where proposalId = &#63;.
1025             *
1026             * <p>
1027             * 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.
1028             * </p>
1029             *
1030             * @param reviewId the primary key of the current tasks review
1031             * @param proposalId the proposal id to search with
1032             * @param orderByComparator the comparator to order the set by
1033             * @return the previous, current, and next tasks review
1034             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a tasks review with the primary key could not be found
1035             * @throws SystemException if a system exception occurred
1036             */
1037            public TasksReview[] findByProposalId_PrevAndNext(long reviewId,
1038                    long proposalId, OrderByComparator orderByComparator)
1039                    throws NoSuchReviewException, SystemException {
1040                    TasksReview tasksReview = findByPrimaryKey(reviewId);
1041    
1042                    Session session = null;
1043    
1044                    try {
1045                            session = openSession();
1046    
1047                            TasksReview[] array = new TasksReviewImpl[3];
1048    
1049                            array[0] = getByProposalId_PrevAndNext(session, tasksReview,
1050                                            proposalId, orderByComparator, true);
1051    
1052                            array[1] = tasksReview;
1053    
1054                            array[2] = getByProposalId_PrevAndNext(session, tasksReview,
1055                                            proposalId, orderByComparator, false);
1056    
1057                            return array;
1058                    }
1059                    catch (Exception e) {
1060                            throw processException(e);
1061                    }
1062                    finally {
1063                            closeSession(session);
1064                    }
1065            }
1066    
1067            protected TasksReview getByProposalId_PrevAndNext(Session session,
1068                    TasksReview tasksReview, long proposalId,
1069                    OrderByComparator orderByComparator, boolean previous) {
1070                    StringBundler query = null;
1071    
1072                    if (orderByComparator != null) {
1073                            query = new StringBundler(6 +
1074                                            (orderByComparator.getOrderByFields().length * 6));
1075                    }
1076                    else {
1077                            query = new StringBundler(3);
1078                    }
1079    
1080                    query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
1081    
1082                    query.append(_FINDER_COLUMN_PROPOSALID_PROPOSALID_2);
1083    
1084                    if (orderByComparator != null) {
1085                            String[] orderByFields = orderByComparator.getOrderByFields();
1086    
1087                            if (orderByFields.length > 0) {
1088                                    query.append(WHERE_AND);
1089                            }
1090    
1091                            for (int i = 0; i < orderByFields.length; i++) {
1092                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1093                                    query.append(orderByFields[i]);
1094    
1095                                    if ((i + 1) < orderByFields.length) {
1096                                            if (orderByComparator.isAscending() ^ previous) {
1097                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1098                                            }
1099                                            else {
1100                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1101                                            }
1102                                    }
1103                                    else {
1104                                            if (orderByComparator.isAscending() ^ previous) {
1105                                                    query.append(WHERE_GREATER_THAN);
1106                                            }
1107                                            else {
1108                                                    query.append(WHERE_LESSER_THAN);
1109                                            }
1110                                    }
1111                            }
1112    
1113                            query.append(ORDER_BY_CLAUSE);
1114    
1115                            for (int i = 0; i < orderByFields.length; i++) {
1116                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1117                                    query.append(orderByFields[i]);
1118    
1119                                    if ((i + 1) < orderByFields.length) {
1120                                            if (orderByComparator.isAscending() ^ previous) {
1121                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1122                                            }
1123                                            else {
1124                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1125                                            }
1126                                    }
1127                                    else {
1128                                            if (orderByComparator.isAscending() ^ previous) {
1129                                                    query.append(ORDER_BY_ASC);
1130                                            }
1131                                            else {
1132                                                    query.append(ORDER_BY_DESC);
1133                                            }
1134                                    }
1135                            }
1136                    }
1137    
1138                    else {
1139                            query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
1140                    }
1141    
1142                    String sql = query.toString();
1143    
1144                    Query q = session.createQuery(sql);
1145    
1146                    q.setFirstResult(0);
1147                    q.setMaxResults(2);
1148    
1149                    QueryPos qPos = QueryPos.getInstance(q);
1150    
1151                    qPos.add(proposalId);
1152    
1153                    if (orderByComparator != null) {
1154                            Object[] values = orderByComparator.getOrderByValues(tasksReview);
1155    
1156                            for (Object value : values) {
1157                                    qPos.add(value);
1158                            }
1159                    }
1160    
1161                    List<TasksReview> list = q.list();
1162    
1163                    if (list.size() == 2) {
1164                            return list.get(1);
1165                    }
1166                    else {
1167                            return null;
1168                    }
1169            }
1170    
1171            /**
1172             * Finds the tasks review where userId = &#63; and proposalId = &#63; or throws a {@link com.liferay.portlet.tasks.NoSuchReviewException} if it could not be found.
1173             *
1174             * @param userId the user id to search with
1175             * @param proposalId the proposal id to search with
1176             * @return the matching tasks review
1177             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
1178             * @throws SystemException if a system exception occurred
1179             */
1180            public TasksReview findByU_P(long userId, long proposalId)
1181                    throws NoSuchReviewException, SystemException {
1182                    TasksReview tasksReview = fetchByU_P(userId, proposalId);
1183    
1184                    if (tasksReview == null) {
1185                            StringBundler msg = new StringBundler(6);
1186    
1187                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1188    
1189                            msg.append("userId=");
1190                            msg.append(userId);
1191    
1192                            msg.append(", proposalId=");
1193                            msg.append(proposalId);
1194    
1195                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1196    
1197                            if (_log.isWarnEnabled()) {
1198                                    _log.warn(msg.toString());
1199                            }
1200    
1201                            throw new NoSuchReviewException(msg.toString());
1202                    }
1203    
1204                    return tasksReview;
1205            }
1206    
1207            /**
1208             * Finds the tasks review where userId = &#63; and proposalId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1209             *
1210             * @param userId the user id to search with
1211             * @param proposalId the proposal id to search with
1212             * @return the matching tasks review, or <code>null</code> if a matching tasks review could not be found
1213             * @throws SystemException if a system exception occurred
1214             */
1215            public TasksReview fetchByU_P(long userId, long proposalId)
1216                    throws SystemException {
1217                    return fetchByU_P(userId, proposalId, true);
1218            }
1219    
1220            /**
1221             * Finds the tasks review where userId = &#63; and proposalId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1222             *
1223             * @param userId the user id to search with
1224             * @param proposalId the proposal id to search with
1225             * @return the matching tasks review, or <code>null</code> if a matching tasks review could not be found
1226             * @throws SystemException if a system exception occurred
1227             */
1228            public TasksReview fetchByU_P(long userId, long proposalId,
1229                    boolean retrieveFromCache) throws SystemException {
1230                    Object[] finderArgs = new Object[] { userId, proposalId };
1231    
1232                    Object result = null;
1233    
1234                    if (retrieveFromCache) {
1235                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_P,
1236                                            finderArgs, this);
1237                    }
1238    
1239                    if (result == null) {
1240                            StringBundler query = new StringBundler(4);
1241    
1242                            query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
1243    
1244                            query.append(_FINDER_COLUMN_U_P_USERID_2);
1245    
1246                            query.append(_FINDER_COLUMN_U_P_PROPOSALID_2);
1247    
1248                            query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
1249    
1250                            String sql = query.toString();
1251    
1252                            Session session = null;
1253    
1254                            try {
1255                                    session = openSession();
1256    
1257                                    Query q = session.createQuery(sql);
1258    
1259                                    QueryPos qPos = QueryPos.getInstance(q);
1260    
1261                                    qPos.add(userId);
1262    
1263                                    qPos.add(proposalId);
1264    
1265                                    List<TasksReview> list = q.list();
1266    
1267                                    result = list;
1268    
1269                                    TasksReview tasksReview = null;
1270    
1271                                    if (list.isEmpty()) {
1272                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_P,
1273                                                    finderArgs, list);
1274                                    }
1275                                    else {
1276                                            tasksReview = list.get(0);
1277    
1278                                            cacheResult(tasksReview);
1279    
1280                                            if ((tasksReview.getUserId() != userId) ||
1281                                                            (tasksReview.getProposalId() != proposalId)) {
1282                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_P,
1283                                                            finderArgs, tasksReview);
1284                                            }
1285                                    }
1286    
1287                                    return tasksReview;
1288                            }
1289                            catch (Exception e) {
1290                                    throw processException(e);
1291                            }
1292                            finally {
1293                                    if (result == null) {
1294                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_P,
1295                                                    finderArgs);
1296                                    }
1297    
1298                                    closeSession(session);
1299                            }
1300                    }
1301                    else {
1302                            if (result instanceof List<?>) {
1303                                    return null;
1304                            }
1305                            else {
1306                                    return (TasksReview)result;
1307                            }
1308                    }
1309            }
1310    
1311            /**
1312             * Finds all the tasks reviews where proposalId = &#63; and stage = &#63;.
1313             *
1314             * @param proposalId the proposal id to search with
1315             * @param stage the stage to search with
1316             * @return the matching tasks reviews
1317             * @throws SystemException if a system exception occurred
1318             */
1319            public List<TasksReview> findByP_S(long proposalId, int stage)
1320                    throws SystemException {
1321                    return findByP_S(proposalId, stage, QueryUtil.ALL_POS,
1322                            QueryUtil.ALL_POS, null);
1323            }
1324    
1325            /**
1326             * Finds a range of all the tasks reviews where proposalId = &#63; and stage = &#63;.
1327             *
1328             * <p>
1329             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1330             * </p>
1331             *
1332             * @param proposalId the proposal id to search with
1333             * @param stage the stage to search with
1334             * @param start the lower bound of the range of tasks reviews to return
1335             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
1336             * @return the range of matching tasks reviews
1337             * @throws SystemException if a system exception occurred
1338             */
1339            public List<TasksReview> findByP_S(long proposalId, int stage, int start,
1340                    int end) throws SystemException {
1341                    return findByP_S(proposalId, stage, start, end, null);
1342            }
1343    
1344            /**
1345             * Finds an ordered range of all the tasks reviews where proposalId = &#63; and stage = &#63;.
1346             *
1347             * <p>
1348             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1349             * </p>
1350             *
1351             * @param proposalId the proposal id to search with
1352             * @param stage the stage to search with
1353             * @param start the lower bound of the range of tasks reviews to return
1354             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
1355             * @param orderByComparator the comparator to order the results by
1356             * @return the ordered range of matching tasks reviews
1357             * @throws SystemException if a system exception occurred
1358             */
1359            public List<TasksReview> findByP_S(long proposalId, int stage, int start,
1360                    int end, OrderByComparator orderByComparator) throws SystemException {
1361                    Object[] finderArgs = new Object[] {
1362                                    proposalId, stage,
1363                                    
1364                                    String.valueOf(start), String.valueOf(end),
1365                                    String.valueOf(orderByComparator)
1366                            };
1367    
1368                    List<TasksReview> list = (List<TasksReview>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_S,
1369                                    finderArgs, this);
1370    
1371                    if (list == null) {
1372                            StringBundler query = null;
1373    
1374                            if (orderByComparator != null) {
1375                                    query = new StringBundler(4 +
1376                                                    (orderByComparator.getOrderByFields().length * 3));
1377                            }
1378                            else {
1379                                    query = new StringBundler(4);
1380                            }
1381    
1382                            query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
1383    
1384                            query.append(_FINDER_COLUMN_P_S_PROPOSALID_2);
1385    
1386                            query.append(_FINDER_COLUMN_P_S_STAGE_2);
1387    
1388                            if (orderByComparator != null) {
1389                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1390                                            orderByComparator);
1391                            }
1392    
1393                            else {
1394                                    query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
1395                            }
1396    
1397                            String sql = query.toString();
1398    
1399                            Session session = null;
1400    
1401                            try {
1402                                    session = openSession();
1403    
1404                                    Query q = session.createQuery(sql);
1405    
1406                                    QueryPos qPos = QueryPos.getInstance(q);
1407    
1408                                    qPos.add(proposalId);
1409    
1410                                    qPos.add(stage);
1411    
1412                                    list = (List<TasksReview>)QueryUtil.list(q, getDialect(),
1413                                                    start, end);
1414                            }
1415                            catch (Exception e) {
1416                                    throw processException(e);
1417                            }
1418                            finally {
1419                                    if (list == null) {
1420                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_P_S,
1421                                                    finderArgs);
1422                                    }
1423                                    else {
1424                                            cacheResult(list);
1425    
1426                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_S,
1427                                                    finderArgs, list);
1428                                    }
1429    
1430                                    closeSession(session);
1431                            }
1432                    }
1433    
1434                    return list;
1435            }
1436    
1437            /**
1438             * Finds the first tasks review in the ordered set where proposalId = &#63; and stage = &#63;.
1439             *
1440             * <p>
1441             * 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.
1442             * </p>
1443             *
1444             * @param proposalId the proposal id to search with
1445             * @param stage the stage to search with
1446             * @param orderByComparator the comparator to order the set by
1447             * @return the first matching tasks review
1448             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
1449             * @throws SystemException if a system exception occurred
1450             */
1451            public TasksReview findByP_S_First(long proposalId, int stage,
1452                    OrderByComparator orderByComparator)
1453                    throws NoSuchReviewException, SystemException {
1454                    List<TasksReview> list = findByP_S(proposalId, stage, 0, 1,
1455                                    orderByComparator);
1456    
1457                    if (list.isEmpty()) {
1458                            StringBundler msg = new StringBundler(6);
1459    
1460                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1461    
1462                            msg.append("proposalId=");
1463                            msg.append(proposalId);
1464    
1465                            msg.append(", stage=");
1466                            msg.append(stage);
1467    
1468                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1469    
1470                            throw new NoSuchReviewException(msg.toString());
1471                    }
1472                    else {
1473                            return list.get(0);
1474                    }
1475            }
1476    
1477            /**
1478             * Finds the last tasks review in the ordered set where proposalId = &#63; and stage = &#63;.
1479             *
1480             * <p>
1481             * 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.
1482             * </p>
1483             *
1484             * @param proposalId the proposal id to search with
1485             * @param stage the stage to search with
1486             * @param orderByComparator the comparator to order the set by
1487             * @return the last matching tasks review
1488             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
1489             * @throws SystemException if a system exception occurred
1490             */
1491            public TasksReview findByP_S_Last(long proposalId, int stage,
1492                    OrderByComparator orderByComparator)
1493                    throws NoSuchReviewException, SystemException {
1494                    int count = countByP_S(proposalId, stage);
1495    
1496                    List<TasksReview> list = findByP_S(proposalId, stage, count - 1, count,
1497                                    orderByComparator);
1498    
1499                    if (list.isEmpty()) {
1500                            StringBundler msg = new StringBundler(6);
1501    
1502                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1503    
1504                            msg.append("proposalId=");
1505                            msg.append(proposalId);
1506    
1507                            msg.append(", stage=");
1508                            msg.append(stage);
1509    
1510                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1511    
1512                            throw new NoSuchReviewException(msg.toString());
1513                    }
1514                    else {
1515                            return list.get(0);
1516                    }
1517            }
1518    
1519            /**
1520             * Finds the tasks reviews before and after the current tasks review in the ordered set where proposalId = &#63; and stage = &#63;.
1521             *
1522             * <p>
1523             * 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.
1524             * </p>
1525             *
1526             * @param reviewId the primary key of the current tasks review
1527             * @param proposalId the proposal id to search with
1528             * @param stage the stage to search with
1529             * @param orderByComparator the comparator to order the set by
1530             * @return the previous, current, and next tasks review
1531             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a tasks review with the primary key could not be found
1532             * @throws SystemException if a system exception occurred
1533             */
1534            public TasksReview[] findByP_S_PrevAndNext(long reviewId, long proposalId,
1535                    int stage, OrderByComparator orderByComparator)
1536                    throws NoSuchReviewException, SystemException {
1537                    TasksReview tasksReview = findByPrimaryKey(reviewId);
1538    
1539                    Session session = null;
1540    
1541                    try {
1542                            session = openSession();
1543    
1544                            TasksReview[] array = new TasksReviewImpl[3];
1545    
1546                            array[0] = getByP_S_PrevAndNext(session, tasksReview, proposalId,
1547                                            stage, orderByComparator, true);
1548    
1549                            array[1] = tasksReview;
1550    
1551                            array[2] = getByP_S_PrevAndNext(session, tasksReview, proposalId,
1552                                            stage, orderByComparator, false);
1553    
1554                            return array;
1555                    }
1556                    catch (Exception e) {
1557                            throw processException(e);
1558                    }
1559                    finally {
1560                            closeSession(session);
1561                    }
1562            }
1563    
1564            protected TasksReview getByP_S_PrevAndNext(Session session,
1565                    TasksReview tasksReview, long proposalId, int stage,
1566                    OrderByComparator orderByComparator, boolean previous) {
1567                    StringBundler query = null;
1568    
1569                    if (orderByComparator != null) {
1570                            query = new StringBundler(6 +
1571                                            (orderByComparator.getOrderByFields().length * 6));
1572                    }
1573                    else {
1574                            query = new StringBundler(3);
1575                    }
1576    
1577                    query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
1578    
1579                    query.append(_FINDER_COLUMN_P_S_PROPOSALID_2);
1580    
1581                    query.append(_FINDER_COLUMN_P_S_STAGE_2);
1582    
1583                    if (orderByComparator != null) {
1584                            String[] orderByFields = orderByComparator.getOrderByFields();
1585    
1586                            if (orderByFields.length > 0) {
1587                                    query.append(WHERE_AND);
1588                            }
1589    
1590                            for (int i = 0; i < orderByFields.length; i++) {
1591                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1592                                    query.append(orderByFields[i]);
1593    
1594                                    if ((i + 1) < orderByFields.length) {
1595                                            if (orderByComparator.isAscending() ^ previous) {
1596                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1597                                            }
1598                                            else {
1599                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1600                                            }
1601                                    }
1602                                    else {
1603                                            if (orderByComparator.isAscending() ^ previous) {
1604                                                    query.append(WHERE_GREATER_THAN);
1605                                            }
1606                                            else {
1607                                                    query.append(WHERE_LESSER_THAN);
1608                                            }
1609                                    }
1610                            }
1611    
1612                            query.append(ORDER_BY_CLAUSE);
1613    
1614                            for (int i = 0; i < orderByFields.length; i++) {
1615                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1616                                    query.append(orderByFields[i]);
1617    
1618                                    if ((i + 1) < orderByFields.length) {
1619                                            if (orderByComparator.isAscending() ^ previous) {
1620                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1621                                            }
1622                                            else {
1623                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1624                                            }
1625                                    }
1626                                    else {
1627                                            if (orderByComparator.isAscending() ^ previous) {
1628                                                    query.append(ORDER_BY_ASC);
1629                                            }
1630                                            else {
1631                                                    query.append(ORDER_BY_DESC);
1632                                            }
1633                                    }
1634                            }
1635                    }
1636    
1637                    else {
1638                            query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
1639                    }
1640    
1641                    String sql = query.toString();
1642    
1643                    Query q = session.createQuery(sql);
1644    
1645                    q.setFirstResult(0);
1646                    q.setMaxResults(2);
1647    
1648                    QueryPos qPos = QueryPos.getInstance(q);
1649    
1650                    qPos.add(proposalId);
1651    
1652                    qPos.add(stage);
1653    
1654                    if (orderByComparator != null) {
1655                            Object[] values = orderByComparator.getOrderByValues(tasksReview);
1656    
1657                            for (Object value : values) {
1658                                    qPos.add(value);
1659                            }
1660                    }
1661    
1662                    List<TasksReview> list = q.list();
1663    
1664                    if (list.size() == 2) {
1665                            return list.get(1);
1666                    }
1667                    else {
1668                            return null;
1669                    }
1670            }
1671    
1672            /**
1673             * Finds all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63;.
1674             *
1675             * @param proposalId the proposal id to search with
1676             * @param stage the stage to search with
1677             * @param completed the completed to search with
1678             * @return the matching tasks reviews
1679             * @throws SystemException if a system exception occurred
1680             */
1681            public List<TasksReview> findByP_S_C(long proposalId, int stage,
1682                    boolean completed) throws SystemException {
1683                    return findByP_S_C(proposalId, stage, completed, QueryUtil.ALL_POS,
1684                            QueryUtil.ALL_POS, null);
1685            }
1686    
1687            /**
1688             * Finds a range of all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63;.
1689             *
1690             * <p>
1691             * 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.
1692             * </p>
1693             *
1694             * @param proposalId the proposal id to search with
1695             * @param stage the stage to search with
1696             * @param completed the completed to search with
1697             * @param start the lower bound of the range of tasks reviews to return
1698             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
1699             * @return the range of matching tasks reviews
1700             * @throws SystemException if a system exception occurred
1701             */
1702            public List<TasksReview> findByP_S_C(long proposalId, int stage,
1703                    boolean completed, int start, int end) throws SystemException {
1704                    return findByP_S_C(proposalId, stage, completed, start, end, null);
1705            }
1706    
1707            /**
1708             * Finds an ordered range of all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63;.
1709             *
1710             * <p>
1711             * 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.
1712             * </p>
1713             *
1714             * @param proposalId the proposal id to search with
1715             * @param stage the stage to search with
1716             * @param completed the completed to search with
1717             * @param start the lower bound of the range of tasks reviews to return
1718             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
1719             * @param orderByComparator the comparator to order the results by
1720             * @return the ordered range of matching tasks reviews
1721             * @throws SystemException if a system exception occurred
1722             */
1723            public List<TasksReview> findByP_S_C(long proposalId, int stage,
1724                    boolean completed, int start, int end,
1725                    OrderByComparator orderByComparator) throws SystemException {
1726                    Object[] finderArgs = new Object[] {
1727                                    proposalId, stage, completed,
1728                                    
1729                                    String.valueOf(start), String.valueOf(end),
1730                                    String.valueOf(orderByComparator)
1731                            };
1732    
1733                    List<TasksReview> list = (List<TasksReview>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_S_C,
1734                                    finderArgs, this);
1735    
1736                    if (list == null) {
1737                            StringBundler query = null;
1738    
1739                            if (orderByComparator != null) {
1740                                    query = new StringBundler(5 +
1741                                                    (orderByComparator.getOrderByFields().length * 3));
1742                            }
1743                            else {
1744                                    query = new StringBundler(5);
1745                            }
1746    
1747                            query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
1748    
1749                            query.append(_FINDER_COLUMN_P_S_C_PROPOSALID_2);
1750    
1751                            query.append(_FINDER_COLUMN_P_S_C_STAGE_2);
1752    
1753                            query.append(_FINDER_COLUMN_P_S_C_COMPLETED_2);
1754    
1755                            if (orderByComparator != null) {
1756                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1757                                            orderByComparator);
1758                            }
1759    
1760                            else {
1761                                    query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
1762                            }
1763    
1764                            String sql = query.toString();
1765    
1766                            Session session = null;
1767    
1768                            try {
1769                                    session = openSession();
1770    
1771                                    Query q = session.createQuery(sql);
1772    
1773                                    QueryPos qPos = QueryPos.getInstance(q);
1774    
1775                                    qPos.add(proposalId);
1776    
1777                                    qPos.add(stage);
1778    
1779                                    qPos.add(completed);
1780    
1781                                    list = (List<TasksReview>)QueryUtil.list(q, getDialect(),
1782                                                    start, end);
1783                            }
1784                            catch (Exception e) {
1785                                    throw processException(e);
1786                            }
1787                            finally {
1788                                    if (list == null) {
1789                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_P_S_C,
1790                                                    finderArgs);
1791                                    }
1792                                    else {
1793                                            cacheResult(list);
1794    
1795                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_S_C,
1796                                                    finderArgs, list);
1797                                    }
1798    
1799                                    closeSession(session);
1800                            }
1801                    }
1802    
1803                    return list;
1804            }
1805    
1806            /**
1807             * Finds the first tasks review in the ordered set where proposalId = &#63; and stage = &#63; and completed = &#63;.
1808             *
1809             * <p>
1810             * 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.
1811             * </p>
1812             *
1813             * @param proposalId the proposal id to search with
1814             * @param stage the stage to search with
1815             * @param completed the completed to search with
1816             * @param orderByComparator the comparator to order the set by
1817             * @return the first matching tasks review
1818             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
1819             * @throws SystemException if a system exception occurred
1820             */
1821            public TasksReview findByP_S_C_First(long proposalId, int stage,
1822                    boolean completed, OrderByComparator orderByComparator)
1823                    throws NoSuchReviewException, SystemException {
1824                    List<TasksReview> list = findByP_S_C(proposalId, stage, completed, 0,
1825                                    1, orderByComparator);
1826    
1827                    if (list.isEmpty()) {
1828                            StringBundler msg = new StringBundler(8);
1829    
1830                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1831    
1832                            msg.append("proposalId=");
1833                            msg.append(proposalId);
1834    
1835                            msg.append(", stage=");
1836                            msg.append(stage);
1837    
1838                            msg.append(", completed=");
1839                            msg.append(completed);
1840    
1841                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1842    
1843                            throw new NoSuchReviewException(msg.toString());
1844                    }
1845                    else {
1846                            return list.get(0);
1847                    }
1848            }
1849    
1850            /**
1851             * Finds the last tasks review in the ordered set where proposalId = &#63; and stage = &#63; and completed = &#63;.
1852             *
1853             * <p>
1854             * 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.
1855             * </p>
1856             *
1857             * @param proposalId the proposal id to search with
1858             * @param stage the stage to search with
1859             * @param completed the completed to search with
1860             * @param orderByComparator the comparator to order the set by
1861             * @return the last matching tasks review
1862             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
1863             * @throws SystemException if a system exception occurred
1864             */
1865            public TasksReview findByP_S_C_Last(long proposalId, int stage,
1866                    boolean completed, OrderByComparator orderByComparator)
1867                    throws NoSuchReviewException, SystemException {
1868                    int count = countByP_S_C(proposalId, stage, completed);
1869    
1870                    List<TasksReview> list = findByP_S_C(proposalId, stage, completed,
1871                                    count - 1, count, orderByComparator);
1872    
1873                    if (list.isEmpty()) {
1874                            StringBundler msg = new StringBundler(8);
1875    
1876                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1877    
1878                            msg.append("proposalId=");
1879                            msg.append(proposalId);
1880    
1881                            msg.append(", stage=");
1882                            msg.append(stage);
1883    
1884                            msg.append(", completed=");
1885                            msg.append(completed);
1886    
1887                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1888    
1889                            throw new NoSuchReviewException(msg.toString());
1890                    }
1891                    else {
1892                            return list.get(0);
1893                    }
1894            }
1895    
1896            /**
1897             * Finds the tasks reviews before and after the current tasks review in the ordered set where proposalId = &#63; and stage = &#63; and completed = &#63;.
1898             *
1899             * <p>
1900             * 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.
1901             * </p>
1902             *
1903             * @param reviewId the primary key of the current tasks review
1904             * @param proposalId the proposal id to search with
1905             * @param stage the stage to search with
1906             * @param completed the completed to search with
1907             * @param orderByComparator the comparator to order the set by
1908             * @return the previous, current, and next tasks review
1909             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a tasks review with the primary key could not be found
1910             * @throws SystemException if a system exception occurred
1911             */
1912            public TasksReview[] findByP_S_C_PrevAndNext(long reviewId,
1913                    long proposalId, int stage, boolean completed,
1914                    OrderByComparator orderByComparator)
1915                    throws NoSuchReviewException, SystemException {
1916                    TasksReview tasksReview = findByPrimaryKey(reviewId);
1917    
1918                    Session session = null;
1919    
1920                    try {
1921                            session = openSession();
1922    
1923                            TasksReview[] array = new TasksReviewImpl[3];
1924    
1925                            array[0] = getByP_S_C_PrevAndNext(session, tasksReview, proposalId,
1926                                            stage, completed, orderByComparator, true);
1927    
1928                            array[1] = tasksReview;
1929    
1930                            array[2] = getByP_S_C_PrevAndNext(session, tasksReview, proposalId,
1931                                            stage, completed, orderByComparator, false);
1932    
1933                            return array;
1934                    }
1935                    catch (Exception e) {
1936                            throw processException(e);
1937                    }
1938                    finally {
1939                            closeSession(session);
1940                    }
1941            }
1942    
1943            protected TasksReview getByP_S_C_PrevAndNext(Session session,
1944                    TasksReview tasksReview, long proposalId, int stage, boolean completed,
1945                    OrderByComparator orderByComparator, boolean previous) {
1946                    StringBundler query = null;
1947    
1948                    if (orderByComparator != null) {
1949                            query = new StringBundler(6 +
1950                                            (orderByComparator.getOrderByFields().length * 6));
1951                    }
1952                    else {
1953                            query = new StringBundler(3);
1954                    }
1955    
1956                    query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
1957    
1958                    query.append(_FINDER_COLUMN_P_S_C_PROPOSALID_2);
1959    
1960                    query.append(_FINDER_COLUMN_P_S_C_STAGE_2);
1961    
1962                    query.append(_FINDER_COLUMN_P_S_C_COMPLETED_2);
1963    
1964                    if (orderByComparator != null) {
1965                            String[] orderByFields = orderByComparator.getOrderByFields();
1966    
1967                            if (orderByFields.length > 0) {
1968                                    query.append(WHERE_AND);
1969                            }
1970    
1971                            for (int i = 0; i < orderByFields.length; i++) {
1972                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1973                                    query.append(orderByFields[i]);
1974    
1975                                    if ((i + 1) < orderByFields.length) {
1976                                            if (orderByComparator.isAscending() ^ previous) {
1977                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1978                                            }
1979                                            else {
1980                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1981                                            }
1982                                    }
1983                                    else {
1984                                            if (orderByComparator.isAscending() ^ previous) {
1985                                                    query.append(WHERE_GREATER_THAN);
1986                                            }
1987                                            else {
1988                                                    query.append(WHERE_LESSER_THAN);
1989                                            }
1990                                    }
1991                            }
1992    
1993                            query.append(ORDER_BY_CLAUSE);
1994    
1995                            for (int i = 0; i < orderByFields.length; i++) {
1996                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1997                                    query.append(orderByFields[i]);
1998    
1999                                    if ((i + 1) < orderByFields.length) {
2000                                            if (orderByComparator.isAscending() ^ previous) {
2001                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2002                                            }
2003                                            else {
2004                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2005                                            }
2006                                    }
2007                                    else {
2008                                            if (orderByComparator.isAscending() ^ previous) {
2009                                                    query.append(ORDER_BY_ASC);
2010                                            }
2011                                            else {
2012                                                    query.append(ORDER_BY_DESC);
2013                                            }
2014                                    }
2015                            }
2016                    }
2017    
2018                    else {
2019                            query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
2020                    }
2021    
2022                    String sql = query.toString();
2023    
2024                    Query q = session.createQuery(sql);
2025    
2026                    q.setFirstResult(0);
2027                    q.setMaxResults(2);
2028    
2029                    QueryPos qPos = QueryPos.getInstance(q);
2030    
2031                    qPos.add(proposalId);
2032    
2033                    qPos.add(stage);
2034    
2035                    qPos.add(completed);
2036    
2037                    if (orderByComparator != null) {
2038                            Object[] values = orderByComparator.getOrderByValues(tasksReview);
2039    
2040                            for (Object value : values) {
2041                                    qPos.add(value);
2042                            }
2043                    }
2044    
2045                    List<TasksReview> list = q.list();
2046    
2047                    if (list.size() == 2) {
2048                            return list.get(1);
2049                    }
2050                    else {
2051                            return null;
2052                    }
2053            }
2054    
2055            /**
2056             * Finds all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63; and rejected = &#63;.
2057             *
2058             * @param proposalId the proposal id to search with
2059             * @param stage the stage to search with
2060             * @param completed the completed to search with
2061             * @param rejected the rejected to search with
2062             * @return the matching tasks reviews
2063             * @throws SystemException if a system exception occurred
2064             */
2065            public List<TasksReview> findByP_S_C_R(long proposalId, int stage,
2066                    boolean completed, boolean rejected) throws SystemException {
2067                    return findByP_S_C_R(proposalId, stage, completed, rejected,
2068                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2069            }
2070    
2071            /**
2072             * Finds a range of all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63; and rejected = &#63;.
2073             *
2074             * <p>
2075             * 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.
2076             * </p>
2077             *
2078             * @param proposalId the proposal id to search with
2079             * @param stage the stage to search with
2080             * @param completed the completed to search with
2081             * @param rejected the rejected to search with
2082             * @param start the lower bound of the range of tasks reviews to return
2083             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
2084             * @return the range of matching tasks reviews
2085             * @throws SystemException if a system exception occurred
2086             */
2087            public List<TasksReview> findByP_S_C_R(long proposalId, int stage,
2088                    boolean completed, boolean rejected, int start, int end)
2089                    throws SystemException {
2090                    return findByP_S_C_R(proposalId, stage, completed, rejected, start,
2091                            end, null);
2092            }
2093    
2094            /**
2095             * Finds an ordered range of all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63; and rejected = &#63;.
2096             *
2097             * <p>
2098             * 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.
2099             * </p>
2100             *
2101             * @param proposalId the proposal id to search with
2102             * @param stage the stage to search with
2103             * @param completed the completed to search with
2104             * @param rejected the rejected to search with
2105             * @param start the lower bound of the range of tasks reviews to return
2106             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
2107             * @param orderByComparator the comparator to order the results by
2108             * @return the ordered range of matching tasks reviews
2109             * @throws SystemException if a system exception occurred
2110             */
2111            public List<TasksReview> findByP_S_C_R(long proposalId, int stage,
2112                    boolean completed, boolean rejected, int start, int end,
2113                    OrderByComparator orderByComparator) throws SystemException {
2114                    Object[] finderArgs = new Object[] {
2115                                    proposalId, stage, completed, rejected,
2116                                    
2117                                    String.valueOf(start), String.valueOf(end),
2118                                    String.valueOf(orderByComparator)
2119                            };
2120    
2121                    List<TasksReview> list = (List<TasksReview>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_S_C_R,
2122                                    finderArgs, this);
2123    
2124                    if (list == null) {
2125                            StringBundler query = null;
2126    
2127                            if (orderByComparator != null) {
2128                                    query = new StringBundler(6 +
2129                                                    (orderByComparator.getOrderByFields().length * 3));
2130                            }
2131                            else {
2132                                    query = new StringBundler(6);
2133                            }
2134    
2135                            query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
2136    
2137                            query.append(_FINDER_COLUMN_P_S_C_R_PROPOSALID_2);
2138    
2139                            query.append(_FINDER_COLUMN_P_S_C_R_STAGE_2);
2140    
2141                            query.append(_FINDER_COLUMN_P_S_C_R_COMPLETED_2);
2142    
2143                            query.append(_FINDER_COLUMN_P_S_C_R_REJECTED_2);
2144    
2145                            if (orderByComparator != null) {
2146                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2147                                            orderByComparator);
2148                            }
2149    
2150                            else {
2151                                    query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
2152                            }
2153    
2154                            String sql = query.toString();
2155    
2156                            Session session = null;
2157    
2158                            try {
2159                                    session = openSession();
2160    
2161                                    Query q = session.createQuery(sql);
2162    
2163                                    QueryPos qPos = QueryPos.getInstance(q);
2164    
2165                                    qPos.add(proposalId);
2166    
2167                                    qPos.add(stage);
2168    
2169                                    qPos.add(completed);
2170    
2171                                    qPos.add(rejected);
2172    
2173                                    list = (List<TasksReview>)QueryUtil.list(q, getDialect(),
2174                                                    start, end);
2175                            }
2176                            catch (Exception e) {
2177                                    throw processException(e);
2178                            }
2179                            finally {
2180                                    if (list == null) {
2181                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_P_S_C_R,
2182                                                    finderArgs);
2183                                    }
2184                                    else {
2185                                            cacheResult(list);
2186    
2187                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_S_C_R,
2188                                                    finderArgs, list);
2189                                    }
2190    
2191                                    closeSession(session);
2192                            }
2193                    }
2194    
2195                    return list;
2196            }
2197    
2198            /**
2199             * Finds the first tasks review in the ordered set where proposalId = &#63; and stage = &#63; and completed = &#63; and rejected = &#63;.
2200             *
2201             * <p>
2202             * 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.
2203             * </p>
2204             *
2205             * @param proposalId the proposal id to search with
2206             * @param stage the stage to search with
2207             * @param completed the completed to search with
2208             * @param rejected the rejected to search with
2209             * @param orderByComparator the comparator to order the set by
2210             * @return the first matching tasks review
2211             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
2212             * @throws SystemException if a system exception occurred
2213             */
2214            public TasksReview findByP_S_C_R_First(long proposalId, int stage,
2215                    boolean completed, boolean rejected, OrderByComparator orderByComparator)
2216                    throws NoSuchReviewException, SystemException {
2217                    List<TasksReview> list = findByP_S_C_R(proposalId, stage, completed,
2218                                    rejected, 0, 1, orderByComparator);
2219    
2220                    if (list.isEmpty()) {
2221                            StringBundler msg = new StringBundler(10);
2222    
2223                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2224    
2225                            msg.append("proposalId=");
2226                            msg.append(proposalId);
2227    
2228                            msg.append(", stage=");
2229                            msg.append(stage);
2230    
2231                            msg.append(", completed=");
2232                            msg.append(completed);
2233    
2234                            msg.append(", rejected=");
2235                            msg.append(rejected);
2236    
2237                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2238    
2239                            throw new NoSuchReviewException(msg.toString());
2240                    }
2241                    else {
2242                            return list.get(0);
2243                    }
2244            }
2245    
2246            /**
2247             * Finds the last tasks review in the ordered set where proposalId = &#63; and stage = &#63; and completed = &#63; and rejected = &#63;.
2248             *
2249             * <p>
2250             * 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.
2251             * </p>
2252             *
2253             * @param proposalId the proposal id to search with
2254             * @param stage the stage to search with
2255             * @param completed the completed to search with
2256             * @param rejected the rejected to search with
2257             * @param orderByComparator the comparator to order the set by
2258             * @return the last matching tasks review
2259             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a matching tasks review could not be found
2260             * @throws SystemException if a system exception occurred
2261             */
2262            public TasksReview findByP_S_C_R_Last(long proposalId, int stage,
2263                    boolean completed, boolean rejected, OrderByComparator orderByComparator)
2264                    throws NoSuchReviewException, SystemException {
2265                    int count = countByP_S_C_R(proposalId, stage, completed, rejected);
2266    
2267                    List<TasksReview> list = findByP_S_C_R(proposalId, stage, completed,
2268                                    rejected, count - 1, count, orderByComparator);
2269    
2270                    if (list.isEmpty()) {
2271                            StringBundler msg = new StringBundler(10);
2272    
2273                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2274    
2275                            msg.append("proposalId=");
2276                            msg.append(proposalId);
2277    
2278                            msg.append(", stage=");
2279                            msg.append(stage);
2280    
2281                            msg.append(", completed=");
2282                            msg.append(completed);
2283    
2284                            msg.append(", rejected=");
2285                            msg.append(rejected);
2286    
2287                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2288    
2289                            throw new NoSuchReviewException(msg.toString());
2290                    }
2291                    else {
2292                            return list.get(0);
2293                    }
2294            }
2295    
2296            /**
2297             * Finds the tasks reviews before and after the current tasks review in the ordered set where proposalId = &#63; and stage = &#63; and completed = &#63; and rejected = &#63;.
2298             *
2299             * <p>
2300             * 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.
2301             * </p>
2302             *
2303             * @param reviewId the primary key of the current tasks review
2304             * @param proposalId the proposal id to search with
2305             * @param stage the stage to search with
2306             * @param completed the completed to search with
2307             * @param rejected the rejected to search with
2308             * @param orderByComparator the comparator to order the set by
2309             * @return the previous, current, and next tasks review
2310             * @throws com.liferay.portlet.tasks.NoSuchReviewException if a tasks review with the primary key could not be found
2311             * @throws SystemException if a system exception occurred
2312             */
2313            public TasksReview[] findByP_S_C_R_PrevAndNext(long reviewId,
2314                    long proposalId, int stage, boolean completed, boolean rejected,
2315                    OrderByComparator orderByComparator)
2316                    throws NoSuchReviewException, SystemException {
2317                    TasksReview tasksReview = findByPrimaryKey(reviewId);
2318    
2319                    Session session = null;
2320    
2321                    try {
2322                            session = openSession();
2323    
2324                            TasksReview[] array = new TasksReviewImpl[3];
2325    
2326                            array[0] = getByP_S_C_R_PrevAndNext(session, tasksReview,
2327                                            proposalId, stage, completed, rejected, orderByComparator,
2328                                            true);
2329    
2330                            array[1] = tasksReview;
2331    
2332                            array[2] = getByP_S_C_R_PrevAndNext(session, tasksReview,
2333                                            proposalId, stage, completed, rejected, orderByComparator,
2334                                            false);
2335    
2336                            return array;
2337                    }
2338                    catch (Exception e) {
2339                            throw processException(e);
2340                    }
2341                    finally {
2342                            closeSession(session);
2343                    }
2344            }
2345    
2346            protected TasksReview getByP_S_C_R_PrevAndNext(Session session,
2347                    TasksReview tasksReview, long proposalId, int stage, boolean completed,
2348                    boolean rejected, OrderByComparator orderByComparator, boolean previous) {
2349                    StringBundler query = null;
2350    
2351                    if (orderByComparator != null) {
2352                            query = new StringBundler(6 +
2353                                            (orderByComparator.getOrderByFields().length * 6));
2354                    }
2355                    else {
2356                            query = new StringBundler(3);
2357                    }
2358    
2359                    query.append(_SQL_SELECT_TASKSREVIEW_WHERE);
2360    
2361                    query.append(_FINDER_COLUMN_P_S_C_R_PROPOSALID_2);
2362    
2363                    query.append(_FINDER_COLUMN_P_S_C_R_STAGE_2);
2364    
2365                    query.append(_FINDER_COLUMN_P_S_C_R_COMPLETED_2);
2366    
2367                    query.append(_FINDER_COLUMN_P_S_C_R_REJECTED_2);
2368    
2369                    if (orderByComparator != null) {
2370                            String[] orderByFields = orderByComparator.getOrderByFields();
2371    
2372                            if (orderByFields.length > 0) {
2373                                    query.append(WHERE_AND);
2374                            }
2375    
2376                            for (int i = 0; i < orderByFields.length; i++) {
2377                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2378                                    query.append(orderByFields[i]);
2379    
2380                                    if ((i + 1) < orderByFields.length) {
2381                                            if (orderByComparator.isAscending() ^ previous) {
2382                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2383                                            }
2384                                            else {
2385                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2386                                            }
2387                                    }
2388                                    else {
2389                                            if (orderByComparator.isAscending() ^ previous) {
2390                                                    query.append(WHERE_GREATER_THAN);
2391                                            }
2392                                            else {
2393                                                    query.append(WHERE_LESSER_THAN);
2394                                            }
2395                                    }
2396                            }
2397    
2398                            query.append(ORDER_BY_CLAUSE);
2399    
2400                            for (int i = 0; i < orderByFields.length; i++) {
2401                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2402                                    query.append(orderByFields[i]);
2403    
2404                                    if ((i + 1) < orderByFields.length) {
2405                                            if (orderByComparator.isAscending() ^ previous) {
2406                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2407                                            }
2408                                            else {
2409                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2410                                            }
2411                                    }
2412                                    else {
2413                                            if (orderByComparator.isAscending() ^ previous) {
2414                                                    query.append(ORDER_BY_ASC);
2415                                            }
2416                                            else {
2417                                                    query.append(ORDER_BY_DESC);
2418                                            }
2419                                    }
2420                            }
2421                    }
2422    
2423                    else {
2424                            query.append(TasksReviewModelImpl.ORDER_BY_JPQL);
2425                    }
2426    
2427                    String sql = query.toString();
2428    
2429                    Query q = session.createQuery(sql);
2430    
2431                    q.setFirstResult(0);
2432                    q.setMaxResults(2);
2433    
2434                    QueryPos qPos = QueryPos.getInstance(q);
2435    
2436                    qPos.add(proposalId);
2437    
2438                    qPos.add(stage);
2439    
2440                    qPos.add(completed);
2441    
2442                    qPos.add(rejected);
2443    
2444                    if (orderByComparator != null) {
2445                            Object[] values = orderByComparator.getOrderByValues(tasksReview);
2446    
2447                            for (Object value : values) {
2448                                    qPos.add(value);
2449                            }
2450                    }
2451    
2452                    List<TasksReview> list = q.list();
2453    
2454                    if (list.size() == 2) {
2455                            return list.get(1);
2456                    }
2457                    else {
2458                            return null;
2459                    }
2460            }
2461    
2462            /**
2463             * Finds all the tasks reviews.
2464             *
2465             * @return the tasks reviews
2466             * @throws SystemException if a system exception occurred
2467             */
2468            public List<TasksReview> findAll() throws SystemException {
2469                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2470            }
2471    
2472            /**
2473             * Finds a range of all the tasks reviews.
2474             *
2475             * <p>
2476             * 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.
2477             * </p>
2478             *
2479             * @param start the lower bound of the range of tasks reviews to return
2480             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
2481             * @return the range of tasks reviews
2482             * @throws SystemException if a system exception occurred
2483             */
2484            public List<TasksReview> findAll(int start, int end)
2485                    throws SystemException {
2486                    return findAll(start, end, null);
2487            }
2488    
2489            /**
2490             * Finds an ordered range of all the tasks reviews.
2491             *
2492             * <p>
2493             * 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.
2494             * </p>
2495             *
2496             * @param start the lower bound of the range of tasks reviews to return
2497             * @param end the upper bound of the range of tasks reviews to return (not inclusive)
2498             * @param orderByComparator the comparator to order the results by
2499             * @return the ordered range of tasks reviews
2500             * @throws SystemException if a system exception occurred
2501             */
2502            public List<TasksReview> findAll(int start, int end,
2503                    OrderByComparator orderByComparator) throws SystemException {
2504                    Object[] finderArgs = new Object[] {
2505                                    String.valueOf(start), String.valueOf(end),
2506                                    String.valueOf(orderByComparator)
2507                            };
2508    
2509                    List<TasksReview> list = (List<TasksReview>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2510                                    finderArgs, this);
2511    
2512                    if (list == null) {
2513                            StringBundler query = null;
2514                            String sql = null;
2515    
2516                            if (orderByComparator != null) {
2517                                    query = new StringBundler(2 +
2518                                                    (orderByComparator.getOrderByFields().length * 3));
2519    
2520                                    query.append(_SQL_SELECT_TASKSREVIEW);
2521    
2522                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2523                                            orderByComparator);
2524    
2525                                    sql = query.toString();
2526                            }
2527                            else {
2528                                    sql = _SQL_SELECT_TASKSREVIEW.concat(TasksReviewModelImpl.ORDER_BY_JPQL);
2529                            }
2530    
2531                            Session session = null;
2532    
2533                            try {
2534                                    session = openSession();
2535    
2536                                    Query q = session.createQuery(sql);
2537    
2538                                    if (orderByComparator == null) {
2539                                            list = (List<TasksReview>)QueryUtil.list(q, getDialect(),
2540                                                            start, end, false);
2541    
2542                                            Collections.sort(list);
2543                                    }
2544                                    else {
2545                                            list = (List<TasksReview>)QueryUtil.list(q, getDialect(),
2546                                                            start, end);
2547                                    }
2548                            }
2549                            catch (Exception e) {
2550                                    throw processException(e);
2551                            }
2552                            finally {
2553                                    if (list == null) {
2554                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
2555                                                    finderArgs);
2556                                    }
2557                                    else {
2558                                            cacheResult(list);
2559    
2560                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
2561                                                    list);
2562                                    }
2563    
2564                                    closeSession(session);
2565                            }
2566                    }
2567    
2568                    return list;
2569            }
2570    
2571            /**
2572             * Removes all the tasks reviews where userId = &#63; from the database.
2573             *
2574             * @param userId the user id to search with
2575             * @throws SystemException if a system exception occurred
2576             */
2577            public void removeByUserId(long userId) throws SystemException {
2578                    for (TasksReview tasksReview : findByUserId(userId)) {
2579                            remove(tasksReview);
2580                    }
2581            }
2582    
2583            /**
2584             * Removes all the tasks reviews where proposalId = &#63; from the database.
2585             *
2586             * @param proposalId the proposal id to search with
2587             * @throws SystemException if a system exception occurred
2588             */
2589            public void removeByProposalId(long proposalId) throws SystemException {
2590                    for (TasksReview tasksReview : findByProposalId(proposalId)) {
2591                            remove(tasksReview);
2592                    }
2593            }
2594    
2595            /**
2596             * Removes the tasks review where userId = &#63; and proposalId = &#63; from the database.
2597             *
2598             * @param userId the user id to search with
2599             * @param proposalId the proposal id to search with
2600             * @throws SystemException if a system exception occurred
2601             */
2602            public void removeByU_P(long userId, long proposalId)
2603                    throws NoSuchReviewException, SystemException {
2604                    TasksReview tasksReview = findByU_P(userId, proposalId);
2605    
2606                    remove(tasksReview);
2607            }
2608    
2609            /**
2610             * Removes all the tasks reviews where proposalId = &#63; and stage = &#63; from the database.
2611             *
2612             * @param proposalId the proposal id to search with
2613             * @param stage the stage to search with
2614             * @throws SystemException if a system exception occurred
2615             */
2616            public void removeByP_S(long proposalId, int stage)
2617                    throws SystemException {
2618                    for (TasksReview tasksReview : findByP_S(proposalId, stage)) {
2619                            remove(tasksReview);
2620                    }
2621            }
2622    
2623            /**
2624             * Removes all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63; from the database.
2625             *
2626             * @param proposalId the proposal id to search with
2627             * @param stage the stage to search with
2628             * @param completed the completed to search with
2629             * @throws SystemException if a system exception occurred
2630             */
2631            public void removeByP_S_C(long proposalId, int stage, boolean completed)
2632                    throws SystemException {
2633                    for (TasksReview tasksReview : findByP_S_C(proposalId, stage, completed)) {
2634                            remove(tasksReview);
2635                    }
2636            }
2637    
2638            /**
2639             * Removes all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63; and rejected = &#63; from the database.
2640             *
2641             * @param proposalId the proposal id to search with
2642             * @param stage the stage to search with
2643             * @param completed the completed to search with
2644             * @param rejected the rejected to search with
2645             * @throws SystemException if a system exception occurred
2646             */
2647            public void removeByP_S_C_R(long proposalId, int stage, boolean completed,
2648                    boolean rejected) throws SystemException {
2649                    for (TasksReview tasksReview : findByP_S_C_R(proposalId, stage,
2650                                    completed, rejected)) {
2651                            remove(tasksReview);
2652                    }
2653            }
2654    
2655            /**
2656             * Removes all the tasks reviews from the database.
2657             *
2658             * @throws SystemException if a system exception occurred
2659             */
2660            public void removeAll() throws SystemException {
2661                    for (TasksReview tasksReview : findAll()) {
2662                            remove(tasksReview);
2663                    }
2664            }
2665    
2666            /**
2667             * Counts all the tasks reviews where userId = &#63;.
2668             *
2669             * @param userId the user id to search with
2670             * @return the number of matching tasks reviews
2671             * @throws SystemException if a system exception occurred
2672             */
2673            public int countByUserId(long userId) throws SystemException {
2674                    Object[] finderArgs = new Object[] { userId };
2675    
2676                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2677                                    finderArgs, this);
2678    
2679                    if (count == null) {
2680                            StringBundler query = new StringBundler(2);
2681    
2682                            query.append(_SQL_COUNT_TASKSREVIEW_WHERE);
2683    
2684                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2685    
2686                            String sql = query.toString();
2687    
2688                            Session session = null;
2689    
2690                            try {
2691                                    session = openSession();
2692    
2693                                    Query q = session.createQuery(sql);
2694    
2695                                    QueryPos qPos = QueryPos.getInstance(q);
2696    
2697                                    qPos.add(userId);
2698    
2699                                    count = (Long)q.uniqueResult();
2700                            }
2701                            catch (Exception e) {
2702                                    throw processException(e);
2703                            }
2704                            finally {
2705                                    if (count == null) {
2706                                            count = Long.valueOf(0);
2707                                    }
2708    
2709                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2710                                            finderArgs, count);
2711    
2712                                    closeSession(session);
2713                            }
2714                    }
2715    
2716                    return count.intValue();
2717            }
2718    
2719            /**
2720             * Counts all the tasks reviews where proposalId = &#63;.
2721             *
2722             * @param proposalId the proposal id to search with
2723             * @return the number of matching tasks reviews
2724             * @throws SystemException if a system exception occurred
2725             */
2726            public int countByProposalId(long proposalId) throws SystemException {
2727                    Object[] finderArgs = new Object[] { proposalId };
2728    
2729                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PROPOSALID,
2730                                    finderArgs, this);
2731    
2732                    if (count == null) {
2733                            StringBundler query = new StringBundler(2);
2734    
2735                            query.append(_SQL_COUNT_TASKSREVIEW_WHERE);
2736    
2737                            query.append(_FINDER_COLUMN_PROPOSALID_PROPOSALID_2);
2738    
2739                            String sql = query.toString();
2740    
2741                            Session session = null;
2742    
2743                            try {
2744                                    session = openSession();
2745    
2746                                    Query q = session.createQuery(sql);
2747    
2748                                    QueryPos qPos = QueryPos.getInstance(q);
2749    
2750                                    qPos.add(proposalId);
2751    
2752                                    count = (Long)q.uniqueResult();
2753                            }
2754                            catch (Exception e) {
2755                                    throw processException(e);
2756                            }
2757                            finally {
2758                                    if (count == null) {
2759                                            count = Long.valueOf(0);
2760                                    }
2761    
2762                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PROPOSALID,
2763                                            finderArgs, count);
2764    
2765                                    closeSession(session);
2766                            }
2767                    }
2768    
2769                    return count.intValue();
2770            }
2771    
2772            /**
2773             * Counts all the tasks reviews where userId = &#63; and proposalId = &#63;.
2774             *
2775             * @param userId the user id to search with
2776             * @param proposalId the proposal id to search with
2777             * @return the number of matching tasks reviews
2778             * @throws SystemException if a system exception occurred
2779             */
2780            public int countByU_P(long userId, long proposalId)
2781                    throws SystemException {
2782                    Object[] finderArgs = new Object[] { userId, proposalId };
2783    
2784                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_P,
2785                                    finderArgs, this);
2786    
2787                    if (count == null) {
2788                            StringBundler query = new StringBundler(3);
2789    
2790                            query.append(_SQL_COUNT_TASKSREVIEW_WHERE);
2791    
2792                            query.append(_FINDER_COLUMN_U_P_USERID_2);
2793    
2794                            query.append(_FINDER_COLUMN_U_P_PROPOSALID_2);
2795    
2796                            String sql = query.toString();
2797    
2798                            Session session = null;
2799    
2800                            try {
2801                                    session = openSession();
2802    
2803                                    Query q = session.createQuery(sql);
2804    
2805                                    QueryPos qPos = QueryPos.getInstance(q);
2806    
2807                                    qPos.add(userId);
2808    
2809                                    qPos.add(proposalId);
2810    
2811                                    count = (Long)q.uniqueResult();
2812                            }
2813                            catch (Exception e) {
2814                                    throw processException(e);
2815                            }
2816                            finally {
2817                                    if (count == null) {
2818                                            count = Long.valueOf(0);
2819                                    }
2820    
2821                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_P, finderArgs,
2822                                            count);
2823    
2824                                    closeSession(session);
2825                            }
2826                    }
2827    
2828                    return count.intValue();
2829            }
2830    
2831            /**
2832             * Counts all the tasks reviews where proposalId = &#63; and stage = &#63;.
2833             *
2834             * @param proposalId the proposal id to search with
2835             * @param stage the stage to search with
2836             * @return the number of matching tasks reviews
2837             * @throws SystemException if a system exception occurred
2838             */
2839            public int countByP_S(long proposalId, int stage) throws SystemException {
2840                    Object[] finderArgs = new Object[] { proposalId, stage };
2841    
2842                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_S,
2843                                    finderArgs, this);
2844    
2845                    if (count == null) {
2846                            StringBundler query = new StringBundler(3);
2847    
2848                            query.append(_SQL_COUNT_TASKSREVIEW_WHERE);
2849    
2850                            query.append(_FINDER_COLUMN_P_S_PROPOSALID_2);
2851    
2852                            query.append(_FINDER_COLUMN_P_S_STAGE_2);
2853    
2854                            String sql = query.toString();
2855    
2856                            Session session = null;
2857    
2858                            try {
2859                                    session = openSession();
2860    
2861                                    Query q = session.createQuery(sql);
2862    
2863                                    QueryPos qPos = QueryPos.getInstance(q);
2864    
2865                                    qPos.add(proposalId);
2866    
2867                                    qPos.add(stage);
2868    
2869                                    count = (Long)q.uniqueResult();
2870                            }
2871                            catch (Exception e) {
2872                                    throw processException(e);
2873                            }
2874                            finally {
2875                                    if (count == null) {
2876                                            count = Long.valueOf(0);
2877                                    }
2878    
2879                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_S, finderArgs,
2880                                            count);
2881    
2882                                    closeSession(session);
2883                            }
2884                    }
2885    
2886                    return count.intValue();
2887            }
2888    
2889            /**
2890             * Counts all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63;.
2891             *
2892             * @param proposalId the proposal id to search with
2893             * @param stage the stage to search with
2894             * @param completed the completed to search with
2895             * @return the number of matching tasks reviews
2896             * @throws SystemException if a system exception occurred
2897             */
2898            public int countByP_S_C(long proposalId, int stage, boolean completed)
2899                    throws SystemException {
2900                    Object[] finderArgs = new Object[] { proposalId, stage, completed };
2901    
2902                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_S_C,
2903                                    finderArgs, this);
2904    
2905                    if (count == null) {
2906                            StringBundler query = new StringBundler(4);
2907    
2908                            query.append(_SQL_COUNT_TASKSREVIEW_WHERE);
2909    
2910                            query.append(_FINDER_COLUMN_P_S_C_PROPOSALID_2);
2911    
2912                            query.append(_FINDER_COLUMN_P_S_C_STAGE_2);
2913    
2914                            query.append(_FINDER_COLUMN_P_S_C_COMPLETED_2);
2915    
2916                            String sql = query.toString();
2917    
2918                            Session session = null;
2919    
2920                            try {
2921                                    session = openSession();
2922    
2923                                    Query q = session.createQuery(sql);
2924    
2925                                    QueryPos qPos = QueryPos.getInstance(q);
2926    
2927                                    qPos.add(proposalId);
2928    
2929                                    qPos.add(stage);
2930    
2931                                    qPos.add(completed);
2932    
2933                                    count = (Long)q.uniqueResult();
2934                            }
2935                            catch (Exception e) {
2936                                    throw processException(e);
2937                            }
2938                            finally {
2939                                    if (count == null) {
2940                                            count = Long.valueOf(0);
2941                                    }
2942    
2943                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_S_C,
2944                                            finderArgs, count);
2945    
2946                                    closeSession(session);
2947                            }
2948                    }
2949    
2950                    return count.intValue();
2951            }
2952    
2953            /**
2954             * Counts all the tasks reviews where proposalId = &#63; and stage = &#63; and completed = &#63; and rejected = &#63;.
2955             *
2956             * @param proposalId the proposal id to search with
2957             * @param stage the stage to search with
2958             * @param completed the completed to search with
2959             * @param rejected the rejected to search with
2960             * @return the number of matching tasks reviews
2961             * @throws SystemException if a system exception occurred
2962             */
2963            public int countByP_S_C_R(long proposalId, int stage, boolean completed,
2964                    boolean rejected) throws SystemException {
2965                    Object[] finderArgs = new Object[] {
2966                                    proposalId, stage, completed, rejected
2967                            };
2968    
2969                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_S_C_R,
2970                                    finderArgs, this);
2971    
2972                    if (count == null) {
2973                            StringBundler query = new StringBundler(5);
2974    
2975                            query.append(_SQL_COUNT_TASKSREVIEW_WHERE);
2976    
2977                            query.append(_FINDER_COLUMN_P_S_C_R_PROPOSALID_2);
2978    
2979                            query.append(_FINDER_COLUMN_P_S_C_R_STAGE_2);
2980    
2981                            query.append(_FINDER_COLUMN_P_S_C_R_COMPLETED_2);
2982    
2983                            query.append(_FINDER_COLUMN_P_S_C_R_REJECTED_2);
2984    
2985                            String sql = query.toString();
2986    
2987                            Session session = null;
2988    
2989                            try {
2990                                    session = openSession();
2991    
2992                                    Query q = session.createQuery(sql);
2993    
2994                                    QueryPos qPos = QueryPos.getInstance(q);
2995    
2996                                    qPos.add(proposalId);
2997    
2998                                    qPos.add(stage);
2999    
3000                                    qPos.add(completed);
3001    
3002                                    qPos.add(rejected);
3003    
3004                                    count = (Long)q.uniqueResult();
3005                            }
3006                            catch (Exception e) {
3007                                    throw processException(e);
3008                            }
3009                            finally {
3010                                    if (count == null) {
3011                                            count = Long.valueOf(0);
3012                                    }
3013    
3014                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_S_C_R,
3015                                            finderArgs, count);
3016    
3017                                    closeSession(session);
3018                            }
3019                    }
3020    
3021                    return count.intValue();
3022            }
3023    
3024            /**
3025             * Counts all the tasks reviews.
3026             *
3027             * @return the number of tasks reviews
3028             * @throws SystemException if a system exception occurred
3029             */
3030            public int countAll() throws SystemException {
3031                    Object[] finderArgs = new Object[0];
3032    
3033                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3034                                    finderArgs, this);
3035    
3036                    if (count == null) {
3037                            Session session = null;
3038    
3039                            try {
3040                                    session = openSession();
3041    
3042                                    Query q = session.createQuery(_SQL_COUNT_TASKSREVIEW);
3043    
3044                                    count = (Long)q.uniqueResult();
3045                            }
3046                            catch (Exception e) {
3047                                    throw processException(e);
3048                            }
3049                            finally {
3050                                    if (count == null) {
3051                                            count = Long.valueOf(0);
3052                                    }
3053    
3054                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3055                                            count);
3056    
3057                                    closeSession(session);
3058                            }
3059                    }
3060    
3061                    return count.intValue();
3062            }
3063    
3064            /**
3065             * Initializes the tasks review persistence.
3066             */
3067            public void afterPropertiesSet() {
3068                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3069                                            com.liferay.portal.util.PropsUtil.get(
3070                                                    "value.object.listener.com.liferay.portlet.tasks.model.TasksReview")));
3071    
3072                    if (listenerClassNames.length > 0) {
3073                            try {
3074                                    List<ModelListener<TasksReview>> listenersList = new ArrayList<ModelListener<TasksReview>>();
3075    
3076                                    for (String listenerClassName : listenerClassNames) {
3077                                            listenersList.add((ModelListener<TasksReview>)InstanceFactory.newInstance(
3078                                                            listenerClassName));
3079                                    }
3080    
3081                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3082                            }
3083                            catch (Exception e) {
3084                                    _log.error(e);
3085                            }
3086                    }
3087            }
3088    
3089            public void destroy() {
3090                    EntityCacheUtil.removeCache(TasksReviewImpl.class.getName());
3091                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3092                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
3093            }
3094    
3095            @BeanReference(type = TasksProposalPersistence.class)
3096            protected TasksProposalPersistence tasksProposalPersistence;
3097            @BeanReference(type = TasksReviewPersistence.class)
3098            protected TasksReviewPersistence tasksReviewPersistence;
3099            @BeanReference(type = ResourcePersistence.class)
3100            protected ResourcePersistence resourcePersistence;
3101            @BeanReference(type = UserPersistence.class)
3102            protected UserPersistence userPersistence;
3103            @BeanReference(type = SocialActivityPersistence.class)
3104            protected SocialActivityPersistence socialActivityPersistence;
3105            private static final String _SQL_SELECT_TASKSREVIEW = "SELECT tasksReview FROM TasksReview tasksReview";
3106            private static final String _SQL_SELECT_TASKSREVIEW_WHERE = "SELECT tasksReview FROM TasksReview tasksReview WHERE ";
3107            private static final String _SQL_COUNT_TASKSREVIEW = "SELECT COUNT(tasksReview) FROM TasksReview tasksReview";
3108            private static final String _SQL_COUNT_TASKSREVIEW_WHERE = "SELECT COUNT(tasksReview) FROM TasksReview tasksReview WHERE ";
3109            private static final String _FINDER_COLUMN_USERID_USERID_2 = "tasksReview.userId = ?";
3110            private static final String _FINDER_COLUMN_PROPOSALID_PROPOSALID_2 = "tasksReview.proposalId = ?";
3111            private static final String _FINDER_COLUMN_U_P_USERID_2 = "tasksReview.userId = ? AND ";
3112            private static final String _FINDER_COLUMN_U_P_PROPOSALID_2 = "tasksReview.proposalId = ?";
3113            private static final String _FINDER_COLUMN_P_S_PROPOSALID_2 = "tasksReview.proposalId = ? AND ";
3114            private static final String _FINDER_COLUMN_P_S_STAGE_2 = "tasksReview.stage = ?";
3115            private static final String _FINDER_COLUMN_P_S_C_PROPOSALID_2 = "tasksReview.proposalId = ? AND ";
3116            private static final String _FINDER_COLUMN_P_S_C_STAGE_2 = "tasksReview.stage = ? AND ";
3117            private static final String _FINDER_COLUMN_P_S_C_COMPLETED_2 = "tasksReview.completed = ?";
3118            private static final String _FINDER_COLUMN_P_S_C_R_PROPOSALID_2 = "tasksReview.proposalId = ? AND ";
3119            private static final String _FINDER_COLUMN_P_S_C_R_STAGE_2 = "tasksReview.stage = ? AND ";
3120            private static final String _FINDER_COLUMN_P_S_C_R_COMPLETED_2 = "tasksReview.completed = ? AND ";
3121            private static final String _FINDER_COLUMN_P_S_C_R_REJECTED_2 = "tasksReview.rejected = ?";
3122            private static final String _ORDER_BY_ENTITY_ALIAS = "tasksReview.";
3123            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No TasksReview exists with the primary key ";
3124            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No TasksReview exists with the key {";
3125            private static Log _log = LogFactoryUtil.getLog(TasksReviewPersistenceImpl.class);
3126    }