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