1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.social.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
22  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderPath;
25  import com.liferay.portal.kernel.dao.orm.Query;
26  import com.liferay.portal.kernel.dao.orm.QueryPos;
27  import com.liferay.portal.kernel.dao.orm.QueryUtil;
28  import com.liferay.portal.kernel.dao.orm.Session;
29  import com.liferay.portal.kernel.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.GetterUtil;
32  import com.liferay.portal.kernel.util.OrderByComparator;
33  import com.liferay.portal.kernel.util.StringBundler;
34  import com.liferay.portal.kernel.util.StringPool;
35  import com.liferay.portal.kernel.util.StringUtil;
36  import com.liferay.portal.kernel.util.Validator;
37  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
38  import com.liferay.portal.model.ModelListener;
39  import com.liferay.portal.service.persistence.BatchSessionUtil;
40  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41  
42  import com.liferay.portlet.social.NoSuchRequestException;
43  import com.liferay.portlet.social.model.SocialRequest;
44  import com.liferay.portlet.social.model.impl.SocialRequestImpl;
45  import com.liferay.portlet.social.model.impl.SocialRequestModelImpl;
46  
47  import java.io.Serializable;
48  
49  import java.util.ArrayList;
50  import java.util.Collections;
51  import java.util.List;
52  
53  /**
54   * <a href="SocialRequestPersistenceImpl.java.html"><b><i>View Source</i></b></a>
55   *
56   * <p>
57   * ServiceBuilder generated this class. Modifications in this class will be
58   * overwritten the next time is generated.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       SocialRequestPersistence
63   * @see       SocialRequestUtil
64   * @generated
65   */
66  public class SocialRequestPersistenceImpl extends BasePersistenceImpl<SocialRequest>
67      implements SocialRequestPersistence {
68      public static final String FINDER_CLASS_NAME_ENTITY = SocialRequestImpl.class.getName();
69      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
70          ".List";
71      public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
72              SocialRequestModelImpl.FINDER_CACHE_ENABLED,
73              FINDER_CLASS_NAME_LIST, "findByUuid",
74              new String[] { String.class.getName() });
75      public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
76              SocialRequestModelImpl.FINDER_CACHE_ENABLED,
77              FINDER_CLASS_NAME_LIST, "findByUuid",
78              new String[] {
79                  String.class.getName(),
80                  
81              "java.lang.Integer", "java.lang.Integer",
82                  "com.liferay.portal.kernel.util.OrderByComparator"
83              });
84      public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
85              SocialRequestModelImpl.FINDER_CACHE_ENABLED,
86              FINDER_CLASS_NAME_LIST, "countByUuid",
87              new String[] { String.class.getName() });
88      public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
89              SocialRequestModelImpl.FINDER_CACHE_ENABLED,
90              FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
91              new String[] { String.class.getName(), Long.class.getName() });
92      public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
93              SocialRequestModelImpl.FINDER_CACHE_ENABLED,
94              FINDER_CLASS_NAME_LIST, "countByUUID_G",
95              new String[] { String.class.getName(), Long.class.getName() });
96      public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
97              SocialRequestModelImpl.FINDER_CACHE_ENABLED,
98              FINDER_CLASS_NAME_LIST, "findByCompanyId",
99              new String[] { Long.class.getName() });
100     public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
101             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
102             FINDER_CLASS_NAME_LIST, "findByCompanyId",
103             new String[] {
104                 Long.class.getName(),
105                 
106             "java.lang.Integer", "java.lang.Integer",
107                 "com.liferay.portal.kernel.util.OrderByComparator"
108             });
109     public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
110             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
111             FINDER_CLASS_NAME_LIST, "countByCompanyId",
112             new String[] { Long.class.getName() });
113     public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
114             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
115             FINDER_CLASS_NAME_LIST, "findByUserId",
116             new String[] { Long.class.getName() });
117     public static final FinderPath FINDER_PATH_FIND_BY_OBC_USERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
118             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
119             FINDER_CLASS_NAME_LIST, "findByUserId",
120             new String[] {
121                 Long.class.getName(),
122                 
123             "java.lang.Integer", "java.lang.Integer",
124                 "com.liferay.portal.kernel.util.OrderByComparator"
125             });
126     public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
127             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
128             FINDER_CLASS_NAME_LIST, "countByUserId",
129             new String[] { Long.class.getName() });
130     public static final FinderPath FINDER_PATH_FIND_BY_RECEIVERUSERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
131             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
132             FINDER_CLASS_NAME_LIST, "findByReceiverUserId",
133             new String[] { Long.class.getName() });
134     public static final FinderPath FINDER_PATH_FIND_BY_OBC_RECEIVERUSERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
135             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
136             FINDER_CLASS_NAME_LIST, "findByReceiverUserId",
137             new String[] {
138                 Long.class.getName(),
139                 
140             "java.lang.Integer", "java.lang.Integer",
141                 "com.liferay.portal.kernel.util.OrderByComparator"
142             });
143     public static final FinderPath FINDER_PATH_COUNT_BY_RECEIVERUSERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
144             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
145             FINDER_CLASS_NAME_LIST, "countByReceiverUserId",
146             new String[] { Long.class.getName() });
147     public static final FinderPath FINDER_PATH_FIND_BY_U_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
148             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
149             FINDER_CLASS_NAME_LIST, "findByU_S",
150             new String[] { Long.class.getName(), Integer.class.getName() });
151     public static final FinderPath FINDER_PATH_FIND_BY_OBC_U_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
152             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
153             FINDER_CLASS_NAME_LIST, "findByU_S",
154             new String[] {
155                 Long.class.getName(), Integer.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_COUNT_BY_U_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
161             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
162             FINDER_CLASS_NAME_LIST, "countByU_S",
163             new String[] { Long.class.getName(), Integer.class.getName() });
164     public static final FinderPath FINDER_PATH_FIND_BY_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
165             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
166             FINDER_CLASS_NAME_LIST, "findByR_S",
167             new String[] { Long.class.getName(), Integer.class.getName() });
168     public static final FinderPath FINDER_PATH_FIND_BY_OBC_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
169             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
170             FINDER_CLASS_NAME_LIST, "findByR_S",
171             new String[] {
172                 Long.class.getName(), Integer.class.getName(),
173                 
174             "java.lang.Integer", "java.lang.Integer",
175                 "com.liferay.portal.kernel.util.OrderByComparator"
176             });
177     public static final FinderPath FINDER_PATH_COUNT_BY_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
178             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
179             FINDER_CLASS_NAME_LIST, "countByR_S",
180             new String[] { Long.class.getName(), Integer.class.getName() });
181     public static final FinderPath FINDER_PATH_FETCH_BY_U_C_C_T_R = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
182             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
183             FINDER_CLASS_NAME_ENTITY, "fetchByU_C_C_T_R",
184             new String[] {
185                 Long.class.getName(), Long.class.getName(), Long.class.getName(),
186                 Integer.class.getName(), Long.class.getName()
187             });
188     public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C_T_R = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
189             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
190             FINDER_CLASS_NAME_LIST, "countByU_C_C_T_R",
191             new String[] {
192                 Long.class.getName(), Long.class.getName(), Long.class.getName(),
193                 Integer.class.getName(), Long.class.getName()
194             });
195     public static final FinderPath FINDER_PATH_FIND_BY_U_C_C_T_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
196             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
197             FINDER_CLASS_NAME_LIST, "findByU_C_C_T_S",
198             new String[] {
199                 Long.class.getName(), Long.class.getName(), Long.class.getName(),
200                 Integer.class.getName(), Integer.class.getName()
201             });
202     public static final FinderPath FINDER_PATH_FIND_BY_OBC_U_C_C_T_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
203             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
204             FINDER_CLASS_NAME_LIST, "findByU_C_C_T_S",
205             new String[] {
206                 Long.class.getName(), Long.class.getName(), Long.class.getName(),
207                 Integer.class.getName(), Integer.class.getName(),
208                 
209             "java.lang.Integer", "java.lang.Integer",
210                 "com.liferay.portal.kernel.util.OrderByComparator"
211             });
212     public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C_T_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
213             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
214             FINDER_CLASS_NAME_LIST, "countByU_C_C_T_S",
215             new String[] {
216                 Long.class.getName(), Long.class.getName(), Long.class.getName(),
217                 Integer.class.getName(), Integer.class.getName()
218             });
219     public static final FinderPath FINDER_PATH_FIND_BY_C_C_T_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
220             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
221             FINDER_CLASS_NAME_LIST, "findByC_C_T_R_S",
222             new String[] {
223                 Long.class.getName(), Long.class.getName(),
224                 Integer.class.getName(), Long.class.getName(),
225                 Integer.class.getName()
226             });
227     public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_C_T_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
228             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
229             FINDER_CLASS_NAME_LIST, "findByC_C_T_R_S",
230             new String[] {
231                 Long.class.getName(), Long.class.getName(),
232                 Integer.class.getName(), Long.class.getName(),
233                 Integer.class.getName(),
234                 
235             "java.lang.Integer", "java.lang.Integer",
236                 "com.liferay.portal.kernel.util.OrderByComparator"
237             });
238     public static final FinderPath FINDER_PATH_COUNT_BY_C_C_T_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
239             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
240             FINDER_CLASS_NAME_LIST, "countByC_C_T_R_S",
241             new String[] {
242                 Long.class.getName(), Long.class.getName(),
243                 Integer.class.getName(), Long.class.getName(),
244                 Integer.class.getName()
245             });
246     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
247             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
248             FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
249     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
250             SocialRequestModelImpl.FINDER_CACHE_ENABLED,
251             FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
252 
253     public void cacheResult(SocialRequest socialRequest) {
254         EntityCacheUtil.putResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
255             SocialRequestImpl.class, socialRequest.getPrimaryKey(),
256             socialRequest);
257 
258         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
259             new Object[] {
260                 socialRequest.getUuid(), new Long(socialRequest.getGroupId())
261             }, socialRequest);
262 
263         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
264             new Object[] {
265                 new Long(socialRequest.getUserId()),
266                 new Long(socialRequest.getClassNameId()),
267                 new Long(socialRequest.getClassPK()),
268                 new Integer(socialRequest.getType()),
269                 new Long(socialRequest.getReceiverUserId())
270             }, socialRequest);
271     }
272 
273     public void cacheResult(List<SocialRequest> socialRequests) {
274         for (SocialRequest socialRequest : socialRequests) {
275             if (EntityCacheUtil.getResult(
276                         SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
277                         SocialRequestImpl.class, socialRequest.getPrimaryKey(),
278                         this) == null) {
279                 cacheResult(socialRequest);
280             }
281         }
282     }
283 
284     public void clearCache() {
285         CacheRegistry.clear(SocialRequestImpl.class.getName());
286         EntityCacheUtil.clearCache(SocialRequestImpl.class.getName());
287         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
288         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
289     }
290 
291     public SocialRequest create(long requestId) {
292         SocialRequest socialRequest = new SocialRequestImpl();
293 
294         socialRequest.setNew(true);
295         socialRequest.setPrimaryKey(requestId);
296 
297         String uuid = PortalUUIDUtil.generate();
298 
299         socialRequest.setUuid(uuid);
300 
301         return socialRequest;
302     }
303 
304     public SocialRequest remove(Serializable primaryKey)
305         throws NoSuchModelException, SystemException {
306         return remove(((Long)primaryKey).longValue());
307     }
308 
309     public SocialRequest remove(long requestId)
310         throws NoSuchRequestException, SystemException {
311         Session session = null;
312 
313         try {
314             session = openSession();
315 
316             SocialRequest socialRequest = (SocialRequest)session.get(SocialRequestImpl.class,
317                     new Long(requestId));
318 
319             if (socialRequest == null) {
320                 if (_log.isWarnEnabled()) {
321                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + requestId);
322                 }
323 
324                 throw new NoSuchRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
325                     requestId);
326             }
327 
328             return remove(socialRequest);
329         }
330         catch (NoSuchRequestException nsee) {
331             throw nsee;
332         }
333         catch (Exception e) {
334             throw processException(e);
335         }
336         finally {
337             closeSession(session);
338         }
339     }
340 
341     public SocialRequest remove(SocialRequest socialRequest)
342         throws SystemException {
343         for (ModelListener<SocialRequest> listener : listeners) {
344             listener.onBeforeRemove(socialRequest);
345         }
346 
347         socialRequest = removeImpl(socialRequest);
348 
349         for (ModelListener<SocialRequest> listener : listeners) {
350             listener.onAfterRemove(socialRequest);
351         }
352 
353         return socialRequest;
354     }
355 
356     protected SocialRequest removeImpl(SocialRequest socialRequest)
357         throws SystemException {
358         socialRequest = toUnwrappedModel(socialRequest);
359 
360         Session session = null;
361 
362         try {
363             session = openSession();
364 
365             if (socialRequest.isCachedModel() || BatchSessionUtil.isEnabled()) {
366                 Object staleObject = session.get(SocialRequestImpl.class,
367                         socialRequest.getPrimaryKeyObj());
368 
369                 if (staleObject != null) {
370                     session.evict(staleObject);
371                 }
372             }
373 
374             session.delete(socialRequest);
375 
376             session.flush();
377         }
378         catch (Exception e) {
379             throw processException(e);
380         }
381         finally {
382             closeSession(session);
383         }
384 
385         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
386 
387         SocialRequestModelImpl socialRequestModelImpl = (SocialRequestModelImpl)socialRequest;
388 
389         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
390             new Object[] {
391                 socialRequestModelImpl.getOriginalUuid(),
392                 new Long(socialRequestModelImpl.getOriginalGroupId())
393             });
394 
395         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
396             new Object[] {
397                 new Long(socialRequestModelImpl.getOriginalUserId()),
398                 new Long(socialRequestModelImpl.getOriginalClassNameId()),
399                 new Long(socialRequestModelImpl.getOriginalClassPK()),
400                 new Integer(socialRequestModelImpl.getOriginalType()),
401                 new Long(socialRequestModelImpl.getOriginalReceiverUserId())
402             });
403 
404         EntityCacheUtil.removeResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
405             SocialRequestImpl.class, socialRequest.getPrimaryKey());
406 
407         return socialRequest;
408     }
409 
410     /**
411      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
412      */
413     public SocialRequest update(SocialRequest socialRequest)
414         throws SystemException {
415         if (_log.isWarnEnabled()) {
416             _log.warn(
417                 "Using the deprecated update(SocialRequest socialRequest) method. Use update(SocialRequest socialRequest, boolean merge) instead.");
418         }
419 
420         return update(socialRequest, false);
421     }
422 
423     public SocialRequest updateImpl(
424         com.liferay.portlet.social.model.SocialRequest socialRequest,
425         boolean merge) throws SystemException {
426         socialRequest = toUnwrappedModel(socialRequest);
427 
428         boolean isNew = socialRequest.isNew();
429 
430         SocialRequestModelImpl socialRequestModelImpl = (SocialRequestModelImpl)socialRequest;
431 
432         if (Validator.isNull(socialRequest.getUuid())) {
433             String uuid = PortalUUIDUtil.generate();
434 
435             socialRequest.setUuid(uuid);
436         }
437 
438         Session session = null;
439 
440         try {
441             session = openSession();
442 
443             BatchSessionUtil.update(session, socialRequest, merge);
444 
445             socialRequest.setNew(false);
446         }
447         catch (Exception e) {
448             throw processException(e);
449         }
450         finally {
451             closeSession(session);
452         }
453 
454         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
455 
456         EntityCacheUtil.putResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
457             SocialRequestImpl.class, socialRequest.getPrimaryKey(),
458             socialRequest);
459 
460         if (!isNew &&
461                 (!Validator.equals(socialRequest.getUuid(),
462                     socialRequestModelImpl.getOriginalUuid()) ||
463                 (socialRequest.getGroupId() != socialRequestModelImpl.getOriginalGroupId()))) {
464             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
465                 new Object[] {
466                     socialRequestModelImpl.getOriginalUuid(),
467                     new Long(socialRequestModelImpl.getOriginalGroupId())
468                 });
469         }
470 
471         if (isNew ||
472                 (!Validator.equals(socialRequest.getUuid(),
473                     socialRequestModelImpl.getOriginalUuid()) ||
474                 (socialRequest.getGroupId() != socialRequestModelImpl.getOriginalGroupId()))) {
475             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
476                 new Object[] {
477                     socialRequest.getUuid(),
478                     new Long(socialRequest.getGroupId())
479                 }, socialRequest);
480         }
481 
482         if (!isNew &&
483                 ((socialRequest.getUserId() != socialRequestModelImpl.getOriginalUserId()) ||
484                 (socialRequest.getClassNameId() != socialRequestModelImpl.getOriginalClassNameId()) ||
485                 (socialRequest.getClassPK() != socialRequestModelImpl.getOriginalClassPK()) ||
486                 (socialRequest.getType() != socialRequestModelImpl.getOriginalType()) ||
487                 (socialRequest.getReceiverUserId() != socialRequestModelImpl.getOriginalReceiverUserId()))) {
488             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
489                 new Object[] {
490                     new Long(socialRequestModelImpl.getOriginalUserId()),
491                     new Long(socialRequestModelImpl.getOriginalClassNameId()),
492                     new Long(socialRequestModelImpl.getOriginalClassPK()),
493                     new Integer(socialRequestModelImpl.getOriginalType()),
494                     new Long(socialRequestModelImpl.getOriginalReceiverUserId())
495                 });
496         }
497 
498         if (isNew ||
499                 ((socialRequest.getUserId() != socialRequestModelImpl.getOriginalUserId()) ||
500                 (socialRequest.getClassNameId() != socialRequestModelImpl.getOriginalClassNameId()) ||
501                 (socialRequest.getClassPK() != socialRequestModelImpl.getOriginalClassPK()) ||
502                 (socialRequest.getType() != socialRequestModelImpl.getOriginalType()) ||
503                 (socialRequest.getReceiverUserId() != socialRequestModelImpl.getOriginalReceiverUserId()))) {
504             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
505                 new Object[] {
506                     new Long(socialRequest.getUserId()),
507                     new Long(socialRequest.getClassNameId()),
508                     new Long(socialRequest.getClassPK()),
509                     new Integer(socialRequest.getType()),
510                     new Long(socialRequest.getReceiverUserId())
511                 }, socialRequest);
512         }
513 
514         return socialRequest;
515     }
516 
517     protected SocialRequest toUnwrappedModel(SocialRequest socialRequest) {
518         if (socialRequest instanceof SocialRequestImpl) {
519             return socialRequest;
520         }
521 
522         SocialRequestImpl socialRequestImpl = new SocialRequestImpl();
523 
524         socialRequestImpl.setNew(socialRequest.isNew());
525         socialRequestImpl.setPrimaryKey(socialRequest.getPrimaryKey());
526 
527         socialRequestImpl.setUuid(socialRequest.getUuid());
528         socialRequestImpl.setRequestId(socialRequest.getRequestId());
529         socialRequestImpl.setGroupId(socialRequest.getGroupId());
530         socialRequestImpl.setCompanyId(socialRequest.getCompanyId());
531         socialRequestImpl.setUserId(socialRequest.getUserId());
532         socialRequestImpl.setCreateDate(socialRequest.getCreateDate());
533         socialRequestImpl.setModifiedDate(socialRequest.getModifiedDate());
534         socialRequestImpl.setClassNameId(socialRequest.getClassNameId());
535         socialRequestImpl.setClassPK(socialRequest.getClassPK());
536         socialRequestImpl.setType(socialRequest.getType());
537         socialRequestImpl.setExtraData(socialRequest.getExtraData());
538         socialRequestImpl.setReceiverUserId(socialRequest.getReceiverUserId());
539         socialRequestImpl.setStatus(socialRequest.getStatus());
540 
541         return socialRequestImpl;
542     }
543 
544     public SocialRequest findByPrimaryKey(Serializable primaryKey)
545         throws NoSuchModelException, SystemException {
546         return findByPrimaryKey(((Long)primaryKey).longValue());
547     }
548 
549     public SocialRequest findByPrimaryKey(long requestId)
550         throws NoSuchRequestException, SystemException {
551         SocialRequest socialRequest = fetchByPrimaryKey(requestId);
552 
553         if (socialRequest == null) {
554             if (_log.isWarnEnabled()) {
555                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + requestId);
556             }
557 
558             throw new NoSuchRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
559                 requestId);
560         }
561 
562         return socialRequest;
563     }
564 
565     public SocialRequest fetchByPrimaryKey(Serializable primaryKey)
566         throws SystemException {
567         return fetchByPrimaryKey(((Long)primaryKey).longValue());
568     }
569 
570     public SocialRequest fetchByPrimaryKey(long requestId)
571         throws SystemException {
572         SocialRequest socialRequest = (SocialRequest)EntityCacheUtil.getResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
573                 SocialRequestImpl.class, requestId, this);
574 
575         if (socialRequest == null) {
576             Session session = null;
577 
578             try {
579                 session = openSession();
580 
581                 socialRequest = (SocialRequest)session.get(SocialRequestImpl.class,
582                         new Long(requestId));
583             }
584             catch (Exception e) {
585                 throw processException(e);
586             }
587             finally {
588                 if (socialRequest != null) {
589                     cacheResult(socialRequest);
590                 }
591 
592                 closeSession(session);
593             }
594         }
595 
596         return socialRequest;
597     }
598 
599     public List<SocialRequest> findByUuid(String uuid)
600         throws SystemException {
601         Object[] finderArgs = new Object[] { uuid };
602 
603         List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
604                 finderArgs, this);
605 
606         if (list == null) {
607             Session session = null;
608 
609             try {
610                 session = openSession();
611 
612                 StringBundler query = new StringBundler(3);
613 
614                 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
615 
616                 if (uuid == null) {
617                     query.append(_FINDER_COLUMN_UUID_UUID_1);
618                 }
619                 else {
620                     if (uuid.equals(StringPool.BLANK)) {
621                         query.append(_FINDER_COLUMN_UUID_UUID_3);
622                     }
623                     else {
624                         query.append(_FINDER_COLUMN_UUID_UUID_2);
625                     }
626                 }
627 
628                 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
629 
630                 String sql = query.toString();
631 
632                 Query q = session.createQuery(sql);
633 
634                 QueryPos qPos = QueryPos.getInstance(q);
635 
636                 if (uuid != null) {
637                     qPos.add(uuid);
638                 }
639 
640                 list = q.list();
641             }
642             catch (Exception e) {
643                 throw processException(e);
644             }
645             finally {
646                 if (list == null) {
647                     list = new ArrayList<SocialRequest>();
648                 }
649 
650                 cacheResult(list);
651 
652                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
653                     list);
654 
655                 closeSession(session);
656             }
657         }
658 
659         return list;
660     }
661 
662     public List<SocialRequest> findByUuid(String uuid, int start, int end)
663         throws SystemException {
664         return findByUuid(uuid, start, end, null);
665     }
666 
667     public List<SocialRequest> findByUuid(String uuid, int start, int end,
668         OrderByComparator obc) throws SystemException {
669         Object[] finderArgs = new Object[] {
670                 uuid,
671                 
672                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
673             };
674 
675         List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
676                 finderArgs, this);
677 
678         if (list == null) {
679             Session session = null;
680 
681             try {
682                 session = openSession();
683 
684                 StringBundler query = null;
685 
686                 if (obc != null) {
687                     query = new StringBundler(3 +
688                             (obc.getOrderByFields().length * 3));
689                 }
690                 else {
691                     query = new StringBundler(3);
692                 }
693 
694                 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
695 
696                 if (uuid == null) {
697                     query.append(_FINDER_COLUMN_UUID_UUID_1);
698                 }
699                 else {
700                     if (uuid.equals(StringPool.BLANK)) {
701                         query.append(_FINDER_COLUMN_UUID_UUID_3);
702                     }
703                     else {
704                         query.append(_FINDER_COLUMN_UUID_UUID_2);
705                     }
706                 }
707 
708                 if (obc != null) {
709                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
710                 }
711 
712                 else {
713                     query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
714                 }
715 
716                 String sql = query.toString();
717 
718                 Query q = session.createQuery(sql);
719 
720                 QueryPos qPos = QueryPos.getInstance(q);
721 
722                 if (uuid != null) {
723                     qPos.add(uuid);
724                 }
725 
726                 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
727                         start, end);
728             }
729             catch (Exception e) {
730                 throw processException(e);
731             }
732             finally {
733                 if (list == null) {
734                     list = new ArrayList<SocialRequest>();
735                 }
736 
737                 cacheResult(list);
738 
739                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
740                     finderArgs, list);
741 
742                 closeSession(session);
743             }
744         }
745 
746         return list;
747     }
748 
749     public SocialRequest findByUuid_First(String uuid, OrderByComparator obc)
750         throws NoSuchRequestException, SystemException {
751         List<SocialRequest> list = findByUuid(uuid, 0, 1, obc);
752 
753         if (list.isEmpty()) {
754             StringBundler msg = new StringBundler(4);
755 
756             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
757 
758             msg.append("uuid=");
759             msg.append(uuid);
760 
761             msg.append(StringPool.CLOSE_CURLY_BRACE);
762 
763             throw new NoSuchRequestException(msg.toString());
764         }
765         else {
766             return list.get(0);
767         }
768     }
769 
770     public SocialRequest findByUuid_Last(String uuid, OrderByComparator obc)
771         throws NoSuchRequestException, SystemException {
772         int count = countByUuid(uuid);
773 
774         List<SocialRequest> list = findByUuid(uuid, count - 1, count, obc);
775 
776         if (list.isEmpty()) {
777             StringBundler msg = new StringBundler(4);
778 
779             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
780 
781             msg.append("uuid=");
782             msg.append(uuid);
783 
784             msg.append(StringPool.CLOSE_CURLY_BRACE);
785 
786             throw new NoSuchRequestException(msg.toString());
787         }
788         else {
789             return list.get(0);
790         }
791     }
792 
793     public SocialRequest[] findByUuid_PrevAndNext(long requestId, String uuid,
794         OrderByComparator obc) throws NoSuchRequestException, SystemException {
795         SocialRequest socialRequest = findByPrimaryKey(requestId);
796 
797         int count = countByUuid(uuid);
798 
799         Session session = null;
800 
801         try {
802             session = openSession();
803 
804             StringBundler query = null;
805 
806             if (obc != null) {
807                 query = new StringBundler(3 +
808                         (obc.getOrderByFields().length * 3));
809             }
810             else {
811                 query = new StringBundler(3);
812             }
813 
814             query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
815 
816             if (uuid == null) {
817                 query.append(_FINDER_COLUMN_UUID_UUID_1);
818             }
819             else {
820                 if (uuid.equals(StringPool.BLANK)) {
821                     query.append(_FINDER_COLUMN_UUID_UUID_3);
822                 }
823                 else {
824                     query.append(_FINDER_COLUMN_UUID_UUID_2);
825                 }
826             }
827 
828             if (obc != null) {
829                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
830             }
831 
832             else {
833                 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
834             }
835 
836             String sql = query.toString();
837 
838             Query q = session.createQuery(sql);
839 
840             QueryPos qPos = QueryPos.getInstance(q);
841 
842             if (uuid != null) {
843                 qPos.add(uuid);
844             }
845 
846             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
847                     socialRequest);
848 
849             SocialRequest[] array = new SocialRequestImpl[3];
850 
851             array[0] = (SocialRequest)objArray[0];
852             array[1] = (SocialRequest)objArray[1];
853             array[2] = (SocialRequest)objArray[2];
854 
855             return array;
856         }
857         catch (Exception e) {
858             throw processException(e);
859         }
860         finally {
861             closeSession(session);
862         }
863     }
864 
865     public SocialRequest findByUUID_G(String uuid, long groupId)
866         throws NoSuchRequestException, SystemException {
867         SocialRequest socialRequest = fetchByUUID_G(uuid, groupId);
868 
869         if (socialRequest == null) {
870             StringBundler msg = new StringBundler(6);
871 
872             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
873 
874             msg.append("uuid=");
875             msg.append(uuid);
876 
877             msg.append(", groupId=");
878             msg.append(groupId);
879 
880             msg.append(StringPool.CLOSE_CURLY_BRACE);
881 
882             if (_log.isWarnEnabled()) {
883                 _log.warn(msg.toString());
884             }
885 
886             throw new NoSuchRequestException(msg.toString());
887         }
888 
889         return socialRequest;
890     }
891 
892     public SocialRequest fetchByUUID_G(String uuid, long groupId)
893         throws SystemException {
894         return fetchByUUID_G(uuid, groupId, true);
895     }
896 
897     public SocialRequest fetchByUUID_G(String uuid, long groupId,
898         boolean retrieveFromCache) throws SystemException {
899         Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
900 
901         Object result = null;
902 
903         if (retrieveFromCache) {
904             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
905                     finderArgs, this);
906         }
907 
908         if (result == null) {
909             Session session = null;
910 
911             try {
912                 session = openSession();
913 
914                 StringBundler query = new StringBundler(4);
915 
916                 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
917 
918                 if (uuid == null) {
919                     query.append(_FINDER_COLUMN_UUID_G_UUID_1);
920                 }
921                 else {
922                     if (uuid.equals(StringPool.BLANK)) {
923                         query.append(_FINDER_COLUMN_UUID_G_UUID_3);
924                     }
925                     else {
926                         query.append(_FINDER_COLUMN_UUID_G_UUID_2);
927                     }
928                 }
929 
930                 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
931 
932                 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
933 
934                 String sql = query.toString();
935 
936                 Query q = session.createQuery(sql);
937 
938                 QueryPos qPos = QueryPos.getInstance(q);
939 
940                 if (uuid != null) {
941                     qPos.add(uuid);
942                 }
943 
944                 qPos.add(groupId);
945 
946                 List<SocialRequest> list = q.list();
947 
948                 result = list;
949 
950                 SocialRequest socialRequest = null;
951 
952                 if (list.isEmpty()) {
953                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
954                         finderArgs, list);
955                 }
956                 else {
957                     socialRequest = list.get(0);
958 
959                     cacheResult(socialRequest);
960 
961                     if ((socialRequest.getUuid() == null) ||
962                             !socialRequest.getUuid().equals(uuid) ||
963                             (socialRequest.getGroupId() != groupId)) {
964                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
965                             finderArgs, socialRequest);
966                     }
967                 }
968 
969                 return socialRequest;
970             }
971             catch (Exception e) {
972                 throw processException(e);
973             }
974             finally {
975                 if (result == null) {
976                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
977                         finderArgs, new ArrayList<SocialRequest>());
978                 }
979 
980                 closeSession(session);
981             }
982         }
983         else {
984             if (result instanceof List<?>) {
985                 return null;
986             }
987             else {
988                 return (SocialRequest)result;
989             }
990         }
991     }
992 
993     public List<SocialRequest> findByCompanyId(long companyId)
994         throws SystemException {
995         Object[] finderArgs = new Object[] { new Long(companyId) };
996 
997         List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
998                 finderArgs, this);
999 
1000        if (list == null) {
1001            Session session = null;
1002
1003            try {
1004                session = openSession();
1005
1006                StringBundler query = new StringBundler(3);
1007
1008                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1009
1010                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1011
1012                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1013
1014                String sql = query.toString();
1015
1016                Query q = session.createQuery(sql);
1017
1018                QueryPos qPos = QueryPos.getInstance(q);
1019
1020                qPos.add(companyId);
1021
1022                list = q.list();
1023            }
1024            catch (Exception e) {
1025                throw processException(e);
1026            }
1027            finally {
1028                if (list == null) {
1029                    list = new ArrayList<SocialRequest>();
1030                }
1031
1032                cacheResult(list);
1033
1034                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1035                    finderArgs, list);
1036
1037                closeSession(session);
1038            }
1039        }
1040
1041        return list;
1042    }
1043
1044    public List<SocialRequest> findByCompanyId(long companyId, int start,
1045        int end) throws SystemException {
1046        return findByCompanyId(companyId, start, end, null);
1047    }
1048
1049    public List<SocialRequest> findByCompanyId(long companyId, int start,
1050        int end, OrderByComparator obc) throws SystemException {
1051        Object[] finderArgs = new Object[] {
1052                new Long(companyId),
1053                
1054                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1055            };
1056
1057        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1058                finderArgs, this);
1059
1060        if (list == null) {
1061            Session session = null;
1062
1063            try {
1064                session = openSession();
1065
1066                StringBundler query = null;
1067
1068                if (obc != null) {
1069                    query = new StringBundler(3 +
1070                            (obc.getOrderByFields().length * 3));
1071                }
1072                else {
1073                    query = new StringBundler(3);
1074                }
1075
1076                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1077
1078                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1079
1080                if (obc != null) {
1081                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1082                }
1083
1084                else {
1085                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1086                }
1087
1088                String sql = query.toString();
1089
1090                Query q = session.createQuery(sql);
1091
1092                QueryPos qPos = QueryPos.getInstance(q);
1093
1094                qPos.add(companyId);
1095
1096                list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1097                        start, end);
1098            }
1099            catch (Exception e) {
1100                throw processException(e);
1101            }
1102            finally {
1103                if (list == null) {
1104                    list = new ArrayList<SocialRequest>();
1105                }
1106
1107                cacheResult(list);
1108
1109                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1110                    finderArgs, list);
1111
1112                closeSession(session);
1113            }
1114        }
1115
1116        return list;
1117    }
1118
1119    public SocialRequest findByCompanyId_First(long companyId,
1120        OrderByComparator obc) throws NoSuchRequestException, SystemException {
1121        List<SocialRequest> list = findByCompanyId(companyId, 0, 1, obc);
1122
1123        if (list.isEmpty()) {
1124            StringBundler msg = new StringBundler(4);
1125
1126            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1127
1128            msg.append("companyId=");
1129            msg.append(companyId);
1130
1131            msg.append(StringPool.CLOSE_CURLY_BRACE);
1132
1133            throw new NoSuchRequestException(msg.toString());
1134        }
1135        else {
1136            return list.get(0);
1137        }
1138    }
1139
1140    public SocialRequest findByCompanyId_Last(long companyId,
1141        OrderByComparator obc) throws NoSuchRequestException, SystemException {
1142        int count = countByCompanyId(companyId);
1143
1144        List<SocialRequest> list = findByCompanyId(companyId, count - 1, count,
1145                obc);
1146
1147        if (list.isEmpty()) {
1148            StringBundler msg = new StringBundler(4);
1149
1150            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1151
1152            msg.append("companyId=");
1153            msg.append(companyId);
1154
1155            msg.append(StringPool.CLOSE_CURLY_BRACE);
1156
1157            throw new NoSuchRequestException(msg.toString());
1158        }
1159        else {
1160            return list.get(0);
1161        }
1162    }
1163
1164    public SocialRequest[] findByCompanyId_PrevAndNext(long requestId,
1165        long companyId, OrderByComparator obc)
1166        throws NoSuchRequestException, SystemException {
1167        SocialRequest socialRequest = findByPrimaryKey(requestId);
1168
1169        int count = countByCompanyId(companyId);
1170
1171        Session session = null;
1172
1173        try {
1174            session = openSession();
1175
1176            StringBundler query = null;
1177
1178            if (obc != null) {
1179                query = new StringBundler(3 +
1180                        (obc.getOrderByFields().length * 3));
1181            }
1182            else {
1183                query = new StringBundler(3);
1184            }
1185
1186            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1187
1188            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1189
1190            if (obc != null) {
1191                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1192            }
1193
1194            else {
1195                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1196            }
1197
1198            String sql = query.toString();
1199
1200            Query q = session.createQuery(sql);
1201
1202            QueryPos qPos = QueryPos.getInstance(q);
1203
1204            qPos.add(companyId);
1205
1206            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1207                    socialRequest);
1208
1209            SocialRequest[] array = new SocialRequestImpl[3];
1210
1211            array[0] = (SocialRequest)objArray[0];
1212            array[1] = (SocialRequest)objArray[1];
1213            array[2] = (SocialRequest)objArray[2];
1214
1215            return array;
1216        }
1217        catch (Exception e) {
1218            throw processException(e);
1219        }
1220        finally {
1221            closeSession(session);
1222        }
1223    }
1224
1225    public List<SocialRequest> findByUserId(long userId)
1226        throws SystemException {
1227        Object[] finderArgs = new Object[] { new Long(userId) };
1228
1229        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
1230                finderArgs, this);
1231
1232        if (list == null) {
1233            Session session = null;
1234
1235            try {
1236                session = openSession();
1237
1238                StringBundler query = new StringBundler(3);
1239
1240                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1241
1242                query.append(_FINDER_COLUMN_USERID_USERID_2);
1243
1244                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1245
1246                String sql = query.toString();
1247
1248                Query q = session.createQuery(sql);
1249
1250                QueryPos qPos = QueryPos.getInstance(q);
1251
1252                qPos.add(userId);
1253
1254                list = q.list();
1255            }
1256            catch (Exception e) {
1257                throw processException(e);
1258            }
1259            finally {
1260                if (list == null) {
1261                    list = new ArrayList<SocialRequest>();
1262                }
1263
1264                cacheResult(list);
1265
1266                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
1267                    finderArgs, list);
1268
1269                closeSession(session);
1270            }
1271        }
1272
1273        return list;
1274    }
1275
1276    public List<SocialRequest> findByUserId(long userId, int start, int end)
1277        throws SystemException {
1278        return findByUserId(userId, start, end, null);
1279    }
1280
1281    public List<SocialRequest> findByUserId(long userId, int start, int end,
1282        OrderByComparator obc) throws SystemException {
1283        Object[] finderArgs = new Object[] {
1284                new Long(userId),
1285                
1286                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1287            };
1288
1289        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_USERID,
1290                finderArgs, this);
1291
1292        if (list == null) {
1293            Session session = null;
1294
1295            try {
1296                session = openSession();
1297
1298                StringBundler query = null;
1299
1300                if (obc != null) {
1301                    query = new StringBundler(3 +
1302                            (obc.getOrderByFields().length * 3));
1303                }
1304                else {
1305                    query = new StringBundler(3);
1306                }
1307
1308                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1309
1310                query.append(_FINDER_COLUMN_USERID_USERID_2);
1311
1312                if (obc != null) {
1313                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1314                }
1315
1316                else {
1317                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1318                }
1319
1320                String sql = query.toString();
1321
1322                Query q = session.createQuery(sql);
1323
1324                QueryPos qPos = QueryPos.getInstance(q);
1325
1326                qPos.add(userId);
1327
1328                list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1329                        start, end);
1330            }
1331            catch (Exception e) {
1332                throw processException(e);
1333            }
1334            finally {
1335                if (list == null) {
1336                    list = new ArrayList<SocialRequest>();
1337                }
1338
1339                cacheResult(list);
1340
1341                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_USERID,
1342                    finderArgs, list);
1343
1344                closeSession(session);
1345            }
1346        }
1347
1348        return list;
1349    }
1350
1351    public SocialRequest findByUserId_First(long userId, OrderByComparator obc)
1352        throws NoSuchRequestException, SystemException {
1353        List<SocialRequest> list = findByUserId(userId, 0, 1, obc);
1354
1355        if (list.isEmpty()) {
1356            StringBundler msg = new StringBundler(4);
1357
1358            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1359
1360            msg.append("userId=");
1361            msg.append(userId);
1362
1363            msg.append(StringPool.CLOSE_CURLY_BRACE);
1364
1365            throw new NoSuchRequestException(msg.toString());
1366        }
1367        else {
1368            return list.get(0);
1369        }
1370    }
1371
1372    public SocialRequest findByUserId_Last(long userId, OrderByComparator obc)
1373        throws NoSuchRequestException, SystemException {
1374        int count = countByUserId(userId);
1375
1376        List<SocialRequest> list = findByUserId(userId, count - 1, count, obc);
1377
1378        if (list.isEmpty()) {
1379            StringBundler msg = new StringBundler(4);
1380
1381            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1382
1383            msg.append("userId=");
1384            msg.append(userId);
1385
1386            msg.append(StringPool.CLOSE_CURLY_BRACE);
1387
1388            throw new NoSuchRequestException(msg.toString());
1389        }
1390        else {
1391            return list.get(0);
1392        }
1393    }
1394
1395    public SocialRequest[] findByUserId_PrevAndNext(long requestId,
1396        long userId, OrderByComparator obc)
1397        throws NoSuchRequestException, SystemException {
1398        SocialRequest socialRequest = findByPrimaryKey(requestId);
1399
1400        int count = countByUserId(userId);
1401
1402        Session session = null;
1403
1404        try {
1405            session = openSession();
1406
1407            StringBundler query = null;
1408
1409            if (obc != null) {
1410                query = new StringBundler(3 +
1411                        (obc.getOrderByFields().length * 3));
1412            }
1413            else {
1414                query = new StringBundler(3);
1415            }
1416
1417            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1418
1419            query.append(_FINDER_COLUMN_USERID_USERID_2);
1420
1421            if (obc != null) {
1422                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1423            }
1424
1425            else {
1426                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1427            }
1428
1429            String sql = query.toString();
1430
1431            Query q = session.createQuery(sql);
1432
1433            QueryPos qPos = QueryPos.getInstance(q);
1434
1435            qPos.add(userId);
1436
1437            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1438                    socialRequest);
1439
1440            SocialRequest[] array = new SocialRequestImpl[3];
1441
1442            array[0] = (SocialRequest)objArray[0];
1443            array[1] = (SocialRequest)objArray[1];
1444            array[2] = (SocialRequest)objArray[2];
1445
1446            return array;
1447        }
1448        catch (Exception e) {
1449            throw processException(e);
1450        }
1451        finally {
1452            closeSession(session);
1453        }
1454    }
1455
1456    public List<SocialRequest> findByReceiverUserId(long receiverUserId)
1457        throws SystemException {
1458        Object[] finderArgs = new Object[] { new Long(receiverUserId) };
1459
1460        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_RECEIVERUSERID,
1461                finderArgs, this);
1462
1463        if (list == null) {
1464            Session session = null;
1465
1466            try {
1467                session = openSession();
1468
1469                StringBundler query = new StringBundler(3);
1470
1471                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1472
1473                query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
1474
1475                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1476
1477                String sql = query.toString();
1478
1479                Query q = session.createQuery(sql);
1480
1481                QueryPos qPos = QueryPos.getInstance(q);
1482
1483                qPos.add(receiverUserId);
1484
1485                list = q.list();
1486            }
1487            catch (Exception e) {
1488                throw processException(e);
1489            }
1490            finally {
1491                if (list == null) {
1492                    list = new ArrayList<SocialRequest>();
1493                }
1494
1495                cacheResult(list);
1496
1497                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_RECEIVERUSERID,
1498                    finderArgs, list);
1499
1500                closeSession(session);
1501            }
1502        }
1503
1504        return list;
1505    }
1506
1507    public List<SocialRequest> findByReceiverUserId(long receiverUserId,
1508        int start, int end) throws SystemException {
1509        return findByReceiverUserId(receiverUserId, start, end, null);
1510    }
1511
1512    public List<SocialRequest> findByReceiverUserId(long receiverUserId,
1513        int start, int end, OrderByComparator obc) throws SystemException {
1514        Object[] finderArgs = new Object[] {
1515                new Long(receiverUserId),
1516                
1517                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1518            };
1519
1520        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_RECEIVERUSERID,
1521                finderArgs, this);
1522
1523        if (list == null) {
1524            Session session = null;
1525
1526            try {
1527                session = openSession();
1528
1529                StringBundler query = null;
1530
1531                if (obc != null) {
1532                    query = new StringBundler(3 +
1533                            (obc.getOrderByFields().length * 3));
1534                }
1535                else {
1536                    query = new StringBundler(3);
1537                }
1538
1539                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1540
1541                query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
1542
1543                if (obc != null) {
1544                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1545                }
1546
1547                else {
1548                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1549                }
1550
1551                String sql = query.toString();
1552
1553                Query q = session.createQuery(sql);
1554
1555                QueryPos qPos = QueryPos.getInstance(q);
1556
1557                qPos.add(receiverUserId);
1558
1559                list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1560                        start, end);
1561            }
1562            catch (Exception e) {
1563                throw processException(e);
1564            }
1565            finally {
1566                if (list == null) {
1567                    list = new ArrayList<SocialRequest>();
1568                }
1569
1570                cacheResult(list);
1571
1572                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_RECEIVERUSERID,
1573                    finderArgs, list);
1574
1575                closeSession(session);
1576            }
1577        }
1578
1579        return list;
1580    }
1581
1582    public SocialRequest findByReceiverUserId_First(long receiverUserId,
1583        OrderByComparator obc) throws NoSuchRequestException, SystemException {
1584        List<SocialRequest> list = findByReceiverUserId(receiverUserId, 0, 1,
1585                obc);
1586
1587        if (list.isEmpty()) {
1588            StringBundler msg = new StringBundler(4);
1589
1590            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1591
1592            msg.append("receiverUserId=");
1593            msg.append(receiverUserId);
1594
1595            msg.append(StringPool.CLOSE_CURLY_BRACE);
1596
1597            throw new NoSuchRequestException(msg.toString());
1598        }
1599        else {
1600            return list.get(0);
1601        }
1602    }
1603
1604    public SocialRequest findByReceiverUserId_Last(long receiverUserId,
1605        OrderByComparator obc) throws NoSuchRequestException, SystemException {
1606        int count = countByReceiverUserId(receiverUserId);
1607
1608        List<SocialRequest> list = findByReceiverUserId(receiverUserId,
1609                count - 1, count, obc);
1610
1611        if (list.isEmpty()) {
1612            StringBundler msg = new StringBundler(4);
1613
1614            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1615
1616            msg.append("receiverUserId=");
1617            msg.append(receiverUserId);
1618
1619            msg.append(StringPool.CLOSE_CURLY_BRACE);
1620
1621            throw new NoSuchRequestException(msg.toString());
1622        }
1623        else {
1624            return list.get(0);
1625        }
1626    }
1627
1628    public SocialRequest[] findByReceiverUserId_PrevAndNext(long requestId,
1629        long receiverUserId, OrderByComparator obc)
1630        throws NoSuchRequestException, SystemException {
1631        SocialRequest socialRequest = findByPrimaryKey(requestId);
1632
1633        int count = countByReceiverUserId(receiverUserId);
1634
1635        Session session = null;
1636
1637        try {
1638            session = openSession();
1639
1640            StringBundler query = null;
1641
1642            if (obc != null) {
1643                query = new StringBundler(3 +
1644                        (obc.getOrderByFields().length * 3));
1645            }
1646            else {
1647                query = new StringBundler(3);
1648            }
1649
1650            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1651
1652            query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
1653
1654            if (obc != null) {
1655                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1656            }
1657
1658            else {
1659                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1660            }
1661
1662            String sql = query.toString();
1663
1664            Query q = session.createQuery(sql);
1665
1666            QueryPos qPos = QueryPos.getInstance(q);
1667
1668            qPos.add(receiverUserId);
1669
1670            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1671                    socialRequest);
1672
1673            SocialRequest[] array = new SocialRequestImpl[3];
1674
1675            array[0] = (SocialRequest)objArray[0];
1676            array[1] = (SocialRequest)objArray[1];
1677            array[2] = (SocialRequest)objArray[2];
1678
1679            return array;
1680        }
1681        catch (Exception e) {
1682            throw processException(e);
1683        }
1684        finally {
1685            closeSession(session);
1686        }
1687    }
1688
1689    public List<SocialRequest> findByU_S(long userId, int status)
1690        throws SystemException {
1691        Object[] finderArgs = new Object[] { new Long(userId), new Integer(status) };
1692
1693        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_S,
1694                finderArgs, this);
1695
1696        if (list == null) {
1697            Session session = null;
1698
1699            try {
1700                session = openSession();
1701
1702                StringBundler query = new StringBundler(4);
1703
1704                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1705
1706                query.append(_FINDER_COLUMN_U_S_USERID_2);
1707
1708                query.append(_FINDER_COLUMN_U_S_STATUS_2);
1709
1710                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1711
1712                String sql = query.toString();
1713
1714                Query q = session.createQuery(sql);
1715
1716                QueryPos qPos = QueryPos.getInstance(q);
1717
1718                qPos.add(userId);
1719
1720                qPos.add(status);
1721
1722                list = q.list();
1723            }
1724            catch (Exception e) {
1725                throw processException(e);
1726            }
1727            finally {
1728                if (list == null) {
1729                    list = new ArrayList<SocialRequest>();
1730                }
1731
1732                cacheResult(list);
1733
1734                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_S, finderArgs,
1735                    list);
1736
1737                closeSession(session);
1738            }
1739        }
1740
1741        return list;
1742    }
1743
1744    public List<SocialRequest> findByU_S(long userId, int status, int start,
1745        int end) throws SystemException {
1746        return findByU_S(userId, status, start, end, null);
1747    }
1748
1749    public List<SocialRequest> findByU_S(long userId, int status, int start,
1750        int end, OrderByComparator obc) throws SystemException {
1751        Object[] finderArgs = new Object[] {
1752                new Long(userId), new Integer(status),
1753                
1754                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1755            };
1756
1757        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_U_S,
1758                finderArgs, this);
1759
1760        if (list == null) {
1761            Session session = null;
1762
1763            try {
1764                session = openSession();
1765
1766                StringBundler query = null;
1767
1768                if (obc != null) {
1769                    query = new StringBundler(4 +
1770                            (obc.getOrderByFields().length * 3));
1771                }
1772                else {
1773                    query = new StringBundler(4);
1774                }
1775
1776                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1777
1778                query.append(_FINDER_COLUMN_U_S_USERID_2);
1779
1780                query.append(_FINDER_COLUMN_U_S_STATUS_2);
1781
1782                if (obc != null) {
1783                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1784                }
1785
1786                else {
1787                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1788                }
1789
1790                String sql = query.toString();
1791
1792                Query q = session.createQuery(sql);
1793
1794                QueryPos qPos = QueryPos.getInstance(q);
1795
1796                qPos.add(userId);
1797
1798                qPos.add(status);
1799
1800                list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1801                        start, end);
1802            }
1803            catch (Exception e) {
1804                throw processException(e);
1805            }
1806            finally {
1807                if (list == null) {
1808                    list = new ArrayList<SocialRequest>();
1809                }
1810
1811                cacheResult(list);
1812
1813                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_U_S,
1814                    finderArgs, list);
1815
1816                closeSession(session);
1817            }
1818        }
1819
1820        return list;
1821    }
1822
1823    public SocialRequest findByU_S_First(long userId, int status,
1824        OrderByComparator obc) throws NoSuchRequestException, SystemException {
1825        List<SocialRequest> list = findByU_S(userId, status, 0, 1, obc);
1826
1827        if (list.isEmpty()) {
1828            StringBundler msg = new StringBundler(6);
1829
1830            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1831
1832            msg.append("userId=");
1833            msg.append(userId);
1834
1835            msg.append(", status=");
1836            msg.append(status);
1837
1838            msg.append(StringPool.CLOSE_CURLY_BRACE);
1839
1840            throw new NoSuchRequestException(msg.toString());
1841        }
1842        else {
1843            return list.get(0);
1844        }
1845    }
1846
1847    public SocialRequest findByU_S_Last(long userId, int status,
1848        OrderByComparator obc) throws NoSuchRequestException, SystemException {
1849        int count = countByU_S(userId, status);
1850
1851        List<SocialRequest> list = findByU_S(userId, status, count - 1, count,
1852                obc);
1853
1854        if (list.isEmpty()) {
1855            StringBundler msg = new StringBundler(6);
1856
1857            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1858
1859            msg.append("userId=");
1860            msg.append(userId);
1861
1862            msg.append(", status=");
1863            msg.append(status);
1864
1865            msg.append(StringPool.CLOSE_CURLY_BRACE);
1866
1867            throw new NoSuchRequestException(msg.toString());
1868        }
1869        else {
1870            return list.get(0);
1871        }
1872    }
1873
1874    public SocialRequest[] findByU_S_PrevAndNext(long requestId, long userId,
1875        int status, OrderByComparator obc)
1876        throws NoSuchRequestException, SystemException {
1877        SocialRequest socialRequest = findByPrimaryKey(requestId);
1878
1879        int count = countByU_S(userId, status);
1880
1881        Session session = null;
1882
1883        try {
1884            session = openSession();
1885
1886            StringBundler query = null;
1887
1888            if (obc != null) {
1889                query = new StringBundler(4 +
1890                        (obc.getOrderByFields().length * 3));
1891            }
1892            else {
1893                query = new StringBundler(4);
1894            }
1895
1896            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1897
1898            query.append(_FINDER_COLUMN_U_S_USERID_2);
1899
1900            query.append(_FINDER_COLUMN_U_S_STATUS_2);
1901
1902            if (obc != null) {
1903                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1904            }
1905
1906            else {
1907                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1908            }
1909
1910            String sql = query.toString();
1911
1912            Query q = session.createQuery(sql);
1913
1914            QueryPos qPos = QueryPos.getInstance(q);
1915
1916            qPos.add(userId);
1917
1918            qPos.add(status);
1919
1920            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1921                    socialRequest);
1922
1923            SocialRequest[] array = new SocialRequestImpl[3];
1924
1925            array[0] = (SocialRequest)objArray[0];
1926            array[1] = (SocialRequest)objArray[1];
1927            array[2] = (SocialRequest)objArray[2];
1928
1929            return array;
1930        }
1931        catch (Exception e) {
1932            throw processException(e);
1933        }
1934        finally {
1935            closeSession(session);
1936        }
1937    }
1938
1939    public List<SocialRequest> findByR_S(long receiverUserId, int status)
1940        throws SystemException {
1941        Object[] finderArgs = new Object[] {
1942                new Long(receiverUserId), new Integer(status)
1943            };
1944
1945        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_R_S,
1946                finderArgs, this);
1947
1948        if (list == null) {
1949            Session session = null;
1950
1951            try {
1952                session = openSession();
1953
1954                StringBundler query = new StringBundler(4);
1955
1956                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1957
1958                query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
1959
1960                query.append(_FINDER_COLUMN_R_S_STATUS_2);
1961
1962                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1963
1964                String sql = query.toString();
1965
1966                Query q = session.createQuery(sql);
1967
1968                QueryPos qPos = QueryPos.getInstance(q);
1969
1970                qPos.add(receiverUserId);
1971
1972                qPos.add(status);
1973
1974                list = q.list();
1975            }
1976            catch (Exception e) {
1977                throw processException(e);
1978            }
1979            finally {
1980                if (list == null) {
1981                    list = new ArrayList<SocialRequest>();
1982                }
1983
1984                cacheResult(list);
1985
1986                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_R_S, finderArgs,
1987                    list);
1988
1989                closeSession(session);
1990            }
1991        }
1992
1993        return list;
1994    }
1995
1996    public List<SocialRequest> findByR_S(long receiverUserId, int status,
1997        int start, int end) throws SystemException {
1998        return findByR_S(receiverUserId, status, start, end, null);
1999    }
2000
2001    public List<SocialRequest> findByR_S(long receiverUserId, int status,
2002        int start, int end, OrderByComparator obc) throws SystemException {
2003        Object[] finderArgs = new Object[] {
2004                new Long(receiverUserId), new Integer(status),
2005                
2006                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2007            };
2008
2009        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_R_S,
2010                finderArgs, this);
2011
2012        if (list == null) {
2013            Session session = null;
2014
2015            try {
2016                session = openSession();
2017
2018                StringBundler query = null;
2019
2020                if (obc != null) {
2021                    query = new StringBundler(4 +
2022                            (obc.getOrderByFields().length * 3));
2023                }
2024                else {
2025                    query = new StringBundler(4);
2026                }
2027
2028                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2029
2030                query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
2031
2032                query.append(_FINDER_COLUMN_R_S_STATUS_2);
2033
2034                if (obc != null) {
2035                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2036                }
2037
2038                else {
2039                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2040                }
2041
2042                String sql = query.toString();
2043
2044                Query q = session.createQuery(sql);
2045
2046                QueryPos qPos = QueryPos.getInstance(q);
2047
2048                qPos.add(receiverUserId);
2049
2050                qPos.add(status);
2051
2052                list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
2053                        start, end);
2054            }
2055            catch (Exception e) {
2056                throw processException(e);
2057            }
2058            finally {
2059                if (list == null) {
2060                    list = new ArrayList<SocialRequest>();
2061                }
2062
2063                cacheResult(list);
2064
2065                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_R_S,
2066                    finderArgs, list);
2067
2068                closeSession(session);
2069            }
2070        }
2071
2072        return list;
2073    }
2074
2075    public SocialRequest findByR_S_First(long receiverUserId, int status,
2076        OrderByComparator obc) throws NoSuchRequestException, SystemException {
2077        List<SocialRequest> list = findByR_S(receiverUserId, status, 0, 1, obc);
2078
2079        if (list.isEmpty()) {
2080            StringBundler msg = new StringBundler(6);
2081
2082            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2083
2084            msg.append("receiverUserId=");
2085            msg.append(receiverUserId);
2086
2087            msg.append(", status=");
2088            msg.append(status);
2089
2090            msg.append(StringPool.CLOSE_CURLY_BRACE);
2091
2092            throw new NoSuchRequestException(msg.toString());
2093        }
2094        else {
2095            return list.get(0);
2096        }
2097    }
2098
2099    public SocialRequest findByR_S_Last(long receiverUserId, int status,
2100        OrderByComparator obc) throws NoSuchRequestException, SystemException {
2101        int count = countByR_S(receiverUserId, status);
2102
2103        List<SocialRequest> list = findByR_S(receiverUserId, status, count - 1,
2104                count, obc);
2105
2106        if (list.isEmpty()) {
2107            StringBundler msg = new StringBundler(6);
2108
2109            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2110
2111            msg.append("receiverUserId=");
2112            msg.append(receiverUserId);
2113
2114            msg.append(", status=");
2115            msg.append(status);
2116
2117            msg.append(StringPool.CLOSE_CURLY_BRACE);
2118
2119            throw new NoSuchRequestException(msg.toString());
2120        }
2121        else {
2122            return list.get(0);
2123        }
2124    }
2125
2126    public SocialRequest[] findByR_S_PrevAndNext(long requestId,
2127        long receiverUserId, int status, OrderByComparator obc)
2128        throws NoSuchRequestException, SystemException {
2129        SocialRequest socialRequest = findByPrimaryKey(requestId);
2130
2131        int count = countByR_S(receiverUserId, status);
2132
2133        Session session = null;
2134
2135        try {
2136            session = openSession();
2137
2138            StringBundler query = null;
2139
2140            if (obc != null) {
2141                query = new StringBundler(4 +
2142                        (obc.getOrderByFields().length * 3));
2143            }
2144            else {
2145                query = new StringBundler(4);
2146            }
2147
2148            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2149
2150            query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
2151
2152            query.append(_FINDER_COLUMN_R_S_STATUS_2);
2153
2154            if (obc != null) {
2155                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2156            }
2157
2158            else {
2159                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2160            }
2161
2162            String sql = query.toString();
2163
2164            Query q = session.createQuery(sql);
2165
2166            QueryPos qPos = QueryPos.getInstance(q);
2167
2168            qPos.add(receiverUserId);
2169
2170            qPos.add(status);
2171
2172            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2173                    socialRequest);
2174
2175            SocialRequest[] array = new SocialRequestImpl[3];
2176
2177            array[0] = (SocialRequest)objArray[0];
2178            array[1] = (SocialRequest)objArray[1];
2179            array[2] = (SocialRequest)objArray[2];
2180
2181            return array;
2182        }
2183        catch (Exception e) {
2184            throw processException(e);
2185        }
2186        finally {
2187            closeSession(session);
2188        }
2189    }
2190
2191    public SocialRequest findByU_C_C_T_R(long userId, long classNameId,
2192        long classPK, int type, long receiverUserId)
2193        throws NoSuchRequestException, SystemException {
2194        SocialRequest socialRequest = fetchByU_C_C_T_R(userId, classNameId,
2195                classPK, type, receiverUserId);
2196
2197        if (socialRequest == null) {
2198            StringBundler msg = new StringBundler(12);
2199
2200            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2201
2202            msg.append("userId=");
2203            msg.append(userId);
2204
2205            msg.append(", classNameId=");
2206            msg.append(classNameId);
2207
2208            msg.append(", classPK=");
2209            msg.append(classPK);
2210
2211            msg.append(", type=");
2212            msg.append(type);
2213
2214            msg.append(", receiverUserId=");
2215            msg.append(receiverUserId);
2216
2217            msg.append(StringPool.CLOSE_CURLY_BRACE);
2218
2219            if (_log.isWarnEnabled()) {
2220                _log.warn(msg.toString());
2221            }
2222
2223            throw new NoSuchRequestException(msg.toString());
2224        }
2225
2226        return socialRequest;
2227    }
2228
2229    public SocialRequest fetchByU_C_C_T_R(long userId, long classNameId,
2230        long classPK, int type, long receiverUserId) throws SystemException {
2231        return fetchByU_C_C_T_R(userId, classNameId, classPK, type,
2232            receiverUserId, true);
2233    }
2234
2235    public SocialRequest fetchByU_C_C_T_R(long userId, long classNameId,
2236        long classPK, int type, long receiverUserId, boolean retrieveFromCache)
2237        throws SystemException {
2238        Object[] finderArgs = new Object[] {
2239                new Long(userId), new Long(classNameId), new Long(classPK),
2240                new Integer(type), new Long(receiverUserId)
2241            };
2242
2243        Object result = null;
2244
2245        if (retrieveFromCache) {
2246            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
2247                    finderArgs, this);
2248        }
2249
2250        if (result == null) {
2251            Session session = null;
2252
2253            try {
2254                session = openSession();
2255
2256                StringBundler query = new StringBundler(7);
2257
2258                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2259
2260                query.append(_FINDER_COLUMN_U_C_C_T_R_USERID_2);
2261
2262                query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2);
2263
2264                query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSPK_2);
2265
2266                query.append(_FINDER_COLUMN_U_C_C_T_R_TYPE_2);
2267
2268                query.append(_FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2);
2269
2270                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2271
2272                String sql = query.toString();
2273
2274                Query q = session.createQuery(sql);
2275
2276                QueryPos qPos = QueryPos.getInstance(q);
2277
2278                qPos.add(userId);
2279
2280                qPos.add(classNameId);
2281
2282                qPos.add(classPK);
2283
2284                qPos.add(type);
2285
2286                qPos.add(receiverUserId);
2287
2288                List<SocialRequest> list = q.list();
2289
2290                result = list;
2291
2292                SocialRequest socialRequest = null;
2293
2294                if (list.isEmpty()) {
2295                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
2296                        finderArgs, list);
2297                }
2298                else {
2299                    socialRequest = list.get(0);
2300
2301                    cacheResult(socialRequest);
2302
2303                    if ((socialRequest.getUserId() != userId) ||
2304                            (socialRequest.getClassNameId() != classNameId) ||
2305                            (socialRequest.getClassPK() != classPK) ||
2306                            (socialRequest.getType() != type) ||
2307                            (socialRequest.getReceiverUserId() != receiverUserId)) {
2308                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
2309                            finderArgs, socialRequest);
2310                    }
2311                }
2312
2313                return socialRequest;
2314            }
2315            catch (Exception e) {
2316                throw processException(e);
2317            }
2318            finally {
2319                if (result == null) {
2320                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
2321                        finderArgs, new ArrayList<SocialRequest>());
2322                }
2323
2324                closeSession(session);
2325            }
2326        }
2327        else {
2328            if (result instanceof List<?>) {
2329                return null;
2330            }
2331            else {
2332                return (SocialRequest)result;
2333            }
2334        }
2335    }
2336
2337    public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
2338        long classPK, int type, int status) throws SystemException {
2339        Object[] finderArgs = new Object[] {
2340                new Long(userId), new Long(classNameId), new Long(classPK),
2341                new Integer(type), new Integer(status)
2342            };
2343
2344        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_C_C_T_S,
2345                finderArgs, this);
2346
2347        if (list == null) {
2348            Session session = null;
2349
2350            try {
2351                session = openSession();
2352
2353                StringBundler query = new StringBundler(7);
2354
2355                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2356
2357                query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
2358
2359                query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
2360
2361                query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
2362
2363                query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
2364
2365                query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
2366
2367                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2368
2369                String sql = query.toString();
2370
2371                Query q = session.createQuery(sql);
2372
2373                QueryPos qPos = QueryPos.getInstance(q);
2374
2375                qPos.add(userId);
2376
2377                qPos.add(classNameId);
2378
2379                qPos.add(classPK);
2380
2381                qPos.add(type);
2382
2383                qPos.add(status);
2384
2385                list = q.list();
2386            }
2387            catch (Exception e) {
2388                throw processException(e);
2389            }
2390            finally {
2391                if (list == null) {
2392                    list = new ArrayList<SocialRequest>();
2393                }
2394
2395                cacheResult(list);
2396
2397                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_C_C_T_S,
2398                    finderArgs, list);
2399
2400                closeSession(session);
2401            }
2402        }
2403
2404        return list;
2405    }
2406
2407    public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
2408        long classPK, int type, int status, int start, int end)
2409        throws SystemException {
2410        return findByU_C_C_T_S(userId, classNameId, classPK, type, status,
2411            start, end, null);
2412    }
2413
2414    public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
2415        long classPK, int type, int status, int start, int end,
2416        OrderByComparator obc) throws SystemException {
2417        Object[] finderArgs = new Object[] {
2418                new Long(userId), new Long(classNameId), new Long(classPK),
2419                new Integer(type), new Integer(status),
2420                
2421                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2422            };
2423
2424        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_U_C_C_T_S,
2425                finderArgs, this);
2426
2427        if (list == null) {
2428            Session session = null;
2429
2430            try {
2431                session = openSession();
2432
2433                StringBundler query = null;
2434
2435                if (obc != null) {
2436                    query = new StringBundler(7 +
2437                            (obc.getOrderByFields().length * 3));
2438                }
2439                else {
2440                    query = new StringBundler(7);
2441                }
2442
2443                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2444
2445                query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
2446
2447                query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
2448
2449                query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
2450
2451                query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
2452
2453                query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
2454
2455                if (obc != null) {
2456                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2457                }
2458
2459                else {
2460                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2461                }
2462
2463                String sql = query.toString();
2464
2465                Query q = session.createQuery(sql);
2466
2467                QueryPos qPos = QueryPos.getInstance(q);
2468
2469                qPos.add(userId);
2470
2471                qPos.add(classNameId);
2472
2473                qPos.add(classPK);
2474
2475                qPos.add(type);
2476
2477                qPos.add(status);
2478
2479                list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
2480                        start, end);
2481            }
2482            catch (Exception e) {
2483                throw processException(e);
2484            }
2485            finally {
2486                if (list == null) {
2487                    list = new ArrayList<SocialRequest>();
2488                }
2489
2490                cacheResult(list);
2491
2492                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_U_C_C_T_S,
2493                    finderArgs, list);
2494
2495                closeSession(session);
2496            }
2497        }
2498
2499        return list;
2500    }
2501
2502    public SocialRequest findByU_C_C_T_S_First(long userId, long classNameId,
2503        long classPK, int type, int status, OrderByComparator obc)
2504        throws NoSuchRequestException, SystemException {
2505        List<SocialRequest> list = findByU_C_C_T_S(userId, classNameId,
2506                classPK, type, status, 0, 1, obc);
2507
2508        if (list.isEmpty()) {
2509            StringBundler msg = new StringBundler(12);
2510
2511            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2512
2513            msg.append("userId=");
2514            msg.append(userId);
2515
2516            msg.append(", classNameId=");
2517            msg.append(classNameId);
2518
2519            msg.append(", classPK=");
2520            msg.append(classPK);
2521
2522            msg.append(", type=");
2523            msg.append(type);
2524
2525            msg.append(", status=");
2526            msg.append(status);
2527
2528            msg.append(StringPool.CLOSE_CURLY_BRACE);
2529
2530            throw new NoSuchRequestException(msg.toString());
2531        }
2532        else {
2533            return list.get(0);
2534        }
2535    }
2536
2537    public SocialRequest findByU_C_C_T_S_Last(long userId, long classNameId,
2538        long classPK, int type, int status, OrderByComparator obc)
2539        throws NoSuchRequestException, SystemException {
2540        int count = countByU_C_C_T_S(userId, classNameId, classPK, type, status);
2541
2542        List<SocialRequest> list = findByU_C_C_T_S(userId, classNameId,
2543                classPK, type, status, count - 1, count, obc);
2544
2545        if (list.isEmpty()) {
2546            StringBundler msg = new StringBundler(12);
2547
2548            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2549
2550            msg.append("userId=");
2551            msg.append(userId);
2552
2553            msg.append(", classNameId=");
2554            msg.append(classNameId);
2555
2556            msg.append(", classPK=");
2557            msg.append(classPK);
2558
2559            msg.append(", type=");
2560            msg.append(type);
2561
2562            msg.append(", status=");
2563            msg.append(status);
2564
2565            msg.append(StringPool.CLOSE_CURLY_BRACE);
2566
2567            throw new NoSuchRequestException(msg.toString());
2568        }
2569        else {
2570            return list.get(0);
2571        }
2572    }
2573
2574    public SocialRequest[] findByU_C_C_T_S_PrevAndNext(long requestId,
2575        long userId, long classNameId, long classPK, int type, int status,
2576        OrderByComparator obc) throws NoSuchRequestException, SystemException {
2577        SocialRequest socialRequest = findByPrimaryKey(requestId);
2578
2579        int count = countByU_C_C_T_S(userId, classNameId, classPK, type, status);
2580
2581        Session session = null;
2582
2583        try {
2584            session = openSession();
2585
2586            StringBundler query = null;
2587
2588            if (obc != null) {
2589                query = new StringBundler(7 +
2590                        (obc.getOrderByFields().length * 3));
2591            }
2592            else {
2593                query = new StringBundler(7);
2594            }
2595
2596            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2597
2598            query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
2599
2600            query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
2601
2602            query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
2603
2604            query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
2605
2606            query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
2607
2608            if (obc != null) {
2609                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2610            }
2611
2612            else {
2613                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2614            }
2615
2616            String sql = query.toString();
2617
2618            Query q = session.createQuery(sql);
2619
2620            QueryPos qPos = QueryPos.getInstance(q);
2621
2622            qPos.add(userId);
2623
2624            qPos.add(classNameId);
2625
2626            qPos.add(classPK);
2627
2628            qPos.add(type);
2629
2630            qPos.add(status);
2631
2632            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2633                    socialRequest);
2634
2635            SocialRequest[] array = new SocialRequestImpl[3];
2636
2637            array[0] = (SocialRequest)objArray[0];
2638            array[1] = (SocialRequest)objArray[1];
2639            array[2] = (SocialRequest)objArray[2];
2640
2641            return array;
2642        }
2643        catch (Exception e) {
2644            throw processException(e);
2645        }
2646        finally {
2647            closeSession(session);
2648        }
2649    }
2650
2651    public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
2652        int type, long receiverUserId, int status) throws SystemException {
2653        Object[] finderArgs = new Object[] {
2654                new Long(classNameId), new Long(classPK), new Integer(type),
2655                new Long(receiverUserId), new Integer(status)
2656            };
2657
2658        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C_T_R_S,
2659                finderArgs, this);
2660
2661        if (list == null) {
2662            Session session = null;
2663
2664            try {
2665                session = openSession();
2666
2667                StringBundler query = new StringBundler(7);
2668
2669                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2670
2671                query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
2672
2673                query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
2674
2675                query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
2676
2677                query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
2678
2679                query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
2680
2681                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2682
2683                String sql = query.toString();
2684
2685                Query q = session.createQuery(sql);
2686
2687                QueryPos qPos = QueryPos.getInstance(q);
2688
2689                qPos.add(classNameId);
2690
2691                qPos.add(classPK);
2692
2693                qPos.add(type);
2694
2695                qPos.add(receiverUserId);
2696
2697                qPos.add(status);
2698
2699                list = q.list();
2700            }
2701            catch (Exception e) {
2702                throw processException(e);
2703            }
2704            finally {
2705                if (list == null) {
2706                    list = new ArrayList<SocialRequest>();
2707                }
2708
2709                cacheResult(list);
2710
2711                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C_T_R_S,
2712                    finderArgs, list);
2713
2714                closeSession(session);
2715            }
2716        }
2717
2718        return list;
2719    }
2720
2721    public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
2722        int type, long receiverUserId, int status, int start, int end)
2723        throws SystemException {
2724        return findByC_C_T_R_S(classNameId, classPK, type, receiverUserId,
2725            status, start, end, null);
2726    }
2727
2728    public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
2729        int type, long receiverUserId, int status, int start, int end,
2730        OrderByComparator obc) throws SystemException {
2731        Object[] finderArgs = new Object[] {
2732                new Long(classNameId), new Long(classPK), new Integer(type),
2733                new Long(receiverUserId), new Integer(status),
2734                
2735                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2736            };
2737
2738        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_C_T_R_S,
2739                finderArgs, this);
2740
2741        if (list == null) {
2742            Session session = null;
2743
2744            try {
2745                session = openSession();
2746
2747                StringBundler query = null;
2748
2749                if (obc != null) {
2750                    query = new StringBundler(7 +
2751                            (obc.getOrderByFields().length * 3));
2752                }
2753                else {
2754                    query = new StringBundler(7);
2755                }
2756
2757                query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2758
2759                query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
2760
2761                query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
2762
2763                query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
2764
2765                query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
2766
2767                query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
2768
2769                if (obc != null) {
2770                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2771                }
2772
2773                else {
2774                    query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2775                }
2776
2777                String sql = query.toString();
2778
2779                Query q = session.createQuery(sql);
2780
2781                QueryPos qPos = QueryPos.getInstance(q);
2782
2783                qPos.add(classNameId);
2784
2785                qPos.add(classPK);
2786
2787                qPos.add(type);
2788
2789                qPos.add(receiverUserId);
2790
2791                qPos.add(status);
2792
2793                list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
2794                        start, end);
2795            }
2796            catch (Exception e) {
2797                throw processException(e);
2798            }
2799            finally {
2800                if (list == null) {
2801                    list = new ArrayList<SocialRequest>();
2802                }
2803
2804                cacheResult(list);
2805
2806                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_C_T_R_S,
2807                    finderArgs, list);
2808
2809                closeSession(session);
2810            }
2811        }
2812
2813        return list;
2814    }
2815
2816    public SocialRequest findByC_C_T_R_S_First(long classNameId, long classPK,
2817        int type, long receiverUserId, int status, OrderByComparator obc)
2818        throws NoSuchRequestException, SystemException {
2819        List<SocialRequest> list = findByC_C_T_R_S(classNameId, classPK, type,
2820                receiverUserId, status, 0, 1, obc);
2821
2822        if (list.isEmpty()) {
2823            StringBundler msg = new StringBundler(12);
2824
2825            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2826
2827            msg.append("classNameId=");
2828            msg.append(classNameId);
2829
2830            msg.append(", classPK=");
2831            msg.append(classPK);
2832
2833            msg.append(", type=");
2834            msg.append(type);
2835
2836            msg.append(", receiverUserId=");
2837            msg.append(receiverUserId);
2838
2839            msg.append(", status=");
2840            msg.append(status);
2841
2842            msg.append(StringPool.CLOSE_CURLY_BRACE);
2843
2844            throw new NoSuchRequestException(msg.toString());
2845        }
2846        else {
2847            return list.get(0);
2848        }
2849    }
2850
2851    public SocialRequest findByC_C_T_R_S_Last(long classNameId, long classPK,
2852        int type, long receiverUserId, int status, OrderByComparator obc)
2853        throws NoSuchRequestException, SystemException {
2854        int count = countByC_C_T_R_S(classNameId, classPK, type,
2855                receiverUserId, status);
2856
2857        List<SocialRequest> list = findByC_C_T_R_S(classNameId, classPK, type,
2858                receiverUserId, status, count - 1, count, obc);
2859
2860        if (list.isEmpty()) {
2861            StringBundler msg = new StringBundler(12);
2862
2863            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2864
2865            msg.append("classNameId=");
2866            msg.append(classNameId);
2867
2868            msg.append(", classPK=");
2869            msg.append(classPK);
2870
2871            msg.append(", type=");
2872            msg.append(type);
2873
2874            msg.append(", receiverUserId=");
2875            msg.append(receiverUserId);
2876
2877            msg.append(", status=");
2878            msg.append(status);
2879
2880            msg.append(StringPool.CLOSE_CURLY_BRACE);
2881
2882            throw new NoSuchRequestException(msg.toString());
2883        }
2884        else {
2885            return list.get(0);
2886        }
2887    }
2888
2889    public SocialRequest[] findByC_C_T_R_S_PrevAndNext(long requestId,
2890        long classNameId, long classPK, int type, long receiverUserId,
2891        int status, OrderByComparator obc)
2892        throws NoSuchRequestException, SystemException {
2893        SocialRequest socialRequest = findByPrimaryKey(requestId);
2894
2895        int count = countByC_C_T_R_S(classNameId, classPK, type,
2896                receiverUserId, status);
2897
2898        Session session = null;
2899
2900        try {
2901            session = openSession();
2902
2903            StringBundler query = null;
2904
2905            if (obc != null) {
2906                query = new StringBundler(7 +
2907                        (obc.getOrderByFields().length * 3));
2908            }
2909            else {
2910                query = new StringBundler(7);
2911            }
2912
2913            query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2914
2915            query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
2916
2917            query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
2918
2919            query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
2920
2921            query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
2922
2923            query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
2924
2925            if (obc != null) {
2926                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2927            }
2928
2929            else {
2930                query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2931            }
2932
2933            String sql = query.toString();
2934
2935            Query q = session.createQuery(sql);
2936
2937            QueryPos qPos = QueryPos.getInstance(q);
2938
2939            qPos.add(classNameId);
2940
2941            qPos.add(classPK);
2942
2943            qPos.add(type);
2944
2945            qPos.add(receiverUserId);
2946
2947            qPos.add(status);
2948
2949            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2950                    socialRequest);
2951
2952            SocialRequest[] array = new SocialRequestImpl[3];
2953
2954            array[0] = (SocialRequest)objArray[0];
2955            array[1] = (SocialRequest)objArray[1];
2956            array[2] = (SocialRequest)objArray[2];
2957
2958            return array;
2959        }
2960        catch (Exception e) {
2961            throw processException(e);
2962        }
2963        finally {
2964            closeSession(session);
2965        }
2966    }
2967
2968    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2969        throws SystemException {
2970        Session session = null;
2971
2972        try {
2973            session = openSession();
2974
2975            dynamicQuery.compile(session);
2976
2977            return dynamicQuery.list();
2978        }
2979        catch (Exception e) {
2980            throw processException(e);
2981        }
2982        finally {
2983            closeSession(session);
2984        }
2985    }
2986
2987    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
2988        int start, int end) throws SystemException {
2989        Session session = null;
2990
2991        try {
2992            session = openSession();
2993
2994            dynamicQuery.setLimit(start, end);
2995
2996            dynamicQuery.compile(session);
2997
2998            return dynamicQuery.list();
2999        }
3000        catch (Exception e) {
3001            throw processException(e);
3002        }
3003        finally {
3004            closeSession(session);
3005        }
3006    }
3007
3008    public List<SocialRequest> findAll() throws SystemException {
3009        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3010    }
3011
3012    public List<SocialRequest> findAll(int start, int end)
3013        throws SystemException {
3014        return findAll(start, end, null);
3015    }
3016
3017    public List<SocialRequest> findAll(int start, int end, OrderByComparator obc)
3018        throws SystemException {
3019        Object[] finderArgs = new Object[] {
3020                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
3021            };
3022
3023        List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3024                finderArgs, this);
3025
3026        if (list == null) {
3027            Session session = null;
3028
3029            try {
3030                session = openSession();
3031
3032                StringBundler query = null;
3033                String sql = null;
3034
3035                if (obc != null) {
3036                    query = new StringBundler(2 +
3037                            (obc.getOrderByFields().length * 3));
3038
3039                    query.append(_SQL_SELECT_SOCIALREQUEST);
3040
3041                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3042
3043                    sql = query.toString();
3044                }
3045
3046                else {
3047                    sql = _SQL_SELECT_SOCIALREQUEST.concat(SocialRequestModelImpl.ORDER_BY_JPQL);
3048                }
3049
3050                Query q = session.createQuery(sql);
3051
3052                if (obc == null) {
3053                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3054                            start, end, false);
3055
3056                    Collections.sort(list);
3057                }
3058                else {
3059                    list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3060                            start, end);
3061                }
3062            }
3063            catch (Exception e) {
3064                throw processException(e);
3065            }
3066            finally {
3067                if (list == null) {
3068                    list = new ArrayList<SocialRequest>();
3069                }
3070
3071                cacheResult(list);
3072
3073                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3074
3075                closeSession(session);
3076            }
3077        }
3078
3079        return list;
3080    }
3081
3082    public void removeByUuid(String uuid) throws SystemException {
3083        for (SocialRequest socialRequest : findByUuid(uuid)) {
3084            remove(socialRequest);
3085        }
3086    }
3087
3088    public void removeByUUID_G(String uuid, long groupId)
3089        throws NoSuchRequestException, SystemException {
3090        SocialRequest socialRequest = findByUUID_G(uuid, groupId);
3091
3092        remove(socialRequest);
3093    }
3094
3095    public void removeByCompanyId(long companyId) throws SystemException {
3096        for (SocialRequest socialRequest : findByCompanyId(companyId)) {
3097            remove(socialRequest);
3098        }
3099    }
3100
3101    public void removeByUserId(long userId) throws SystemException {
3102        for (SocialRequest socialRequest : findByUserId(userId)) {
3103            remove(socialRequest);
3104        }
3105    }
3106
3107    public void removeByReceiverUserId(long receiverUserId)
3108        throws SystemException {
3109        for (SocialRequest socialRequest : findByReceiverUserId(receiverUserId)) {
3110            remove(socialRequest);
3111        }
3112    }
3113
3114    public void removeByU_S(long userId, int status) throws SystemException {
3115        for (SocialRequest socialRequest : findByU_S(userId, status)) {
3116            remove(socialRequest);
3117        }
3118    }
3119
3120    public void removeByR_S(long receiverUserId, int status)
3121        throws SystemException {
3122        for (SocialRequest socialRequest : findByR_S(receiverUserId, status)) {
3123            remove(socialRequest);
3124        }
3125    }
3126
3127    public void removeByU_C_C_T_R(long userId, long classNameId, long classPK,
3128        int type, long receiverUserId)
3129        throws NoSuchRequestException, SystemException {
3130        SocialRequest socialRequest = findByU_C_C_T_R(userId, classNameId,
3131                classPK, type, receiverUserId);
3132
3133        remove(socialRequest);
3134    }
3135
3136    public void removeByU_C_C_T_S(long userId, long classNameId, long classPK,
3137        int type, int status) throws SystemException {
3138        for (SocialRequest socialRequest : findByU_C_C_T_S(userId, classNameId,
3139                classPK, type, status)) {
3140            remove(socialRequest);
3141        }
3142    }
3143
3144    public void removeByC_C_T_R_S(long classNameId, long classPK, int type,
3145        long receiverUserId, int status) throws SystemException {
3146        for (SocialRequest socialRequest : findByC_C_T_R_S(classNameId,
3147                classPK, type, receiverUserId, status)) {
3148            remove(socialRequest);
3149        }
3150    }
3151
3152    public void removeAll() throws SystemException {
3153        for (SocialRequest socialRequest : findAll()) {
3154            remove(socialRequest);
3155        }
3156    }
3157
3158    public int countByUuid(String uuid) throws SystemException {
3159        Object[] finderArgs = new Object[] { uuid };
3160
3161        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3162                finderArgs, this);
3163
3164        if (count == null) {
3165            Session session = null;
3166
3167            try {
3168                session = openSession();
3169
3170                StringBundler query = new StringBundler(2);
3171
3172                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3173
3174                if (uuid == null) {
3175                    query.append(_FINDER_COLUMN_UUID_UUID_1);
3176                }
3177                else {
3178                    if (uuid.equals(StringPool.BLANK)) {
3179                        query.append(_FINDER_COLUMN_UUID_UUID_3);
3180                    }
3181                    else {
3182                        query.append(_FINDER_COLUMN_UUID_UUID_2);
3183                    }
3184                }
3185
3186                String sql = query.toString();
3187
3188                Query q = session.createQuery(sql);
3189
3190                QueryPos qPos = QueryPos.getInstance(q);
3191
3192                if (uuid != null) {
3193                    qPos.add(uuid);
3194                }
3195
3196                count = (Long)q.uniqueResult();
3197            }
3198            catch (Exception e) {
3199                throw processException(e);
3200            }
3201            finally {
3202                if (count == null) {
3203                    count = Long.valueOf(0);
3204                }
3205
3206                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3207                    finderArgs, count);
3208
3209                closeSession(session);
3210            }
3211        }
3212
3213        return count.intValue();
3214    }
3215
3216    public int countByUUID_G(String uuid, long groupId)
3217        throws SystemException {
3218        Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
3219
3220        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3221                finderArgs, this);
3222
3223        if (count == null) {
3224            Session session = null;
3225
3226            try {
3227                session = openSession();
3228
3229                StringBundler query = new StringBundler(3);
3230
3231                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3232
3233                if (uuid == null) {
3234                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3235                }
3236                else {
3237                    if (uuid.equals(StringPool.BLANK)) {
3238                        query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3239                    }
3240                    else {
3241                        query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3242                    }
3243                }
3244
3245                query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3246
3247                String sql = query.toString();
3248
3249                Query q = session.createQuery(sql);
3250
3251                QueryPos qPos = QueryPos.getInstance(q);
3252
3253                if (uuid != null) {
3254                    qPos.add(uuid);
3255                }
3256
3257                qPos.add(groupId);
3258
3259                count = (Long)q.uniqueResult();
3260            }
3261            catch (Exception e) {
3262                throw processException(e);
3263            }
3264            finally {
3265                if (count == null) {
3266                    count = Long.valueOf(0);
3267                }
3268
3269                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3270                    finderArgs, count);
3271
3272                closeSession(session);
3273            }
3274        }
3275
3276        return count.intValue();
3277    }
3278
3279    public int countByCompanyId(long companyId) throws SystemException {
3280        Object[] finderArgs = new Object[] { new Long(companyId) };
3281
3282        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3283                finderArgs, this);
3284
3285        if (count == null) {
3286            Session session = null;
3287
3288            try {
3289                session = openSession();
3290
3291                StringBundler query = new StringBundler(2);
3292
3293                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3294
3295                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3296
3297                String sql = query.toString();
3298
3299                Query q = session.createQuery(sql);
3300
3301                QueryPos qPos = QueryPos.getInstance(q);
3302
3303                qPos.add(companyId);
3304
3305                count = (Long)q.uniqueResult();
3306            }
3307            catch (Exception e) {
3308                throw processException(e);
3309            }
3310            finally {
3311                if (count == null) {
3312                    count = Long.valueOf(0);
3313                }
3314
3315                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3316                    finderArgs, count);
3317
3318                closeSession(session);
3319            }
3320        }
3321
3322        return count.intValue();
3323    }
3324
3325    public int countByUserId(long userId) throws SystemException {
3326        Object[] finderArgs = new Object[] { new Long(userId) };
3327
3328        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
3329                finderArgs, this);
3330
3331        if (count == null) {
3332            Session session = null;
3333
3334            try {
3335                session = openSession();
3336
3337                StringBundler query = new StringBundler(2);
3338
3339                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3340
3341                query.append(_FINDER_COLUMN_USERID_USERID_2);
3342
3343                String sql = query.toString();
3344
3345                Query q = session.createQuery(sql);
3346
3347                QueryPos qPos = QueryPos.getInstance(q);
3348
3349                qPos.add(userId);
3350
3351                count = (Long)q.uniqueResult();
3352            }
3353            catch (Exception e) {
3354                throw processException(e);
3355            }
3356            finally {
3357                if (count == null) {
3358                    count = Long.valueOf(0);
3359                }
3360
3361                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
3362                    finderArgs, count);
3363
3364                closeSession(session);
3365            }
3366        }
3367
3368        return count.intValue();
3369    }
3370
3371    public int countByReceiverUserId(long receiverUserId)
3372        throws SystemException {
3373        Object[] finderArgs = new Object[] { new Long(receiverUserId) };
3374
3375        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
3376                finderArgs, this);
3377
3378        if (count == null) {
3379            Session session = null;
3380
3381            try {
3382                session = openSession();
3383
3384                StringBundler query = new StringBundler(2);
3385
3386                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3387
3388                query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
3389
3390                String sql = query.toString();
3391
3392                Query q = session.createQuery(sql);
3393
3394                QueryPos qPos = QueryPos.getInstance(q);
3395
3396                qPos.add(receiverUserId);
3397
3398                count = (Long)q.uniqueResult();
3399            }
3400            catch (Exception e) {
3401                throw processException(e);
3402            }
3403            finally {
3404                if (count == null) {
3405                    count = Long.valueOf(0);
3406                }
3407
3408                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
3409                    finderArgs, count);
3410
3411                closeSession(session);
3412            }
3413        }
3414
3415        return count.intValue();
3416    }
3417
3418    public int countByU_S(long userId, int status) throws SystemException {
3419        Object[] finderArgs = new Object[] { new Long(userId), new Integer(status) };
3420
3421        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_S,
3422                finderArgs, this);
3423
3424        if (count == null) {
3425            Session session = null;
3426
3427            try {
3428                session = openSession();
3429
3430                StringBundler query = new StringBundler(3);
3431
3432                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3433
3434                query.append(_FINDER_COLUMN_U_S_USERID_2);
3435
3436                query.append(_FINDER_COLUMN_U_S_STATUS_2);
3437
3438                String sql = query.toString();
3439
3440                Query q = session.createQuery(sql);
3441
3442                QueryPos qPos = QueryPos.getInstance(q);
3443
3444                qPos.add(userId);
3445
3446                qPos.add(status);
3447
3448                count = (Long)q.uniqueResult();
3449            }
3450            catch (Exception e) {
3451                throw processException(e);
3452            }
3453            finally {
3454                if (count == null) {
3455                    count = Long.valueOf(0);
3456                }
3457
3458                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_S, finderArgs,
3459                    count);
3460
3461                closeSession(session);
3462            }
3463        }
3464
3465        return count.intValue();
3466    }
3467
3468    public int countByR_S(long receiverUserId, int status)
3469        throws SystemException {
3470        Object[] finderArgs = new Object[] {
3471                new Long(receiverUserId), new Integer(status)
3472            };
3473
3474        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_S,
3475                finderArgs, this);
3476
3477        if (count == null) {
3478            Session session = null;
3479
3480            try {
3481                session = openSession();
3482
3483                StringBundler query = new StringBundler(3);
3484
3485                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3486
3487                query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
3488
3489                query.append(_FINDER_COLUMN_R_S_STATUS_2);
3490
3491                String sql = query.toString();
3492
3493                Query q = session.createQuery(sql);
3494
3495                QueryPos qPos = QueryPos.getInstance(q);
3496
3497                qPos.add(receiverUserId);
3498
3499                qPos.add(status);
3500
3501                count = (Long)q.uniqueResult();
3502            }
3503            catch (Exception e) {
3504                throw processException(e);
3505            }
3506            finally {
3507                if (count == null) {
3508                    count = Long.valueOf(0);
3509                }
3510
3511                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_S, finderArgs,
3512                    count);
3513
3514                closeSession(session);
3515            }
3516        }
3517
3518        return count.intValue();
3519    }
3520
3521    public int countByU_C_C_T_R(long userId, long classNameId, long classPK,
3522        int type, long receiverUserId) throws SystemException {
3523        Object[] finderArgs = new Object[] {
3524                new Long(userId), new Long(classNameId), new Long(classPK),
3525                new Integer(type), new Long(receiverUserId)
3526            };
3527
3528        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C_T_R,
3529                finderArgs, this);
3530
3531        if (count == null) {
3532            Session session = null;
3533
3534            try {
3535                session = openSession();
3536
3537                StringBundler query = new StringBundler(6);
3538
3539                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3540
3541                query.append(_FINDER_COLUMN_U_C_C_T_R_USERID_2);
3542
3543                query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2);
3544
3545                query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSPK_2);
3546
3547                query.append(_FINDER_COLUMN_U_C_C_T_R_TYPE_2);
3548
3549                query.append(_FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2);
3550
3551                String sql = query.toString();
3552
3553                Query q = session.createQuery(sql);
3554
3555                QueryPos qPos = QueryPos.getInstance(q);
3556
3557                qPos.add(userId);
3558
3559                qPos.add(classNameId);
3560
3561                qPos.add(classPK);
3562
3563                qPos.add(type);
3564
3565                qPos.add(receiverUserId);
3566
3567                count = (Long)q.uniqueResult();
3568            }
3569            catch (Exception e) {
3570                throw processException(e);
3571            }
3572            finally {
3573                if (count == null) {
3574                    count = Long.valueOf(0);
3575                }
3576
3577                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C_T_R,
3578                    finderArgs, count);
3579
3580                closeSession(session);
3581            }
3582        }
3583
3584        return count.intValue();
3585    }
3586
3587    public int countByU_C_C_T_S(long userId, long classNameId, long classPK,
3588        int type, int status) throws SystemException {
3589        Object[] finderArgs = new Object[] {
3590                new Long(userId), new Long(classNameId), new Long(classPK),
3591                new Integer(type), new Integer(status)
3592            };
3593
3594        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
3595                finderArgs, this);
3596
3597        if (count == null) {
3598            Session session = null;
3599
3600            try {
3601                session = openSession();
3602
3603                StringBundler query = new StringBundler(6);
3604
3605                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3606
3607                query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
3608
3609                query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
3610
3611                query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
3612
3613                query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
3614
3615                query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
3616
3617                String sql = query.toString();
3618
3619                Query q = session.createQuery(sql);
3620
3621                QueryPos qPos = QueryPos.getInstance(q);
3622
3623                qPos.add(userId);
3624
3625                qPos.add(classNameId);
3626
3627                qPos.add(classPK);
3628
3629                qPos.add(type);
3630
3631                qPos.add(status);
3632
3633                count = (Long)q.uniqueResult();
3634            }
3635            catch (Exception e) {
3636                throw processException(e);
3637            }
3638            finally {
3639                if (count == null) {
3640                    count = Long.valueOf(0);
3641                }
3642
3643                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
3644                    finderArgs, count);
3645
3646                closeSession(session);
3647            }
3648        }
3649
3650        return count.intValue();
3651    }
3652
3653    public int countByC_C_T_R_S(long classNameId, long classPK, int type,
3654        long receiverUserId, int status) throws SystemException {
3655        Object[] finderArgs = new Object[] {
3656                new Long(classNameId), new Long(classPK), new Integer(type),
3657                new Long(receiverUserId), new Integer(status)
3658            };
3659
3660        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
3661                finderArgs, this);
3662
3663        if (count == null) {
3664            Session session = null;
3665
3666            try {
3667                session = openSession();
3668
3669                StringBundler query = new StringBundler(6);
3670
3671                query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
3672
3673                query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
3674
3675                query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
3676
3677                query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
3678
3679                query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
3680
3681                query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
3682
3683                String sql = query.toString();
3684
3685                Query q = session.createQuery(sql);
3686
3687                QueryPos qPos = QueryPos.getInstance(q);
3688
3689                qPos.add(classNameId);
3690
3691                qPos.add(classPK);
3692
3693                qPos.add(type);
3694
3695                qPos.add(receiverUserId);
3696
3697                qPos.add(status);
3698
3699                count = (Long)q.uniqueResult();
3700            }
3701            catch (Exception e) {
3702                throw processException(e);
3703            }
3704            finally {
3705                if (count == null) {
3706                    count = Long.valueOf(0);
3707                }
3708
3709                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
3710                    finderArgs, count);
3711
3712                closeSession(session);
3713            }
3714        }
3715
3716        return count.intValue();
3717    }
3718
3719    public int countAll() throws SystemException {
3720        Object[] finderArgs = new Object[0];
3721
3722        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3723                finderArgs, this);
3724
3725        if (count == null) {
3726            Session session = null;
3727
3728            try {
3729                session = openSession();
3730
3731                Query q = session.createQuery(_SQL_COUNT_SOCIALREQUEST);
3732
3733                count = (Long)q.uniqueResult();
3734            }
3735            catch (Exception e) {
3736                throw processException(e);
3737            }
3738            finally {
3739                if (count == null) {
3740                    count = Long.valueOf(0);
3741                }
3742
3743                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3744                    count);
3745
3746                closeSession(session);
3747            }
3748        }
3749
3750        return count.intValue();
3751    }
3752
3753    public void afterPropertiesSet() {
3754        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3755                    com.liferay.portal.util.PropsUtil.get(
3756                        "value.object.listener.com.liferay.portlet.social.model.SocialRequest")));
3757
3758        if (listenerClassNames.length > 0) {
3759            try {
3760                List<ModelListener<SocialRequest>> listenersList = new ArrayList<ModelListener<SocialRequest>>();
3761
3762                for (String listenerClassName : listenerClassNames) {
3763                    listenersList.add((ModelListener<SocialRequest>)Class.forName(
3764                            listenerClassName).newInstance());
3765                }
3766
3767                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3768            }
3769            catch (Exception e) {
3770                _log.error(e);
3771            }
3772        }
3773    }
3774
3775    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence")
3776    protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
3777    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialRelationPersistence")
3778    protected com.liferay.portlet.social.service.persistence.SocialRelationPersistence socialRelationPersistence;
3779    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialRequestPersistence")
3780    protected com.liferay.portlet.social.service.persistence.SocialRequestPersistence socialRequestPersistence;
3781    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
3782    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
3783    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
3784    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
3785    private static final String _SQL_SELECT_SOCIALREQUEST = "SELECT socialRequest FROM SocialRequest socialRequest";
3786    private static final String _SQL_SELECT_SOCIALREQUEST_WHERE = "SELECT socialRequest FROM SocialRequest socialRequest WHERE ";
3787    private static final String _SQL_COUNT_SOCIALREQUEST = "SELECT COUNT(socialRequest) FROM SocialRequest socialRequest";
3788    private static final String _SQL_COUNT_SOCIALREQUEST_WHERE = "SELECT COUNT(socialRequest) FROM SocialRequest socialRequest WHERE ";
3789    private static final String _FINDER_COLUMN_UUID_UUID_1 = "socialRequest.uuid IS NULL";
3790    private static final String _FINDER_COLUMN_UUID_UUID_2 = "socialRequest.uuid = ?";
3791    private static final String _FINDER_COLUMN_UUID_UUID_3 = "(socialRequest.uuid IS NULL OR socialRequest.uuid = ?)";
3792    private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "socialRequest.uuid IS NULL AND ";
3793    private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "socialRequest.uuid = ? AND ";
3794    private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(socialRequest.uuid IS NULL OR socialRequest.uuid = ?) AND ";
3795    private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "socialRequest.groupId = ?";
3796    private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "socialRequest.companyId = ?";
3797    private static final String _FINDER_COLUMN_USERID_USERID_2 = "socialRequest.userId = ?";
3798    private static final String _FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ?";
3799    private static final String _FINDER_COLUMN_U_S_USERID_2 = "socialRequest.userId = ? AND ";
3800    private static final String _FINDER_COLUMN_U_S_STATUS_2 = "socialRequest.status = ?";
3801    private static final String _FINDER_COLUMN_R_S_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ? AND ";
3802    private static final String _FINDER_COLUMN_R_S_STATUS_2 = "socialRequest.status = ?";
3803    private static final String _FINDER_COLUMN_U_C_C_T_R_USERID_2 = "socialRequest.userId = ? AND ";
3804    private static final String _FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
3805    private static final String _FINDER_COLUMN_U_C_C_T_R_CLASSPK_2 = "socialRequest.classPK = ? AND ";
3806    private static final String _FINDER_COLUMN_U_C_C_T_R_TYPE_2 = "socialRequest.type = ? AND ";
3807    private static final String _FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ?";
3808    private static final String _FINDER_COLUMN_U_C_C_T_S_USERID_2 = "socialRequest.userId = ? AND ";
3809    private static final String _FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
3810    private static final String _FINDER_COLUMN_U_C_C_T_S_CLASSPK_2 = "socialRequest.classPK = ? AND ";
3811    private static final String _FINDER_COLUMN_U_C_C_T_S_TYPE_2 = "socialRequest.type = ? AND ";
3812    private static final String _FINDER_COLUMN_U_C_C_T_S_STATUS_2 = "socialRequest.status = ?";
3813    private static final String _FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
3814    private static final String _FINDER_COLUMN_C_C_T_R_S_CLASSPK_2 = "socialRequest.classPK = ? AND ";
3815    private static final String _FINDER_COLUMN_C_C_T_R_S_TYPE_2 = "socialRequest.type = ? AND ";
3816    private static final String _FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ? AND ";
3817    private static final String _FINDER_COLUMN_C_C_T_R_S_STATUS_2 = "socialRequest.status = ?";
3818    private static final String _ORDER_BY_ENTITY_ALIAS = "socialRequest.";
3819    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialRequest exists with the primary key ";
3820    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialRequest exists with the key {";
3821    private static Log _log = LogFactoryUtil.getLog(SocialRequestPersistenceImpl.class);
3822}