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