001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.social.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.service.persistence.BatchSessionUtil;
041    import com.liferay.portal.service.persistence.ResourcePersistence;
042    import com.liferay.portal.service.persistence.UserPersistence;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import com.liferay.portlet.social.NoSuchRequestException;
046    import com.liferay.portlet.social.model.SocialRequest;
047    import com.liferay.portlet.social.model.impl.SocialRequestImpl;
048    import com.liferay.portlet.social.model.impl.SocialRequestModelImpl;
049    
050    import java.io.Serializable;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.List;
055    
056    /**
057     * The persistence implementation for the social request service.
058     *
059     * <p>
060     * Caching information and settings can be found in <code>portal.properties</code>
061     * </p>
062     *
063     * @author Brian Wing Shun Chan
064     * @see SocialRequestPersistence
065     * @see SocialRequestUtil
066     * @generated
067     */
068    public class SocialRequestPersistenceImpl extends BasePersistenceImpl<SocialRequest>
069            implements SocialRequestPersistence {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link SocialRequestUtil} to access the social request persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
074             */
075            public static final String FINDER_CLASS_NAME_ENTITY = SocialRequestImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List1";
078            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List2";
080            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
081                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
082                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
083                            "findByUuid",
084                            new String[] {
085                                    String.class.getName(),
086                                    
087                            "java.lang.Integer", "java.lang.Integer",
088                                    "com.liferay.portal.kernel.util.OrderByComparator"
089                            });
090            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
091                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
092                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
093                            "findByUuid", new String[] { String.class.getName() },
094                            SocialRequestModelImpl.UUID_COLUMN_BITMASK);
095            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
096                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
098                            new String[] { String.class.getName() });
099            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
100                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
101                            SocialRequestImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
102                            new String[] { String.class.getName(), Long.class.getName() },
103                            SocialRequestModelImpl.UUID_COLUMN_BITMASK |
104                            SocialRequestModelImpl.GROUPID_COLUMN_BITMASK);
105            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
106                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
108                            new String[] { String.class.getName(), Long.class.getName() });
109            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
110                    new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
111                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
112                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
113                            "findByCompanyId",
114                            new String[] {
115                                    Long.class.getName(),
116                                    
117                            "java.lang.Integer", "java.lang.Integer",
118                                    "com.liferay.portal.kernel.util.OrderByComparator"
119                            });
120            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
121                    new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
122                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
123                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
124                            "findByCompanyId", new String[] { Long.class.getName() },
125                            SocialRequestModelImpl.COMPANYID_COLUMN_BITMASK);
126            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
127                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
129                            new String[] { Long.class.getName() });
130            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
131                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
132                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
133                            "findByUserId",
134                            new String[] {
135                                    Long.class.getName(),
136                                    
137                            "java.lang.Integer", "java.lang.Integer",
138                                    "com.liferay.portal.kernel.util.OrderByComparator"
139                            });
140            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
141                    new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
142                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
143                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
144                            "findByUserId", new String[] { Long.class.getName() },
145                            SocialRequestModelImpl.USERID_COLUMN_BITMASK);
146            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
147                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
148                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
149                            new String[] { Long.class.getName() });
150            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RECEIVERUSERID =
151                    new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
152                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
153                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
154                            "findByReceiverUserId",
155                            new String[] {
156                                    Long.class.getName(),
157                                    
158                            "java.lang.Integer", "java.lang.Integer",
159                                    "com.liferay.portal.kernel.util.OrderByComparator"
160                            });
161            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID =
162                    new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
163                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
164                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
165                            "findByReceiverUserId", new String[] { Long.class.getName() },
166                            SocialRequestModelImpl.RECEIVERUSERID_COLUMN_BITMASK);
167            public static final FinderPath FINDER_PATH_COUNT_BY_RECEIVERUSERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
168                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
169                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByReceiverUserId",
170                            new String[] { Long.class.getName() });
171            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
172                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
173                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
174                            "findByU_S",
175                            new String[] {
176                                    Long.class.getName(), Integer.class.getName(),
177                                    
178                            "java.lang.Integer", "java.lang.Integer",
179                                    "com.liferay.portal.kernel.util.OrderByComparator"
180                            });
181            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
182                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
183                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
184                            "findByU_S",
185                            new String[] { Long.class.getName(), Integer.class.getName() },
186                            SocialRequestModelImpl.USERID_COLUMN_BITMASK |
187                            SocialRequestModelImpl.STATUS_COLUMN_BITMASK);
188            public static final FinderPath FINDER_PATH_COUNT_BY_U_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
189                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
190                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_S",
191                            new String[] { Long.class.getName(), Integer.class.getName() });
192            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
193                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
194                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
195                            "findByR_S",
196                            new String[] {
197                                    Long.class.getName(), Integer.class.getName(),
198                                    
199                            "java.lang.Integer", "java.lang.Integer",
200                                    "com.liferay.portal.kernel.util.OrderByComparator"
201                            });
202            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
203                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
204                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
205                            "findByR_S",
206                            new String[] { Long.class.getName(), Integer.class.getName() },
207                            SocialRequestModelImpl.RECEIVERUSERID_COLUMN_BITMASK |
208                            SocialRequestModelImpl.STATUS_COLUMN_BITMASK);
209            public static final FinderPath FINDER_PATH_COUNT_BY_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
210                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
211                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_S",
212                            new String[] { Long.class.getName(), Integer.class.getName() });
213            public static final FinderPath FINDER_PATH_FETCH_BY_U_C_C_T_R = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
214                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
215                            SocialRequestImpl.class, FINDER_CLASS_NAME_ENTITY,
216                            "fetchByU_C_C_T_R",
217                            new String[] {
218                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
219                                    Integer.class.getName(), Long.class.getName()
220                            },
221                            SocialRequestModelImpl.USERID_COLUMN_BITMASK |
222                            SocialRequestModelImpl.CLASSNAMEID_COLUMN_BITMASK |
223                            SocialRequestModelImpl.CLASSPK_COLUMN_BITMASK |
224                            SocialRequestModelImpl.TYPE_COLUMN_BITMASK |
225                            SocialRequestModelImpl.RECEIVERUSERID_COLUMN_BITMASK);
226            public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C_T_R = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
227                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
228                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_C_T_R",
229                            new String[] {
230                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
231                                    Integer.class.getName(), Long.class.getName()
232                            });
233            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C_T_S =
234                    new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
235                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
236                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
237                            "findByU_C_C_T_S",
238                            new String[] {
239                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
240                                    Integer.class.getName(), Integer.class.getName(),
241                                    
242                            "java.lang.Integer", "java.lang.Integer",
243                                    "com.liferay.portal.kernel.util.OrderByComparator"
244                            });
245            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T_S =
246                    new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
247                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
248                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
249                            "findByU_C_C_T_S",
250                            new String[] {
251                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
252                                    Integer.class.getName(), Integer.class.getName()
253                            },
254                            SocialRequestModelImpl.USERID_COLUMN_BITMASK |
255                            SocialRequestModelImpl.CLASSNAMEID_COLUMN_BITMASK |
256                            SocialRequestModelImpl.CLASSPK_COLUMN_BITMASK |
257                            SocialRequestModelImpl.TYPE_COLUMN_BITMASK |
258                            SocialRequestModelImpl.STATUS_COLUMN_BITMASK);
259            public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C_T_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
260                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
261                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_C_T_S",
262                            new String[] {
263                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
264                                    Integer.class.getName(), Integer.class.getName()
265                            });
266            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_T_R_S =
267                    new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
268                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
269                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
270                            "findByC_C_T_R_S",
271                            new String[] {
272                                    Long.class.getName(), Long.class.getName(),
273                                    Integer.class.getName(), Long.class.getName(),
274                                    Integer.class.getName(),
275                                    
276                            "java.lang.Integer", "java.lang.Integer",
277                                    "com.liferay.portal.kernel.util.OrderByComparator"
278                            });
279            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T_R_S =
280                    new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
281                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
282                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
283                            "findByC_C_T_R_S",
284                            new String[] {
285                                    Long.class.getName(), Long.class.getName(),
286                                    Integer.class.getName(), Long.class.getName(),
287                                    Integer.class.getName()
288                            },
289                            SocialRequestModelImpl.CLASSNAMEID_COLUMN_BITMASK |
290                            SocialRequestModelImpl.CLASSPK_COLUMN_BITMASK |
291                            SocialRequestModelImpl.TYPE_COLUMN_BITMASK |
292                            SocialRequestModelImpl.RECEIVERUSERID_COLUMN_BITMASK |
293                            SocialRequestModelImpl.STATUS_COLUMN_BITMASK);
294            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_T_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
295                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
296                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_T_R_S",
297                            new String[] {
298                                    Long.class.getName(), Long.class.getName(),
299                                    Integer.class.getName(), Long.class.getName(),
300                                    Integer.class.getName()
301                            });
302            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
303                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
304                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
305                            "findAll", new String[0]);
306            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
307                            SocialRequestModelImpl.FINDER_CACHE_ENABLED,
308                            SocialRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
309                            "findAll", new String[0]);
310            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
311                            SocialRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
312                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
313    
314            /**
315             * Caches the social request in the entity cache if it is enabled.
316             *
317             * @param socialRequest the social request
318             */
319            public void cacheResult(SocialRequest socialRequest) {
320                    EntityCacheUtil.putResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
321                            SocialRequestImpl.class, socialRequest.getPrimaryKey(),
322                            socialRequest);
323    
324                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
325                            new Object[] {
326                                    socialRequest.getUuid(),
327                                    Long.valueOf(socialRequest.getGroupId())
328                            }, socialRequest);
329    
330                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
331                            new Object[] {
332                                    Long.valueOf(socialRequest.getUserId()),
333                                    Long.valueOf(socialRequest.getClassNameId()),
334                                    Long.valueOf(socialRequest.getClassPK()),
335                                    Integer.valueOf(socialRequest.getType()),
336                                    Long.valueOf(socialRequest.getReceiverUserId())
337                            }, socialRequest);
338    
339                    socialRequest.resetOriginalValues();
340            }
341    
342            /**
343             * Caches the social requests in the entity cache if it is enabled.
344             *
345             * @param socialRequests the social requests
346             */
347            public void cacheResult(List<SocialRequest> socialRequests) {
348                    for (SocialRequest socialRequest : socialRequests) {
349                            if (EntityCacheUtil.getResult(
350                                                    SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
351                                                    SocialRequestImpl.class, socialRequest.getPrimaryKey()) == null) {
352                                    cacheResult(socialRequest);
353                            }
354                            else {
355                                    socialRequest.resetOriginalValues();
356                            }
357                    }
358            }
359    
360            /**
361             * Clears the cache for all social requests.
362             *
363             * <p>
364             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
365             * </p>
366             */
367            @Override
368            public void clearCache() {
369                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
370                            CacheRegistryUtil.clear(SocialRequestImpl.class.getName());
371                    }
372    
373                    EntityCacheUtil.clearCache(SocialRequestImpl.class.getName());
374    
375                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
376                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
377                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
378            }
379    
380            /**
381             * Clears the cache for the social request.
382             *
383             * <p>
384             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
385             * </p>
386             */
387            @Override
388            public void clearCache(SocialRequest socialRequest) {
389                    EntityCacheUtil.removeResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
390                            SocialRequestImpl.class, socialRequest.getPrimaryKey());
391    
392                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
393                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
394    
395                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
396                            new Object[] {
397                                    socialRequest.getUuid(),
398                                    Long.valueOf(socialRequest.getGroupId())
399                            });
400    
401                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
402                            new Object[] {
403                                    Long.valueOf(socialRequest.getUserId()),
404                                    Long.valueOf(socialRequest.getClassNameId()),
405                                    Long.valueOf(socialRequest.getClassPK()),
406                                    Integer.valueOf(socialRequest.getType()),
407                                    Long.valueOf(socialRequest.getReceiverUserId())
408                            });
409            }
410    
411            /**
412             * Creates a new social request with the primary key. Does not add the social request to the database.
413             *
414             * @param requestId the primary key for the new social request
415             * @return the new social request
416             */
417            public SocialRequest create(long requestId) {
418                    SocialRequest socialRequest = new SocialRequestImpl();
419    
420                    socialRequest.setNew(true);
421                    socialRequest.setPrimaryKey(requestId);
422    
423                    String uuid = PortalUUIDUtil.generate();
424    
425                    socialRequest.setUuid(uuid);
426    
427                    return socialRequest;
428            }
429    
430            /**
431             * Removes the social request with the primary key from the database. Also notifies the appropriate model listeners.
432             *
433             * @param primaryKey the primary key of the social request
434             * @return the social request that was removed
435             * @throws com.liferay.portal.NoSuchModelException if a social request with the primary key could not be found
436             * @throws SystemException if a system exception occurred
437             */
438            @Override
439            public SocialRequest remove(Serializable primaryKey)
440                    throws NoSuchModelException, SystemException {
441                    return remove(((Long)primaryKey).longValue());
442            }
443    
444            /**
445             * Removes the social request with the primary key from the database. Also notifies the appropriate model listeners.
446             *
447             * @param requestId the primary key of the social request
448             * @return the social request that was removed
449             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
450             * @throws SystemException if a system exception occurred
451             */
452            public SocialRequest remove(long requestId)
453                    throws NoSuchRequestException, SystemException {
454                    Session session = null;
455    
456                    try {
457                            session = openSession();
458    
459                            SocialRequest socialRequest = (SocialRequest)session.get(SocialRequestImpl.class,
460                                            Long.valueOf(requestId));
461    
462                            if (socialRequest == null) {
463                                    if (_log.isWarnEnabled()) {
464                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + requestId);
465                                    }
466    
467                                    throw new NoSuchRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
468                                            requestId);
469                            }
470    
471                            return socialRequestPersistence.remove(socialRequest);
472                    }
473                    catch (NoSuchRequestException nsee) {
474                            throw nsee;
475                    }
476                    catch (Exception e) {
477                            throw processException(e);
478                    }
479                    finally {
480                            closeSession(session);
481                    }
482            }
483    
484            /**
485             * Removes the social request from the database. Also notifies the appropriate model listeners.
486             *
487             * @param socialRequest the social request
488             * @return the social request that was removed
489             * @throws SystemException if a system exception occurred
490             */
491            @Override
492            public SocialRequest remove(SocialRequest socialRequest)
493                    throws SystemException {
494                    return super.remove(socialRequest);
495            }
496    
497            @Override
498            protected SocialRequest removeImpl(SocialRequest socialRequest)
499                    throws SystemException {
500                    socialRequest = toUnwrappedModel(socialRequest);
501    
502                    Session session = null;
503    
504                    try {
505                            session = openSession();
506    
507                            BatchSessionUtil.delete(session, socialRequest);
508                    }
509                    catch (Exception e) {
510                            throw processException(e);
511                    }
512                    finally {
513                            closeSession(session);
514                    }
515    
516                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
517                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
518    
519                    SocialRequestModelImpl socialRequestModelImpl = (SocialRequestModelImpl)socialRequest;
520    
521                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
522                            new Object[] {
523                                    socialRequestModelImpl.getUuid(),
524                                    Long.valueOf(socialRequestModelImpl.getGroupId())
525                            });
526    
527                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
528                            new Object[] {
529                                    Long.valueOf(socialRequestModelImpl.getUserId()),
530                                    Long.valueOf(socialRequestModelImpl.getClassNameId()),
531                                    Long.valueOf(socialRequestModelImpl.getClassPK()),
532                                    Integer.valueOf(socialRequestModelImpl.getType()),
533                                    Long.valueOf(socialRequestModelImpl.getReceiverUserId())
534                            });
535    
536                    EntityCacheUtil.removeResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
537                            SocialRequestImpl.class, socialRequest.getPrimaryKey());
538    
539                    return socialRequest;
540            }
541    
542            @Override
543            public SocialRequest updateImpl(
544                    com.liferay.portlet.social.model.SocialRequest socialRequest,
545                    boolean merge) throws SystemException {
546                    socialRequest = toUnwrappedModel(socialRequest);
547    
548                    boolean isNew = socialRequest.isNew();
549    
550                    SocialRequestModelImpl socialRequestModelImpl = (SocialRequestModelImpl)socialRequest;
551    
552                    if (Validator.isNull(socialRequest.getUuid())) {
553                            String uuid = PortalUUIDUtil.generate();
554    
555                            socialRequest.setUuid(uuid);
556                    }
557    
558                    Session session = null;
559    
560                    try {
561                            session = openSession();
562    
563                            BatchSessionUtil.update(session, socialRequest, merge);
564    
565                            socialRequest.setNew(false);
566                    }
567                    catch (Exception e) {
568                            throw processException(e);
569                    }
570                    finally {
571                            closeSession(session);
572                    }
573    
574                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
575    
576                    if (isNew || !SocialRequestModelImpl.COLUMN_BITMASK_ENABLED) {
577                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
578                    }
579    
580                    else {
581                            if ((socialRequestModelImpl.getColumnBitmask() &
582                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
583                                    Object[] args = new Object[] {
584                                                    socialRequestModelImpl.getOriginalUuid()
585                                            };
586    
587                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
588                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
589                                            args);
590    
591                                    args = new Object[] { socialRequestModelImpl.getUuid() };
592    
593                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
594                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
595                                            args);
596                            }
597    
598                            if ((socialRequestModelImpl.getColumnBitmask() &
599                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
600                                    Object[] args = new Object[] {
601                                                    Long.valueOf(socialRequestModelImpl.getOriginalCompanyId())
602                                            };
603    
604                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
605                                            args);
606                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
607                                            args);
608    
609                                    args = new Object[] {
610                                                    Long.valueOf(socialRequestModelImpl.getCompanyId())
611                                            };
612    
613                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
614                                            args);
615                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
616                                            args);
617                            }
618    
619                            if ((socialRequestModelImpl.getColumnBitmask() &
620                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
621                                    Object[] args = new Object[] {
622                                                    Long.valueOf(socialRequestModelImpl.getOriginalUserId())
623                                            };
624    
625                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
626                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
627                                            args);
628    
629                                    args = new Object[] {
630                                                    Long.valueOf(socialRequestModelImpl.getUserId())
631                                            };
632    
633                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
634                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
635                                            args);
636                            }
637    
638                            if ((socialRequestModelImpl.getColumnBitmask() &
639                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID.getColumnBitmask()) != 0) {
640                                    Object[] args = new Object[] {
641                                                    Long.valueOf(socialRequestModelImpl.getOriginalReceiverUserId())
642                                            };
643    
644                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
645                                            args);
646                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID,
647                                            args);
648    
649                                    args = new Object[] {
650                                                    Long.valueOf(socialRequestModelImpl.getReceiverUserId())
651                                            };
652    
653                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
654                                            args);
655                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID,
656                                            args);
657                            }
658    
659                            if ((socialRequestModelImpl.getColumnBitmask() &
660                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_S.getColumnBitmask()) != 0) {
661                                    Object[] args = new Object[] {
662                                                    Long.valueOf(socialRequestModelImpl.getOriginalUserId()),
663                                                    Integer.valueOf(socialRequestModelImpl.getOriginalStatus())
664                                            };
665    
666                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_S, args);
667                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_S,
668                                            args);
669    
670                                    args = new Object[] {
671                                                    Long.valueOf(socialRequestModelImpl.getUserId()),
672                                                    Integer.valueOf(socialRequestModelImpl.getStatus())
673                                            };
674    
675                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_S, args);
676                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_S,
677                                            args);
678                            }
679    
680                            if ((socialRequestModelImpl.getColumnBitmask() &
681                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S.getColumnBitmask()) != 0) {
682                                    Object[] args = new Object[] {
683                                                    Long.valueOf(socialRequestModelImpl.getOriginalReceiverUserId()),
684                                                    Integer.valueOf(socialRequestModelImpl.getOriginalStatus())
685                                            };
686    
687                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_S, args);
688                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S,
689                                            args);
690    
691                                    args = new Object[] {
692                                                    Long.valueOf(socialRequestModelImpl.getReceiverUserId()),
693                                                    Integer.valueOf(socialRequestModelImpl.getStatus())
694                                            };
695    
696                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_S, args);
697                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S,
698                                            args);
699                            }
700    
701                            if ((socialRequestModelImpl.getColumnBitmask() &
702                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T_S.getColumnBitmask()) != 0) {
703                                    Object[] args = new Object[] {
704                                                    Long.valueOf(socialRequestModelImpl.getOriginalUserId()),
705                                                    Long.valueOf(socialRequestModelImpl.getOriginalClassNameId()),
706                                                    Long.valueOf(socialRequestModelImpl.getOriginalClassPK()),
707                                                    Integer.valueOf(socialRequestModelImpl.getOriginalType()),
708                                                    Integer.valueOf(socialRequestModelImpl.getOriginalStatus())
709                                            };
710    
711                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
712                                            args);
713                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T_S,
714                                            args);
715    
716                                    args = new Object[] {
717                                                    Long.valueOf(socialRequestModelImpl.getUserId()),
718                                                    Long.valueOf(socialRequestModelImpl.getClassNameId()),
719                                                    Long.valueOf(socialRequestModelImpl.getClassPK()),
720                                                    Integer.valueOf(socialRequestModelImpl.getType()),
721                                                    Integer.valueOf(socialRequestModelImpl.getStatus())
722                                            };
723    
724                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
725                                            args);
726                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T_S,
727                                            args);
728                            }
729    
730                            if ((socialRequestModelImpl.getColumnBitmask() &
731                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T_R_S.getColumnBitmask()) != 0) {
732                                    Object[] args = new Object[] {
733                                                    Long.valueOf(socialRequestModelImpl.getOriginalClassNameId()),
734                                                    Long.valueOf(socialRequestModelImpl.getOriginalClassPK()),
735                                                    Integer.valueOf(socialRequestModelImpl.getOriginalType()),
736                                                    Long.valueOf(socialRequestModelImpl.getOriginalReceiverUserId()),
737                                                    Integer.valueOf(socialRequestModelImpl.getOriginalStatus())
738                                            };
739    
740                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
741                                            args);
742                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T_R_S,
743                                            args);
744    
745                                    args = new Object[] {
746                                                    Long.valueOf(socialRequestModelImpl.getClassNameId()),
747                                                    Long.valueOf(socialRequestModelImpl.getClassPK()),
748                                                    Integer.valueOf(socialRequestModelImpl.getType()),
749                                                    Long.valueOf(socialRequestModelImpl.getReceiverUserId()),
750                                                    Integer.valueOf(socialRequestModelImpl.getStatus())
751                                            };
752    
753                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
754                                            args);
755                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T_R_S,
756                                            args);
757                            }
758                    }
759    
760                    EntityCacheUtil.putResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
761                            SocialRequestImpl.class, socialRequest.getPrimaryKey(),
762                            socialRequest);
763    
764                    if (isNew) {
765                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
766                                    new Object[] {
767                                            socialRequest.getUuid(),
768                                            Long.valueOf(socialRequest.getGroupId())
769                                    }, socialRequest);
770    
771                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
772                                    new Object[] {
773                                            Long.valueOf(socialRequest.getUserId()),
774                                            Long.valueOf(socialRequest.getClassNameId()),
775                                            Long.valueOf(socialRequest.getClassPK()),
776                                            Integer.valueOf(socialRequest.getType()),
777                                            Long.valueOf(socialRequest.getReceiverUserId())
778                                    }, socialRequest);
779                    }
780                    else {
781                            if ((socialRequestModelImpl.getColumnBitmask() &
782                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
783                                    Object[] args = new Object[] {
784                                                    socialRequestModelImpl.getOriginalUuid(),
785                                                    Long.valueOf(socialRequestModelImpl.getOriginalGroupId())
786                                            };
787    
788                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
789                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
790    
791                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
792                                            new Object[] {
793                                                    socialRequest.getUuid(),
794                                                    Long.valueOf(socialRequest.getGroupId())
795                                            }, socialRequest);
796                            }
797    
798                            if ((socialRequestModelImpl.getColumnBitmask() &
799                                            FINDER_PATH_FETCH_BY_U_C_C_T_R.getColumnBitmask()) != 0) {
800                                    Object[] args = new Object[] {
801                                                    Long.valueOf(socialRequestModelImpl.getOriginalUserId()),
802                                                    Long.valueOf(socialRequestModelImpl.getOriginalClassNameId()),
803                                                    Long.valueOf(socialRequestModelImpl.getOriginalClassPK()),
804                                                    Integer.valueOf(socialRequestModelImpl.getOriginalType()),
805                                                    Long.valueOf(socialRequestModelImpl.getOriginalReceiverUserId())
806                                            };
807    
808                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_C_T_R,
809                                            args);
810                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
811                                            args);
812    
813                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
814                                            new Object[] {
815                                                    Long.valueOf(socialRequest.getUserId()),
816                                                    Long.valueOf(socialRequest.getClassNameId()),
817                                                    Long.valueOf(socialRequest.getClassPK()),
818                                                    Integer.valueOf(socialRequest.getType()),
819                                                    Long.valueOf(socialRequest.getReceiverUserId())
820                                            }, socialRequest);
821                            }
822                    }
823    
824                    return socialRequest;
825            }
826    
827            protected SocialRequest toUnwrappedModel(SocialRequest socialRequest) {
828                    if (socialRequest instanceof SocialRequestImpl) {
829                            return socialRequest;
830                    }
831    
832                    SocialRequestImpl socialRequestImpl = new SocialRequestImpl();
833    
834                    socialRequestImpl.setNew(socialRequest.isNew());
835                    socialRequestImpl.setPrimaryKey(socialRequest.getPrimaryKey());
836    
837                    socialRequestImpl.setUuid(socialRequest.getUuid());
838                    socialRequestImpl.setRequestId(socialRequest.getRequestId());
839                    socialRequestImpl.setGroupId(socialRequest.getGroupId());
840                    socialRequestImpl.setCompanyId(socialRequest.getCompanyId());
841                    socialRequestImpl.setUserId(socialRequest.getUserId());
842                    socialRequestImpl.setCreateDate(socialRequest.getCreateDate());
843                    socialRequestImpl.setModifiedDate(socialRequest.getModifiedDate());
844                    socialRequestImpl.setClassNameId(socialRequest.getClassNameId());
845                    socialRequestImpl.setClassPK(socialRequest.getClassPK());
846                    socialRequestImpl.setType(socialRequest.getType());
847                    socialRequestImpl.setExtraData(socialRequest.getExtraData());
848                    socialRequestImpl.setReceiverUserId(socialRequest.getReceiverUserId());
849                    socialRequestImpl.setStatus(socialRequest.getStatus());
850    
851                    return socialRequestImpl;
852            }
853    
854            /**
855             * Returns the social request with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
856             *
857             * @param primaryKey the primary key of the social request
858             * @return the social request
859             * @throws com.liferay.portal.NoSuchModelException if a social request with the primary key could not be found
860             * @throws SystemException if a system exception occurred
861             */
862            @Override
863            public SocialRequest findByPrimaryKey(Serializable primaryKey)
864                    throws NoSuchModelException, SystemException {
865                    return findByPrimaryKey(((Long)primaryKey).longValue());
866            }
867    
868            /**
869             * Returns the social request with the primary key or throws a {@link com.liferay.portlet.social.NoSuchRequestException} if it could not be found.
870             *
871             * @param requestId the primary key of the social request
872             * @return the social request
873             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
874             * @throws SystemException if a system exception occurred
875             */
876            public SocialRequest findByPrimaryKey(long requestId)
877                    throws NoSuchRequestException, SystemException {
878                    SocialRequest socialRequest = fetchByPrimaryKey(requestId);
879    
880                    if (socialRequest == null) {
881                            if (_log.isWarnEnabled()) {
882                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + requestId);
883                            }
884    
885                            throw new NoSuchRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
886                                    requestId);
887                    }
888    
889                    return socialRequest;
890            }
891    
892            /**
893             * Returns the social request with the primary key or returns <code>null</code> if it could not be found.
894             *
895             * @param primaryKey the primary key of the social request
896             * @return the social request, or <code>null</code> if a social request with the primary key could not be found
897             * @throws SystemException if a system exception occurred
898             */
899            @Override
900            public SocialRequest fetchByPrimaryKey(Serializable primaryKey)
901                    throws SystemException {
902                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
903            }
904    
905            /**
906             * Returns the social request with the primary key or returns <code>null</code> if it could not be found.
907             *
908             * @param requestId the primary key of the social request
909             * @return the social request, or <code>null</code> if a social request with the primary key could not be found
910             * @throws SystemException if a system exception occurred
911             */
912            public SocialRequest fetchByPrimaryKey(long requestId)
913                    throws SystemException {
914                    SocialRequest socialRequest = (SocialRequest)EntityCacheUtil.getResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
915                                    SocialRequestImpl.class, requestId);
916    
917                    if (socialRequest == _nullSocialRequest) {
918                            return null;
919                    }
920    
921                    if (socialRequest == null) {
922                            Session session = null;
923    
924                            boolean hasException = false;
925    
926                            try {
927                                    session = openSession();
928    
929                                    socialRequest = (SocialRequest)session.get(SocialRequestImpl.class,
930                                                    Long.valueOf(requestId));
931                            }
932                            catch (Exception e) {
933                                    hasException = true;
934    
935                                    throw processException(e);
936                            }
937                            finally {
938                                    if (socialRequest != null) {
939                                            cacheResult(socialRequest);
940                                    }
941                                    else if (!hasException) {
942                                            EntityCacheUtil.putResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
943                                                    SocialRequestImpl.class, requestId, _nullSocialRequest);
944                                    }
945    
946                                    closeSession(session);
947                            }
948                    }
949    
950                    return socialRequest;
951            }
952    
953            /**
954             * Returns all the social requests where uuid = &#63;.
955             *
956             * @param uuid the uuid
957             * @return the matching social requests
958             * @throws SystemException if a system exception occurred
959             */
960            public List<SocialRequest> findByUuid(String uuid)
961                    throws SystemException {
962                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
963            }
964    
965            /**
966             * Returns a range of all the social requests where uuid = &#63;.
967             *
968             * <p>
969             * 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.
970             * </p>
971             *
972             * @param uuid the uuid
973             * @param start the lower bound of the range of social requests
974             * @param end the upper bound of the range of social requests (not inclusive)
975             * @return the range of matching social requests
976             * @throws SystemException if a system exception occurred
977             */
978            public List<SocialRequest> findByUuid(String uuid, int start, int end)
979                    throws SystemException {
980                    return findByUuid(uuid, start, end, null);
981            }
982    
983            /**
984             * Returns an ordered range of all the social requests where uuid = &#63;.
985             *
986             * <p>
987             * 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.
988             * </p>
989             *
990             * @param uuid the uuid
991             * @param start the lower bound of the range of social requests
992             * @param end the upper bound of the range of social requests (not inclusive)
993             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
994             * @return the ordered range of matching social requests
995             * @throws SystemException if a system exception occurred
996             */
997            public List<SocialRequest> findByUuid(String uuid, int start, int end,
998                    OrderByComparator orderByComparator) throws SystemException {
999                    FinderPath finderPath = null;
1000                    Object[] finderArgs = null;
1001    
1002                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1003                                    (orderByComparator == null)) {
1004                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1005                            finderArgs = new Object[] { uuid };
1006                    }
1007                    else {
1008                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1009                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1010                    }
1011    
1012                    List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(finderPath,
1013                                    finderArgs, this);
1014    
1015                    if (list == null) {
1016                            StringBundler query = null;
1017    
1018                            if (orderByComparator != null) {
1019                                    query = new StringBundler(3 +
1020                                                    (orderByComparator.getOrderByFields().length * 3));
1021                            }
1022                            else {
1023                                    query = new StringBundler(3);
1024                            }
1025    
1026                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1027    
1028                            if (uuid == null) {
1029                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1030                            }
1031                            else {
1032                                    if (uuid.equals(StringPool.BLANK)) {
1033                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1034                                    }
1035                                    else {
1036                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1037                                    }
1038                            }
1039    
1040                            if (orderByComparator != null) {
1041                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1042                                            orderByComparator);
1043                            }
1044    
1045                            else {
1046                                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1047                            }
1048    
1049                            String sql = query.toString();
1050    
1051                            Session session = null;
1052    
1053                            try {
1054                                    session = openSession();
1055    
1056                                    Query q = session.createQuery(sql);
1057    
1058                                    QueryPos qPos = QueryPos.getInstance(q);
1059    
1060                                    if (uuid != null) {
1061                                            qPos.add(uuid);
1062                                    }
1063    
1064                                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1065                                                    start, end);
1066                            }
1067                            catch (Exception e) {
1068                                    throw processException(e);
1069                            }
1070                            finally {
1071                                    if (list == null) {
1072                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1073                                    }
1074                                    else {
1075                                            cacheResult(list);
1076    
1077                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1078                                    }
1079    
1080                                    closeSession(session);
1081                            }
1082                    }
1083    
1084                    return list;
1085            }
1086    
1087            /**
1088             * Returns the first social request in the ordered set where uuid = &#63;.
1089             *
1090             * <p>
1091             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1092             * </p>
1093             *
1094             * @param uuid the uuid
1095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1096             * @return the first matching social request
1097             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
1098             * @throws SystemException if a system exception occurred
1099             */
1100            public SocialRequest findByUuid_First(String uuid,
1101                    OrderByComparator orderByComparator)
1102                    throws NoSuchRequestException, SystemException {
1103                    List<SocialRequest> list = findByUuid(uuid, 0, 1, orderByComparator);
1104    
1105                    if (list.isEmpty()) {
1106                            StringBundler msg = new StringBundler(4);
1107    
1108                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1109    
1110                            msg.append("uuid=");
1111                            msg.append(uuid);
1112    
1113                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1114    
1115                            throw new NoSuchRequestException(msg.toString());
1116                    }
1117                    else {
1118                            return list.get(0);
1119                    }
1120            }
1121    
1122            /**
1123             * Returns the last social request in the ordered set where uuid = &#63;.
1124             *
1125             * <p>
1126             * 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.
1127             * </p>
1128             *
1129             * @param uuid the uuid
1130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1131             * @return the last matching social request
1132             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
1133             * @throws SystemException if a system exception occurred
1134             */
1135            public SocialRequest findByUuid_Last(String uuid,
1136                    OrderByComparator orderByComparator)
1137                    throws NoSuchRequestException, SystemException {
1138                    int count = countByUuid(uuid);
1139    
1140                    List<SocialRequest> list = findByUuid(uuid, count - 1, count,
1141                                    orderByComparator);
1142    
1143                    if (list.isEmpty()) {
1144                            StringBundler msg = new StringBundler(4);
1145    
1146                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1147    
1148                            msg.append("uuid=");
1149                            msg.append(uuid);
1150    
1151                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1152    
1153                            throw new NoSuchRequestException(msg.toString());
1154                    }
1155                    else {
1156                            return list.get(0);
1157                    }
1158            }
1159    
1160            /**
1161             * Returns the social requests before and after the current social request in the ordered set where uuid = &#63;.
1162             *
1163             * <p>
1164             * 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.
1165             * </p>
1166             *
1167             * @param requestId the primary key of the current social request
1168             * @param uuid the uuid
1169             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1170             * @return the previous, current, and next social request
1171             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
1172             * @throws SystemException if a system exception occurred
1173             */
1174            public SocialRequest[] findByUuid_PrevAndNext(long requestId, String uuid,
1175                    OrderByComparator orderByComparator)
1176                    throws NoSuchRequestException, SystemException {
1177                    SocialRequest socialRequest = findByPrimaryKey(requestId);
1178    
1179                    Session session = null;
1180    
1181                    try {
1182                            session = openSession();
1183    
1184                            SocialRequest[] array = new SocialRequestImpl[3];
1185    
1186                            array[0] = getByUuid_PrevAndNext(session, socialRequest, uuid,
1187                                            orderByComparator, true);
1188    
1189                            array[1] = socialRequest;
1190    
1191                            array[2] = getByUuid_PrevAndNext(session, socialRequest, uuid,
1192                                            orderByComparator, false);
1193    
1194                            return array;
1195                    }
1196                    catch (Exception e) {
1197                            throw processException(e);
1198                    }
1199                    finally {
1200                            closeSession(session);
1201                    }
1202            }
1203    
1204            protected SocialRequest getByUuid_PrevAndNext(Session session,
1205                    SocialRequest socialRequest, String uuid,
1206                    OrderByComparator orderByComparator, boolean previous) {
1207                    StringBundler query = null;
1208    
1209                    if (orderByComparator != null) {
1210                            query = new StringBundler(6 +
1211                                            (orderByComparator.getOrderByFields().length * 6));
1212                    }
1213                    else {
1214                            query = new StringBundler(3);
1215                    }
1216    
1217                    query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1218    
1219                    if (uuid == null) {
1220                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1221                    }
1222                    else {
1223                            if (uuid.equals(StringPool.BLANK)) {
1224                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1225                            }
1226                            else {
1227                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1228                            }
1229                    }
1230    
1231                    if (orderByComparator != null) {
1232                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1233    
1234                            if (orderByConditionFields.length > 0) {
1235                                    query.append(WHERE_AND);
1236                            }
1237    
1238                            for (int i = 0; i < orderByConditionFields.length; i++) {
1239                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1240                                    query.append(orderByConditionFields[i]);
1241    
1242                                    if ((i + 1) < orderByConditionFields.length) {
1243                                            if (orderByComparator.isAscending() ^ previous) {
1244                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1245                                            }
1246                                            else {
1247                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1248                                            }
1249                                    }
1250                                    else {
1251                                            if (orderByComparator.isAscending() ^ previous) {
1252                                                    query.append(WHERE_GREATER_THAN);
1253                                            }
1254                                            else {
1255                                                    query.append(WHERE_LESSER_THAN);
1256                                            }
1257                                    }
1258                            }
1259    
1260                            query.append(ORDER_BY_CLAUSE);
1261    
1262                            String[] orderByFields = orderByComparator.getOrderByFields();
1263    
1264                            for (int i = 0; i < orderByFields.length; i++) {
1265                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1266                                    query.append(orderByFields[i]);
1267    
1268                                    if ((i + 1) < orderByFields.length) {
1269                                            if (orderByComparator.isAscending() ^ previous) {
1270                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1271                                            }
1272                                            else {
1273                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1274                                            }
1275                                    }
1276                                    else {
1277                                            if (orderByComparator.isAscending() ^ previous) {
1278                                                    query.append(ORDER_BY_ASC);
1279                                            }
1280                                            else {
1281                                                    query.append(ORDER_BY_DESC);
1282                                            }
1283                                    }
1284                            }
1285                    }
1286    
1287                    else {
1288                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1289                    }
1290    
1291                    String sql = query.toString();
1292    
1293                    Query q = session.createQuery(sql);
1294    
1295                    q.setFirstResult(0);
1296                    q.setMaxResults(2);
1297    
1298                    QueryPos qPos = QueryPos.getInstance(q);
1299    
1300                    if (uuid != null) {
1301                            qPos.add(uuid);
1302                    }
1303    
1304                    if (orderByComparator != null) {
1305                            Object[] values = orderByComparator.getOrderByConditionValues(socialRequest);
1306    
1307                            for (Object value : values) {
1308                                    qPos.add(value);
1309                            }
1310                    }
1311    
1312                    List<SocialRequest> list = q.list();
1313    
1314                    if (list.size() == 2) {
1315                            return list.get(1);
1316                    }
1317                    else {
1318                            return null;
1319                    }
1320            }
1321    
1322            /**
1323             * Returns the social request where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.social.NoSuchRequestException} if it could not be found.
1324             *
1325             * @param uuid the uuid
1326             * @param groupId the group ID
1327             * @return the matching social request
1328             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
1329             * @throws SystemException if a system exception occurred
1330             */
1331            public SocialRequest findByUUID_G(String uuid, long groupId)
1332                    throws NoSuchRequestException, SystemException {
1333                    SocialRequest socialRequest = fetchByUUID_G(uuid, groupId);
1334    
1335                    if (socialRequest == null) {
1336                            StringBundler msg = new StringBundler(6);
1337    
1338                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1339    
1340                            msg.append("uuid=");
1341                            msg.append(uuid);
1342    
1343                            msg.append(", groupId=");
1344                            msg.append(groupId);
1345    
1346                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1347    
1348                            if (_log.isWarnEnabled()) {
1349                                    _log.warn(msg.toString());
1350                            }
1351    
1352                            throw new NoSuchRequestException(msg.toString());
1353                    }
1354    
1355                    return socialRequest;
1356            }
1357    
1358            /**
1359             * Returns the social request where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1360             *
1361             * @param uuid the uuid
1362             * @param groupId the group ID
1363             * @return the matching social request, or <code>null</code> if a matching social request could not be found
1364             * @throws SystemException if a system exception occurred
1365             */
1366            public SocialRequest fetchByUUID_G(String uuid, long groupId)
1367                    throws SystemException {
1368                    return fetchByUUID_G(uuid, groupId, true);
1369            }
1370    
1371            /**
1372             * Returns the social request where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1373             *
1374             * @param uuid the uuid
1375             * @param groupId the group ID
1376             * @param retrieveFromCache whether to use the finder cache
1377             * @return the matching social request, or <code>null</code> if a matching social request could not be found
1378             * @throws SystemException if a system exception occurred
1379             */
1380            public SocialRequest fetchByUUID_G(String uuid, long groupId,
1381                    boolean retrieveFromCache) throws SystemException {
1382                    Object[] finderArgs = new Object[] { uuid, groupId };
1383    
1384                    Object result = null;
1385    
1386                    if (retrieveFromCache) {
1387                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1388                                            finderArgs, this);
1389                    }
1390    
1391                    if (result == null) {
1392                            StringBundler query = new StringBundler(4);
1393    
1394                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1395    
1396                            if (uuid == null) {
1397                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1398                            }
1399                            else {
1400                                    if (uuid.equals(StringPool.BLANK)) {
1401                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1402                                    }
1403                                    else {
1404                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1405                                    }
1406                            }
1407    
1408                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1409    
1410                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1411    
1412                            String sql = query.toString();
1413    
1414                            Session session = null;
1415    
1416                            try {
1417                                    session = openSession();
1418    
1419                                    Query q = session.createQuery(sql);
1420    
1421                                    QueryPos qPos = QueryPos.getInstance(q);
1422    
1423                                    if (uuid != null) {
1424                                            qPos.add(uuid);
1425                                    }
1426    
1427                                    qPos.add(groupId);
1428    
1429                                    List<SocialRequest> list = q.list();
1430    
1431                                    result = list;
1432    
1433                                    SocialRequest socialRequest = null;
1434    
1435                                    if (list.isEmpty()) {
1436                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1437                                                    finderArgs, list);
1438                                    }
1439                                    else {
1440                                            socialRequest = list.get(0);
1441    
1442                                            cacheResult(socialRequest);
1443    
1444                                            if ((socialRequest.getUuid() == null) ||
1445                                                            !socialRequest.getUuid().equals(uuid) ||
1446                                                            (socialRequest.getGroupId() != groupId)) {
1447                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1448                                                            finderArgs, socialRequest);
1449                                            }
1450                                    }
1451    
1452                                    return socialRequest;
1453                            }
1454                            catch (Exception e) {
1455                                    throw processException(e);
1456                            }
1457                            finally {
1458                                    if (result == null) {
1459                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1460                                                    finderArgs);
1461                                    }
1462    
1463                                    closeSession(session);
1464                            }
1465                    }
1466                    else {
1467                            if (result instanceof List<?>) {
1468                                    return null;
1469                            }
1470                            else {
1471                                    return (SocialRequest)result;
1472                            }
1473                    }
1474            }
1475    
1476            /**
1477             * Returns all the social requests where companyId = &#63;.
1478             *
1479             * @param companyId the company ID
1480             * @return the matching social requests
1481             * @throws SystemException if a system exception occurred
1482             */
1483            public List<SocialRequest> findByCompanyId(long companyId)
1484                    throws SystemException {
1485                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1486                            null);
1487            }
1488    
1489            /**
1490             * Returns a range of all the social requests where companyId = &#63;.
1491             *
1492             * <p>
1493             * 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.
1494             * </p>
1495             *
1496             * @param companyId the company ID
1497             * @param start the lower bound of the range of social requests
1498             * @param end the upper bound of the range of social requests (not inclusive)
1499             * @return the range of matching social requests
1500             * @throws SystemException if a system exception occurred
1501             */
1502            public List<SocialRequest> findByCompanyId(long companyId, int start,
1503                    int end) throws SystemException {
1504                    return findByCompanyId(companyId, start, end, null);
1505            }
1506    
1507            /**
1508             * Returns an ordered range of all the social requests where companyId = &#63;.
1509             *
1510             * <p>
1511             * 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.
1512             * </p>
1513             *
1514             * @param companyId the company ID
1515             * @param start the lower bound of the range of social requests
1516             * @param end the upper bound of the range of social requests (not inclusive)
1517             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1518             * @return the ordered range of matching social requests
1519             * @throws SystemException if a system exception occurred
1520             */
1521            public List<SocialRequest> findByCompanyId(long companyId, int start,
1522                    int end, OrderByComparator orderByComparator) throws SystemException {
1523                    FinderPath finderPath = null;
1524                    Object[] finderArgs = null;
1525    
1526                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1527                                    (orderByComparator == null)) {
1528                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1529                            finderArgs = new Object[] { companyId };
1530                    }
1531                    else {
1532                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1533                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1534                    }
1535    
1536                    List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(finderPath,
1537                                    finderArgs, this);
1538    
1539                    if (list == null) {
1540                            StringBundler query = null;
1541    
1542                            if (orderByComparator != null) {
1543                                    query = new StringBundler(3 +
1544                                                    (orderByComparator.getOrderByFields().length * 3));
1545                            }
1546                            else {
1547                                    query = new StringBundler(3);
1548                            }
1549    
1550                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1551    
1552                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1553    
1554                            if (orderByComparator != null) {
1555                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1556                                            orderByComparator);
1557                            }
1558    
1559                            else {
1560                                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1561                            }
1562    
1563                            String sql = query.toString();
1564    
1565                            Session session = null;
1566    
1567                            try {
1568                                    session = openSession();
1569    
1570                                    Query q = session.createQuery(sql);
1571    
1572                                    QueryPos qPos = QueryPos.getInstance(q);
1573    
1574                                    qPos.add(companyId);
1575    
1576                                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1577                                                    start, end);
1578                            }
1579                            catch (Exception e) {
1580                                    throw processException(e);
1581                            }
1582                            finally {
1583                                    if (list == null) {
1584                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1585                                    }
1586                                    else {
1587                                            cacheResult(list);
1588    
1589                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1590                                    }
1591    
1592                                    closeSession(session);
1593                            }
1594                    }
1595    
1596                    return list;
1597            }
1598    
1599            /**
1600             * Returns the first social request in the ordered set where companyId = &#63;.
1601             *
1602             * <p>
1603             * 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.
1604             * </p>
1605             *
1606             * @param companyId the company ID
1607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1608             * @return the first matching social request
1609             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
1610             * @throws SystemException if a system exception occurred
1611             */
1612            public SocialRequest findByCompanyId_First(long companyId,
1613                    OrderByComparator orderByComparator)
1614                    throws NoSuchRequestException, SystemException {
1615                    List<SocialRequest> list = findByCompanyId(companyId, 0, 1,
1616                                    orderByComparator);
1617    
1618                    if (list.isEmpty()) {
1619                            StringBundler msg = new StringBundler(4);
1620    
1621                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1622    
1623                            msg.append("companyId=");
1624                            msg.append(companyId);
1625    
1626                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1627    
1628                            throw new NoSuchRequestException(msg.toString());
1629                    }
1630                    else {
1631                            return list.get(0);
1632                    }
1633            }
1634    
1635            /**
1636             * Returns the last social request in the ordered set where companyId = &#63;.
1637             *
1638             * <p>
1639             * 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.
1640             * </p>
1641             *
1642             * @param companyId the company ID
1643             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1644             * @return the last matching social request
1645             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
1646             * @throws SystemException if a system exception occurred
1647             */
1648            public SocialRequest findByCompanyId_Last(long companyId,
1649                    OrderByComparator orderByComparator)
1650                    throws NoSuchRequestException, SystemException {
1651                    int count = countByCompanyId(companyId);
1652    
1653                    List<SocialRequest> list = findByCompanyId(companyId, count - 1, count,
1654                                    orderByComparator);
1655    
1656                    if (list.isEmpty()) {
1657                            StringBundler msg = new StringBundler(4);
1658    
1659                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1660    
1661                            msg.append("companyId=");
1662                            msg.append(companyId);
1663    
1664                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1665    
1666                            throw new NoSuchRequestException(msg.toString());
1667                    }
1668                    else {
1669                            return list.get(0);
1670                    }
1671            }
1672    
1673            /**
1674             * Returns the social requests before and after the current social request in the ordered set where companyId = &#63;.
1675             *
1676             * <p>
1677             * 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.
1678             * </p>
1679             *
1680             * @param requestId the primary key of the current social request
1681             * @param companyId the company ID
1682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1683             * @return the previous, current, and next social request
1684             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
1685             * @throws SystemException if a system exception occurred
1686             */
1687            public SocialRequest[] findByCompanyId_PrevAndNext(long requestId,
1688                    long companyId, OrderByComparator orderByComparator)
1689                    throws NoSuchRequestException, SystemException {
1690                    SocialRequest socialRequest = findByPrimaryKey(requestId);
1691    
1692                    Session session = null;
1693    
1694                    try {
1695                            session = openSession();
1696    
1697                            SocialRequest[] array = new SocialRequestImpl[3];
1698    
1699                            array[0] = getByCompanyId_PrevAndNext(session, socialRequest,
1700                                            companyId, orderByComparator, true);
1701    
1702                            array[1] = socialRequest;
1703    
1704                            array[2] = getByCompanyId_PrevAndNext(session, socialRequest,
1705                                            companyId, orderByComparator, false);
1706    
1707                            return array;
1708                    }
1709                    catch (Exception e) {
1710                            throw processException(e);
1711                    }
1712                    finally {
1713                            closeSession(session);
1714                    }
1715            }
1716    
1717            protected SocialRequest getByCompanyId_PrevAndNext(Session session,
1718                    SocialRequest socialRequest, long companyId,
1719                    OrderByComparator orderByComparator, boolean previous) {
1720                    StringBundler query = null;
1721    
1722                    if (orderByComparator != null) {
1723                            query = new StringBundler(6 +
1724                                            (orderByComparator.getOrderByFields().length * 6));
1725                    }
1726                    else {
1727                            query = new StringBundler(3);
1728                    }
1729    
1730                    query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1731    
1732                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1733    
1734                    if (orderByComparator != null) {
1735                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1736    
1737                            if (orderByConditionFields.length > 0) {
1738                                    query.append(WHERE_AND);
1739                            }
1740    
1741                            for (int i = 0; i < orderByConditionFields.length; i++) {
1742                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1743                                    query.append(orderByConditionFields[i]);
1744    
1745                                    if ((i + 1) < orderByConditionFields.length) {
1746                                            if (orderByComparator.isAscending() ^ previous) {
1747                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1748                                            }
1749                                            else {
1750                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1751                                            }
1752                                    }
1753                                    else {
1754                                            if (orderByComparator.isAscending() ^ previous) {
1755                                                    query.append(WHERE_GREATER_THAN);
1756                                            }
1757                                            else {
1758                                                    query.append(WHERE_LESSER_THAN);
1759                                            }
1760                                    }
1761                            }
1762    
1763                            query.append(ORDER_BY_CLAUSE);
1764    
1765                            String[] orderByFields = orderByComparator.getOrderByFields();
1766    
1767                            for (int i = 0; i < orderByFields.length; i++) {
1768                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1769                                    query.append(orderByFields[i]);
1770    
1771                                    if ((i + 1) < orderByFields.length) {
1772                                            if (orderByComparator.isAscending() ^ previous) {
1773                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1774                                            }
1775                                            else {
1776                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1777                                            }
1778                                    }
1779                                    else {
1780                                            if (orderByComparator.isAscending() ^ previous) {
1781                                                    query.append(ORDER_BY_ASC);
1782                                            }
1783                                            else {
1784                                                    query.append(ORDER_BY_DESC);
1785                                            }
1786                                    }
1787                            }
1788                    }
1789    
1790                    else {
1791                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1792                    }
1793    
1794                    String sql = query.toString();
1795    
1796                    Query q = session.createQuery(sql);
1797    
1798                    q.setFirstResult(0);
1799                    q.setMaxResults(2);
1800    
1801                    QueryPos qPos = QueryPos.getInstance(q);
1802    
1803                    qPos.add(companyId);
1804    
1805                    if (orderByComparator != null) {
1806                            Object[] values = orderByComparator.getOrderByConditionValues(socialRequest);
1807    
1808                            for (Object value : values) {
1809                                    qPos.add(value);
1810                            }
1811                    }
1812    
1813                    List<SocialRequest> list = q.list();
1814    
1815                    if (list.size() == 2) {
1816                            return list.get(1);
1817                    }
1818                    else {
1819                            return null;
1820                    }
1821            }
1822    
1823            /**
1824             * Returns all the social requests where userId = &#63;.
1825             *
1826             * @param userId the user ID
1827             * @return the matching social requests
1828             * @throws SystemException if a system exception occurred
1829             */
1830            public List<SocialRequest> findByUserId(long userId)
1831                    throws SystemException {
1832                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1833            }
1834    
1835            /**
1836             * Returns a range of all the social requests where userId = &#63;.
1837             *
1838             * <p>
1839             * 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.
1840             * </p>
1841             *
1842             * @param userId the user ID
1843             * @param start the lower bound of the range of social requests
1844             * @param end the upper bound of the range of social requests (not inclusive)
1845             * @return the range of matching social requests
1846             * @throws SystemException if a system exception occurred
1847             */
1848            public List<SocialRequest> findByUserId(long userId, int start, int end)
1849                    throws SystemException {
1850                    return findByUserId(userId, start, end, null);
1851            }
1852    
1853            /**
1854             * Returns an ordered range of all the social requests where userId = &#63;.
1855             *
1856             * <p>
1857             * 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.
1858             * </p>
1859             *
1860             * @param userId the user ID
1861             * @param start the lower bound of the range of social requests
1862             * @param end the upper bound of the range of social requests (not inclusive)
1863             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1864             * @return the ordered range of matching social requests
1865             * @throws SystemException if a system exception occurred
1866             */
1867            public List<SocialRequest> findByUserId(long userId, int start, int end,
1868                    OrderByComparator orderByComparator) throws SystemException {
1869                    FinderPath finderPath = null;
1870                    Object[] finderArgs = null;
1871    
1872                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1873                                    (orderByComparator == null)) {
1874                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1875                            finderArgs = new Object[] { userId };
1876                    }
1877                    else {
1878                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1879                            finderArgs = new Object[] { userId, start, end, orderByComparator };
1880                    }
1881    
1882                    List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(finderPath,
1883                                    finderArgs, this);
1884    
1885                    if (list == null) {
1886                            StringBundler query = null;
1887    
1888                            if (orderByComparator != null) {
1889                                    query = new StringBundler(3 +
1890                                                    (orderByComparator.getOrderByFields().length * 3));
1891                            }
1892                            else {
1893                                    query = new StringBundler(3);
1894                            }
1895    
1896                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1897    
1898                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1899    
1900                            if (orderByComparator != null) {
1901                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1902                                            orderByComparator);
1903                            }
1904    
1905                            else {
1906                                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1907                            }
1908    
1909                            String sql = query.toString();
1910    
1911                            Session session = null;
1912    
1913                            try {
1914                                    session = openSession();
1915    
1916                                    Query q = session.createQuery(sql);
1917    
1918                                    QueryPos qPos = QueryPos.getInstance(q);
1919    
1920                                    qPos.add(userId);
1921    
1922                                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1923                                                    start, end);
1924                            }
1925                            catch (Exception e) {
1926                                    throw processException(e);
1927                            }
1928                            finally {
1929                                    if (list == null) {
1930                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1931                                    }
1932                                    else {
1933                                            cacheResult(list);
1934    
1935                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1936                                    }
1937    
1938                                    closeSession(session);
1939                            }
1940                    }
1941    
1942                    return list;
1943            }
1944    
1945            /**
1946             * Returns the first social request in the ordered set where userId = &#63;.
1947             *
1948             * <p>
1949             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1950             * </p>
1951             *
1952             * @param userId the user ID
1953             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1954             * @return the first matching social request
1955             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
1956             * @throws SystemException if a system exception occurred
1957             */
1958            public SocialRequest findByUserId_First(long userId,
1959                    OrderByComparator orderByComparator)
1960                    throws NoSuchRequestException, SystemException {
1961                    List<SocialRequest> list = findByUserId(userId, 0, 1, orderByComparator);
1962    
1963                    if (list.isEmpty()) {
1964                            StringBundler msg = new StringBundler(4);
1965    
1966                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1967    
1968                            msg.append("userId=");
1969                            msg.append(userId);
1970    
1971                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1972    
1973                            throw new NoSuchRequestException(msg.toString());
1974                    }
1975                    else {
1976                            return list.get(0);
1977                    }
1978            }
1979    
1980            /**
1981             * Returns the last social request in the ordered set where userId = &#63;.
1982             *
1983             * <p>
1984             * 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.
1985             * </p>
1986             *
1987             * @param userId the user ID
1988             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1989             * @return the last matching social request
1990             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
1991             * @throws SystemException if a system exception occurred
1992             */
1993            public SocialRequest findByUserId_Last(long userId,
1994                    OrderByComparator orderByComparator)
1995                    throws NoSuchRequestException, SystemException {
1996                    int count = countByUserId(userId);
1997    
1998                    List<SocialRequest> list = findByUserId(userId, count - 1, count,
1999                                    orderByComparator);
2000    
2001                    if (list.isEmpty()) {
2002                            StringBundler msg = new StringBundler(4);
2003    
2004                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2005    
2006                            msg.append("userId=");
2007                            msg.append(userId);
2008    
2009                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2010    
2011                            throw new NoSuchRequestException(msg.toString());
2012                    }
2013                    else {
2014                            return list.get(0);
2015                    }
2016            }
2017    
2018            /**
2019             * Returns the social requests before and after the current social request in the ordered set where userId = &#63;.
2020             *
2021             * <p>
2022             * 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.
2023             * </p>
2024             *
2025             * @param requestId the primary key of the current social request
2026             * @param userId the user ID
2027             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2028             * @return the previous, current, and next social request
2029             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
2030             * @throws SystemException if a system exception occurred
2031             */
2032            public SocialRequest[] findByUserId_PrevAndNext(long requestId,
2033                    long userId, OrderByComparator orderByComparator)
2034                    throws NoSuchRequestException, SystemException {
2035                    SocialRequest socialRequest = findByPrimaryKey(requestId);
2036    
2037                    Session session = null;
2038    
2039                    try {
2040                            session = openSession();
2041    
2042                            SocialRequest[] array = new SocialRequestImpl[3];
2043    
2044                            array[0] = getByUserId_PrevAndNext(session, socialRequest, userId,
2045                                            orderByComparator, true);
2046    
2047                            array[1] = socialRequest;
2048    
2049                            array[2] = getByUserId_PrevAndNext(session, socialRequest, userId,
2050                                            orderByComparator, false);
2051    
2052                            return array;
2053                    }
2054                    catch (Exception e) {
2055                            throw processException(e);
2056                    }
2057                    finally {
2058                            closeSession(session);
2059                    }
2060            }
2061    
2062            protected SocialRequest getByUserId_PrevAndNext(Session session,
2063                    SocialRequest socialRequest, long userId,
2064                    OrderByComparator orderByComparator, boolean previous) {
2065                    StringBundler query = null;
2066    
2067                    if (orderByComparator != null) {
2068                            query = new StringBundler(6 +
2069                                            (orderByComparator.getOrderByFields().length * 6));
2070                    }
2071                    else {
2072                            query = new StringBundler(3);
2073                    }
2074    
2075                    query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2076    
2077                    query.append(_FINDER_COLUMN_USERID_USERID_2);
2078    
2079                    if (orderByComparator != null) {
2080                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2081    
2082                            if (orderByConditionFields.length > 0) {
2083                                    query.append(WHERE_AND);
2084                            }
2085    
2086                            for (int i = 0; i < orderByConditionFields.length; i++) {
2087                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2088                                    query.append(orderByConditionFields[i]);
2089    
2090                                    if ((i + 1) < orderByConditionFields.length) {
2091                                            if (orderByComparator.isAscending() ^ previous) {
2092                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2093                                            }
2094                                            else {
2095                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2096                                            }
2097                                    }
2098                                    else {
2099                                            if (orderByComparator.isAscending() ^ previous) {
2100                                                    query.append(WHERE_GREATER_THAN);
2101                                            }
2102                                            else {
2103                                                    query.append(WHERE_LESSER_THAN);
2104                                            }
2105                                    }
2106                            }
2107    
2108                            query.append(ORDER_BY_CLAUSE);
2109    
2110                            String[] orderByFields = orderByComparator.getOrderByFields();
2111    
2112                            for (int i = 0; i < orderByFields.length; i++) {
2113                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2114                                    query.append(orderByFields[i]);
2115    
2116                                    if ((i + 1) < orderByFields.length) {
2117                                            if (orderByComparator.isAscending() ^ previous) {
2118                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2119                                            }
2120                                            else {
2121                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2122                                            }
2123                                    }
2124                                    else {
2125                                            if (orderByComparator.isAscending() ^ previous) {
2126                                                    query.append(ORDER_BY_ASC);
2127                                            }
2128                                            else {
2129                                                    query.append(ORDER_BY_DESC);
2130                                            }
2131                                    }
2132                            }
2133                    }
2134    
2135                    else {
2136                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2137                    }
2138    
2139                    String sql = query.toString();
2140    
2141                    Query q = session.createQuery(sql);
2142    
2143                    q.setFirstResult(0);
2144                    q.setMaxResults(2);
2145    
2146                    QueryPos qPos = QueryPos.getInstance(q);
2147    
2148                    qPos.add(userId);
2149    
2150                    if (orderByComparator != null) {
2151                            Object[] values = orderByComparator.getOrderByConditionValues(socialRequest);
2152    
2153                            for (Object value : values) {
2154                                    qPos.add(value);
2155                            }
2156                    }
2157    
2158                    List<SocialRequest> list = q.list();
2159    
2160                    if (list.size() == 2) {
2161                            return list.get(1);
2162                    }
2163                    else {
2164                            return null;
2165                    }
2166            }
2167    
2168            /**
2169             * Returns all the social requests where receiverUserId = &#63;.
2170             *
2171             * @param receiverUserId the receiver user ID
2172             * @return the matching social requests
2173             * @throws SystemException if a system exception occurred
2174             */
2175            public List<SocialRequest> findByReceiverUserId(long receiverUserId)
2176                    throws SystemException {
2177                    return findByReceiverUserId(receiverUserId, QueryUtil.ALL_POS,
2178                            QueryUtil.ALL_POS, null);
2179            }
2180    
2181            /**
2182             * Returns a range of all the social requests where receiverUserId = &#63;.
2183             *
2184             * <p>
2185             * 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.
2186             * </p>
2187             *
2188             * @param receiverUserId the receiver user ID
2189             * @param start the lower bound of the range of social requests
2190             * @param end the upper bound of the range of social requests (not inclusive)
2191             * @return the range of matching social requests
2192             * @throws SystemException if a system exception occurred
2193             */
2194            public List<SocialRequest> findByReceiverUserId(long receiverUserId,
2195                    int start, int end) throws SystemException {
2196                    return findByReceiverUserId(receiverUserId, start, end, null);
2197            }
2198    
2199            /**
2200             * Returns an ordered range of all the social requests where receiverUserId = &#63;.
2201             *
2202             * <p>
2203             * 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.
2204             * </p>
2205             *
2206             * @param receiverUserId the receiver user ID
2207             * @param start the lower bound of the range of social requests
2208             * @param end the upper bound of the range of social requests (not inclusive)
2209             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2210             * @return the ordered range of matching social requests
2211             * @throws SystemException if a system exception occurred
2212             */
2213            public List<SocialRequest> findByReceiverUserId(long receiverUserId,
2214                    int start, int end, OrderByComparator orderByComparator)
2215                    throws SystemException {
2216                    FinderPath finderPath = null;
2217                    Object[] finderArgs = null;
2218    
2219                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2220                                    (orderByComparator == null)) {
2221                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID;
2222                            finderArgs = new Object[] { receiverUserId };
2223                    }
2224                    else {
2225                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RECEIVERUSERID;
2226                            finderArgs = new Object[] {
2227                                            receiverUserId,
2228                                            
2229                                            start, end, orderByComparator
2230                                    };
2231                    }
2232    
2233                    List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(finderPath,
2234                                    finderArgs, this);
2235    
2236                    if (list == null) {
2237                            StringBundler query = null;
2238    
2239                            if (orderByComparator != null) {
2240                                    query = new StringBundler(3 +
2241                                                    (orderByComparator.getOrderByFields().length * 3));
2242                            }
2243                            else {
2244                                    query = new StringBundler(3);
2245                            }
2246    
2247                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2248    
2249                            query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
2250    
2251                            if (orderByComparator != null) {
2252                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2253                                            orderByComparator);
2254                            }
2255    
2256                            else {
2257                                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2258                            }
2259    
2260                            String sql = query.toString();
2261    
2262                            Session session = null;
2263    
2264                            try {
2265                                    session = openSession();
2266    
2267                                    Query q = session.createQuery(sql);
2268    
2269                                    QueryPos qPos = QueryPos.getInstance(q);
2270    
2271                                    qPos.add(receiverUserId);
2272    
2273                                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
2274                                                    start, end);
2275                            }
2276                            catch (Exception e) {
2277                                    throw processException(e);
2278                            }
2279                            finally {
2280                                    if (list == null) {
2281                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2282                                    }
2283                                    else {
2284                                            cacheResult(list);
2285    
2286                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2287                                    }
2288    
2289                                    closeSession(session);
2290                            }
2291                    }
2292    
2293                    return list;
2294            }
2295    
2296            /**
2297             * Returns the first social request in the ordered set where receiverUserId = &#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 receiverUserId the receiver user ID
2304             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2305             * @return the first matching social request
2306             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
2307             * @throws SystemException if a system exception occurred
2308             */
2309            public SocialRequest findByReceiverUserId_First(long receiverUserId,
2310                    OrderByComparator orderByComparator)
2311                    throws NoSuchRequestException, SystemException {
2312                    List<SocialRequest> list = findByReceiverUserId(receiverUserId, 0, 1,
2313                                    orderByComparator);
2314    
2315                    if (list.isEmpty()) {
2316                            StringBundler msg = new StringBundler(4);
2317    
2318                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2319    
2320                            msg.append("receiverUserId=");
2321                            msg.append(receiverUserId);
2322    
2323                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2324    
2325                            throw new NoSuchRequestException(msg.toString());
2326                    }
2327                    else {
2328                            return list.get(0);
2329                    }
2330            }
2331    
2332            /**
2333             * Returns the last social request in the ordered set where receiverUserId = &#63;.
2334             *
2335             * <p>
2336             * 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.
2337             * </p>
2338             *
2339             * @param receiverUserId the receiver user ID
2340             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2341             * @return the last matching social request
2342             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
2343             * @throws SystemException if a system exception occurred
2344             */
2345            public SocialRequest findByReceiverUserId_Last(long receiverUserId,
2346                    OrderByComparator orderByComparator)
2347                    throws NoSuchRequestException, SystemException {
2348                    int count = countByReceiverUserId(receiverUserId);
2349    
2350                    List<SocialRequest> list = findByReceiverUserId(receiverUserId,
2351                                    count - 1, count, orderByComparator);
2352    
2353                    if (list.isEmpty()) {
2354                            StringBundler msg = new StringBundler(4);
2355    
2356                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2357    
2358                            msg.append("receiverUserId=");
2359                            msg.append(receiverUserId);
2360    
2361                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2362    
2363                            throw new NoSuchRequestException(msg.toString());
2364                    }
2365                    else {
2366                            return list.get(0);
2367                    }
2368            }
2369    
2370            /**
2371             * Returns the social requests before and after the current social request in the ordered set where receiverUserId = &#63;.
2372             *
2373             * <p>
2374             * 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.
2375             * </p>
2376             *
2377             * @param requestId the primary key of the current social request
2378             * @param receiverUserId the receiver user ID
2379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2380             * @return the previous, current, and next social request
2381             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
2382             * @throws SystemException if a system exception occurred
2383             */
2384            public SocialRequest[] findByReceiverUserId_PrevAndNext(long requestId,
2385                    long receiverUserId, OrderByComparator orderByComparator)
2386                    throws NoSuchRequestException, SystemException {
2387                    SocialRequest socialRequest = findByPrimaryKey(requestId);
2388    
2389                    Session session = null;
2390    
2391                    try {
2392                            session = openSession();
2393    
2394                            SocialRequest[] array = new SocialRequestImpl[3];
2395    
2396                            array[0] = getByReceiverUserId_PrevAndNext(session, socialRequest,
2397                                            receiverUserId, orderByComparator, true);
2398    
2399                            array[1] = socialRequest;
2400    
2401                            array[2] = getByReceiverUserId_PrevAndNext(session, socialRequest,
2402                                            receiverUserId, orderByComparator, false);
2403    
2404                            return array;
2405                    }
2406                    catch (Exception e) {
2407                            throw processException(e);
2408                    }
2409                    finally {
2410                            closeSession(session);
2411                    }
2412            }
2413    
2414            protected SocialRequest getByReceiverUserId_PrevAndNext(Session session,
2415                    SocialRequest socialRequest, long receiverUserId,
2416                    OrderByComparator orderByComparator, boolean previous) {
2417                    StringBundler query = null;
2418    
2419                    if (orderByComparator != null) {
2420                            query = new StringBundler(6 +
2421                                            (orderByComparator.getOrderByFields().length * 6));
2422                    }
2423                    else {
2424                            query = new StringBundler(3);
2425                    }
2426    
2427                    query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2428    
2429                    query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
2430    
2431                    if (orderByComparator != null) {
2432                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2433    
2434                            if (orderByConditionFields.length > 0) {
2435                                    query.append(WHERE_AND);
2436                            }
2437    
2438                            for (int i = 0; i < orderByConditionFields.length; i++) {
2439                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2440                                    query.append(orderByConditionFields[i]);
2441    
2442                                    if ((i + 1) < orderByConditionFields.length) {
2443                                            if (orderByComparator.isAscending() ^ previous) {
2444                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2445                                            }
2446                                            else {
2447                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2448                                            }
2449                                    }
2450                                    else {
2451                                            if (orderByComparator.isAscending() ^ previous) {
2452                                                    query.append(WHERE_GREATER_THAN);
2453                                            }
2454                                            else {
2455                                                    query.append(WHERE_LESSER_THAN);
2456                                            }
2457                                    }
2458                            }
2459    
2460                            query.append(ORDER_BY_CLAUSE);
2461    
2462                            String[] orderByFields = orderByComparator.getOrderByFields();
2463    
2464                            for (int i = 0; i < orderByFields.length; i++) {
2465                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2466                                    query.append(orderByFields[i]);
2467    
2468                                    if ((i + 1) < orderByFields.length) {
2469                                            if (orderByComparator.isAscending() ^ previous) {
2470                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2471                                            }
2472                                            else {
2473                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2474                                            }
2475                                    }
2476                                    else {
2477                                            if (orderByComparator.isAscending() ^ previous) {
2478                                                    query.append(ORDER_BY_ASC);
2479                                            }
2480                                            else {
2481                                                    query.append(ORDER_BY_DESC);
2482                                            }
2483                                    }
2484                            }
2485                    }
2486    
2487                    else {
2488                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2489                    }
2490    
2491                    String sql = query.toString();
2492    
2493                    Query q = session.createQuery(sql);
2494    
2495                    q.setFirstResult(0);
2496                    q.setMaxResults(2);
2497    
2498                    QueryPos qPos = QueryPos.getInstance(q);
2499    
2500                    qPos.add(receiverUserId);
2501    
2502                    if (orderByComparator != null) {
2503                            Object[] values = orderByComparator.getOrderByConditionValues(socialRequest);
2504    
2505                            for (Object value : values) {
2506                                    qPos.add(value);
2507                            }
2508                    }
2509    
2510                    List<SocialRequest> list = q.list();
2511    
2512                    if (list.size() == 2) {
2513                            return list.get(1);
2514                    }
2515                    else {
2516                            return null;
2517                    }
2518            }
2519    
2520            /**
2521             * Returns all the social requests where userId = &#63; and status = &#63;.
2522             *
2523             * @param userId the user ID
2524             * @param status the status
2525             * @return the matching social requests
2526             * @throws SystemException if a system exception occurred
2527             */
2528            public List<SocialRequest> findByU_S(long userId, int status)
2529                    throws SystemException {
2530                    return findByU_S(userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2531                            null);
2532            }
2533    
2534            /**
2535             * Returns a range of all the social requests where userId = &#63; and status = &#63;.
2536             *
2537             * <p>
2538             * 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.
2539             * </p>
2540             *
2541             * @param userId the user ID
2542             * @param status the status
2543             * @param start the lower bound of the range of social requests
2544             * @param end the upper bound of the range of social requests (not inclusive)
2545             * @return the range of matching social requests
2546             * @throws SystemException if a system exception occurred
2547             */
2548            public List<SocialRequest> findByU_S(long userId, int status, int start,
2549                    int end) throws SystemException {
2550                    return findByU_S(userId, status, start, end, null);
2551            }
2552    
2553            /**
2554             * Returns an ordered range of all the social requests where userId = &#63; and status = &#63;.
2555             *
2556             * <p>
2557             * 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.
2558             * </p>
2559             *
2560             * @param userId the user ID
2561             * @param status the status
2562             * @param start the lower bound of the range of social requests
2563             * @param end the upper bound of the range of social requests (not inclusive)
2564             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2565             * @return the ordered range of matching social requests
2566             * @throws SystemException if a system exception occurred
2567             */
2568            public List<SocialRequest> findByU_S(long userId, int status, int start,
2569                    int end, OrderByComparator orderByComparator) throws SystemException {
2570                    FinderPath finderPath = null;
2571                    Object[] finderArgs = null;
2572    
2573                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2574                                    (orderByComparator == null)) {
2575                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_S;
2576                            finderArgs = new Object[] { userId, status };
2577                    }
2578                    else {
2579                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_S;
2580                            finderArgs = new Object[] {
2581                                            userId, status,
2582                                            
2583                                            start, end, orderByComparator
2584                                    };
2585                    }
2586    
2587                    List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(finderPath,
2588                                    finderArgs, this);
2589    
2590                    if (list == null) {
2591                            StringBundler query = null;
2592    
2593                            if (orderByComparator != null) {
2594                                    query = new StringBundler(4 +
2595                                                    (orderByComparator.getOrderByFields().length * 3));
2596                            }
2597                            else {
2598                                    query = new StringBundler(4);
2599                            }
2600    
2601                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2602    
2603                            query.append(_FINDER_COLUMN_U_S_USERID_2);
2604    
2605                            query.append(_FINDER_COLUMN_U_S_STATUS_2);
2606    
2607                            if (orderByComparator != null) {
2608                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2609                                            orderByComparator);
2610                            }
2611    
2612                            else {
2613                                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2614                            }
2615    
2616                            String sql = query.toString();
2617    
2618                            Session session = null;
2619    
2620                            try {
2621                                    session = openSession();
2622    
2623                                    Query q = session.createQuery(sql);
2624    
2625                                    QueryPos qPos = QueryPos.getInstance(q);
2626    
2627                                    qPos.add(userId);
2628    
2629                                    qPos.add(status);
2630    
2631                                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
2632                                                    start, end);
2633                            }
2634                            catch (Exception e) {
2635                                    throw processException(e);
2636                            }
2637                            finally {
2638                                    if (list == null) {
2639                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2640                                    }
2641                                    else {
2642                                            cacheResult(list);
2643    
2644                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2645                                    }
2646    
2647                                    closeSession(session);
2648                            }
2649                    }
2650    
2651                    return list;
2652            }
2653    
2654            /**
2655             * Returns the first social request in the ordered set where userId = &#63; and status = &#63;.
2656             *
2657             * <p>
2658             * 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.
2659             * </p>
2660             *
2661             * @param userId the user ID
2662             * @param status the status
2663             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2664             * @return the first matching social request
2665             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
2666             * @throws SystemException if a system exception occurred
2667             */
2668            public SocialRequest findByU_S_First(long userId, int status,
2669                    OrderByComparator orderByComparator)
2670                    throws NoSuchRequestException, SystemException {
2671                    List<SocialRequest> list = findByU_S(userId, status, 0, 1,
2672                                    orderByComparator);
2673    
2674                    if (list.isEmpty()) {
2675                            StringBundler msg = new StringBundler(6);
2676    
2677                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2678    
2679                            msg.append("userId=");
2680                            msg.append(userId);
2681    
2682                            msg.append(", status=");
2683                            msg.append(status);
2684    
2685                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2686    
2687                            throw new NoSuchRequestException(msg.toString());
2688                    }
2689                    else {
2690                            return list.get(0);
2691                    }
2692            }
2693    
2694            /**
2695             * Returns the last social request in the ordered set where userId = &#63; and status = &#63;.
2696             *
2697             * <p>
2698             * 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.
2699             * </p>
2700             *
2701             * @param userId the user ID
2702             * @param status the status
2703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2704             * @return the last matching social request
2705             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
2706             * @throws SystemException if a system exception occurred
2707             */
2708            public SocialRequest findByU_S_Last(long userId, int status,
2709                    OrderByComparator orderByComparator)
2710                    throws NoSuchRequestException, SystemException {
2711                    int count = countByU_S(userId, status);
2712    
2713                    List<SocialRequest> list = findByU_S(userId, status, count - 1, count,
2714                                    orderByComparator);
2715    
2716                    if (list.isEmpty()) {
2717                            StringBundler msg = new StringBundler(6);
2718    
2719                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2720    
2721                            msg.append("userId=");
2722                            msg.append(userId);
2723    
2724                            msg.append(", status=");
2725                            msg.append(status);
2726    
2727                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2728    
2729                            throw new NoSuchRequestException(msg.toString());
2730                    }
2731                    else {
2732                            return list.get(0);
2733                    }
2734            }
2735    
2736            /**
2737             * Returns the social requests before and after the current social request in the ordered set where userId = &#63; and status = &#63;.
2738             *
2739             * <p>
2740             * 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.
2741             * </p>
2742             *
2743             * @param requestId the primary key of the current social request
2744             * @param userId the user ID
2745             * @param status the status
2746             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2747             * @return the previous, current, and next social request
2748             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
2749             * @throws SystemException if a system exception occurred
2750             */
2751            public SocialRequest[] findByU_S_PrevAndNext(long requestId, long userId,
2752                    int status, OrderByComparator orderByComparator)
2753                    throws NoSuchRequestException, SystemException {
2754                    SocialRequest socialRequest = findByPrimaryKey(requestId);
2755    
2756                    Session session = null;
2757    
2758                    try {
2759                            session = openSession();
2760    
2761                            SocialRequest[] array = new SocialRequestImpl[3];
2762    
2763                            array[0] = getByU_S_PrevAndNext(session, socialRequest, userId,
2764                                            status, orderByComparator, true);
2765    
2766                            array[1] = socialRequest;
2767    
2768                            array[2] = getByU_S_PrevAndNext(session, socialRequest, userId,
2769                                            status, orderByComparator, false);
2770    
2771                            return array;
2772                    }
2773                    catch (Exception e) {
2774                            throw processException(e);
2775                    }
2776                    finally {
2777                            closeSession(session);
2778                    }
2779            }
2780    
2781            protected SocialRequest getByU_S_PrevAndNext(Session session,
2782                    SocialRequest socialRequest, long userId, int status,
2783                    OrderByComparator orderByComparator, boolean previous) {
2784                    StringBundler query = null;
2785    
2786                    if (orderByComparator != null) {
2787                            query = new StringBundler(6 +
2788                                            (orderByComparator.getOrderByFields().length * 6));
2789                    }
2790                    else {
2791                            query = new StringBundler(3);
2792                    }
2793    
2794                    query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2795    
2796                    query.append(_FINDER_COLUMN_U_S_USERID_2);
2797    
2798                    query.append(_FINDER_COLUMN_U_S_STATUS_2);
2799    
2800                    if (orderByComparator != null) {
2801                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2802    
2803                            if (orderByConditionFields.length > 0) {
2804                                    query.append(WHERE_AND);
2805                            }
2806    
2807                            for (int i = 0; i < orderByConditionFields.length; i++) {
2808                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2809                                    query.append(orderByConditionFields[i]);
2810    
2811                                    if ((i + 1) < orderByConditionFields.length) {
2812                                            if (orderByComparator.isAscending() ^ previous) {
2813                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2814                                            }
2815                                            else {
2816                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2817                                            }
2818                                    }
2819                                    else {
2820                                            if (orderByComparator.isAscending() ^ previous) {
2821                                                    query.append(WHERE_GREATER_THAN);
2822                                            }
2823                                            else {
2824                                                    query.append(WHERE_LESSER_THAN);
2825                                            }
2826                                    }
2827                            }
2828    
2829                            query.append(ORDER_BY_CLAUSE);
2830    
2831                            String[] orderByFields = orderByComparator.getOrderByFields();
2832    
2833                            for (int i = 0; i < orderByFields.length; i++) {
2834                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2835                                    query.append(orderByFields[i]);
2836    
2837                                    if ((i + 1) < orderByFields.length) {
2838                                            if (orderByComparator.isAscending() ^ previous) {
2839                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2840                                            }
2841                                            else {
2842                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2843                                            }
2844                                    }
2845                                    else {
2846                                            if (orderByComparator.isAscending() ^ previous) {
2847                                                    query.append(ORDER_BY_ASC);
2848                                            }
2849                                            else {
2850                                                    query.append(ORDER_BY_DESC);
2851                                            }
2852                                    }
2853                            }
2854                    }
2855    
2856                    else {
2857                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2858                    }
2859    
2860                    String sql = query.toString();
2861    
2862                    Query q = session.createQuery(sql);
2863    
2864                    q.setFirstResult(0);
2865                    q.setMaxResults(2);
2866    
2867                    QueryPos qPos = QueryPos.getInstance(q);
2868    
2869                    qPos.add(userId);
2870    
2871                    qPos.add(status);
2872    
2873                    if (orderByComparator != null) {
2874                            Object[] values = orderByComparator.getOrderByConditionValues(socialRequest);
2875    
2876                            for (Object value : values) {
2877                                    qPos.add(value);
2878                            }
2879                    }
2880    
2881                    List<SocialRequest> list = q.list();
2882    
2883                    if (list.size() == 2) {
2884                            return list.get(1);
2885                    }
2886                    else {
2887                            return null;
2888                    }
2889            }
2890    
2891            /**
2892             * Returns all the social requests where receiverUserId = &#63; and status = &#63;.
2893             *
2894             * @param receiverUserId the receiver user ID
2895             * @param status the status
2896             * @return the matching social requests
2897             * @throws SystemException if a system exception occurred
2898             */
2899            public List<SocialRequest> findByR_S(long receiverUserId, int status)
2900                    throws SystemException {
2901                    return findByR_S(receiverUserId, status, QueryUtil.ALL_POS,
2902                            QueryUtil.ALL_POS, null);
2903            }
2904    
2905            /**
2906             * Returns a range of all the social requests where receiverUserId = &#63; and status = &#63;.
2907             *
2908             * <p>
2909             * 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.
2910             * </p>
2911             *
2912             * @param receiverUserId the receiver user ID
2913             * @param status the status
2914             * @param start the lower bound of the range of social requests
2915             * @param end the upper bound of the range of social requests (not inclusive)
2916             * @return the range of matching social requests
2917             * @throws SystemException if a system exception occurred
2918             */
2919            public List<SocialRequest> findByR_S(long receiverUserId, int status,
2920                    int start, int end) throws SystemException {
2921                    return findByR_S(receiverUserId, status, start, end, null);
2922            }
2923    
2924            /**
2925             * Returns an ordered range of all the social requests where receiverUserId = &#63; and status = &#63;.
2926             *
2927             * <p>
2928             * 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.
2929             * </p>
2930             *
2931             * @param receiverUserId the receiver user ID
2932             * @param status the status
2933             * @param start the lower bound of the range of social requests
2934             * @param end the upper bound of the range of social requests (not inclusive)
2935             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2936             * @return the ordered range of matching social requests
2937             * @throws SystemException if a system exception occurred
2938             */
2939            public List<SocialRequest> findByR_S(long receiverUserId, int status,
2940                    int start, int end, OrderByComparator orderByComparator)
2941                    throws SystemException {
2942                    FinderPath finderPath = null;
2943                    Object[] finderArgs = null;
2944    
2945                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2946                                    (orderByComparator == null)) {
2947                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S;
2948                            finderArgs = new Object[] { receiverUserId, status };
2949                    }
2950                    else {
2951                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S;
2952                            finderArgs = new Object[] {
2953                                            receiverUserId, status,
2954                                            
2955                                            start, end, orderByComparator
2956                                    };
2957                    }
2958    
2959                    List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(finderPath,
2960                                    finderArgs, this);
2961    
2962                    if (list == null) {
2963                            StringBundler query = null;
2964    
2965                            if (orderByComparator != null) {
2966                                    query = new StringBundler(4 +
2967                                                    (orderByComparator.getOrderByFields().length * 3));
2968                            }
2969                            else {
2970                                    query = new StringBundler(4);
2971                            }
2972    
2973                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2974    
2975                            query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
2976    
2977                            query.append(_FINDER_COLUMN_R_S_STATUS_2);
2978    
2979                            if (orderByComparator != null) {
2980                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2981                                            orderByComparator);
2982                            }
2983    
2984                            else {
2985                                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2986                            }
2987    
2988                            String sql = query.toString();
2989    
2990                            Session session = null;
2991    
2992                            try {
2993                                    session = openSession();
2994    
2995                                    Query q = session.createQuery(sql);
2996    
2997                                    QueryPos qPos = QueryPos.getInstance(q);
2998    
2999                                    qPos.add(receiverUserId);
3000    
3001                                    qPos.add(status);
3002    
3003                                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3004                                                    start, end);
3005                            }
3006                            catch (Exception e) {
3007                                    throw processException(e);
3008                            }
3009                            finally {
3010                                    if (list == null) {
3011                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3012                                    }
3013                                    else {
3014                                            cacheResult(list);
3015    
3016                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3017                                    }
3018    
3019                                    closeSession(session);
3020                            }
3021                    }
3022    
3023                    return list;
3024            }
3025    
3026            /**
3027             * Returns the first social request in the ordered set where receiverUserId = &#63; and status = &#63;.
3028             *
3029             * <p>
3030             * 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.
3031             * </p>
3032             *
3033             * @param receiverUserId the receiver user ID
3034             * @param status the status
3035             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3036             * @return the first matching social request
3037             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
3038             * @throws SystemException if a system exception occurred
3039             */
3040            public SocialRequest findByR_S_First(long receiverUserId, int status,
3041                    OrderByComparator orderByComparator)
3042                    throws NoSuchRequestException, SystemException {
3043                    List<SocialRequest> list = findByR_S(receiverUserId, status, 0, 1,
3044                                    orderByComparator);
3045    
3046                    if (list.isEmpty()) {
3047                            StringBundler msg = new StringBundler(6);
3048    
3049                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3050    
3051                            msg.append("receiverUserId=");
3052                            msg.append(receiverUserId);
3053    
3054                            msg.append(", status=");
3055                            msg.append(status);
3056    
3057                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3058    
3059                            throw new NoSuchRequestException(msg.toString());
3060                    }
3061                    else {
3062                            return list.get(0);
3063                    }
3064            }
3065    
3066            /**
3067             * Returns the last social request in the ordered set where receiverUserId = &#63; and status = &#63;.
3068             *
3069             * <p>
3070             * 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.
3071             * </p>
3072             *
3073             * @param receiverUserId the receiver user ID
3074             * @param status the status
3075             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3076             * @return the last matching social request
3077             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
3078             * @throws SystemException if a system exception occurred
3079             */
3080            public SocialRequest findByR_S_Last(long receiverUserId, int status,
3081                    OrderByComparator orderByComparator)
3082                    throws NoSuchRequestException, SystemException {
3083                    int count = countByR_S(receiverUserId, status);
3084    
3085                    List<SocialRequest> list = findByR_S(receiverUserId, status, count - 1,
3086                                    count, orderByComparator);
3087    
3088                    if (list.isEmpty()) {
3089                            StringBundler msg = new StringBundler(6);
3090    
3091                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3092    
3093                            msg.append("receiverUserId=");
3094                            msg.append(receiverUserId);
3095    
3096                            msg.append(", status=");
3097                            msg.append(status);
3098    
3099                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3100    
3101                            throw new NoSuchRequestException(msg.toString());
3102                    }
3103                    else {
3104                            return list.get(0);
3105                    }
3106            }
3107    
3108            /**
3109             * Returns the social requests before and after the current social request in the ordered set where receiverUserId = &#63; and status = &#63;.
3110             *
3111             * <p>
3112             * 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.
3113             * </p>
3114             *
3115             * @param requestId the primary key of the current social request
3116             * @param receiverUserId the receiver user ID
3117             * @param status the status
3118             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3119             * @return the previous, current, and next social request
3120             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
3121             * @throws SystemException if a system exception occurred
3122             */
3123            public SocialRequest[] findByR_S_PrevAndNext(long requestId,
3124                    long receiverUserId, int status, OrderByComparator orderByComparator)
3125                    throws NoSuchRequestException, SystemException {
3126                    SocialRequest socialRequest = findByPrimaryKey(requestId);
3127    
3128                    Session session = null;
3129    
3130                    try {
3131                            session = openSession();
3132    
3133                            SocialRequest[] array = new SocialRequestImpl[3];
3134    
3135                            array[0] = getByR_S_PrevAndNext(session, socialRequest,
3136                                            receiverUserId, status, orderByComparator, true);
3137    
3138                            array[1] = socialRequest;
3139    
3140                            array[2] = getByR_S_PrevAndNext(session, socialRequest,
3141                                            receiverUserId, status, orderByComparator, false);
3142    
3143                            return array;
3144                    }
3145                    catch (Exception e) {
3146                            throw processException(e);
3147                    }
3148                    finally {
3149                            closeSession(session);
3150                    }
3151            }
3152    
3153            protected SocialRequest getByR_S_PrevAndNext(Session session,
3154                    SocialRequest socialRequest, long receiverUserId, int status,
3155                    OrderByComparator orderByComparator, boolean previous) {
3156                    StringBundler query = null;
3157    
3158                    if (orderByComparator != null) {
3159                            query = new StringBundler(6 +
3160                                            (orderByComparator.getOrderByFields().length * 6));
3161                    }
3162                    else {
3163                            query = new StringBundler(3);
3164                    }
3165    
3166                    query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3167    
3168                    query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
3169    
3170                    query.append(_FINDER_COLUMN_R_S_STATUS_2);
3171    
3172                    if (orderByComparator != null) {
3173                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3174    
3175                            if (orderByConditionFields.length > 0) {
3176                                    query.append(WHERE_AND);
3177                            }
3178    
3179                            for (int i = 0; i < orderByConditionFields.length; i++) {
3180                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3181                                    query.append(orderByConditionFields[i]);
3182    
3183                                    if ((i + 1) < orderByConditionFields.length) {
3184                                            if (orderByComparator.isAscending() ^ previous) {
3185                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3186                                            }
3187                                            else {
3188                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3189                                            }
3190                                    }
3191                                    else {
3192                                            if (orderByComparator.isAscending() ^ previous) {
3193                                                    query.append(WHERE_GREATER_THAN);
3194                                            }
3195                                            else {
3196                                                    query.append(WHERE_LESSER_THAN);
3197                                            }
3198                                    }
3199                            }
3200    
3201                            query.append(ORDER_BY_CLAUSE);
3202    
3203                            String[] orderByFields = orderByComparator.getOrderByFields();
3204    
3205                            for (int i = 0; i < orderByFields.length; i++) {
3206                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3207                                    query.append(orderByFields[i]);
3208    
3209                                    if ((i + 1) < orderByFields.length) {
3210                                            if (orderByComparator.isAscending() ^ previous) {
3211                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3212                                            }
3213                                            else {
3214                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3215                                            }
3216                                    }
3217                                    else {
3218                                            if (orderByComparator.isAscending() ^ previous) {
3219                                                    query.append(ORDER_BY_ASC);
3220                                            }
3221                                            else {
3222                                                    query.append(ORDER_BY_DESC);
3223                                            }
3224                                    }
3225                            }
3226                    }
3227    
3228                    else {
3229                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3230                    }
3231    
3232                    String sql = query.toString();
3233    
3234                    Query q = session.createQuery(sql);
3235    
3236                    q.setFirstResult(0);
3237                    q.setMaxResults(2);
3238    
3239                    QueryPos qPos = QueryPos.getInstance(q);
3240    
3241                    qPos.add(receiverUserId);
3242    
3243                    qPos.add(status);
3244    
3245                    if (orderByComparator != null) {
3246                            Object[] values = orderByComparator.getOrderByConditionValues(socialRequest);
3247    
3248                            for (Object value : values) {
3249                                    qPos.add(value);
3250                            }
3251                    }
3252    
3253                    List<SocialRequest> list = q.list();
3254    
3255                    if (list.size() == 2) {
3256                            return list.get(1);
3257                    }
3258                    else {
3259                            return null;
3260                    }
3261            }
3262    
3263            /**
3264             * Returns the social request where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; or throws a {@link com.liferay.portlet.social.NoSuchRequestException} if it could not be found.
3265             *
3266             * @param userId the user ID
3267             * @param classNameId the class name ID
3268             * @param classPK the class p k
3269             * @param type the type
3270             * @param receiverUserId the receiver user ID
3271             * @return the matching social request
3272             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
3273             * @throws SystemException if a system exception occurred
3274             */
3275            public SocialRequest findByU_C_C_T_R(long userId, long classNameId,
3276                    long classPK, int type, long receiverUserId)
3277                    throws NoSuchRequestException, SystemException {
3278                    SocialRequest socialRequest = fetchByU_C_C_T_R(userId, classNameId,
3279                                    classPK, type, receiverUserId);
3280    
3281                    if (socialRequest == null) {
3282                            StringBundler msg = new StringBundler(12);
3283    
3284                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3285    
3286                            msg.append("userId=");
3287                            msg.append(userId);
3288    
3289                            msg.append(", classNameId=");
3290                            msg.append(classNameId);
3291    
3292                            msg.append(", classPK=");
3293                            msg.append(classPK);
3294    
3295                            msg.append(", type=");
3296                            msg.append(type);
3297    
3298                            msg.append(", receiverUserId=");
3299                            msg.append(receiverUserId);
3300    
3301                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3302    
3303                            if (_log.isWarnEnabled()) {
3304                                    _log.warn(msg.toString());
3305                            }
3306    
3307                            throw new NoSuchRequestException(msg.toString());
3308                    }
3309    
3310                    return socialRequest;
3311            }
3312    
3313            /**
3314             * Returns the social request where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3315             *
3316             * @param userId the user ID
3317             * @param classNameId the class name ID
3318             * @param classPK the class p k
3319             * @param type the type
3320             * @param receiverUserId the receiver user ID
3321             * @return the matching social request, or <code>null</code> if a matching social request could not be found
3322             * @throws SystemException if a system exception occurred
3323             */
3324            public SocialRequest fetchByU_C_C_T_R(long userId, long classNameId,
3325                    long classPK, int type, long receiverUserId) throws SystemException {
3326                    return fetchByU_C_C_T_R(userId, classNameId, classPK, type,
3327                            receiverUserId, true);
3328            }
3329    
3330            /**
3331             * Returns the social request where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
3332             *
3333             * @param userId the user ID
3334             * @param classNameId the class name ID
3335             * @param classPK the class p k
3336             * @param type the type
3337             * @param receiverUserId the receiver user ID
3338             * @param retrieveFromCache whether to use the finder cache
3339             * @return the matching social request, or <code>null</code> if a matching social request could not be found
3340             * @throws SystemException if a system exception occurred
3341             */
3342            public SocialRequest fetchByU_C_C_T_R(long userId, long classNameId,
3343                    long classPK, int type, long receiverUserId, boolean retrieveFromCache)
3344                    throws SystemException {
3345                    Object[] finderArgs = new Object[] {
3346                                    userId, classNameId, classPK, type, receiverUserId
3347                            };
3348    
3349                    Object result = null;
3350    
3351                    if (retrieveFromCache) {
3352                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3353                                            finderArgs, this);
3354                    }
3355    
3356                    if (result == null) {
3357                            StringBundler query = new StringBundler(7);
3358    
3359                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3360    
3361                            query.append(_FINDER_COLUMN_U_C_C_T_R_USERID_2);
3362    
3363                            query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2);
3364    
3365                            query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSPK_2);
3366    
3367                            query.append(_FINDER_COLUMN_U_C_C_T_R_TYPE_2);
3368    
3369                            query.append(_FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2);
3370    
3371                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3372    
3373                            String sql = query.toString();
3374    
3375                            Session session = null;
3376    
3377                            try {
3378                                    session = openSession();
3379    
3380                                    Query q = session.createQuery(sql);
3381    
3382                                    QueryPos qPos = QueryPos.getInstance(q);
3383    
3384                                    qPos.add(userId);
3385    
3386                                    qPos.add(classNameId);
3387    
3388                                    qPos.add(classPK);
3389    
3390                                    qPos.add(type);
3391    
3392                                    qPos.add(receiverUserId);
3393    
3394                                    List<SocialRequest> list = q.list();
3395    
3396                                    result = list;
3397    
3398                                    SocialRequest socialRequest = null;
3399    
3400                                    if (list.isEmpty()) {
3401                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3402                                                    finderArgs, list);
3403                                    }
3404                                    else {
3405                                            socialRequest = list.get(0);
3406    
3407                                            cacheResult(socialRequest);
3408    
3409                                            if ((socialRequest.getUserId() != userId) ||
3410                                                            (socialRequest.getClassNameId() != classNameId) ||
3411                                                            (socialRequest.getClassPK() != classPK) ||
3412                                                            (socialRequest.getType() != type) ||
3413                                                            (socialRequest.getReceiverUserId() != receiverUserId)) {
3414                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3415                                                            finderArgs, socialRequest);
3416                                            }
3417                                    }
3418    
3419                                    return socialRequest;
3420                            }
3421                            catch (Exception e) {
3422                                    throw processException(e);
3423                            }
3424                            finally {
3425                                    if (result == null) {
3426                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3427                                                    finderArgs);
3428                                    }
3429    
3430                                    closeSession(session);
3431                            }
3432                    }
3433                    else {
3434                            if (result instanceof List<?>) {
3435                                    return null;
3436                            }
3437                            else {
3438                                    return (SocialRequest)result;
3439                            }
3440                    }
3441            }
3442    
3443            /**
3444             * Returns all the social requests where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and status = &#63;.
3445             *
3446             * @param userId the user ID
3447             * @param classNameId the class name ID
3448             * @param classPK the class p k
3449             * @param type the type
3450             * @param status the status
3451             * @return the matching social requests
3452             * @throws SystemException if a system exception occurred
3453             */
3454            public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
3455                    long classPK, int type, int status) throws SystemException {
3456                    return findByU_C_C_T_S(userId, classNameId, classPK, type, status,
3457                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3458            }
3459    
3460            /**
3461             * Returns a range of all the social requests where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and status = &#63;.
3462             *
3463             * <p>
3464             * 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.
3465             * </p>
3466             *
3467             * @param userId the user ID
3468             * @param classNameId the class name ID
3469             * @param classPK the class p k
3470             * @param type the type
3471             * @param status the status
3472             * @param start the lower bound of the range of social requests
3473             * @param end the upper bound of the range of social requests (not inclusive)
3474             * @return the range of matching social requests
3475             * @throws SystemException if a system exception occurred
3476             */
3477            public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
3478                    long classPK, int type, int status, int start, int end)
3479                    throws SystemException {
3480                    return findByU_C_C_T_S(userId, classNameId, classPK, type, status,
3481                            start, end, null);
3482            }
3483    
3484            /**
3485             * Returns an ordered range of all the social requests where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and status = &#63;.
3486             *
3487             * <p>
3488             * 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.
3489             * </p>
3490             *
3491             * @param userId the user ID
3492             * @param classNameId the class name ID
3493             * @param classPK the class p k
3494             * @param type the type
3495             * @param status the status
3496             * @param start the lower bound of the range of social requests
3497             * @param end the upper bound of the range of social requests (not inclusive)
3498             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3499             * @return the ordered range of matching social requests
3500             * @throws SystemException if a system exception occurred
3501             */
3502            public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
3503                    long classPK, int type, int status, int start, int end,
3504                    OrderByComparator orderByComparator) throws SystemException {
3505                    FinderPath finderPath = null;
3506                    Object[] finderArgs = null;
3507    
3508                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3509                                    (orderByComparator == null)) {
3510                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T_S;
3511                            finderArgs = new Object[] { userId, classNameId, classPK, type, status };
3512                    }
3513                    else {
3514                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C_T_S;
3515                            finderArgs = new Object[] {
3516                                            userId, classNameId, classPK, type, status,
3517                                            
3518                                            start, end, orderByComparator
3519                                    };
3520                    }
3521    
3522                    List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(finderPath,
3523                                    finderArgs, this);
3524    
3525                    if (list == null) {
3526                            StringBundler query = null;
3527    
3528                            if (orderByComparator != null) {
3529                                    query = new StringBundler(7 +
3530                                                    (orderByComparator.getOrderByFields().length * 3));
3531                            }
3532                            else {
3533                                    query = new StringBundler(7);
3534                            }
3535    
3536                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3537    
3538                            query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
3539    
3540                            query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
3541    
3542                            query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
3543    
3544                            query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
3545    
3546                            query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
3547    
3548                            if (orderByComparator != null) {
3549                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3550                                            orderByComparator);
3551                            }
3552    
3553                            else {
3554                                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3555                            }
3556    
3557                            String sql = query.toString();
3558    
3559                            Session session = null;
3560    
3561                            try {
3562                                    session = openSession();
3563    
3564                                    Query q = session.createQuery(sql);
3565    
3566                                    QueryPos qPos = QueryPos.getInstance(q);
3567    
3568                                    qPos.add(userId);
3569    
3570                                    qPos.add(classNameId);
3571    
3572                                    qPos.add(classPK);
3573    
3574                                    qPos.add(type);
3575    
3576                                    qPos.add(status);
3577    
3578                                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3579                                                    start, end);
3580                            }
3581                            catch (Exception e) {
3582                                    throw processException(e);
3583                            }
3584                            finally {
3585                                    if (list == null) {
3586                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3587                                    }
3588                                    else {
3589                                            cacheResult(list);
3590    
3591                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3592                                    }
3593    
3594                                    closeSession(session);
3595                            }
3596                    }
3597    
3598                    return list;
3599            }
3600    
3601            /**
3602             * Returns the first social request in the ordered set where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and status = &#63;.
3603             *
3604             * <p>
3605             * 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.
3606             * </p>
3607             *
3608             * @param userId the user ID
3609             * @param classNameId the class name ID
3610             * @param classPK the class p k
3611             * @param type the type
3612             * @param status the status
3613             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3614             * @return the first matching social request
3615             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
3616             * @throws SystemException if a system exception occurred
3617             */
3618            public SocialRequest findByU_C_C_T_S_First(long userId, long classNameId,
3619                    long classPK, int type, int status, OrderByComparator orderByComparator)
3620                    throws NoSuchRequestException, SystemException {
3621                    List<SocialRequest> list = findByU_C_C_T_S(userId, classNameId,
3622                                    classPK, type, status, 0, 1, orderByComparator);
3623    
3624                    if (list.isEmpty()) {
3625                            StringBundler msg = new StringBundler(12);
3626    
3627                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3628    
3629                            msg.append("userId=");
3630                            msg.append(userId);
3631    
3632                            msg.append(", classNameId=");
3633                            msg.append(classNameId);
3634    
3635                            msg.append(", classPK=");
3636                            msg.append(classPK);
3637    
3638                            msg.append(", type=");
3639                            msg.append(type);
3640    
3641                            msg.append(", status=");
3642                            msg.append(status);
3643    
3644                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3645    
3646                            throw new NoSuchRequestException(msg.toString());
3647                    }
3648                    else {
3649                            return list.get(0);
3650                    }
3651            }
3652    
3653            /**
3654             * Returns the last social request in the ordered set where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and status = &#63;.
3655             *
3656             * <p>
3657             * 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.
3658             * </p>
3659             *
3660             * @param userId the user ID
3661             * @param classNameId the class name ID
3662             * @param classPK the class p k
3663             * @param type the type
3664             * @param status the status
3665             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3666             * @return the last matching social request
3667             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
3668             * @throws SystemException if a system exception occurred
3669             */
3670            public SocialRequest findByU_C_C_T_S_Last(long userId, long classNameId,
3671                    long classPK, int type, int status, OrderByComparator orderByComparator)
3672                    throws NoSuchRequestException, SystemException {
3673                    int count = countByU_C_C_T_S(userId, classNameId, classPK, type, status);
3674    
3675                    List<SocialRequest> list = findByU_C_C_T_S(userId, classNameId,
3676                                    classPK, type, status, count - 1, count, orderByComparator);
3677    
3678                    if (list.isEmpty()) {
3679                            StringBundler msg = new StringBundler(12);
3680    
3681                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3682    
3683                            msg.append("userId=");
3684                            msg.append(userId);
3685    
3686                            msg.append(", classNameId=");
3687                            msg.append(classNameId);
3688    
3689                            msg.append(", classPK=");
3690                            msg.append(classPK);
3691    
3692                            msg.append(", type=");
3693                            msg.append(type);
3694    
3695                            msg.append(", status=");
3696                            msg.append(status);
3697    
3698                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3699    
3700                            throw new NoSuchRequestException(msg.toString());
3701                    }
3702                    else {
3703                            return list.get(0);
3704                    }
3705            }
3706    
3707            /**
3708             * Returns the social requests before and after the current social request in the ordered set where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and status = &#63;.
3709             *
3710             * <p>
3711             * 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.
3712             * </p>
3713             *
3714             * @param requestId the primary key of the current social request
3715             * @param userId the user ID
3716             * @param classNameId the class name ID
3717             * @param classPK the class p k
3718             * @param type the type
3719             * @param status the status
3720             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3721             * @return the previous, current, and next social request
3722             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
3723             * @throws SystemException if a system exception occurred
3724             */
3725            public SocialRequest[] findByU_C_C_T_S_PrevAndNext(long requestId,
3726                    long userId, long classNameId, long classPK, int type, int status,
3727                    OrderByComparator orderByComparator)
3728                    throws NoSuchRequestException, SystemException {
3729                    SocialRequest socialRequest = findByPrimaryKey(requestId);
3730    
3731                    Session session = null;
3732    
3733                    try {
3734                            session = openSession();
3735    
3736                            SocialRequest[] array = new SocialRequestImpl[3];
3737    
3738                            array[0] = getByU_C_C_T_S_PrevAndNext(session, socialRequest,
3739                                            userId, classNameId, classPK, type, status,
3740                                            orderByComparator, true);
3741    
3742                            array[1] = socialRequest;
3743    
3744                            array[2] = getByU_C_C_T_S_PrevAndNext(session, socialRequest,
3745                                            userId, classNameId, classPK, type, status,
3746                                            orderByComparator, false);
3747    
3748                            return array;
3749                    }
3750                    catch (Exception e) {
3751                            throw processException(e);
3752                    }
3753                    finally {
3754                            closeSession(session);
3755                    }
3756            }
3757    
3758            protected SocialRequest getByU_C_C_T_S_PrevAndNext(Session session,
3759                    SocialRequest socialRequest, long userId, long classNameId,
3760                    long classPK, int type, int status,
3761                    OrderByComparator orderByComparator, boolean previous) {
3762                    StringBundler query = null;
3763    
3764                    if (orderByComparator != null) {
3765                            query = new StringBundler(6 +
3766                                            (orderByComparator.getOrderByFields().length * 6));
3767                    }
3768                    else {
3769                            query = new StringBundler(3);
3770                    }
3771    
3772                    query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3773    
3774                    query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
3775    
3776                    query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
3777    
3778                    query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
3779    
3780                    query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
3781    
3782                    query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
3783    
3784                    if (orderByComparator != null) {
3785                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3786    
3787                            if (orderByConditionFields.length > 0) {
3788                                    query.append(WHERE_AND);
3789                            }
3790    
3791                            for (int i = 0; i < orderByConditionFields.length; i++) {
3792                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3793                                    query.append(orderByConditionFields[i]);
3794    
3795                                    if ((i + 1) < orderByConditionFields.length) {
3796                                            if (orderByComparator.isAscending() ^ previous) {
3797                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3798                                            }
3799                                            else {
3800                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3801                                            }
3802                                    }
3803                                    else {
3804                                            if (orderByComparator.isAscending() ^ previous) {
3805                                                    query.append(WHERE_GREATER_THAN);
3806                                            }
3807                                            else {
3808                                                    query.append(WHERE_LESSER_THAN);
3809                                            }
3810                                    }
3811                            }
3812    
3813                            query.append(ORDER_BY_CLAUSE);
3814    
3815                            String[] orderByFields = orderByComparator.getOrderByFields();
3816    
3817                            for (int i = 0; i < orderByFields.length; i++) {
3818                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3819                                    query.append(orderByFields[i]);
3820    
3821                                    if ((i + 1) < orderByFields.length) {
3822                                            if (orderByComparator.isAscending() ^ previous) {
3823                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3824                                            }
3825                                            else {
3826                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3827                                            }
3828                                    }
3829                                    else {
3830                                            if (orderByComparator.isAscending() ^ previous) {
3831                                                    query.append(ORDER_BY_ASC);
3832                                            }
3833                                            else {
3834                                                    query.append(ORDER_BY_DESC);
3835                                            }
3836                                    }
3837                            }
3838                    }
3839    
3840                    else {
3841                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3842                    }
3843    
3844                    String sql = query.toString();
3845    
3846                    Query q = session.createQuery(sql);
3847    
3848                    q.setFirstResult(0);
3849                    q.setMaxResults(2);
3850    
3851                    QueryPos qPos = QueryPos.getInstance(q);
3852    
3853                    qPos.add(userId);
3854    
3855                    qPos.add(classNameId);
3856    
3857                    qPos.add(classPK);
3858    
3859                    qPos.add(type);
3860    
3861                    qPos.add(status);
3862    
3863                    if (orderByComparator != null) {
3864                            Object[] values = orderByComparator.getOrderByConditionValues(socialRequest);
3865    
3866                            for (Object value : values) {
3867                                    qPos.add(value);
3868                            }
3869                    }
3870    
3871                    List<SocialRequest> list = q.list();
3872    
3873                    if (list.size() == 2) {
3874                            return list.get(1);
3875                    }
3876                    else {
3877                            return null;
3878                    }
3879            }
3880    
3881            /**
3882             * Returns all the social requests where classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; and status = &#63;.
3883             *
3884             * @param classNameId the class name ID
3885             * @param classPK the class p k
3886             * @param type the type
3887             * @param receiverUserId the receiver user ID
3888             * @param status the status
3889             * @return the matching social requests
3890             * @throws SystemException if a system exception occurred
3891             */
3892            public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
3893                    int type, long receiverUserId, int status) throws SystemException {
3894                    return findByC_C_T_R_S(classNameId, classPK, type, receiverUserId,
3895                            status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3896            }
3897    
3898            /**
3899             * Returns a range of all the social requests where classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; and status = &#63;.
3900             *
3901             * <p>
3902             * 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.
3903             * </p>
3904             *
3905             * @param classNameId the class name ID
3906             * @param classPK the class p k
3907             * @param type the type
3908             * @param receiverUserId the receiver user ID
3909             * @param status the status
3910             * @param start the lower bound of the range of social requests
3911             * @param end the upper bound of the range of social requests (not inclusive)
3912             * @return the range of matching social requests
3913             * @throws SystemException if a system exception occurred
3914             */
3915            public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
3916                    int type, long receiverUserId, int status, int start, int end)
3917                    throws SystemException {
3918                    return findByC_C_T_R_S(classNameId, classPK, type, receiverUserId,
3919                            status, start, end, null);
3920            }
3921    
3922            /**
3923             * Returns an ordered range of all the social requests where classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; and status = &#63;.
3924             *
3925             * <p>
3926             * 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.
3927             * </p>
3928             *
3929             * @param classNameId the class name ID
3930             * @param classPK the class p k
3931             * @param type the type
3932             * @param receiverUserId the receiver user ID
3933             * @param status the status
3934             * @param start the lower bound of the range of social requests
3935             * @param end the upper bound of the range of social requests (not inclusive)
3936             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3937             * @return the ordered range of matching social requests
3938             * @throws SystemException if a system exception occurred
3939             */
3940            public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
3941                    int type, long receiverUserId, int status, int start, int end,
3942                    OrderByComparator orderByComparator) throws SystemException {
3943                    FinderPath finderPath = null;
3944                    Object[] finderArgs = null;
3945    
3946                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3947                                    (orderByComparator == null)) {
3948                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T_R_S;
3949                            finderArgs = new Object[] {
3950                                            classNameId, classPK, type, receiverUserId, status
3951                                    };
3952                    }
3953                    else {
3954                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_T_R_S;
3955                            finderArgs = new Object[] {
3956                                            classNameId, classPK, type, receiverUserId, status,
3957                                            
3958                                            start, end, orderByComparator
3959                                    };
3960                    }
3961    
3962                    List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(finderPath,
3963                                    finderArgs, this);
3964    
3965                    if (list == null) {
3966                            StringBundler query = null;
3967    
3968                            if (orderByComparator != null) {
3969                                    query = new StringBundler(7 +
3970                                                    (orderByComparator.getOrderByFields().length * 3));
3971                            }
3972                            else {
3973                                    query = new StringBundler(7);
3974                            }
3975    
3976                            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3977    
3978                            query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
3979    
3980                            query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
3981    
3982                            query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
3983    
3984                            query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
3985    
3986                            query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
3987    
3988                            if (orderByComparator != null) {
3989                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3990                                            orderByComparator);
3991                            }
3992    
3993                            else {
3994                                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3995                            }
3996    
3997                            String sql = query.toString();
3998    
3999                            Session session = null;
4000    
4001                            try {
4002                                    session = openSession();
4003    
4004                                    Query q = session.createQuery(sql);
4005    
4006                                    QueryPos qPos = QueryPos.getInstance(q);
4007    
4008                                    qPos.add(classNameId);
4009    
4010                                    qPos.add(classPK);
4011    
4012                                    qPos.add(type);
4013    
4014                                    qPos.add(receiverUserId);
4015    
4016                                    qPos.add(status);
4017    
4018                                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
4019                                                    start, end);
4020                            }
4021                            catch (Exception e) {
4022                                    throw processException(e);
4023                            }
4024                            finally {
4025                                    if (list == null) {
4026                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4027                                    }
4028                                    else {
4029                                            cacheResult(list);
4030    
4031                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4032                                    }
4033    
4034                                    closeSession(session);
4035                            }
4036                    }
4037    
4038                    return list;
4039            }
4040    
4041            /**
4042             * Returns the first social request in the ordered set where classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; and status = &#63;.
4043             *
4044             * <p>
4045             * 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.
4046             * </p>
4047             *
4048             * @param classNameId the class name ID
4049             * @param classPK the class p k
4050             * @param type the type
4051             * @param receiverUserId the receiver user ID
4052             * @param status the status
4053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4054             * @return the first matching social request
4055             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
4056             * @throws SystemException if a system exception occurred
4057             */
4058            public SocialRequest findByC_C_T_R_S_First(long classNameId, long classPK,
4059                    int type, long receiverUserId, int status,
4060                    OrderByComparator orderByComparator)
4061                    throws NoSuchRequestException, SystemException {
4062                    List<SocialRequest> list = findByC_C_T_R_S(classNameId, classPK, type,
4063                                    receiverUserId, status, 0, 1, orderByComparator);
4064    
4065                    if (list.isEmpty()) {
4066                            StringBundler msg = new StringBundler(12);
4067    
4068                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4069    
4070                            msg.append("classNameId=");
4071                            msg.append(classNameId);
4072    
4073                            msg.append(", classPK=");
4074                            msg.append(classPK);
4075    
4076                            msg.append(", type=");
4077                            msg.append(type);
4078    
4079                            msg.append(", receiverUserId=");
4080                            msg.append(receiverUserId);
4081    
4082                            msg.append(", status=");
4083                            msg.append(status);
4084    
4085                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4086    
4087                            throw new NoSuchRequestException(msg.toString());
4088                    }
4089                    else {
4090                            return list.get(0);
4091                    }
4092            }
4093    
4094            /**
4095             * Returns the last social request in the ordered set where classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; and status = &#63;.
4096             *
4097             * <p>
4098             * 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.
4099             * </p>
4100             *
4101             * @param classNameId the class name ID
4102             * @param classPK the class p k
4103             * @param type the type
4104             * @param receiverUserId the receiver user ID
4105             * @param status the status
4106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4107             * @return the last matching social request
4108             * @throws com.liferay.portlet.social.NoSuchRequestException if a matching social request could not be found
4109             * @throws SystemException if a system exception occurred
4110             */
4111            public SocialRequest findByC_C_T_R_S_Last(long classNameId, long classPK,
4112                    int type, long receiverUserId, int status,
4113                    OrderByComparator orderByComparator)
4114                    throws NoSuchRequestException, SystemException {
4115                    int count = countByC_C_T_R_S(classNameId, classPK, type,
4116                                    receiverUserId, status);
4117    
4118                    List<SocialRequest> list = findByC_C_T_R_S(classNameId, classPK, type,
4119                                    receiverUserId, status, count - 1, count, orderByComparator);
4120    
4121                    if (list.isEmpty()) {
4122                            StringBundler msg = new StringBundler(12);
4123    
4124                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4125    
4126                            msg.append("classNameId=");
4127                            msg.append(classNameId);
4128    
4129                            msg.append(", classPK=");
4130                            msg.append(classPK);
4131    
4132                            msg.append(", type=");
4133                            msg.append(type);
4134    
4135                            msg.append(", receiverUserId=");
4136                            msg.append(receiverUserId);
4137    
4138                            msg.append(", status=");
4139                            msg.append(status);
4140    
4141                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4142    
4143                            throw new NoSuchRequestException(msg.toString());
4144                    }
4145                    else {
4146                            return list.get(0);
4147                    }
4148            }
4149    
4150            /**
4151             * Returns the social requests before and after the current social request in the ordered set where classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; and status = &#63;.
4152             *
4153             * <p>
4154             * 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.
4155             * </p>
4156             *
4157             * @param requestId the primary key of the current social request
4158             * @param classNameId the class name ID
4159             * @param classPK the class p k
4160             * @param type the type
4161             * @param receiverUserId the receiver user ID
4162             * @param status the status
4163             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4164             * @return the previous, current, and next social request
4165             * @throws com.liferay.portlet.social.NoSuchRequestException if a social request with the primary key could not be found
4166             * @throws SystemException if a system exception occurred
4167             */
4168            public SocialRequest[] findByC_C_T_R_S_PrevAndNext(long requestId,
4169                    long classNameId, long classPK, int type, long receiverUserId,
4170                    int status, OrderByComparator orderByComparator)
4171                    throws NoSuchRequestException, SystemException {
4172                    SocialRequest socialRequest = findByPrimaryKey(requestId);
4173    
4174                    Session session = null;
4175    
4176                    try {
4177                            session = openSession();
4178    
4179                            SocialRequest[] array = new SocialRequestImpl[3];
4180    
4181                            array[0] = getByC_C_T_R_S_PrevAndNext(session, socialRequest,
4182                                            classNameId, classPK, type, receiverUserId, status,
4183                                            orderByComparator, true);
4184    
4185                            array[1] = socialRequest;
4186    
4187                            array[2] = getByC_C_T_R_S_PrevAndNext(session, socialRequest,
4188                                            classNameId, classPK, type, receiverUserId, status,
4189                                            orderByComparator, false);
4190    
4191                            return array;
4192                    }
4193                    catch (Exception e) {
4194                            throw processException(e);
4195                    }
4196                    finally {
4197                            closeSession(session);
4198                    }
4199            }
4200    
4201            protected SocialRequest getByC_C_T_R_S_PrevAndNext(Session session,
4202                    SocialRequest socialRequest, long classNameId, long classPK, int type,
4203                    long receiverUserId, int status, OrderByComparator orderByComparator,
4204                    boolean previous) {
4205                    StringBundler query = null;
4206    
4207                    if (orderByComparator != null) {
4208                            query = new StringBundler(6 +
4209                                            (orderByComparator.getOrderByFields().length * 6));
4210                    }
4211                    else {
4212                            query = new StringBundler(3);
4213                    }
4214    
4215                    query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
4216    
4217                    query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
4218    
4219                    query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
4220    
4221                    query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
4222    
4223                    query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
4224    
4225                    query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
4226    
4227                    if (orderByComparator != null) {
4228                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4229    
4230                            if (orderByConditionFields.length > 0) {
4231                                    query.append(WHERE_AND);
4232                            }
4233    
4234                            for (int i = 0; i < orderByConditionFields.length; i++) {
4235                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4236                                    query.append(orderByConditionFields[i]);
4237    
4238                                    if ((i + 1) < orderByConditionFields.length) {
4239                                            if (orderByComparator.isAscending() ^ previous) {
4240                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4241                                            }
4242                                            else {
4243                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4244                                            }
4245                                    }
4246                                    else {
4247                                            if (orderByComparator.isAscending() ^ previous) {
4248                                                    query.append(WHERE_GREATER_THAN);
4249                                            }
4250                                            else {
4251                                                    query.append(WHERE_LESSER_THAN);
4252                                            }
4253                                    }
4254                            }
4255    
4256                            query.append(ORDER_BY_CLAUSE);
4257    
4258                            String[] orderByFields = orderByComparator.getOrderByFields();
4259    
4260                            for (int i = 0; i < orderByFields.length; i++) {
4261                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4262                                    query.append(orderByFields[i]);
4263    
4264                                    if ((i + 1) < orderByFields.length) {
4265                                            if (orderByComparator.isAscending() ^ previous) {
4266                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4267                                            }
4268                                            else {
4269                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4270                                            }
4271                                    }
4272                                    else {
4273                                            if (orderByComparator.isAscending() ^ previous) {
4274                                                    query.append(ORDER_BY_ASC);
4275                                            }
4276                                            else {
4277                                                    query.append(ORDER_BY_DESC);
4278                                            }
4279                                    }
4280                            }
4281                    }
4282    
4283                    else {
4284                            query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
4285                    }
4286    
4287                    String sql = query.toString();
4288    
4289                    Query q = session.createQuery(sql);
4290    
4291                    q.setFirstResult(0);
4292                    q.setMaxResults(2);
4293    
4294                    QueryPos qPos = QueryPos.getInstance(q);
4295    
4296                    qPos.add(classNameId);
4297    
4298                    qPos.add(classPK);
4299    
4300                    qPos.add(type);
4301    
4302                    qPos.add(receiverUserId);
4303    
4304                    qPos.add(status);
4305    
4306                    if (orderByComparator != null) {
4307                            Object[] values = orderByComparator.getOrderByConditionValues(socialRequest);
4308    
4309                            for (Object value : values) {
4310                                    qPos.add(value);
4311                            }
4312                    }
4313    
4314                    List<SocialRequest> list = q.list();
4315    
4316                    if (list.size() == 2) {
4317                            return list.get(1);
4318                    }
4319                    else {
4320                            return null;
4321                    }
4322            }
4323    
4324            /**
4325             * Returns all the social requests.
4326             *
4327             * @return the social requests
4328             * @throws SystemException if a system exception occurred
4329             */
4330            public List<SocialRequest> findAll() throws SystemException {
4331                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4332            }
4333    
4334            /**
4335             * Returns a range of all the social requests.
4336             *
4337             * <p>
4338             * 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.
4339             * </p>
4340             *
4341             * @param start the lower bound of the range of social requests
4342             * @param end the upper bound of the range of social requests (not inclusive)
4343             * @return the range of social requests
4344             * @throws SystemException if a system exception occurred
4345             */
4346            public List<SocialRequest> findAll(int start, int end)
4347                    throws SystemException {
4348                    return findAll(start, end, null);
4349            }
4350    
4351            /**
4352             * Returns an ordered range of all the social requests.
4353             *
4354             * <p>
4355             * 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.
4356             * </p>
4357             *
4358             * @param start the lower bound of the range of social requests
4359             * @param end the upper bound of the range of social requests (not inclusive)
4360             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4361             * @return the ordered range of social requests
4362             * @throws SystemException if a system exception occurred
4363             */
4364            public List<SocialRequest> findAll(int start, int end,
4365                    OrderByComparator orderByComparator) throws SystemException {
4366                    FinderPath finderPath = null;
4367                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
4368    
4369                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4370                                    (orderByComparator == null)) {
4371                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4372                            finderArgs = FINDER_ARGS_EMPTY;
4373                    }
4374                    else {
4375                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4376                            finderArgs = new Object[] { start, end, orderByComparator };
4377                    }
4378    
4379                    List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(finderPath,
4380                                    finderArgs, this);
4381    
4382                    if (list == null) {
4383                            StringBundler query = null;
4384                            String sql = null;
4385    
4386                            if (orderByComparator != null) {
4387                                    query = new StringBundler(2 +
4388                                                    (orderByComparator.getOrderByFields().length * 3));
4389    
4390                                    query.append(_SQL_SELECT_SOCIALREQUEST);
4391    
4392                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4393                                            orderByComparator);
4394    
4395                                    sql = query.toString();
4396                            }
4397                            else {
4398                                    sql = _SQL_SELECT_SOCIALREQUEST.concat(SocialRequestModelImpl.ORDER_BY_JPQL);
4399                            }
4400    
4401                            Session session = null;
4402    
4403                            try {
4404                                    session = openSession();
4405    
4406                                    Query q = session.createQuery(sql);
4407    
4408                                    if (orderByComparator == null) {
4409                                            list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
4410                                                            start, end, false);
4411    
4412                                            Collections.sort(list);
4413                                    }
4414                                    else {
4415                                            list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
4416                                                            start, end);
4417                                    }
4418                            }
4419                            catch (Exception e) {
4420                                    throw processException(e);
4421                            }
4422                            finally {
4423                                    if (list == null) {
4424                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4425                                    }
4426                                    else {
4427                                            cacheResult(list);
4428    
4429                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4430                                    }
4431    
4432                                    closeSession(session);
4433                            }
4434                    }
4435    
4436                    return list;
4437            }
4438    
4439            /**
4440             * Removes all the social requests where uuid = &#63; from the database.
4441             *
4442             * @param uuid the uuid
4443             * @throws SystemException if a system exception occurred
4444             */
4445            public void removeByUuid(String uuid) throws SystemException {
4446                    for (SocialRequest socialRequest : findByUuid(uuid)) {
4447                            socialRequestPersistence.remove(socialRequest);
4448                    }
4449            }
4450    
4451            /**
4452             * Removes the social request where uuid = &#63; and groupId = &#63; from the database.
4453             *
4454             * @param uuid the uuid
4455             * @param groupId the group ID
4456             * @throws SystemException if a system exception occurred
4457             */
4458            public void removeByUUID_G(String uuid, long groupId)
4459                    throws NoSuchRequestException, SystemException {
4460                    SocialRequest socialRequest = findByUUID_G(uuid, groupId);
4461    
4462                    socialRequestPersistence.remove(socialRequest);
4463            }
4464    
4465            /**
4466             * Removes all the social requests where companyId = &#63; from the database.
4467             *
4468             * @param companyId the company ID
4469             * @throws SystemException if a system exception occurred
4470             */
4471            public void removeByCompanyId(long companyId) throws SystemException {
4472                    for (SocialRequest socialRequest : findByCompanyId(companyId)) {
4473                            socialRequestPersistence.remove(socialRequest);
4474                    }
4475            }
4476    
4477            /**
4478             * Removes all the social requests where userId = &#63; from the database.
4479             *
4480             * @param userId the user ID
4481             * @throws SystemException if a system exception occurred
4482             */
4483            public void removeByUserId(long userId) throws SystemException {
4484                    for (SocialRequest socialRequest : findByUserId(userId)) {
4485                            socialRequestPersistence.remove(socialRequest);
4486                    }
4487            }
4488    
4489            /**
4490             * Removes all the social requests where receiverUserId = &#63; from the database.
4491             *
4492             * @param receiverUserId the receiver user ID
4493             * @throws SystemException if a system exception occurred
4494             */
4495            public void removeByReceiverUserId(long receiverUserId)
4496                    throws SystemException {
4497                    for (SocialRequest socialRequest : findByReceiverUserId(receiverUserId)) {
4498                            socialRequestPersistence.remove(socialRequest);
4499                    }
4500            }
4501    
4502            /**
4503             * Removes all the social requests where userId = &#63; and status = &#63; from the database.
4504             *
4505             * @param userId the user ID
4506             * @param status the status
4507             * @throws SystemException if a system exception occurred
4508             */
4509            public void removeByU_S(long userId, int status) throws SystemException {
4510                    for (SocialRequest socialRequest : findByU_S(userId, status)) {
4511                            socialRequestPersistence.remove(socialRequest);
4512                    }
4513            }
4514    
4515            /**
4516             * Removes all the social requests where receiverUserId = &#63; and status = &#63; from the database.
4517             *
4518             * @param receiverUserId the receiver user ID
4519             * @param status the status
4520             * @throws SystemException if a system exception occurred
4521             */
4522            public void removeByR_S(long receiverUserId, int status)
4523                    throws SystemException {
4524                    for (SocialRequest socialRequest : findByR_S(receiverUserId, status)) {
4525                            socialRequestPersistence.remove(socialRequest);
4526                    }
4527            }
4528    
4529            /**
4530             * Removes the social request where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; from the database.
4531             *
4532             * @param userId the user ID
4533             * @param classNameId the class name ID
4534             * @param classPK the class p k
4535             * @param type the type
4536             * @param receiverUserId the receiver user ID
4537             * @throws SystemException if a system exception occurred
4538             */
4539            public void removeByU_C_C_T_R(long userId, long classNameId, long classPK,
4540                    int type, long receiverUserId)
4541                    throws NoSuchRequestException, SystemException {
4542                    SocialRequest socialRequest = findByU_C_C_T_R(userId, classNameId,
4543                                    classPK, type, receiverUserId);
4544    
4545                    socialRequestPersistence.remove(socialRequest);
4546            }
4547    
4548            /**
4549             * Removes all the social requests where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and status = &#63; from the database.
4550             *
4551             * @param userId the user ID
4552             * @param classNameId the class name ID
4553             * @param classPK the class p k
4554             * @param type the type
4555             * @param status the status
4556             * @throws SystemException if a system exception occurred
4557             */
4558            public void removeByU_C_C_T_S(long userId, long classNameId, long classPK,
4559                    int type, int status) throws SystemException {
4560                    for (SocialRequest socialRequest : findByU_C_C_T_S(userId, classNameId,
4561                                    classPK, type, status)) {
4562                            socialRequestPersistence.remove(socialRequest);
4563                    }
4564            }
4565    
4566            /**
4567             * Removes all the social requests where classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; and status = &#63; from the database.
4568             *
4569             * @param classNameId the class name ID
4570             * @param classPK the class p k
4571             * @param type the type
4572             * @param receiverUserId the receiver user ID
4573             * @param status the status
4574             * @throws SystemException if a system exception occurred
4575             */
4576            public void removeByC_C_T_R_S(long classNameId, long classPK, int type,
4577                    long receiverUserId, int status) throws SystemException {
4578                    for (SocialRequest socialRequest : findByC_C_T_R_S(classNameId,
4579                                    classPK, type, receiverUserId, status)) {
4580                            socialRequestPersistence.remove(socialRequest);
4581                    }
4582            }
4583    
4584            /**
4585             * Removes all the social requests from the database.
4586             *
4587             * @throws SystemException if a system exception occurred
4588             */
4589            public void removeAll() throws SystemException {
4590                    for (SocialRequest socialRequest : findAll()) {
4591                            socialRequestPersistence.remove(socialRequest);
4592                    }
4593            }
4594    
4595            /**
4596             * Returns the number of social requests where uuid = &#63;.
4597             *
4598             * @param uuid the uuid
4599             * @return the number of matching social requests
4600             * @throws SystemException if a system exception occurred
4601             */
4602            public int countByUuid(String uuid) throws SystemException {
4603                    Object[] finderArgs = new Object[] { uuid };
4604    
4605                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4606                                    finderArgs, this);
4607    
4608                    if (count == null) {
4609                            StringBundler query = new StringBundler(2);
4610    
4611                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4612    
4613                            if (uuid == null) {
4614                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
4615                            }
4616                            else {
4617                                    if (uuid.equals(StringPool.BLANK)) {
4618                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
4619                                    }
4620                                    else {
4621                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
4622                                    }
4623                            }
4624    
4625                            String sql = query.toString();
4626    
4627                            Session session = null;
4628    
4629                            try {
4630                                    session = openSession();
4631    
4632                                    Query q = session.createQuery(sql);
4633    
4634                                    QueryPos qPos = QueryPos.getInstance(q);
4635    
4636                                    if (uuid != null) {
4637                                            qPos.add(uuid);
4638                                    }
4639    
4640                                    count = (Long)q.uniqueResult();
4641                            }
4642                            catch (Exception e) {
4643                                    throw processException(e);
4644                            }
4645                            finally {
4646                                    if (count == null) {
4647                                            count = Long.valueOf(0);
4648                                    }
4649    
4650                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4651                                            finderArgs, count);
4652    
4653                                    closeSession(session);
4654                            }
4655                    }
4656    
4657                    return count.intValue();
4658            }
4659    
4660            /**
4661             * Returns the number of social requests where uuid = &#63; and groupId = &#63;.
4662             *
4663             * @param uuid the uuid
4664             * @param groupId the group ID
4665             * @return the number of matching social requests
4666             * @throws SystemException if a system exception occurred
4667             */
4668            public int countByUUID_G(String uuid, long groupId)
4669                    throws SystemException {
4670                    Object[] finderArgs = new Object[] { uuid, groupId };
4671    
4672                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4673                                    finderArgs, this);
4674    
4675                    if (count == null) {
4676                            StringBundler query = new StringBundler(3);
4677    
4678                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4679    
4680                            if (uuid == null) {
4681                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4682                            }
4683                            else {
4684                                    if (uuid.equals(StringPool.BLANK)) {
4685                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4686                                    }
4687                                    else {
4688                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4689                                    }
4690                            }
4691    
4692                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4693    
4694                            String sql = query.toString();
4695    
4696                            Session session = null;
4697    
4698                            try {
4699                                    session = openSession();
4700    
4701                                    Query q = session.createQuery(sql);
4702    
4703                                    QueryPos qPos = QueryPos.getInstance(q);
4704    
4705                                    if (uuid != null) {
4706                                            qPos.add(uuid);
4707                                    }
4708    
4709                                    qPos.add(groupId);
4710    
4711                                    count = (Long)q.uniqueResult();
4712                            }
4713                            catch (Exception e) {
4714                                    throw processException(e);
4715                            }
4716                            finally {
4717                                    if (count == null) {
4718                                            count = Long.valueOf(0);
4719                                    }
4720    
4721                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4722                                            finderArgs, count);
4723    
4724                                    closeSession(session);
4725                            }
4726                    }
4727    
4728                    return count.intValue();
4729            }
4730    
4731            /**
4732             * Returns the number of social requests where companyId = &#63;.
4733             *
4734             * @param companyId the company ID
4735             * @return the number of matching social requests
4736             * @throws SystemException if a system exception occurred
4737             */
4738            public int countByCompanyId(long companyId) throws SystemException {
4739                    Object[] finderArgs = new Object[] { companyId };
4740    
4741                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4742                                    finderArgs, this);
4743    
4744                    if (count == null) {
4745                            StringBundler query = new StringBundler(2);
4746    
4747                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4748    
4749                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4750    
4751                            String sql = query.toString();
4752    
4753                            Session session = null;
4754    
4755                            try {
4756                                    session = openSession();
4757    
4758                                    Query q = session.createQuery(sql);
4759    
4760                                    QueryPos qPos = QueryPos.getInstance(q);
4761    
4762                                    qPos.add(companyId);
4763    
4764                                    count = (Long)q.uniqueResult();
4765                            }
4766                            catch (Exception e) {
4767                                    throw processException(e);
4768                            }
4769                            finally {
4770                                    if (count == null) {
4771                                            count = Long.valueOf(0);
4772                                    }
4773    
4774                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4775                                            finderArgs, count);
4776    
4777                                    closeSession(session);
4778                            }
4779                    }
4780    
4781                    return count.intValue();
4782            }
4783    
4784            /**
4785             * Returns the number of social requests where userId = &#63;.
4786             *
4787             * @param userId the user ID
4788             * @return the number of matching social requests
4789             * @throws SystemException if a system exception occurred
4790             */
4791            public int countByUserId(long userId) throws SystemException {
4792                    Object[] finderArgs = new Object[] { userId };
4793    
4794                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
4795                                    finderArgs, this);
4796    
4797                    if (count == null) {
4798                            StringBundler query = new StringBundler(2);
4799    
4800                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4801    
4802                            query.append(_FINDER_COLUMN_USERID_USERID_2);
4803    
4804                            String sql = query.toString();
4805    
4806                            Session session = null;
4807    
4808                            try {
4809                                    session = openSession();
4810    
4811                                    Query q = session.createQuery(sql);
4812    
4813                                    QueryPos qPos = QueryPos.getInstance(q);
4814    
4815                                    qPos.add(userId);
4816    
4817                                    count = (Long)q.uniqueResult();
4818                            }
4819                            catch (Exception e) {
4820                                    throw processException(e);
4821                            }
4822                            finally {
4823                                    if (count == null) {
4824                                            count = Long.valueOf(0);
4825                                    }
4826    
4827                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
4828                                            finderArgs, count);
4829    
4830                                    closeSession(session);
4831                            }
4832                    }
4833    
4834                    return count.intValue();
4835            }
4836    
4837            /**
4838             * Returns the number of social requests where receiverUserId = &#63;.
4839             *
4840             * @param receiverUserId the receiver user ID
4841             * @return the number of matching social requests
4842             * @throws SystemException if a system exception occurred
4843             */
4844            public int countByReceiverUserId(long receiverUserId)
4845                    throws SystemException {
4846                    Object[] finderArgs = new Object[] { receiverUserId };
4847    
4848                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
4849                                    finderArgs, this);
4850    
4851                    if (count == null) {
4852                            StringBundler query = new StringBundler(2);
4853    
4854                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4855    
4856                            query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
4857    
4858                            String sql = query.toString();
4859    
4860                            Session session = null;
4861    
4862                            try {
4863                                    session = openSession();
4864    
4865                                    Query q = session.createQuery(sql);
4866    
4867                                    QueryPos qPos = QueryPos.getInstance(q);
4868    
4869                                    qPos.add(receiverUserId);
4870    
4871                                    count = (Long)q.uniqueResult();
4872                            }
4873                            catch (Exception e) {
4874                                    throw processException(e);
4875                            }
4876                            finally {
4877                                    if (count == null) {
4878                                            count = Long.valueOf(0);
4879                                    }
4880    
4881                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
4882                                            finderArgs, count);
4883    
4884                                    closeSession(session);
4885                            }
4886                    }
4887    
4888                    return count.intValue();
4889            }
4890    
4891            /**
4892             * Returns the number of social requests where userId = &#63; and status = &#63;.
4893             *
4894             * @param userId the user ID
4895             * @param status the status
4896             * @return the number of matching social requests
4897             * @throws SystemException if a system exception occurred
4898             */
4899            public int countByU_S(long userId, int status) throws SystemException {
4900                    Object[] finderArgs = new Object[] { userId, status };
4901    
4902                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_S,
4903                                    finderArgs, this);
4904    
4905                    if (count == null) {
4906                            StringBundler query = new StringBundler(3);
4907    
4908                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4909    
4910                            query.append(_FINDER_COLUMN_U_S_USERID_2);
4911    
4912                            query.append(_FINDER_COLUMN_U_S_STATUS_2);
4913    
4914                            String sql = query.toString();
4915    
4916                            Session session = null;
4917    
4918                            try {
4919                                    session = openSession();
4920    
4921                                    Query q = session.createQuery(sql);
4922    
4923                                    QueryPos qPos = QueryPos.getInstance(q);
4924    
4925                                    qPos.add(userId);
4926    
4927                                    qPos.add(status);
4928    
4929                                    count = (Long)q.uniqueResult();
4930                            }
4931                            catch (Exception e) {
4932                                    throw processException(e);
4933                            }
4934                            finally {
4935                                    if (count == null) {
4936                                            count = Long.valueOf(0);
4937                                    }
4938    
4939                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_S, finderArgs,
4940                                            count);
4941    
4942                                    closeSession(session);
4943                            }
4944                    }
4945    
4946                    return count.intValue();
4947            }
4948    
4949            /**
4950             * Returns the number of social requests where receiverUserId = &#63; and status = &#63;.
4951             *
4952             * @param receiverUserId the receiver user ID
4953             * @param status the status
4954             * @return the number of matching social requests
4955             * @throws SystemException if a system exception occurred
4956             */
4957            public int countByR_S(long receiverUserId, int status)
4958                    throws SystemException {
4959                    Object[] finderArgs = new Object[] { receiverUserId, status };
4960    
4961                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_S,
4962                                    finderArgs, this);
4963    
4964                    if (count == null) {
4965                            StringBundler query = new StringBundler(3);
4966    
4967                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4968    
4969                            query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
4970    
4971                            query.append(_FINDER_COLUMN_R_S_STATUS_2);
4972    
4973                            String sql = query.toString();
4974    
4975                            Session session = null;
4976    
4977                            try {
4978                                    session = openSession();
4979    
4980                                    Query q = session.createQuery(sql);
4981    
4982                                    QueryPos qPos = QueryPos.getInstance(q);
4983    
4984                                    qPos.add(receiverUserId);
4985    
4986                                    qPos.add(status);
4987    
4988                                    count = (Long)q.uniqueResult();
4989                            }
4990                            catch (Exception e) {
4991                                    throw processException(e);
4992                            }
4993                            finally {
4994                                    if (count == null) {
4995                                            count = Long.valueOf(0);
4996                                    }
4997    
4998                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_S, finderArgs,
4999                                            count);
5000    
5001                                    closeSession(session);
5002                            }
5003                    }
5004    
5005                    return count.intValue();
5006            }
5007    
5008            /**
5009             * Returns the number of social requests where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63;.
5010             *
5011             * @param userId the user ID
5012             * @param classNameId the class name ID
5013             * @param classPK the class p k
5014             * @param type the type
5015             * @param receiverUserId the receiver user ID
5016             * @return the number of matching social requests
5017             * @throws SystemException if a system exception occurred
5018             */
5019            public int countByU_C_C_T_R(long userId, long classNameId, long classPK,
5020                    int type, long receiverUserId) throws SystemException {
5021                    Object[] finderArgs = new Object[] {
5022                                    userId, classNameId, classPK, type, receiverUserId
5023                            };
5024    
5025                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C_T_R,
5026                                    finderArgs, this);
5027    
5028                    if (count == null) {
5029                            StringBundler query = new StringBundler(6);
5030    
5031                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
5032    
5033                            query.append(_FINDER_COLUMN_U_C_C_T_R_USERID_2);
5034    
5035                            query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2);
5036    
5037                            query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSPK_2);
5038    
5039                            query.append(_FINDER_COLUMN_U_C_C_T_R_TYPE_2);
5040    
5041                            query.append(_FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2);
5042    
5043                            String sql = query.toString();
5044    
5045                            Session session = null;
5046    
5047                            try {
5048                                    session = openSession();
5049    
5050                                    Query q = session.createQuery(sql);
5051    
5052                                    QueryPos qPos = QueryPos.getInstance(q);
5053    
5054                                    qPos.add(userId);
5055    
5056                                    qPos.add(classNameId);
5057    
5058                                    qPos.add(classPK);
5059    
5060                                    qPos.add(type);
5061    
5062                                    qPos.add(receiverUserId);
5063    
5064                                    count = (Long)q.uniqueResult();
5065                            }
5066                            catch (Exception e) {
5067                                    throw processException(e);
5068                            }
5069                            finally {
5070                                    if (count == null) {
5071                                            count = Long.valueOf(0);
5072                                    }
5073    
5074                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C_T_R,
5075                                            finderArgs, count);
5076    
5077                                    closeSession(session);
5078                            }
5079                    }
5080    
5081                    return count.intValue();
5082            }
5083    
5084            /**
5085             * Returns the number of social requests where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and status = &#63;.
5086             *
5087             * @param userId the user ID
5088             * @param classNameId the class name ID
5089             * @param classPK the class p k
5090             * @param type the type
5091             * @param status the status
5092             * @return the number of matching social requests
5093             * @throws SystemException if a system exception occurred
5094             */
5095            public int countByU_C_C_T_S(long userId, long classNameId, long classPK,
5096                    int type, int status) throws SystemException {
5097                    Object[] finderArgs = new Object[] {
5098                                    userId, classNameId, classPK, type, status
5099                            };
5100    
5101                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
5102                                    finderArgs, this);
5103    
5104                    if (count == null) {
5105                            StringBundler query = new StringBundler(6);
5106    
5107                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
5108    
5109                            query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
5110    
5111                            query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
5112    
5113                            query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
5114    
5115                            query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
5116    
5117                            query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
5118    
5119                            String sql = query.toString();
5120    
5121                            Session session = null;
5122    
5123                            try {
5124                                    session = openSession();
5125    
5126                                    Query q = session.createQuery(sql);
5127    
5128                                    QueryPos qPos = QueryPos.getInstance(q);
5129    
5130                                    qPos.add(userId);
5131    
5132                                    qPos.add(classNameId);
5133    
5134                                    qPos.add(classPK);
5135    
5136                                    qPos.add(type);
5137    
5138                                    qPos.add(status);
5139    
5140                                    count = (Long)q.uniqueResult();
5141                            }
5142                            catch (Exception e) {
5143                                    throw processException(e);
5144                            }
5145                            finally {
5146                                    if (count == null) {
5147                                            count = Long.valueOf(0);
5148                                    }
5149    
5150                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
5151                                            finderArgs, count);
5152    
5153                                    closeSession(session);
5154                            }
5155                    }
5156    
5157                    return count.intValue();
5158            }
5159    
5160            /**
5161             * Returns the number of social requests where classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; and status = &#63;.
5162             *
5163             * @param classNameId the class name ID
5164             * @param classPK the class p k
5165             * @param type the type
5166             * @param receiverUserId the receiver user ID
5167             * @param status the status
5168             * @return the number of matching social requests
5169             * @throws SystemException if a system exception occurred
5170             */
5171            public int countByC_C_T_R_S(long classNameId, long classPK, int type,
5172                    long receiverUserId, int status) throws SystemException {
5173                    Object[] finderArgs = new Object[] {
5174                                    classNameId, classPK, type, receiverUserId, status
5175                            };
5176    
5177                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
5178                                    finderArgs, this);
5179    
5180                    if (count == null) {
5181                            StringBundler query = new StringBundler(6);
5182    
5183                            query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
5184    
5185                            query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
5186    
5187                            query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
5188    
5189                            query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
5190    
5191                            query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
5192    
5193                            query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
5194    
5195                            String sql = query.toString();
5196    
5197                            Session session = null;
5198    
5199                            try {
5200                                    session = openSession();
5201    
5202                                    Query q = session.createQuery(sql);
5203    
5204                                    QueryPos qPos = QueryPos.getInstance(q);
5205    
5206                                    qPos.add(classNameId);
5207    
5208                                    qPos.add(classPK);
5209    
5210                                    qPos.add(type);
5211    
5212                                    qPos.add(receiverUserId);
5213    
5214                                    qPos.add(status);
5215    
5216                                    count = (Long)q.uniqueResult();
5217                            }
5218                            catch (Exception e) {
5219                                    throw processException(e);
5220                            }
5221                            finally {
5222                                    if (count == null) {
5223                                            count = Long.valueOf(0);
5224                                    }
5225    
5226                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
5227                                            finderArgs, count);
5228    
5229                                    closeSession(session);
5230                            }
5231                    }
5232    
5233                    return count.intValue();
5234            }
5235    
5236            /**
5237             * Returns the number of social requests.
5238             *
5239             * @return the number of social requests
5240             * @throws SystemException if a system exception occurred
5241             */
5242            public int countAll() throws SystemException {
5243                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5244                                    FINDER_ARGS_EMPTY, this);
5245    
5246                    if (count == null) {
5247                            Session session = null;
5248    
5249                            try {
5250                                    session = openSession();
5251    
5252                                    Query q = session.createQuery(_SQL_COUNT_SOCIALREQUEST);
5253    
5254                                    count = (Long)q.uniqueResult();
5255                            }
5256                            catch (Exception e) {
5257                                    throw processException(e);
5258                            }
5259                            finally {
5260                                    if (count == null) {
5261                                            count = Long.valueOf(0);
5262                                    }
5263    
5264                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5265                                            FINDER_ARGS_EMPTY, count);
5266    
5267                                    closeSession(session);
5268                            }
5269                    }
5270    
5271                    return count.intValue();
5272            }
5273    
5274            /**
5275             * Initializes the social request persistence.
5276             */
5277            public void afterPropertiesSet() {
5278                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5279                                            com.liferay.portal.util.PropsUtil.get(
5280                                                    "value.object.listener.com.liferay.portlet.social.model.SocialRequest")));
5281    
5282                    if (listenerClassNames.length > 0) {
5283                            try {
5284                                    List<ModelListener<SocialRequest>> listenersList = new ArrayList<ModelListener<SocialRequest>>();
5285    
5286                                    for (String listenerClassName : listenerClassNames) {
5287                                            listenersList.add((ModelListener<SocialRequest>)InstanceFactory.newInstance(
5288                                                            listenerClassName));
5289                                    }
5290    
5291                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5292                            }
5293                            catch (Exception e) {
5294                                    _log.error(e);
5295                            }
5296                    }
5297            }
5298    
5299            public void destroy() {
5300                    EntityCacheUtil.removeCache(SocialRequestImpl.class.getName());
5301                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5302                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5303            }
5304    
5305            @BeanReference(type = SocialActivityPersistence.class)
5306            protected SocialActivityPersistence socialActivityPersistence;
5307            @BeanReference(type = SocialActivityAchievementPersistence.class)
5308            protected SocialActivityAchievementPersistence socialActivityAchievementPersistence;
5309            @BeanReference(type = SocialActivityCounterPersistence.class)
5310            protected SocialActivityCounterPersistence socialActivityCounterPersistence;
5311            @BeanReference(type = SocialActivityLimitPersistence.class)
5312            protected SocialActivityLimitPersistence socialActivityLimitPersistence;
5313            @BeanReference(type = SocialActivitySettingPersistence.class)
5314            protected SocialActivitySettingPersistence socialActivitySettingPersistence;
5315            @BeanReference(type = SocialRelationPersistence.class)
5316            protected SocialRelationPersistence socialRelationPersistence;
5317            @BeanReference(type = SocialRequestPersistence.class)
5318            protected SocialRequestPersistence socialRequestPersistence;
5319            @BeanReference(type = ResourcePersistence.class)
5320            protected ResourcePersistence resourcePersistence;
5321            @BeanReference(type = UserPersistence.class)
5322            protected UserPersistence userPersistence;
5323            private static final String _SQL_SELECT_SOCIALREQUEST = "SELECT socialRequest FROM SocialRequest socialRequest";
5324            private static final String _SQL_SELECT_SOCIALREQUEST_WHERE = "SELECT socialRequest FROM SocialRequest socialRequest WHERE ";
5325            private static final String _SQL_COUNT_SOCIALREQUEST = "SELECT COUNT(socialRequest) FROM SocialRequest socialRequest";
5326            private static final String _SQL_COUNT_SOCIALREQUEST_WHERE = "SELECT COUNT(socialRequest) FROM SocialRequest socialRequest WHERE ";
5327            private static final String _FINDER_COLUMN_UUID_UUID_1 = "socialRequest.uuid IS NULL";
5328            private static final String _FINDER_COLUMN_UUID_UUID_2 = "socialRequest.uuid = ?";
5329            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(socialRequest.uuid IS NULL OR socialRequest.uuid = ?)";
5330            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "socialRequest.uuid IS NULL AND ";
5331            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "socialRequest.uuid = ? AND ";
5332            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(socialRequest.uuid IS NULL OR socialRequest.uuid = ?) AND ";
5333            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "socialRequest.groupId = ?";
5334            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "socialRequest.companyId = ?";
5335            private static final String _FINDER_COLUMN_USERID_USERID_2 = "socialRequest.userId = ?";
5336            private static final String _FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ?";
5337            private static final String _FINDER_COLUMN_U_S_USERID_2 = "socialRequest.userId = ? AND ";
5338            private static final String _FINDER_COLUMN_U_S_STATUS_2 = "socialRequest.status = ?";
5339            private static final String _FINDER_COLUMN_R_S_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ? AND ";
5340            private static final String _FINDER_COLUMN_R_S_STATUS_2 = "socialRequest.status = ?";
5341            private static final String _FINDER_COLUMN_U_C_C_T_R_USERID_2 = "socialRequest.userId = ? AND ";
5342            private static final String _FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
5343            private static final String _FINDER_COLUMN_U_C_C_T_R_CLASSPK_2 = "socialRequest.classPK = ? AND ";
5344            private static final String _FINDER_COLUMN_U_C_C_T_R_TYPE_2 = "socialRequest.type = ? AND ";
5345            private static final String _FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ?";
5346            private static final String _FINDER_COLUMN_U_C_C_T_S_USERID_2 = "socialRequest.userId = ? AND ";
5347            private static final String _FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
5348            private static final String _FINDER_COLUMN_U_C_C_T_S_CLASSPK_2 = "socialRequest.classPK = ? AND ";
5349            private static final String _FINDER_COLUMN_U_C_C_T_S_TYPE_2 = "socialRequest.type = ? AND ";
5350            private static final String _FINDER_COLUMN_U_C_C_T_S_STATUS_2 = "socialRequest.status = ?";
5351            private static final String _FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
5352            private static final String _FINDER_COLUMN_C_C_T_R_S_CLASSPK_2 = "socialRequest.classPK = ? AND ";
5353            private static final String _FINDER_COLUMN_C_C_T_R_S_TYPE_2 = "socialRequest.type = ? AND ";
5354            private static final String _FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ? AND ";
5355            private static final String _FINDER_COLUMN_C_C_T_R_S_STATUS_2 = "socialRequest.status = ?";
5356            private static final String _ORDER_BY_ENTITY_ALIAS = "socialRequest.";
5357            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialRequest exists with the primary key ";
5358            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialRequest exists with the key {";
5359            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5360            private static Log _log = LogFactoryUtil.getLog(SocialRequestPersistenceImpl.class);
5361            private static SocialRequest _nullSocialRequest = new SocialRequestImpl() {
5362                            @Override
5363                            public Object clone() {
5364                                    return this;
5365                            }
5366    
5367                            @Override
5368                            public CacheModel<SocialRequest> toCacheModel() {
5369                                    return _nullSocialRequestCacheModel;
5370                            }
5371                    };
5372    
5373            private static CacheModel<SocialRequest> _nullSocialRequestCacheModel = new CacheModel<SocialRequest>() {
5374                            public SocialRequest toEntityModel() {
5375                                    return _nullSocialRequest;
5376                            }
5377                    };
5378    }