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