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