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