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