001
014
015 package com.liferay.portlet.social.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.service.persistence.BatchSessionUtil;
040 import com.liferay.portal.service.persistence.ResourcePersistence;
041 import com.liferay.portal.service.persistence.UserPersistence;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import com.liferay.portlet.social.NoSuchRequestException;
045 import com.liferay.portlet.social.model.SocialRequest;
046 import com.liferay.portlet.social.model.impl.SocialRequestImpl;
047 import com.liferay.portlet.social.model.impl.SocialRequestModelImpl;
048
049 import java.io.Serializable;
050
051 import java.util.ArrayList;
052 import java.util.Collections;
053 import java.util.List;
054
055
071 public class SocialRequestPersistenceImpl extends BasePersistenceImpl<SocialRequest>
072 implements SocialRequestPersistence {
073 public static final String FINDER_CLASS_NAME_ENTITY = SocialRequestImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
075 ".List";
076 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
077 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
078 FINDER_CLASS_NAME_LIST, "findByUuid",
079 new String[] {
080 String.class.getName(),
081
082 "java.lang.Integer", "java.lang.Integer",
083 "com.liferay.portal.kernel.util.OrderByComparator"
084 });
085 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
086 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
087 FINDER_CLASS_NAME_LIST, "countByUuid",
088 new String[] { String.class.getName() });
089 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
090 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
091 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
092 new String[] { String.class.getName(), Long.class.getName() });
093 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
094 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
095 FINDER_CLASS_NAME_LIST, "countByUUID_G",
096 new String[] { String.class.getName(), Long.class.getName() });
097 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
098 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
099 FINDER_CLASS_NAME_LIST, "findByCompanyId",
100 new String[] {
101 Long.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
107 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
108 FINDER_CLASS_NAME_LIST, "countByCompanyId",
109 new String[] { Long.class.getName() });
110 public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
111 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_LIST, "findByUserId",
113 new String[] {
114 Long.class.getName(),
115
116 "java.lang.Integer", "java.lang.Integer",
117 "com.liferay.portal.kernel.util.OrderByComparator"
118 });
119 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
120 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
121 FINDER_CLASS_NAME_LIST, "countByUserId",
122 new String[] { Long.class.getName() });
123 public static final FinderPath FINDER_PATH_FIND_BY_RECEIVERUSERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
124 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
125 FINDER_CLASS_NAME_LIST, "findByReceiverUserId",
126 new String[] {
127 Long.class.getName(),
128
129 "java.lang.Integer", "java.lang.Integer",
130 "com.liferay.portal.kernel.util.OrderByComparator"
131 });
132 public static final FinderPath FINDER_PATH_COUNT_BY_RECEIVERUSERID = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
133 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
134 FINDER_CLASS_NAME_LIST, "countByReceiverUserId",
135 new String[] { Long.class.getName() });
136 public static final FinderPath FINDER_PATH_FIND_BY_U_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
137 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
138 FINDER_CLASS_NAME_LIST, "findByU_S",
139 new String[] {
140 Long.class.getName(), Integer.class.getName(),
141
142 "java.lang.Integer", "java.lang.Integer",
143 "com.liferay.portal.kernel.util.OrderByComparator"
144 });
145 public static final FinderPath FINDER_PATH_COUNT_BY_U_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
146 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
147 FINDER_CLASS_NAME_LIST, "countByU_S",
148 new String[] { Long.class.getName(), Integer.class.getName() });
149 public static final FinderPath FINDER_PATH_FIND_BY_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
150 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
151 FINDER_CLASS_NAME_LIST, "findByR_S",
152 new String[] {
153 Long.class.getName(), Integer.class.getName(),
154
155 "java.lang.Integer", "java.lang.Integer",
156 "com.liferay.portal.kernel.util.OrderByComparator"
157 });
158 public static final FinderPath FINDER_PATH_COUNT_BY_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
159 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
160 FINDER_CLASS_NAME_LIST, "countByR_S",
161 new String[] { Long.class.getName(), Integer.class.getName() });
162 public static final FinderPath FINDER_PATH_FETCH_BY_U_C_C_T_R = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
163 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
164 FINDER_CLASS_NAME_ENTITY, "fetchByU_C_C_T_R",
165 new String[] {
166 Long.class.getName(), Long.class.getName(), Long.class.getName(),
167 Integer.class.getName(), Long.class.getName()
168 });
169 public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C_T_R = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
170 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
171 FINDER_CLASS_NAME_LIST, "countByU_C_C_T_R",
172 new String[] {
173 Long.class.getName(), Long.class.getName(), Long.class.getName(),
174 Integer.class.getName(), Long.class.getName()
175 });
176 public static final FinderPath FINDER_PATH_FIND_BY_U_C_C_T_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
177 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
178 FINDER_CLASS_NAME_LIST, "findByU_C_C_T_S",
179 new String[] {
180 Long.class.getName(), Long.class.getName(), Long.class.getName(),
181 Integer.class.getName(), Integer.class.getName(),
182
183 "java.lang.Integer", "java.lang.Integer",
184 "com.liferay.portal.kernel.util.OrderByComparator"
185 });
186 public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C_T_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
187 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
188 FINDER_CLASS_NAME_LIST, "countByU_C_C_T_S",
189 new String[] {
190 Long.class.getName(), Long.class.getName(), Long.class.getName(),
191 Integer.class.getName(), Integer.class.getName()
192 });
193 public static final FinderPath FINDER_PATH_FIND_BY_C_C_T_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
194 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
195 FINDER_CLASS_NAME_LIST, "findByC_C_T_R_S",
196 new String[] {
197 Long.class.getName(), Long.class.getName(),
198 Integer.class.getName(), Long.class.getName(),
199 Integer.class.getName(),
200
201 "java.lang.Integer", "java.lang.Integer",
202 "com.liferay.portal.kernel.util.OrderByComparator"
203 });
204 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_T_R_S = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
205 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
206 FINDER_CLASS_NAME_LIST, "countByC_C_T_R_S",
207 new String[] {
208 Long.class.getName(), Long.class.getName(),
209 Integer.class.getName(), Long.class.getName(),
210 Integer.class.getName()
211 });
212 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
213 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
214 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
215 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
216 SocialRequestModelImpl.FINDER_CACHE_ENABLED,
217 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
218
219
224 public void cacheResult(SocialRequest socialRequest) {
225 EntityCacheUtil.putResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
226 SocialRequestImpl.class, socialRequest.getPrimaryKey(),
227 socialRequest);
228
229 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
230 new Object[] {
231 socialRequest.getUuid(), new Long(socialRequest.getGroupId())
232 }, socialRequest);
233
234 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
235 new Object[] {
236 new Long(socialRequest.getUserId()),
237 new Long(socialRequest.getClassNameId()),
238 new Long(socialRequest.getClassPK()),
239 new Integer(socialRequest.getType()),
240 new Long(socialRequest.getReceiverUserId())
241 }, socialRequest);
242 }
243
244
249 public void cacheResult(List<SocialRequest> socialRequests) {
250 for (SocialRequest socialRequest : socialRequests) {
251 if (EntityCacheUtil.getResult(
252 SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
253 SocialRequestImpl.class, socialRequest.getPrimaryKey(),
254 this) == null) {
255 cacheResult(socialRequest);
256 }
257 }
258 }
259
260
267 public void clearCache() {
268 CacheRegistryUtil.clear(SocialRequestImpl.class.getName());
269 EntityCacheUtil.clearCache(SocialRequestImpl.class.getName());
270 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
271 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
272 }
273
274
281 public void clearCache(SocialRequest socialRequest) {
282 EntityCacheUtil.removeResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
283 SocialRequestImpl.class, socialRequest.getPrimaryKey());
284
285 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
286 new Object[] {
287 socialRequest.getUuid(), new Long(socialRequest.getGroupId())
288 });
289
290 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
291 new Object[] {
292 new Long(socialRequest.getUserId()),
293 new Long(socialRequest.getClassNameId()),
294 new Long(socialRequest.getClassPK()),
295 new Integer(socialRequest.getType()),
296 new Long(socialRequest.getReceiverUserId())
297 });
298 }
299
300
306 public SocialRequest create(long requestId) {
307 SocialRequest socialRequest = new SocialRequestImpl();
308
309 socialRequest.setNew(true);
310 socialRequest.setPrimaryKey(requestId);
311
312 String uuid = PortalUUIDUtil.generate();
313
314 socialRequest.setUuid(uuid);
315
316 return socialRequest;
317 }
318
319
327 public SocialRequest remove(Serializable primaryKey)
328 throws NoSuchModelException, SystemException {
329 return remove(((Long)primaryKey).longValue());
330 }
331
332
340 public SocialRequest remove(long requestId)
341 throws NoSuchRequestException, SystemException {
342 Session session = null;
343
344 try {
345 session = openSession();
346
347 SocialRequest socialRequest = (SocialRequest)session.get(SocialRequestImpl.class,
348 new Long(requestId));
349
350 if (socialRequest == null) {
351 if (_log.isWarnEnabled()) {
352 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + requestId);
353 }
354
355 throw new NoSuchRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
356 requestId);
357 }
358
359 return remove(socialRequest);
360 }
361 catch (NoSuchRequestException nsee) {
362 throw nsee;
363 }
364 catch (Exception e) {
365 throw processException(e);
366 }
367 finally {
368 closeSession(session);
369 }
370 }
371
372 protected SocialRequest removeImpl(SocialRequest socialRequest)
373 throws SystemException {
374 socialRequest = toUnwrappedModel(socialRequest);
375
376 Session session = null;
377
378 try {
379 session = openSession();
380
381 BatchSessionUtil.delete(session, socialRequest);
382 }
383 catch (Exception e) {
384 throw processException(e);
385 }
386 finally {
387 closeSession(session);
388 }
389
390 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
391
392 SocialRequestModelImpl socialRequestModelImpl = (SocialRequestModelImpl)socialRequest;
393
394 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
395 new Object[] {
396 socialRequestModelImpl.getOriginalUuid(),
397 new Long(socialRequestModelImpl.getOriginalGroupId())
398 });
399
400 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
401 new Object[] {
402 new Long(socialRequestModelImpl.getOriginalUserId()),
403 new Long(socialRequestModelImpl.getOriginalClassNameId()),
404 new Long(socialRequestModelImpl.getOriginalClassPK()),
405 new Integer(socialRequestModelImpl.getOriginalType()),
406 new Long(socialRequestModelImpl.getOriginalReceiverUserId())
407 });
408
409 EntityCacheUtil.removeResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
410 SocialRequestImpl.class, socialRequest.getPrimaryKey());
411
412 return socialRequest;
413 }
414
415 public SocialRequest updateImpl(
416 com.liferay.portlet.social.model.SocialRequest socialRequest,
417 boolean merge) throws SystemException {
418 socialRequest = toUnwrappedModel(socialRequest);
419
420 boolean isNew = socialRequest.isNew();
421
422 SocialRequestModelImpl socialRequestModelImpl = (SocialRequestModelImpl)socialRequest;
423
424 if (Validator.isNull(socialRequest.getUuid())) {
425 String uuid = PortalUUIDUtil.generate();
426
427 socialRequest.setUuid(uuid);
428 }
429
430 Session session = null;
431
432 try {
433 session = openSession();
434
435 BatchSessionUtil.update(session, socialRequest, merge);
436
437 socialRequest.setNew(false);
438 }
439 catch (Exception e) {
440 throw processException(e);
441 }
442 finally {
443 closeSession(session);
444 }
445
446 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
447
448 EntityCacheUtil.putResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
449 SocialRequestImpl.class, socialRequest.getPrimaryKey(),
450 socialRequest);
451
452 if (!isNew &&
453 (!Validator.equals(socialRequest.getUuid(),
454 socialRequestModelImpl.getOriginalUuid()) ||
455 (socialRequest.getGroupId() != socialRequestModelImpl.getOriginalGroupId()))) {
456 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
457 new Object[] {
458 socialRequestModelImpl.getOriginalUuid(),
459 new Long(socialRequestModelImpl.getOriginalGroupId())
460 });
461 }
462
463 if (isNew ||
464 (!Validator.equals(socialRequest.getUuid(),
465 socialRequestModelImpl.getOriginalUuid()) ||
466 (socialRequest.getGroupId() != socialRequestModelImpl.getOriginalGroupId()))) {
467 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
468 new Object[] {
469 socialRequest.getUuid(),
470 new Long(socialRequest.getGroupId())
471 }, socialRequest);
472 }
473
474 if (!isNew &&
475 ((socialRequest.getUserId() != socialRequestModelImpl.getOriginalUserId()) ||
476 (socialRequest.getClassNameId() != socialRequestModelImpl.getOriginalClassNameId()) ||
477 (socialRequest.getClassPK() != socialRequestModelImpl.getOriginalClassPK()) ||
478 (socialRequest.getType() != socialRequestModelImpl.getOriginalType()) ||
479 (socialRequest.getReceiverUserId() != socialRequestModelImpl.getOriginalReceiverUserId()))) {
480 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
481 new Object[] {
482 new Long(socialRequestModelImpl.getOriginalUserId()),
483 new Long(socialRequestModelImpl.getOriginalClassNameId()),
484 new Long(socialRequestModelImpl.getOriginalClassPK()),
485 new Integer(socialRequestModelImpl.getOriginalType()),
486 new Long(socialRequestModelImpl.getOriginalReceiverUserId())
487 });
488 }
489
490 if (isNew ||
491 ((socialRequest.getUserId() != socialRequestModelImpl.getOriginalUserId()) ||
492 (socialRequest.getClassNameId() != socialRequestModelImpl.getOriginalClassNameId()) ||
493 (socialRequest.getClassPK() != socialRequestModelImpl.getOriginalClassPK()) ||
494 (socialRequest.getType() != socialRequestModelImpl.getOriginalType()) ||
495 (socialRequest.getReceiverUserId() != socialRequestModelImpl.getOriginalReceiverUserId()))) {
496 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
497 new Object[] {
498 new Long(socialRequest.getUserId()),
499 new Long(socialRequest.getClassNameId()),
500 new Long(socialRequest.getClassPK()),
501 new Integer(socialRequest.getType()),
502 new Long(socialRequest.getReceiverUserId())
503 }, socialRequest);
504 }
505
506 return socialRequest;
507 }
508
509 protected SocialRequest toUnwrappedModel(SocialRequest socialRequest) {
510 if (socialRequest instanceof SocialRequestImpl) {
511 return socialRequest;
512 }
513
514 SocialRequestImpl socialRequestImpl = new SocialRequestImpl();
515
516 socialRequestImpl.setNew(socialRequest.isNew());
517 socialRequestImpl.setPrimaryKey(socialRequest.getPrimaryKey());
518
519 socialRequestImpl.setUuid(socialRequest.getUuid());
520 socialRequestImpl.setRequestId(socialRequest.getRequestId());
521 socialRequestImpl.setGroupId(socialRequest.getGroupId());
522 socialRequestImpl.setCompanyId(socialRequest.getCompanyId());
523 socialRequestImpl.setUserId(socialRequest.getUserId());
524 socialRequestImpl.setCreateDate(socialRequest.getCreateDate());
525 socialRequestImpl.setModifiedDate(socialRequest.getModifiedDate());
526 socialRequestImpl.setClassNameId(socialRequest.getClassNameId());
527 socialRequestImpl.setClassPK(socialRequest.getClassPK());
528 socialRequestImpl.setType(socialRequest.getType());
529 socialRequestImpl.setExtraData(socialRequest.getExtraData());
530 socialRequestImpl.setReceiverUserId(socialRequest.getReceiverUserId());
531 socialRequestImpl.setStatus(socialRequest.getStatus());
532
533 return socialRequestImpl;
534 }
535
536
544 public SocialRequest findByPrimaryKey(Serializable primaryKey)
545 throws NoSuchModelException, SystemException {
546 return findByPrimaryKey(((Long)primaryKey).longValue());
547 }
548
549
557 public SocialRequest findByPrimaryKey(long requestId)
558 throws NoSuchRequestException, SystemException {
559 SocialRequest socialRequest = fetchByPrimaryKey(requestId);
560
561 if (socialRequest == null) {
562 if (_log.isWarnEnabled()) {
563 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + requestId);
564 }
565
566 throw new NoSuchRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
567 requestId);
568 }
569
570 return socialRequest;
571 }
572
573
580 public SocialRequest fetchByPrimaryKey(Serializable primaryKey)
581 throws SystemException {
582 return fetchByPrimaryKey(((Long)primaryKey).longValue());
583 }
584
585
592 public SocialRequest fetchByPrimaryKey(long requestId)
593 throws SystemException {
594 SocialRequest socialRequest = (SocialRequest)EntityCacheUtil.getResult(SocialRequestModelImpl.ENTITY_CACHE_ENABLED,
595 SocialRequestImpl.class, requestId, this);
596
597 if (socialRequest == null) {
598 Session session = null;
599
600 try {
601 session = openSession();
602
603 socialRequest = (SocialRequest)session.get(SocialRequestImpl.class,
604 new Long(requestId));
605 }
606 catch (Exception e) {
607 throw processException(e);
608 }
609 finally {
610 if (socialRequest != null) {
611 cacheResult(socialRequest);
612 }
613
614 closeSession(session);
615 }
616 }
617
618 return socialRequest;
619 }
620
621
628 public List<SocialRequest> findByUuid(String uuid)
629 throws SystemException {
630 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
631 }
632
633
646 public List<SocialRequest> findByUuid(String uuid, int start, int end)
647 throws SystemException {
648 return findByUuid(uuid, start, end, null);
649 }
650
651
665 public List<SocialRequest> findByUuid(String uuid, int start, int end,
666 OrderByComparator orderByComparator) throws SystemException {
667 Object[] finderArgs = new Object[] {
668 uuid,
669
670 String.valueOf(start), String.valueOf(end),
671 String.valueOf(orderByComparator)
672 };
673
674 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
675 finderArgs, this);
676
677 if (list == null) {
678 Session session = null;
679
680 try {
681 session = openSession();
682
683 StringBundler query = null;
684
685 if (orderByComparator != null) {
686 query = new StringBundler(3 +
687 (orderByComparator.getOrderByFields().length * 3));
688 }
689 else {
690 query = new StringBundler(3);
691 }
692
693 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
694
695 if (uuid == null) {
696 query.append(_FINDER_COLUMN_UUID_UUID_1);
697 }
698 else {
699 if (uuid.equals(StringPool.BLANK)) {
700 query.append(_FINDER_COLUMN_UUID_UUID_3);
701 }
702 else {
703 query.append(_FINDER_COLUMN_UUID_UUID_2);
704 }
705 }
706
707 if (orderByComparator != null) {
708 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
709 orderByComparator);
710 }
711
712 else {
713 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
714 }
715
716 String sql = query.toString();
717
718 Query q = session.createQuery(sql);
719
720 QueryPos qPos = QueryPos.getInstance(q);
721
722 if (uuid != null) {
723 qPos.add(uuid);
724 }
725
726 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
727 start, end);
728 }
729 catch (Exception e) {
730 throw processException(e);
731 }
732 finally {
733 if (list == null) {
734 list = new ArrayList<SocialRequest>();
735 }
736
737 cacheResult(list);
738
739 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
740 list);
741
742 closeSession(session);
743 }
744 }
745
746 return list;
747 }
748
749
762 public SocialRequest findByUuid_First(String uuid,
763 OrderByComparator orderByComparator)
764 throws NoSuchRequestException, SystemException {
765 List<SocialRequest> list = findByUuid(uuid, 0, 1, orderByComparator);
766
767 if (list.isEmpty()) {
768 StringBundler msg = new StringBundler(4);
769
770 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
771
772 msg.append("uuid=");
773 msg.append(uuid);
774
775 msg.append(StringPool.CLOSE_CURLY_BRACE);
776
777 throw new NoSuchRequestException(msg.toString());
778 }
779 else {
780 return list.get(0);
781 }
782 }
783
784
797 public SocialRequest findByUuid_Last(String uuid,
798 OrderByComparator orderByComparator)
799 throws NoSuchRequestException, SystemException {
800 int count = countByUuid(uuid);
801
802 List<SocialRequest> list = findByUuid(uuid, count - 1, count,
803 orderByComparator);
804
805 if (list.isEmpty()) {
806 StringBundler msg = new StringBundler(4);
807
808 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
809
810 msg.append("uuid=");
811 msg.append(uuid);
812
813 msg.append(StringPool.CLOSE_CURLY_BRACE);
814
815 throw new NoSuchRequestException(msg.toString());
816 }
817 else {
818 return list.get(0);
819 }
820 }
821
822
836 public SocialRequest[] findByUuid_PrevAndNext(long requestId, String uuid,
837 OrderByComparator orderByComparator)
838 throws NoSuchRequestException, SystemException {
839 SocialRequest socialRequest = findByPrimaryKey(requestId);
840
841 Session session = null;
842
843 try {
844 session = openSession();
845
846 SocialRequest[] array = new SocialRequestImpl[3];
847
848 array[0] = getByUuid_PrevAndNext(session, socialRequest, uuid,
849 orderByComparator, true);
850
851 array[1] = socialRequest;
852
853 array[2] = getByUuid_PrevAndNext(session, socialRequest, uuid,
854 orderByComparator, false);
855
856 return array;
857 }
858 catch (Exception e) {
859 throw processException(e);
860 }
861 finally {
862 closeSession(session);
863 }
864 }
865
866 protected SocialRequest getByUuid_PrevAndNext(Session session,
867 SocialRequest socialRequest, String uuid,
868 OrderByComparator orderByComparator, boolean previous) {
869 StringBundler query = null;
870
871 if (orderByComparator != null) {
872 query = new StringBundler(6 +
873 (orderByComparator.getOrderByFields().length * 6));
874 }
875 else {
876 query = new StringBundler(3);
877 }
878
879 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
880
881 if (uuid == null) {
882 query.append(_FINDER_COLUMN_UUID_UUID_1);
883 }
884 else {
885 if (uuid.equals(StringPool.BLANK)) {
886 query.append(_FINDER_COLUMN_UUID_UUID_3);
887 }
888 else {
889 query.append(_FINDER_COLUMN_UUID_UUID_2);
890 }
891 }
892
893 if (orderByComparator != null) {
894 String[] orderByFields = orderByComparator.getOrderByFields();
895
896 if (orderByFields.length > 0) {
897 query.append(WHERE_AND);
898 }
899
900 for (int i = 0; i < orderByFields.length; i++) {
901 query.append(_ORDER_BY_ENTITY_ALIAS);
902 query.append(orderByFields[i]);
903
904 if ((i + 1) < orderByFields.length) {
905 if (orderByComparator.isAscending() ^ previous) {
906 query.append(WHERE_GREATER_THAN_HAS_NEXT);
907 }
908 else {
909 query.append(WHERE_LESSER_THAN_HAS_NEXT);
910 }
911 }
912 else {
913 if (orderByComparator.isAscending() ^ previous) {
914 query.append(WHERE_GREATER_THAN);
915 }
916 else {
917 query.append(WHERE_LESSER_THAN);
918 }
919 }
920 }
921
922 query.append(ORDER_BY_CLAUSE);
923
924 for (int i = 0; i < orderByFields.length; i++) {
925 query.append(_ORDER_BY_ENTITY_ALIAS);
926 query.append(orderByFields[i]);
927
928 if ((i + 1) < orderByFields.length) {
929 if (orderByComparator.isAscending() ^ previous) {
930 query.append(ORDER_BY_ASC_HAS_NEXT);
931 }
932 else {
933 query.append(ORDER_BY_DESC_HAS_NEXT);
934 }
935 }
936 else {
937 if (orderByComparator.isAscending() ^ previous) {
938 query.append(ORDER_BY_ASC);
939 }
940 else {
941 query.append(ORDER_BY_DESC);
942 }
943 }
944 }
945 }
946
947 else {
948 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
949 }
950
951 String sql = query.toString();
952
953 Query q = session.createQuery(sql);
954
955 q.setFirstResult(0);
956 q.setMaxResults(2);
957
958 QueryPos qPos = QueryPos.getInstance(q);
959
960 if (uuid != null) {
961 qPos.add(uuid);
962 }
963
964 if (orderByComparator != null) {
965 Object[] values = orderByComparator.getOrderByValues(socialRequest);
966
967 for (Object value : values) {
968 qPos.add(value);
969 }
970 }
971
972 List<SocialRequest> list = q.list();
973
974 if (list.size() == 2) {
975 return list.get(1);
976 }
977 else {
978 return null;
979 }
980 }
981
982
991 public SocialRequest findByUUID_G(String uuid, long groupId)
992 throws NoSuchRequestException, SystemException {
993 SocialRequest socialRequest = fetchByUUID_G(uuid, groupId);
994
995 if (socialRequest == null) {
996 StringBundler msg = new StringBundler(6);
997
998 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
999
1000 msg.append("uuid=");
1001 msg.append(uuid);
1002
1003 msg.append(", groupId=");
1004 msg.append(groupId);
1005
1006 msg.append(StringPool.CLOSE_CURLY_BRACE);
1007
1008 if (_log.isWarnEnabled()) {
1009 _log.warn(msg.toString());
1010 }
1011
1012 throw new NoSuchRequestException(msg.toString());
1013 }
1014
1015 return socialRequest;
1016 }
1017
1018
1026 public SocialRequest fetchByUUID_G(String uuid, long groupId)
1027 throws SystemException {
1028 return fetchByUUID_G(uuid, groupId, true);
1029 }
1030
1031
1039 public SocialRequest fetchByUUID_G(String uuid, long groupId,
1040 boolean retrieveFromCache) throws SystemException {
1041 Object[] finderArgs = new Object[] { uuid, groupId };
1042
1043 Object result = null;
1044
1045 if (retrieveFromCache) {
1046 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1047 finderArgs, this);
1048 }
1049
1050 if (result == null) {
1051 Session session = null;
1052
1053 try {
1054 session = openSession();
1055
1056 StringBundler query = new StringBundler(4);
1057
1058 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1059
1060 if (uuid == null) {
1061 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1062 }
1063 else {
1064 if (uuid.equals(StringPool.BLANK)) {
1065 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1066 }
1067 else {
1068 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1069 }
1070 }
1071
1072 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1073
1074 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1075
1076 String sql = query.toString();
1077
1078 Query q = session.createQuery(sql);
1079
1080 QueryPos qPos = QueryPos.getInstance(q);
1081
1082 if (uuid != null) {
1083 qPos.add(uuid);
1084 }
1085
1086 qPos.add(groupId);
1087
1088 List<SocialRequest> list = q.list();
1089
1090 result = list;
1091
1092 SocialRequest socialRequest = null;
1093
1094 if (list.isEmpty()) {
1095 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1096 finderArgs, list);
1097 }
1098 else {
1099 socialRequest = list.get(0);
1100
1101 cacheResult(socialRequest);
1102
1103 if ((socialRequest.getUuid() == null) ||
1104 !socialRequest.getUuid().equals(uuid) ||
1105 (socialRequest.getGroupId() != groupId)) {
1106 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1107 finderArgs, socialRequest);
1108 }
1109 }
1110
1111 return socialRequest;
1112 }
1113 catch (Exception e) {
1114 throw processException(e);
1115 }
1116 finally {
1117 if (result == null) {
1118 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1119 finderArgs, new ArrayList<SocialRequest>());
1120 }
1121
1122 closeSession(session);
1123 }
1124 }
1125 else {
1126 if (result instanceof List<?>) {
1127 return null;
1128 }
1129 else {
1130 return (SocialRequest)result;
1131 }
1132 }
1133 }
1134
1135
1142 public List<SocialRequest> findByCompanyId(long companyId)
1143 throws SystemException {
1144 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1145 null);
1146 }
1147
1148
1161 public List<SocialRequest> findByCompanyId(long companyId, int start,
1162 int end) throws SystemException {
1163 return findByCompanyId(companyId, start, end, null);
1164 }
1165
1166
1180 public List<SocialRequest> findByCompanyId(long companyId, int start,
1181 int end, OrderByComparator orderByComparator) throws SystemException {
1182 Object[] finderArgs = new Object[] {
1183 companyId,
1184
1185 String.valueOf(start), String.valueOf(end),
1186 String.valueOf(orderByComparator)
1187 };
1188
1189 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1190 finderArgs, this);
1191
1192 if (list == null) {
1193 Session session = null;
1194
1195 try {
1196 session = openSession();
1197
1198 StringBundler query = null;
1199
1200 if (orderByComparator != null) {
1201 query = new StringBundler(3 +
1202 (orderByComparator.getOrderByFields().length * 3));
1203 }
1204 else {
1205 query = new StringBundler(3);
1206 }
1207
1208 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1209
1210 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1211
1212 if (orderByComparator != null) {
1213 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1214 orderByComparator);
1215 }
1216
1217 else {
1218 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1219 }
1220
1221 String sql = query.toString();
1222
1223 Query q = session.createQuery(sql);
1224
1225 QueryPos qPos = QueryPos.getInstance(q);
1226
1227 qPos.add(companyId);
1228
1229 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1230 start, end);
1231 }
1232 catch (Exception e) {
1233 throw processException(e);
1234 }
1235 finally {
1236 if (list == null) {
1237 list = new ArrayList<SocialRequest>();
1238 }
1239
1240 cacheResult(list);
1241
1242 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1243 finderArgs, list);
1244
1245 closeSession(session);
1246 }
1247 }
1248
1249 return list;
1250 }
1251
1252
1265 public SocialRequest findByCompanyId_First(long companyId,
1266 OrderByComparator orderByComparator)
1267 throws NoSuchRequestException, SystemException {
1268 List<SocialRequest> list = findByCompanyId(companyId, 0, 1,
1269 orderByComparator);
1270
1271 if (list.isEmpty()) {
1272 StringBundler msg = new StringBundler(4);
1273
1274 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1275
1276 msg.append("companyId=");
1277 msg.append(companyId);
1278
1279 msg.append(StringPool.CLOSE_CURLY_BRACE);
1280
1281 throw new NoSuchRequestException(msg.toString());
1282 }
1283 else {
1284 return list.get(0);
1285 }
1286 }
1287
1288
1301 public SocialRequest findByCompanyId_Last(long companyId,
1302 OrderByComparator orderByComparator)
1303 throws NoSuchRequestException, SystemException {
1304 int count = countByCompanyId(companyId);
1305
1306 List<SocialRequest> list = findByCompanyId(companyId, count - 1, count,
1307 orderByComparator);
1308
1309 if (list.isEmpty()) {
1310 StringBundler msg = new StringBundler(4);
1311
1312 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1313
1314 msg.append("companyId=");
1315 msg.append(companyId);
1316
1317 msg.append(StringPool.CLOSE_CURLY_BRACE);
1318
1319 throw new NoSuchRequestException(msg.toString());
1320 }
1321 else {
1322 return list.get(0);
1323 }
1324 }
1325
1326
1340 public SocialRequest[] findByCompanyId_PrevAndNext(long requestId,
1341 long companyId, OrderByComparator orderByComparator)
1342 throws NoSuchRequestException, SystemException {
1343 SocialRequest socialRequest = findByPrimaryKey(requestId);
1344
1345 Session session = null;
1346
1347 try {
1348 session = openSession();
1349
1350 SocialRequest[] array = new SocialRequestImpl[3];
1351
1352 array[0] = getByCompanyId_PrevAndNext(session, socialRequest,
1353 companyId, orderByComparator, true);
1354
1355 array[1] = socialRequest;
1356
1357 array[2] = getByCompanyId_PrevAndNext(session, socialRequest,
1358 companyId, orderByComparator, false);
1359
1360 return array;
1361 }
1362 catch (Exception e) {
1363 throw processException(e);
1364 }
1365 finally {
1366 closeSession(session);
1367 }
1368 }
1369
1370 protected SocialRequest getByCompanyId_PrevAndNext(Session session,
1371 SocialRequest socialRequest, long companyId,
1372 OrderByComparator orderByComparator, boolean previous) {
1373 StringBundler query = null;
1374
1375 if (orderByComparator != null) {
1376 query = new StringBundler(6 +
1377 (orderByComparator.getOrderByFields().length * 6));
1378 }
1379 else {
1380 query = new StringBundler(3);
1381 }
1382
1383 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1384
1385 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1386
1387 if (orderByComparator != null) {
1388 String[] orderByFields = orderByComparator.getOrderByFields();
1389
1390 if (orderByFields.length > 0) {
1391 query.append(WHERE_AND);
1392 }
1393
1394 for (int i = 0; i < orderByFields.length; i++) {
1395 query.append(_ORDER_BY_ENTITY_ALIAS);
1396 query.append(orderByFields[i]);
1397
1398 if ((i + 1) < orderByFields.length) {
1399 if (orderByComparator.isAscending() ^ previous) {
1400 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1401 }
1402 else {
1403 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1404 }
1405 }
1406 else {
1407 if (orderByComparator.isAscending() ^ previous) {
1408 query.append(WHERE_GREATER_THAN);
1409 }
1410 else {
1411 query.append(WHERE_LESSER_THAN);
1412 }
1413 }
1414 }
1415
1416 query.append(ORDER_BY_CLAUSE);
1417
1418 for (int i = 0; i < orderByFields.length; i++) {
1419 query.append(_ORDER_BY_ENTITY_ALIAS);
1420 query.append(orderByFields[i]);
1421
1422 if ((i + 1) < orderByFields.length) {
1423 if (orderByComparator.isAscending() ^ previous) {
1424 query.append(ORDER_BY_ASC_HAS_NEXT);
1425 }
1426 else {
1427 query.append(ORDER_BY_DESC_HAS_NEXT);
1428 }
1429 }
1430 else {
1431 if (orderByComparator.isAscending() ^ previous) {
1432 query.append(ORDER_BY_ASC);
1433 }
1434 else {
1435 query.append(ORDER_BY_DESC);
1436 }
1437 }
1438 }
1439 }
1440
1441 else {
1442 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1443 }
1444
1445 String sql = query.toString();
1446
1447 Query q = session.createQuery(sql);
1448
1449 q.setFirstResult(0);
1450 q.setMaxResults(2);
1451
1452 QueryPos qPos = QueryPos.getInstance(q);
1453
1454 qPos.add(companyId);
1455
1456 if (orderByComparator != null) {
1457 Object[] values = orderByComparator.getOrderByValues(socialRequest);
1458
1459 for (Object value : values) {
1460 qPos.add(value);
1461 }
1462 }
1463
1464 List<SocialRequest> list = q.list();
1465
1466 if (list.size() == 2) {
1467 return list.get(1);
1468 }
1469 else {
1470 return null;
1471 }
1472 }
1473
1474
1481 public List<SocialRequest> findByUserId(long userId)
1482 throws SystemException {
1483 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1484 }
1485
1486
1499 public List<SocialRequest> findByUserId(long userId, int start, int end)
1500 throws SystemException {
1501 return findByUserId(userId, start, end, null);
1502 }
1503
1504
1518 public List<SocialRequest> findByUserId(long userId, int start, int end,
1519 OrderByComparator orderByComparator) throws SystemException {
1520 Object[] finderArgs = new Object[] {
1521 userId,
1522
1523 String.valueOf(start), String.valueOf(end),
1524 String.valueOf(orderByComparator)
1525 };
1526
1527 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
1528 finderArgs, this);
1529
1530 if (list == null) {
1531 Session session = null;
1532
1533 try {
1534 session = openSession();
1535
1536 StringBundler query = null;
1537
1538 if (orderByComparator != null) {
1539 query = new StringBundler(3 +
1540 (orderByComparator.getOrderByFields().length * 3));
1541 }
1542 else {
1543 query = new StringBundler(3);
1544 }
1545
1546 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1547
1548 query.append(_FINDER_COLUMN_USERID_USERID_2);
1549
1550 if (orderByComparator != null) {
1551 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1552 orderByComparator);
1553 }
1554
1555 else {
1556 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1557 }
1558
1559 String sql = query.toString();
1560
1561 Query q = session.createQuery(sql);
1562
1563 QueryPos qPos = QueryPos.getInstance(q);
1564
1565 qPos.add(userId);
1566
1567 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1568 start, end);
1569 }
1570 catch (Exception e) {
1571 throw processException(e);
1572 }
1573 finally {
1574 if (list == null) {
1575 list = new ArrayList<SocialRequest>();
1576 }
1577
1578 cacheResult(list);
1579
1580 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
1581 finderArgs, list);
1582
1583 closeSession(session);
1584 }
1585 }
1586
1587 return list;
1588 }
1589
1590
1603 public SocialRequest findByUserId_First(long userId,
1604 OrderByComparator orderByComparator)
1605 throws NoSuchRequestException, SystemException {
1606 List<SocialRequest> list = findByUserId(userId, 0, 1, orderByComparator);
1607
1608 if (list.isEmpty()) {
1609 StringBundler msg = new StringBundler(4);
1610
1611 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1612
1613 msg.append("userId=");
1614 msg.append(userId);
1615
1616 msg.append(StringPool.CLOSE_CURLY_BRACE);
1617
1618 throw new NoSuchRequestException(msg.toString());
1619 }
1620 else {
1621 return list.get(0);
1622 }
1623 }
1624
1625
1638 public SocialRequest findByUserId_Last(long userId,
1639 OrderByComparator orderByComparator)
1640 throws NoSuchRequestException, SystemException {
1641 int count = countByUserId(userId);
1642
1643 List<SocialRequest> list = findByUserId(userId, count - 1, count,
1644 orderByComparator);
1645
1646 if (list.isEmpty()) {
1647 StringBundler msg = new StringBundler(4);
1648
1649 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1650
1651 msg.append("userId=");
1652 msg.append(userId);
1653
1654 msg.append(StringPool.CLOSE_CURLY_BRACE);
1655
1656 throw new NoSuchRequestException(msg.toString());
1657 }
1658 else {
1659 return list.get(0);
1660 }
1661 }
1662
1663
1677 public SocialRequest[] findByUserId_PrevAndNext(long requestId,
1678 long userId, OrderByComparator orderByComparator)
1679 throws NoSuchRequestException, SystemException {
1680 SocialRequest socialRequest = findByPrimaryKey(requestId);
1681
1682 Session session = null;
1683
1684 try {
1685 session = openSession();
1686
1687 SocialRequest[] array = new SocialRequestImpl[3];
1688
1689 array[0] = getByUserId_PrevAndNext(session, socialRequest, userId,
1690 orderByComparator, true);
1691
1692 array[1] = socialRequest;
1693
1694 array[2] = getByUserId_PrevAndNext(session, socialRequest, userId,
1695 orderByComparator, false);
1696
1697 return array;
1698 }
1699 catch (Exception e) {
1700 throw processException(e);
1701 }
1702 finally {
1703 closeSession(session);
1704 }
1705 }
1706
1707 protected SocialRequest getByUserId_PrevAndNext(Session session,
1708 SocialRequest socialRequest, long userId,
1709 OrderByComparator orderByComparator, boolean previous) {
1710 StringBundler query = null;
1711
1712 if (orderByComparator != null) {
1713 query = new StringBundler(6 +
1714 (orderByComparator.getOrderByFields().length * 6));
1715 }
1716 else {
1717 query = new StringBundler(3);
1718 }
1719
1720 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1721
1722 query.append(_FINDER_COLUMN_USERID_USERID_2);
1723
1724 if (orderByComparator != null) {
1725 String[] orderByFields = orderByComparator.getOrderByFields();
1726
1727 if (orderByFields.length > 0) {
1728 query.append(WHERE_AND);
1729 }
1730
1731 for (int i = 0; i < orderByFields.length; i++) {
1732 query.append(_ORDER_BY_ENTITY_ALIAS);
1733 query.append(orderByFields[i]);
1734
1735 if ((i + 1) < orderByFields.length) {
1736 if (orderByComparator.isAscending() ^ previous) {
1737 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1738 }
1739 else {
1740 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1741 }
1742 }
1743 else {
1744 if (orderByComparator.isAscending() ^ previous) {
1745 query.append(WHERE_GREATER_THAN);
1746 }
1747 else {
1748 query.append(WHERE_LESSER_THAN);
1749 }
1750 }
1751 }
1752
1753 query.append(ORDER_BY_CLAUSE);
1754
1755 for (int i = 0; i < orderByFields.length; i++) {
1756 query.append(_ORDER_BY_ENTITY_ALIAS);
1757 query.append(orderByFields[i]);
1758
1759 if ((i + 1) < orderByFields.length) {
1760 if (orderByComparator.isAscending() ^ previous) {
1761 query.append(ORDER_BY_ASC_HAS_NEXT);
1762 }
1763 else {
1764 query.append(ORDER_BY_DESC_HAS_NEXT);
1765 }
1766 }
1767 else {
1768 if (orderByComparator.isAscending() ^ previous) {
1769 query.append(ORDER_BY_ASC);
1770 }
1771 else {
1772 query.append(ORDER_BY_DESC);
1773 }
1774 }
1775 }
1776 }
1777
1778 else {
1779 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1780 }
1781
1782 String sql = query.toString();
1783
1784 Query q = session.createQuery(sql);
1785
1786 q.setFirstResult(0);
1787 q.setMaxResults(2);
1788
1789 QueryPos qPos = QueryPos.getInstance(q);
1790
1791 qPos.add(userId);
1792
1793 if (orderByComparator != null) {
1794 Object[] values = orderByComparator.getOrderByValues(socialRequest);
1795
1796 for (Object value : values) {
1797 qPos.add(value);
1798 }
1799 }
1800
1801 List<SocialRequest> list = q.list();
1802
1803 if (list.size() == 2) {
1804 return list.get(1);
1805 }
1806 else {
1807 return null;
1808 }
1809 }
1810
1811
1818 public List<SocialRequest> findByReceiverUserId(long receiverUserId)
1819 throws SystemException {
1820 return findByReceiverUserId(receiverUserId, QueryUtil.ALL_POS,
1821 QueryUtil.ALL_POS, null);
1822 }
1823
1824
1837 public List<SocialRequest> findByReceiverUserId(long receiverUserId,
1838 int start, int end) throws SystemException {
1839 return findByReceiverUserId(receiverUserId, start, end, null);
1840 }
1841
1842
1856 public List<SocialRequest> findByReceiverUserId(long receiverUserId,
1857 int start, int end, OrderByComparator orderByComparator)
1858 throws SystemException {
1859 Object[] finderArgs = new Object[] {
1860 receiverUserId,
1861
1862 String.valueOf(start), String.valueOf(end),
1863 String.valueOf(orderByComparator)
1864 };
1865
1866 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_RECEIVERUSERID,
1867 finderArgs, this);
1868
1869 if (list == null) {
1870 Session session = null;
1871
1872 try {
1873 session = openSession();
1874
1875 StringBundler query = null;
1876
1877 if (orderByComparator != null) {
1878 query = new StringBundler(3 +
1879 (orderByComparator.getOrderByFields().length * 3));
1880 }
1881 else {
1882 query = new StringBundler(3);
1883 }
1884
1885 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1886
1887 query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
1888
1889 if (orderByComparator != null) {
1890 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1891 orderByComparator);
1892 }
1893
1894 else {
1895 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1896 }
1897
1898 String sql = query.toString();
1899
1900 Query q = session.createQuery(sql);
1901
1902 QueryPos qPos = QueryPos.getInstance(q);
1903
1904 qPos.add(receiverUserId);
1905
1906 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1907 start, end);
1908 }
1909 catch (Exception e) {
1910 throw processException(e);
1911 }
1912 finally {
1913 if (list == null) {
1914 list = new ArrayList<SocialRequest>();
1915 }
1916
1917 cacheResult(list);
1918
1919 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_RECEIVERUSERID,
1920 finderArgs, list);
1921
1922 closeSession(session);
1923 }
1924 }
1925
1926 return list;
1927 }
1928
1929
1942 public SocialRequest findByReceiverUserId_First(long receiverUserId,
1943 OrderByComparator orderByComparator)
1944 throws NoSuchRequestException, SystemException {
1945 List<SocialRequest> list = findByReceiverUserId(receiverUserId, 0, 1,
1946 orderByComparator);
1947
1948 if (list.isEmpty()) {
1949 StringBundler msg = new StringBundler(4);
1950
1951 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1952
1953 msg.append("receiverUserId=");
1954 msg.append(receiverUserId);
1955
1956 msg.append(StringPool.CLOSE_CURLY_BRACE);
1957
1958 throw new NoSuchRequestException(msg.toString());
1959 }
1960 else {
1961 return list.get(0);
1962 }
1963 }
1964
1965
1978 public SocialRequest findByReceiverUserId_Last(long receiverUserId,
1979 OrderByComparator orderByComparator)
1980 throws NoSuchRequestException, SystemException {
1981 int count = countByReceiverUserId(receiverUserId);
1982
1983 List<SocialRequest> list = findByReceiverUserId(receiverUserId,
1984 count - 1, count, orderByComparator);
1985
1986 if (list.isEmpty()) {
1987 StringBundler msg = new StringBundler(4);
1988
1989 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1990
1991 msg.append("receiverUserId=");
1992 msg.append(receiverUserId);
1993
1994 msg.append(StringPool.CLOSE_CURLY_BRACE);
1995
1996 throw new NoSuchRequestException(msg.toString());
1997 }
1998 else {
1999 return list.get(0);
2000 }
2001 }
2002
2003
2017 public SocialRequest[] findByReceiverUserId_PrevAndNext(long requestId,
2018 long receiverUserId, OrderByComparator orderByComparator)
2019 throws NoSuchRequestException, SystemException {
2020 SocialRequest socialRequest = findByPrimaryKey(requestId);
2021
2022 Session session = null;
2023
2024 try {
2025 session = openSession();
2026
2027 SocialRequest[] array = new SocialRequestImpl[3];
2028
2029 array[0] = getByReceiverUserId_PrevAndNext(session, socialRequest,
2030 receiverUserId, orderByComparator, true);
2031
2032 array[1] = socialRequest;
2033
2034 array[2] = getByReceiverUserId_PrevAndNext(session, socialRequest,
2035 receiverUserId, orderByComparator, false);
2036
2037 return array;
2038 }
2039 catch (Exception e) {
2040 throw processException(e);
2041 }
2042 finally {
2043 closeSession(session);
2044 }
2045 }
2046
2047 protected SocialRequest getByReceiverUserId_PrevAndNext(Session session,
2048 SocialRequest socialRequest, long receiverUserId,
2049 OrderByComparator orderByComparator, boolean previous) {
2050 StringBundler query = null;
2051
2052 if (orderByComparator != null) {
2053 query = new StringBundler(6 +
2054 (orderByComparator.getOrderByFields().length * 6));
2055 }
2056 else {
2057 query = new StringBundler(3);
2058 }
2059
2060 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2061
2062 query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
2063
2064 if (orderByComparator != null) {
2065 String[] orderByFields = orderByComparator.getOrderByFields();
2066
2067 if (orderByFields.length > 0) {
2068 query.append(WHERE_AND);
2069 }
2070
2071 for (int i = 0; i < orderByFields.length; i++) {
2072 query.append(_ORDER_BY_ENTITY_ALIAS);
2073 query.append(orderByFields[i]);
2074
2075 if ((i + 1) < orderByFields.length) {
2076 if (orderByComparator.isAscending() ^ previous) {
2077 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2078 }
2079 else {
2080 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2081 }
2082 }
2083 else {
2084 if (orderByComparator.isAscending() ^ previous) {
2085 query.append(WHERE_GREATER_THAN);
2086 }
2087 else {
2088 query.append(WHERE_LESSER_THAN);
2089 }
2090 }
2091 }
2092
2093 query.append(ORDER_BY_CLAUSE);
2094
2095 for (int i = 0; i < orderByFields.length; i++) {
2096 query.append(_ORDER_BY_ENTITY_ALIAS);
2097 query.append(orderByFields[i]);
2098
2099 if ((i + 1) < orderByFields.length) {
2100 if (orderByComparator.isAscending() ^ previous) {
2101 query.append(ORDER_BY_ASC_HAS_NEXT);
2102 }
2103 else {
2104 query.append(ORDER_BY_DESC_HAS_NEXT);
2105 }
2106 }
2107 else {
2108 if (orderByComparator.isAscending() ^ previous) {
2109 query.append(ORDER_BY_ASC);
2110 }
2111 else {
2112 query.append(ORDER_BY_DESC);
2113 }
2114 }
2115 }
2116 }
2117
2118 else {
2119 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2120 }
2121
2122 String sql = query.toString();
2123
2124 Query q = session.createQuery(sql);
2125
2126 q.setFirstResult(0);
2127 q.setMaxResults(2);
2128
2129 QueryPos qPos = QueryPos.getInstance(q);
2130
2131 qPos.add(receiverUserId);
2132
2133 if (orderByComparator != null) {
2134 Object[] values = orderByComparator.getOrderByValues(socialRequest);
2135
2136 for (Object value : values) {
2137 qPos.add(value);
2138 }
2139 }
2140
2141 List<SocialRequest> list = q.list();
2142
2143 if (list.size() == 2) {
2144 return list.get(1);
2145 }
2146 else {
2147 return null;
2148 }
2149 }
2150
2151
2159 public List<SocialRequest> findByU_S(long userId, int status)
2160 throws SystemException {
2161 return findByU_S(userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2162 null);
2163 }
2164
2165
2179 public List<SocialRequest> findByU_S(long userId, int status, int start,
2180 int end) throws SystemException {
2181 return findByU_S(userId, status, start, end, null);
2182 }
2183
2184
2199 public List<SocialRequest> findByU_S(long userId, int status, int start,
2200 int end, OrderByComparator orderByComparator) throws SystemException {
2201 Object[] finderArgs = new Object[] {
2202 userId, status,
2203
2204 String.valueOf(start), String.valueOf(end),
2205 String.valueOf(orderByComparator)
2206 };
2207
2208 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_S,
2209 finderArgs, this);
2210
2211 if (list == null) {
2212 Session session = null;
2213
2214 try {
2215 session = openSession();
2216
2217 StringBundler query = null;
2218
2219 if (orderByComparator != null) {
2220 query = new StringBundler(4 +
2221 (orderByComparator.getOrderByFields().length * 3));
2222 }
2223 else {
2224 query = new StringBundler(4);
2225 }
2226
2227 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2228
2229 query.append(_FINDER_COLUMN_U_S_USERID_2);
2230
2231 query.append(_FINDER_COLUMN_U_S_STATUS_2);
2232
2233 if (orderByComparator != null) {
2234 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2235 orderByComparator);
2236 }
2237
2238 else {
2239 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2240 }
2241
2242 String sql = query.toString();
2243
2244 Query q = session.createQuery(sql);
2245
2246 QueryPos qPos = QueryPos.getInstance(q);
2247
2248 qPos.add(userId);
2249
2250 qPos.add(status);
2251
2252 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
2253 start, end);
2254 }
2255 catch (Exception e) {
2256 throw processException(e);
2257 }
2258 finally {
2259 if (list == null) {
2260 list = new ArrayList<SocialRequest>();
2261 }
2262
2263 cacheResult(list);
2264
2265 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_S, finderArgs,
2266 list);
2267
2268 closeSession(session);
2269 }
2270 }
2271
2272 return list;
2273 }
2274
2275
2289 public SocialRequest findByU_S_First(long userId, int status,
2290 OrderByComparator orderByComparator)
2291 throws NoSuchRequestException, SystemException {
2292 List<SocialRequest> list = findByU_S(userId, status, 0, 1,
2293 orderByComparator);
2294
2295 if (list.isEmpty()) {
2296 StringBundler msg = new StringBundler(6);
2297
2298 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2299
2300 msg.append("userId=");
2301 msg.append(userId);
2302
2303 msg.append(", status=");
2304 msg.append(status);
2305
2306 msg.append(StringPool.CLOSE_CURLY_BRACE);
2307
2308 throw new NoSuchRequestException(msg.toString());
2309 }
2310 else {
2311 return list.get(0);
2312 }
2313 }
2314
2315
2329 public SocialRequest findByU_S_Last(long userId, int status,
2330 OrderByComparator orderByComparator)
2331 throws NoSuchRequestException, SystemException {
2332 int count = countByU_S(userId, status);
2333
2334 List<SocialRequest> list = findByU_S(userId, status, count - 1, count,
2335 orderByComparator);
2336
2337 if (list.isEmpty()) {
2338 StringBundler msg = new StringBundler(6);
2339
2340 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2341
2342 msg.append("userId=");
2343 msg.append(userId);
2344
2345 msg.append(", status=");
2346 msg.append(status);
2347
2348 msg.append(StringPool.CLOSE_CURLY_BRACE);
2349
2350 throw new NoSuchRequestException(msg.toString());
2351 }
2352 else {
2353 return list.get(0);
2354 }
2355 }
2356
2357
2372 public SocialRequest[] findByU_S_PrevAndNext(long requestId, long userId,
2373 int status, OrderByComparator orderByComparator)
2374 throws NoSuchRequestException, SystemException {
2375 SocialRequest socialRequest = findByPrimaryKey(requestId);
2376
2377 Session session = null;
2378
2379 try {
2380 session = openSession();
2381
2382 SocialRequest[] array = new SocialRequestImpl[3];
2383
2384 array[0] = getByU_S_PrevAndNext(session, socialRequest, userId,
2385 status, orderByComparator, true);
2386
2387 array[1] = socialRequest;
2388
2389 array[2] = getByU_S_PrevAndNext(session, socialRequest, userId,
2390 status, orderByComparator, false);
2391
2392 return array;
2393 }
2394 catch (Exception e) {
2395 throw processException(e);
2396 }
2397 finally {
2398 closeSession(session);
2399 }
2400 }
2401
2402 protected SocialRequest getByU_S_PrevAndNext(Session session,
2403 SocialRequest socialRequest, long userId, int status,
2404 OrderByComparator orderByComparator, boolean previous) {
2405 StringBundler query = null;
2406
2407 if (orderByComparator != null) {
2408 query = new StringBundler(6 +
2409 (orderByComparator.getOrderByFields().length * 6));
2410 }
2411 else {
2412 query = new StringBundler(3);
2413 }
2414
2415 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2416
2417 query.append(_FINDER_COLUMN_U_S_USERID_2);
2418
2419 query.append(_FINDER_COLUMN_U_S_STATUS_2);
2420
2421 if (orderByComparator != null) {
2422 String[] orderByFields = orderByComparator.getOrderByFields();
2423
2424 if (orderByFields.length > 0) {
2425 query.append(WHERE_AND);
2426 }
2427
2428 for (int i = 0; i < orderByFields.length; i++) {
2429 query.append(_ORDER_BY_ENTITY_ALIAS);
2430 query.append(orderByFields[i]);
2431
2432 if ((i + 1) < orderByFields.length) {
2433 if (orderByComparator.isAscending() ^ previous) {
2434 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2435 }
2436 else {
2437 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2438 }
2439 }
2440 else {
2441 if (orderByComparator.isAscending() ^ previous) {
2442 query.append(WHERE_GREATER_THAN);
2443 }
2444 else {
2445 query.append(WHERE_LESSER_THAN);
2446 }
2447 }
2448 }
2449
2450 query.append(ORDER_BY_CLAUSE);
2451
2452 for (int i = 0; i < orderByFields.length; i++) {
2453 query.append(_ORDER_BY_ENTITY_ALIAS);
2454 query.append(orderByFields[i]);
2455
2456 if ((i + 1) < orderByFields.length) {
2457 if (orderByComparator.isAscending() ^ previous) {
2458 query.append(ORDER_BY_ASC_HAS_NEXT);
2459 }
2460 else {
2461 query.append(ORDER_BY_DESC_HAS_NEXT);
2462 }
2463 }
2464 else {
2465 if (orderByComparator.isAscending() ^ previous) {
2466 query.append(ORDER_BY_ASC);
2467 }
2468 else {
2469 query.append(ORDER_BY_DESC);
2470 }
2471 }
2472 }
2473 }
2474
2475 else {
2476 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2477 }
2478
2479 String sql = query.toString();
2480
2481 Query q = session.createQuery(sql);
2482
2483 q.setFirstResult(0);
2484 q.setMaxResults(2);
2485
2486 QueryPos qPos = QueryPos.getInstance(q);
2487
2488 qPos.add(userId);
2489
2490 qPos.add(status);
2491
2492 if (orderByComparator != null) {
2493 Object[] values = orderByComparator.getOrderByValues(socialRequest);
2494
2495 for (Object value : values) {
2496 qPos.add(value);
2497 }
2498 }
2499
2500 List<SocialRequest> list = q.list();
2501
2502 if (list.size() == 2) {
2503 return list.get(1);
2504 }
2505 else {
2506 return null;
2507 }
2508 }
2509
2510
2518 public List<SocialRequest> findByR_S(long receiverUserId, int status)
2519 throws SystemException {
2520 return findByR_S(receiverUserId, status, QueryUtil.ALL_POS,
2521 QueryUtil.ALL_POS, null);
2522 }
2523
2524
2538 public List<SocialRequest> findByR_S(long receiverUserId, int status,
2539 int start, int end) throws SystemException {
2540 return findByR_S(receiverUserId, status, start, end, null);
2541 }
2542
2543
2558 public List<SocialRequest> findByR_S(long receiverUserId, int status,
2559 int start, int end, OrderByComparator orderByComparator)
2560 throws SystemException {
2561 Object[] finderArgs = new Object[] {
2562 receiverUserId, status,
2563
2564 String.valueOf(start), String.valueOf(end),
2565 String.valueOf(orderByComparator)
2566 };
2567
2568 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_R_S,
2569 finderArgs, this);
2570
2571 if (list == null) {
2572 Session session = null;
2573
2574 try {
2575 session = openSession();
2576
2577 StringBundler query = null;
2578
2579 if (orderByComparator != null) {
2580 query = new StringBundler(4 +
2581 (orderByComparator.getOrderByFields().length * 3));
2582 }
2583 else {
2584 query = new StringBundler(4);
2585 }
2586
2587 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2588
2589 query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
2590
2591 query.append(_FINDER_COLUMN_R_S_STATUS_2);
2592
2593 if (orderByComparator != null) {
2594 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2595 orderByComparator);
2596 }
2597
2598 else {
2599 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2600 }
2601
2602 String sql = query.toString();
2603
2604 Query q = session.createQuery(sql);
2605
2606 QueryPos qPos = QueryPos.getInstance(q);
2607
2608 qPos.add(receiverUserId);
2609
2610 qPos.add(status);
2611
2612 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
2613 start, end);
2614 }
2615 catch (Exception e) {
2616 throw processException(e);
2617 }
2618 finally {
2619 if (list == null) {
2620 list = new ArrayList<SocialRequest>();
2621 }
2622
2623 cacheResult(list);
2624
2625 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_R_S, finderArgs,
2626 list);
2627
2628 closeSession(session);
2629 }
2630 }
2631
2632 return list;
2633 }
2634
2635
2649 public SocialRequest findByR_S_First(long receiverUserId, int status,
2650 OrderByComparator orderByComparator)
2651 throws NoSuchRequestException, SystemException {
2652 List<SocialRequest> list = findByR_S(receiverUserId, status, 0, 1,
2653 orderByComparator);
2654
2655 if (list.isEmpty()) {
2656 StringBundler msg = new StringBundler(6);
2657
2658 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2659
2660 msg.append("receiverUserId=");
2661 msg.append(receiverUserId);
2662
2663 msg.append(", status=");
2664 msg.append(status);
2665
2666 msg.append(StringPool.CLOSE_CURLY_BRACE);
2667
2668 throw new NoSuchRequestException(msg.toString());
2669 }
2670 else {
2671 return list.get(0);
2672 }
2673 }
2674
2675
2689 public SocialRequest findByR_S_Last(long receiverUserId, int status,
2690 OrderByComparator orderByComparator)
2691 throws NoSuchRequestException, SystemException {
2692 int count = countByR_S(receiverUserId, status);
2693
2694 List<SocialRequest> list = findByR_S(receiverUserId, status, count - 1,
2695 count, orderByComparator);
2696
2697 if (list.isEmpty()) {
2698 StringBundler msg = new StringBundler(6);
2699
2700 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2701
2702 msg.append("receiverUserId=");
2703 msg.append(receiverUserId);
2704
2705 msg.append(", status=");
2706 msg.append(status);
2707
2708 msg.append(StringPool.CLOSE_CURLY_BRACE);
2709
2710 throw new NoSuchRequestException(msg.toString());
2711 }
2712 else {
2713 return list.get(0);
2714 }
2715 }
2716
2717
2732 public SocialRequest[] findByR_S_PrevAndNext(long requestId,
2733 long receiverUserId, int status, OrderByComparator orderByComparator)
2734 throws NoSuchRequestException, SystemException {
2735 SocialRequest socialRequest = findByPrimaryKey(requestId);
2736
2737 Session session = null;
2738
2739 try {
2740 session = openSession();
2741
2742 SocialRequest[] array = new SocialRequestImpl[3];
2743
2744 array[0] = getByR_S_PrevAndNext(session, socialRequest,
2745 receiverUserId, status, orderByComparator, true);
2746
2747 array[1] = socialRequest;
2748
2749 array[2] = getByR_S_PrevAndNext(session, socialRequest,
2750 receiverUserId, status, orderByComparator, false);
2751
2752 return array;
2753 }
2754 catch (Exception e) {
2755 throw processException(e);
2756 }
2757 finally {
2758 closeSession(session);
2759 }
2760 }
2761
2762 protected SocialRequest getByR_S_PrevAndNext(Session session,
2763 SocialRequest socialRequest, long receiverUserId, int status,
2764 OrderByComparator orderByComparator, boolean previous) {
2765 StringBundler query = null;
2766
2767 if (orderByComparator != null) {
2768 query = new StringBundler(6 +
2769 (orderByComparator.getOrderByFields().length * 6));
2770 }
2771 else {
2772 query = new StringBundler(3);
2773 }
2774
2775 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2776
2777 query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
2778
2779 query.append(_FINDER_COLUMN_R_S_STATUS_2);
2780
2781 if (orderByComparator != null) {
2782 String[] orderByFields = orderByComparator.getOrderByFields();
2783
2784 if (orderByFields.length > 0) {
2785 query.append(WHERE_AND);
2786 }
2787
2788 for (int i = 0; i < orderByFields.length; i++) {
2789 query.append(_ORDER_BY_ENTITY_ALIAS);
2790 query.append(orderByFields[i]);
2791
2792 if ((i + 1) < orderByFields.length) {
2793 if (orderByComparator.isAscending() ^ previous) {
2794 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2795 }
2796 else {
2797 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2798 }
2799 }
2800 else {
2801 if (orderByComparator.isAscending() ^ previous) {
2802 query.append(WHERE_GREATER_THAN);
2803 }
2804 else {
2805 query.append(WHERE_LESSER_THAN);
2806 }
2807 }
2808 }
2809
2810 query.append(ORDER_BY_CLAUSE);
2811
2812 for (int i = 0; i < orderByFields.length; i++) {
2813 query.append(_ORDER_BY_ENTITY_ALIAS);
2814 query.append(orderByFields[i]);
2815
2816 if ((i + 1) < orderByFields.length) {
2817 if (orderByComparator.isAscending() ^ previous) {
2818 query.append(ORDER_BY_ASC_HAS_NEXT);
2819 }
2820 else {
2821 query.append(ORDER_BY_DESC_HAS_NEXT);
2822 }
2823 }
2824 else {
2825 if (orderByComparator.isAscending() ^ previous) {
2826 query.append(ORDER_BY_ASC);
2827 }
2828 else {
2829 query.append(ORDER_BY_DESC);
2830 }
2831 }
2832 }
2833 }
2834
2835 else {
2836 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2837 }
2838
2839 String sql = query.toString();
2840
2841 Query q = session.createQuery(sql);
2842
2843 q.setFirstResult(0);
2844 q.setMaxResults(2);
2845
2846 QueryPos qPos = QueryPos.getInstance(q);
2847
2848 qPos.add(receiverUserId);
2849
2850 qPos.add(status);
2851
2852 if (orderByComparator != null) {
2853 Object[] values = orderByComparator.getOrderByValues(socialRequest);
2854
2855 for (Object value : values) {
2856 qPos.add(value);
2857 }
2858 }
2859
2860 List<SocialRequest> list = q.list();
2861
2862 if (list.size() == 2) {
2863 return list.get(1);
2864 }
2865 else {
2866 return null;
2867 }
2868 }
2869
2870
2882 public SocialRequest findByU_C_C_T_R(long userId, long classNameId,
2883 long classPK, int type, long receiverUserId)
2884 throws NoSuchRequestException, SystemException {
2885 SocialRequest socialRequest = fetchByU_C_C_T_R(userId, classNameId,
2886 classPK, type, receiverUserId);
2887
2888 if (socialRequest == null) {
2889 StringBundler msg = new StringBundler(12);
2890
2891 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2892
2893 msg.append("userId=");
2894 msg.append(userId);
2895
2896 msg.append(", classNameId=");
2897 msg.append(classNameId);
2898
2899 msg.append(", classPK=");
2900 msg.append(classPK);
2901
2902 msg.append(", type=");
2903 msg.append(type);
2904
2905 msg.append(", receiverUserId=");
2906 msg.append(receiverUserId);
2907
2908 msg.append(StringPool.CLOSE_CURLY_BRACE);
2909
2910 if (_log.isWarnEnabled()) {
2911 _log.warn(msg.toString());
2912 }
2913
2914 throw new NoSuchRequestException(msg.toString());
2915 }
2916
2917 return socialRequest;
2918 }
2919
2920
2931 public SocialRequest fetchByU_C_C_T_R(long userId, long classNameId,
2932 long classPK, int type, long receiverUserId) throws SystemException {
2933 return fetchByU_C_C_T_R(userId, classNameId, classPK, type,
2934 receiverUserId, true);
2935 }
2936
2937
2948 public SocialRequest fetchByU_C_C_T_R(long userId, long classNameId,
2949 long classPK, int type, long receiverUserId, boolean retrieveFromCache)
2950 throws SystemException {
2951 Object[] finderArgs = new Object[] {
2952 userId, classNameId, classPK, type, receiverUserId
2953 };
2954
2955 Object result = null;
2956
2957 if (retrieveFromCache) {
2958 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
2959 finderArgs, this);
2960 }
2961
2962 if (result == null) {
2963 Session session = null;
2964
2965 try {
2966 session = openSession();
2967
2968 StringBundler query = new StringBundler(7);
2969
2970 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2971
2972 query.append(_FINDER_COLUMN_U_C_C_T_R_USERID_2);
2973
2974 query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2);
2975
2976 query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSPK_2);
2977
2978 query.append(_FINDER_COLUMN_U_C_C_T_R_TYPE_2);
2979
2980 query.append(_FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2);
2981
2982 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2983
2984 String sql = query.toString();
2985
2986 Query q = session.createQuery(sql);
2987
2988 QueryPos qPos = QueryPos.getInstance(q);
2989
2990 qPos.add(userId);
2991
2992 qPos.add(classNameId);
2993
2994 qPos.add(classPK);
2995
2996 qPos.add(type);
2997
2998 qPos.add(receiverUserId);
2999
3000 List<SocialRequest> list = q.list();
3001
3002 result = list;
3003
3004 SocialRequest socialRequest = null;
3005
3006 if (list.isEmpty()) {
3007 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3008 finderArgs, list);
3009 }
3010 else {
3011 socialRequest = list.get(0);
3012
3013 cacheResult(socialRequest);
3014
3015 if ((socialRequest.getUserId() != userId) ||
3016 (socialRequest.getClassNameId() != classNameId) ||
3017 (socialRequest.getClassPK() != classPK) ||
3018 (socialRequest.getType() != type) ||
3019 (socialRequest.getReceiverUserId() != receiverUserId)) {
3020 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3021 finderArgs, socialRequest);
3022 }
3023 }
3024
3025 return socialRequest;
3026 }
3027 catch (Exception e) {
3028 throw processException(e);
3029 }
3030 finally {
3031 if (result == null) {
3032 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3033 finderArgs, new ArrayList<SocialRequest>());
3034 }
3035
3036 closeSession(session);
3037 }
3038 }
3039 else {
3040 if (result instanceof List<?>) {
3041 return null;
3042 }
3043 else {
3044 return (SocialRequest)result;
3045 }
3046 }
3047 }
3048
3049
3060 public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
3061 long classPK, int type, int status) throws SystemException {
3062 return findByU_C_C_T_S(userId, classNameId, classPK, type, status,
3063 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3064 }
3065
3066
3083 public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
3084 long classPK, int type, int status, int start, int end)
3085 throws SystemException {
3086 return findByU_C_C_T_S(userId, classNameId, classPK, type, status,
3087 start, end, null);
3088 }
3089
3090
3108 public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
3109 long classPK, int type, int status, int start, int end,
3110 OrderByComparator orderByComparator) throws SystemException {
3111 Object[] finderArgs = new Object[] {
3112 userId, classNameId, classPK, type, status,
3113
3114 String.valueOf(start), String.valueOf(end),
3115 String.valueOf(orderByComparator)
3116 };
3117
3118 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_C_C_T_S,
3119 finderArgs, this);
3120
3121 if (list == null) {
3122 Session session = null;
3123
3124 try {
3125 session = openSession();
3126
3127 StringBundler query = null;
3128
3129 if (orderByComparator != null) {
3130 query = new StringBundler(7 +
3131 (orderByComparator.getOrderByFields().length * 3));
3132 }
3133 else {
3134 query = new StringBundler(7);
3135 }
3136
3137 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3138
3139 query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
3140
3141 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
3142
3143 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
3144
3145 query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
3146
3147 query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
3148
3149 if (orderByComparator != null) {
3150 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3151 orderByComparator);
3152 }
3153
3154 else {
3155 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3156 }
3157
3158 String sql = query.toString();
3159
3160 Query q = session.createQuery(sql);
3161
3162 QueryPos qPos = QueryPos.getInstance(q);
3163
3164 qPos.add(userId);
3165
3166 qPos.add(classNameId);
3167
3168 qPos.add(classPK);
3169
3170 qPos.add(type);
3171
3172 qPos.add(status);
3173
3174 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3175 start, end);
3176 }
3177 catch (Exception e) {
3178 throw processException(e);
3179 }
3180 finally {
3181 if (list == null) {
3182 list = new ArrayList<SocialRequest>();
3183 }
3184
3185 cacheResult(list);
3186
3187 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_C_C_T_S,
3188 finderArgs, list);
3189
3190 closeSession(session);
3191 }
3192 }
3193
3194 return list;
3195 }
3196
3197
3214 public SocialRequest findByU_C_C_T_S_First(long userId, long classNameId,
3215 long classPK, int type, int status, OrderByComparator orderByComparator)
3216 throws NoSuchRequestException, SystemException {
3217 List<SocialRequest> list = findByU_C_C_T_S(userId, classNameId,
3218 classPK, type, status, 0, 1, orderByComparator);
3219
3220 if (list.isEmpty()) {
3221 StringBundler msg = new StringBundler(12);
3222
3223 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3224
3225 msg.append("userId=");
3226 msg.append(userId);
3227
3228 msg.append(", classNameId=");
3229 msg.append(classNameId);
3230
3231 msg.append(", classPK=");
3232 msg.append(classPK);
3233
3234 msg.append(", type=");
3235 msg.append(type);
3236
3237 msg.append(", status=");
3238 msg.append(status);
3239
3240 msg.append(StringPool.CLOSE_CURLY_BRACE);
3241
3242 throw new NoSuchRequestException(msg.toString());
3243 }
3244 else {
3245 return list.get(0);
3246 }
3247 }
3248
3249
3266 public SocialRequest findByU_C_C_T_S_Last(long userId, long classNameId,
3267 long classPK, int type, int status, OrderByComparator orderByComparator)
3268 throws NoSuchRequestException, SystemException {
3269 int count = countByU_C_C_T_S(userId, classNameId, classPK, type, status);
3270
3271 List<SocialRequest> list = findByU_C_C_T_S(userId, classNameId,
3272 classPK, type, status, count - 1, count, orderByComparator);
3273
3274 if (list.isEmpty()) {
3275 StringBundler msg = new StringBundler(12);
3276
3277 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3278
3279 msg.append("userId=");
3280 msg.append(userId);
3281
3282 msg.append(", classNameId=");
3283 msg.append(classNameId);
3284
3285 msg.append(", classPK=");
3286 msg.append(classPK);
3287
3288 msg.append(", type=");
3289 msg.append(type);
3290
3291 msg.append(", status=");
3292 msg.append(status);
3293
3294 msg.append(StringPool.CLOSE_CURLY_BRACE);
3295
3296 throw new NoSuchRequestException(msg.toString());
3297 }
3298 else {
3299 return list.get(0);
3300 }
3301 }
3302
3303
3321 public SocialRequest[] findByU_C_C_T_S_PrevAndNext(long requestId,
3322 long userId, long classNameId, long classPK, int type, int status,
3323 OrderByComparator orderByComparator)
3324 throws NoSuchRequestException, SystemException {
3325 SocialRequest socialRequest = findByPrimaryKey(requestId);
3326
3327 Session session = null;
3328
3329 try {
3330 session = openSession();
3331
3332 SocialRequest[] array = new SocialRequestImpl[3];
3333
3334 array[0] = getByU_C_C_T_S_PrevAndNext(session, socialRequest,
3335 userId, classNameId, classPK, type, status,
3336 orderByComparator, true);
3337
3338 array[1] = socialRequest;
3339
3340 array[2] = getByU_C_C_T_S_PrevAndNext(session, socialRequest,
3341 userId, classNameId, classPK, type, status,
3342 orderByComparator, false);
3343
3344 return array;
3345 }
3346 catch (Exception e) {
3347 throw processException(e);
3348 }
3349 finally {
3350 closeSession(session);
3351 }
3352 }
3353
3354 protected SocialRequest getByU_C_C_T_S_PrevAndNext(Session session,
3355 SocialRequest socialRequest, long userId, long classNameId,
3356 long classPK, int type, int status,
3357 OrderByComparator orderByComparator, boolean previous) {
3358 StringBundler query = null;
3359
3360 if (orderByComparator != null) {
3361 query = new StringBundler(6 +
3362 (orderByComparator.getOrderByFields().length * 6));
3363 }
3364 else {
3365 query = new StringBundler(3);
3366 }
3367
3368 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3369
3370 query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
3371
3372 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
3373
3374 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
3375
3376 query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
3377
3378 query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
3379
3380 if (orderByComparator != null) {
3381 String[] orderByFields = orderByComparator.getOrderByFields();
3382
3383 if (orderByFields.length > 0) {
3384 query.append(WHERE_AND);
3385 }
3386
3387 for (int i = 0; i < orderByFields.length; i++) {
3388 query.append(_ORDER_BY_ENTITY_ALIAS);
3389 query.append(orderByFields[i]);
3390
3391 if ((i + 1) < orderByFields.length) {
3392 if (orderByComparator.isAscending() ^ previous) {
3393 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3394 }
3395 else {
3396 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3397 }
3398 }
3399 else {
3400 if (orderByComparator.isAscending() ^ previous) {
3401 query.append(WHERE_GREATER_THAN);
3402 }
3403 else {
3404 query.append(WHERE_LESSER_THAN);
3405 }
3406 }
3407 }
3408
3409 query.append(ORDER_BY_CLAUSE);
3410
3411 for (int i = 0; i < orderByFields.length; i++) {
3412 query.append(_ORDER_BY_ENTITY_ALIAS);
3413 query.append(orderByFields[i]);
3414
3415 if ((i + 1) < orderByFields.length) {
3416 if (orderByComparator.isAscending() ^ previous) {
3417 query.append(ORDER_BY_ASC_HAS_NEXT);
3418 }
3419 else {
3420 query.append(ORDER_BY_DESC_HAS_NEXT);
3421 }
3422 }
3423 else {
3424 if (orderByComparator.isAscending() ^ previous) {
3425 query.append(ORDER_BY_ASC);
3426 }
3427 else {
3428 query.append(ORDER_BY_DESC);
3429 }
3430 }
3431 }
3432 }
3433
3434 else {
3435 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3436 }
3437
3438 String sql = query.toString();
3439
3440 Query q = session.createQuery(sql);
3441
3442 q.setFirstResult(0);
3443 q.setMaxResults(2);
3444
3445 QueryPos qPos = QueryPos.getInstance(q);
3446
3447 qPos.add(userId);
3448
3449 qPos.add(classNameId);
3450
3451 qPos.add(classPK);
3452
3453 qPos.add(type);
3454
3455 qPos.add(status);
3456
3457 if (orderByComparator != null) {
3458 Object[] values = orderByComparator.getOrderByValues(socialRequest);
3459
3460 for (Object value : values) {
3461 qPos.add(value);
3462 }
3463 }
3464
3465 List<SocialRequest> list = q.list();
3466
3467 if (list.size() == 2) {
3468 return list.get(1);
3469 }
3470 else {
3471 return null;
3472 }
3473 }
3474
3475
3486 public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
3487 int type, long receiverUserId, int status) throws SystemException {
3488 return findByC_C_T_R_S(classNameId, classPK, type, receiverUserId,
3489 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3490 }
3491
3492
3509 public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
3510 int type, long receiverUserId, int status, int start, int end)
3511 throws SystemException {
3512 return findByC_C_T_R_S(classNameId, classPK, type, receiverUserId,
3513 status, start, end, null);
3514 }
3515
3516
3534 public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
3535 int type, long receiverUserId, int status, int start, int end,
3536 OrderByComparator orderByComparator) throws SystemException {
3537 Object[] finderArgs = new Object[] {
3538 classNameId, classPK, type, receiverUserId, status,
3539
3540 String.valueOf(start), String.valueOf(end),
3541 String.valueOf(orderByComparator)
3542 };
3543
3544 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C_T_R_S,
3545 finderArgs, this);
3546
3547 if (list == null) {
3548 Session session = null;
3549
3550 try {
3551 session = openSession();
3552
3553 StringBundler query = null;
3554
3555 if (orderByComparator != null) {
3556 query = new StringBundler(7 +
3557 (orderByComparator.getOrderByFields().length * 3));
3558 }
3559 else {
3560 query = new StringBundler(7);
3561 }
3562
3563 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3564
3565 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
3566
3567 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
3568
3569 query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
3570
3571 query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
3572
3573 query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
3574
3575 if (orderByComparator != null) {
3576 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3577 orderByComparator);
3578 }
3579
3580 else {
3581 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3582 }
3583
3584 String sql = query.toString();
3585
3586 Query q = session.createQuery(sql);
3587
3588 QueryPos qPos = QueryPos.getInstance(q);
3589
3590 qPos.add(classNameId);
3591
3592 qPos.add(classPK);
3593
3594 qPos.add(type);
3595
3596 qPos.add(receiverUserId);
3597
3598 qPos.add(status);
3599
3600 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3601 start, end);
3602 }
3603 catch (Exception e) {
3604 throw processException(e);
3605 }
3606 finally {
3607 if (list == null) {
3608 list = new ArrayList<SocialRequest>();
3609 }
3610
3611 cacheResult(list);
3612
3613 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C_T_R_S,
3614 finderArgs, list);
3615
3616 closeSession(session);
3617 }
3618 }
3619
3620 return list;
3621 }
3622
3623
3640 public SocialRequest findByC_C_T_R_S_First(long classNameId, long classPK,
3641 int type, long receiverUserId, int status,
3642 OrderByComparator orderByComparator)
3643 throws NoSuchRequestException, SystemException {
3644 List<SocialRequest> list = findByC_C_T_R_S(classNameId, classPK, type,
3645 receiverUserId, status, 0, 1, orderByComparator);
3646
3647 if (list.isEmpty()) {
3648 StringBundler msg = new StringBundler(12);
3649
3650 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3651
3652 msg.append("classNameId=");
3653 msg.append(classNameId);
3654
3655 msg.append(", classPK=");
3656 msg.append(classPK);
3657
3658 msg.append(", type=");
3659 msg.append(type);
3660
3661 msg.append(", receiverUserId=");
3662 msg.append(receiverUserId);
3663
3664 msg.append(", status=");
3665 msg.append(status);
3666
3667 msg.append(StringPool.CLOSE_CURLY_BRACE);
3668
3669 throw new NoSuchRequestException(msg.toString());
3670 }
3671 else {
3672 return list.get(0);
3673 }
3674 }
3675
3676
3693 public SocialRequest findByC_C_T_R_S_Last(long classNameId, long classPK,
3694 int type, long receiverUserId, int status,
3695 OrderByComparator orderByComparator)
3696 throws NoSuchRequestException, SystemException {
3697 int count = countByC_C_T_R_S(classNameId, classPK, type,
3698 receiverUserId, status);
3699
3700 List<SocialRequest> list = findByC_C_T_R_S(classNameId, classPK, type,
3701 receiverUserId, status, count - 1, count, orderByComparator);
3702
3703 if (list.isEmpty()) {
3704 StringBundler msg = new StringBundler(12);
3705
3706 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3707
3708 msg.append("classNameId=");
3709 msg.append(classNameId);
3710
3711 msg.append(", classPK=");
3712 msg.append(classPK);
3713
3714 msg.append(", type=");
3715 msg.append(type);
3716
3717 msg.append(", receiverUserId=");
3718 msg.append(receiverUserId);
3719
3720 msg.append(", status=");
3721 msg.append(status);
3722
3723 msg.append(StringPool.CLOSE_CURLY_BRACE);
3724
3725 throw new NoSuchRequestException(msg.toString());
3726 }
3727 else {
3728 return list.get(0);
3729 }
3730 }
3731
3732
3750 public SocialRequest[] findByC_C_T_R_S_PrevAndNext(long requestId,
3751 long classNameId, long classPK, int type, long receiverUserId,
3752 int status, OrderByComparator orderByComparator)
3753 throws NoSuchRequestException, SystemException {
3754 SocialRequest socialRequest = findByPrimaryKey(requestId);
3755
3756 Session session = null;
3757
3758 try {
3759 session = openSession();
3760
3761 SocialRequest[] array = new SocialRequestImpl[3];
3762
3763 array[0] = getByC_C_T_R_S_PrevAndNext(session, socialRequest,
3764 classNameId, classPK, type, receiverUserId, status,
3765 orderByComparator, true);
3766
3767 array[1] = socialRequest;
3768
3769 array[2] = getByC_C_T_R_S_PrevAndNext(session, socialRequest,
3770 classNameId, classPK, type, receiverUserId, status,
3771 orderByComparator, false);
3772
3773 return array;
3774 }
3775 catch (Exception e) {
3776 throw processException(e);
3777 }
3778 finally {
3779 closeSession(session);
3780 }
3781 }
3782
3783 protected SocialRequest getByC_C_T_R_S_PrevAndNext(Session session,
3784 SocialRequest socialRequest, long classNameId, long classPK, int type,
3785 long receiverUserId, int status, OrderByComparator orderByComparator,
3786 boolean previous) {
3787 StringBundler query = null;
3788
3789 if (orderByComparator != null) {
3790 query = new StringBundler(6 +
3791 (orderByComparator.getOrderByFields().length * 6));
3792 }
3793 else {
3794 query = new StringBundler(3);
3795 }
3796
3797 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3798
3799 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
3800
3801 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
3802
3803 query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
3804
3805 query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
3806
3807 query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
3808
3809 if (orderByComparator != null) {
3810 String[] orderByFields = orderByComparator.getOrderByFields();
3811
3812 if (orderByFields.length > 0) {
3813 query.append(WHERE_AND);
3814 }
3815
3816 for (int i = 0; i < orderByFields.length; i++) {
3817 query.append(_ORDER_BY_ENTITY_ALIAS);
3818 query.append(orderByFields[i]);
3819
3820 if ((i + 1) < orderByFields.length) {
3821 if (orderByComparator.isAscending() ^ previous) {
3822 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3823 }
3824 else {
3825 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3826 }
3827 }
3828 else {
3829 if (orderByComparator.isAscending() ^ previous) {
3830 query.append(WHERE_GREATER_THAN);
3831 }
3832 else {
3833 query.append(WHERE_LESSER_THAN);
3834 }
3835 }
3836 }
3837
3838 query.append(ORDER_BY_CLAUSE);
3839
3840 for (int i = 0; i < orderByFields.length; i++) {
3841 query.append(_ORDER_BY_ENTITY_ALIAS);
3842 query.append(orderByFields[i]);
3843
3844 if ((i + 1) < orderByFields.length) {
3845 if (orderByComparator.isAscending() ^ previous) {
3846 query.append(ORDER_BY_ASC_HAS_NEXT);
3847 }
3848 else {
3849 query.append(ORDER_BY_DESC_HAS_NEXT);
3850 }
3851 }
3852 else {
3853 if (orderByComparator.isAscending() ^ previous) {
3854 query.append(ORDER_BY_ASC);
3855 }
3856 else {
3857 query.append(ORDER_BY_DESC);
3858 }
3859 }
3860 }
3861 }
3862
3863 else {
3864 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3865 }
3866
3867 String sql = query.toString();
3868
3869 Query q = session.createQuery(sql);
3870
3871 q.setFirstResult(0);
3872 q.setMaxResults(2);
3873
3874 QueryPos qPos = QueryPos.getInstance(q);
3875
3876 qPos.add(classNameId);
3877
3878 qPos.add(classPK);
3879
3880 qPos.add(type);
3881
3882 qPos.add(receiverUserId);
3883
3884 qPos.add(status);
3885
3886 if (orderByComparator != null) {
3887 Object[] values = orderByComparator.getOrderByValues(socialRequest);
3888
3889 for (Object value : values) {
3890 qPos.add(value);
3891 }
3892 }
3893
3894 List<SocialRequest> list = q.list();
3895
3896 if (list.size() == 2) {
3897 return list.get(1);
3898 }
3899 else {
3900 return null;
3901 }
3902 }
3903
3904
3910 public List<SocialRequest> findAll() throws SystemException {
3911 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3912 }
3913
3914
3926 public List<SocialRequest> findAll(int start, int end)
3927 throws SystemException {
3928 return findAll(start, end, null);
3929 }
3930
3931
3944 public List<SocialRequest> findAll(int start, int end,
3945 OrderByComparator orderByComparator) throws SystemException {
3946 Object[] finderArgs = new Object[] {
3947 String.valueOf(start), String.valueOf(end),
3948 String.valueOf(orderByComparator)
3949 };
3950
3951 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3952 finderArgs, this);
3953
3954 if (list == null) {
3955 Session session = null;
3956
3957 try {
3958 session = openSession();
3959
3960 StringBundler query = null;
3961 String sql = null;
3962
3963 if (orderByComparator != null) {
3964 query = new StringBundler(2 +
3965 (orderByComparator.getOrderByFields().length * 3));
3966
3967 query.append(_SQL_SELECT_SOCIALREQUEST);
3968
3969 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3970 orderByComparator);
3971
3972 sql = query.toString();
3973 }
3974 else {
3975 sql = _SQL_SELECT_SOCIALREQUEST.concat(SocialRequestModelImpl.ORDER_BY_JPQL);
3976 }
3977
3978 Query q = session.createQuery(sql);
3979
3980 if (orderByComparator == null) {
3981 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3982 start, end, false);
3983
3984 Collections.sort(list);
3985 }
3986 else {
3987 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3988 start, end);
3989 }
3990 }
3991 catch (Exception e) {
3992 throw processException(e);
3993 }
3994 finally {
3995 if (list == null) {
3996 list = new ArrayList<SocialRequest>();
3997 }
3998
3999 cacheResult(list);
4000
4001 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
4002
4003 closeSession(session);
4004 }
4005 }
4006
4007 return list;
4008 }
4009
4010
4016 public void removeByUuid(String uuid) throws SystemException {
4017 for (SocialRequest socialRequest : findByUuid(uuid)) {
4018 remove(socialRequest);
4019 }
4020 }
4021
4022
4029 public void removeByUUID_G(String uuid, long groupId)
4030 throws NoSuchRequestException, SystemException {
4031 SocialRequest socialRequest = findByUUID_G(uuid, groupId);
4032
4033 remove(socialRequest);
4034 }
4035
4036
4042 public void removeByCompanyId(long companyId) throws SystemException {
4043 for (SocialRequest socialRequest : findByCompanyId(companyId)) {
4044 remove(socialRequest);
4045 }
4046 }
4047
4048
4054 public void removeByUserId(long userId) throws SystemException {
4055 for (SocialRequest socialRequest : findByUserId(userId)) {
4056 remove(socialRequest);
4057 }
4058 }
4059
4060
4066 public void removeByReceiverUserId(long receiverUserId)
4067 throws SystemException {
4068 for (SocialRequest socialRequest : findByReceiverUserId(receiverUserId)) {
4069 remove(socialRequest);
4070 }
4071 }
4072
4073
4080 public void removeByU_S(long userId, int status) throws SystemException {
4081 for (SocialRequest socialRequest : findByU_S(userId, status)) {
4082 remove(socialRequest);
4083 }
4084 }
4085
4086
4093 public void removeByR_S(long receiverUserId, int status)
4094 throws SystemException {
4095 for (SocialRequest socialRequest : findByR_S(receiverUserId, status)) {
4096 remove(socialRequest);
4097 }
4098 }
4099
4100
4110 public void removeByU_C_C_T_R(long userId, long classNameId, long classPK,
4111 int type, long receiverUserId)
4112 throws NoSuchRequestException, SystemException {
4113 SocialRequest socialRequest = findByU_C_C_T_R(userId, classNameId,
4114 classPK, type, receiverUserId);
4115
4116 remove(socialRequest);
4117 }
4118
4119
4129 public void removeByU_C_C_T_S(long userId, long classNameId, long classPK,
4130 int type, int status) throws SystemException {
4131 for (SocialRequest socialRequest : findByU_C_C_T_S(userId, classNameId,
4132 classPK, type, status)) {
4133 remove(socialRequest);
4134 }
4135 }
4136
4137
4147 public void removeByC_C_T_R_S(long classNameId, long classPK, int type,
4148 long receiverUserId, int status) throws SystemException {
4149 for (SocialRequest socialRequest : findByC_C_T_R_S(classNameId,
4150 classPK, type, receiverUserId, status)) {
4151 remove(socialRequest);
4152 }
4153 }
4154
4155
4160 public void removeAll() throws SystemException {
4161 for (SocialRequest socialRequest : findAll()) {
4162 remove(socialRequest);
4163 }
4164 }
4165
4166
4173 public int countByUuid(String uuid) throws SystemException {
4174 Object[] finderArgs = new Object[] { uuid };
4175
4176 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4177 finderArgs, this);
4178
4179 if (count == null) {
4180 Session session = null;
4181
4182 try {
4183 session = openSession();
4184
4185 StringBundler query = new StringBundler(2);
4186
4187 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4188
4189 if (uuid == null) {
4190 query.append(_FINDER_COLUMN_UUID_UUID_1);
4191 }
4192 else {
4193 if (uuid.equals(StringPool.BLANK)) {
4194 query.append(_FINDER_COLUMN_UUID_UUID_3);
4195 }
4196 else {
4197 query.append(_FINDER_COLUMN_UUID_UUID_2);
4198 }
4199 }
4200
4201 String sql = query.toString();
4202
4203 Query q = session.createQuery(sql);
4204
4205 QueryPos qPos = QueryPos.getInstance(q);
4206
4207 if (uuid != null) {
4208 qPos.add(uuid);
4209 }
4210
4211 count = (Long)q.uniqueResult();
4212 }
4213 catch (Exception e) {
4214 throw processException(e);
4215 }
4216 finally {
4217 if (count == null) {
4218 count = Long.valueOf(0);
4219 }
4220
4221 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4222 finderArgs, count);
4223
4224 closeSession(session);
4225 }
4226 }
4227
4228 return count.intValue();
4229 }
4230
4231
4239 public int countByUUID_G(String uuid, long groupId)
4240 throws SystemException {
4241 Object[] finderArgs = new Object[] { uuid, groupId };
4242
4243 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4244 finderArgs, this);
4245
4246 if (count == null) {
4247 Session session = null;
4248
4249 try {
4250 session = openSession();
4251
4252 StringBundler query = new StringBundler(3);
4253
4254 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4255
4256 if (uuid == null) {
4257 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4258 }
4259 else {
4260 if (uuid.equals(StringPool.BLANK)) {
4261 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4262 }
4263 else {
4264 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4265 }
4266 }
4267
4268 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4269
4270 String sql = query.toString();
4271
4272 Query q = session.createQuery(sql);
4273
4274 QueryPos qPos = QueryPos.getInstance(q);
4275
4276 if (uuid != null) {
4277 qPos.add(uuid);
4278 }
4279
4280 qPos.add(groupId);
4281
4282 count = (Long)q.uniqueResult();
4283 }
4284 catch (Exception e) {
4285 throw processException(e);
4286 }
4287 finally {
4288 if (count == null) {
4289 count = Long.valueOf(0);
4290 }
4291
4292 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4293 finderArgs, count);
4294
4295 closeSession(session);
4296 }
4297 }
4298
4299 return count.intValue();
4300 }
4301
4302
4309 public int countByCompanyId(long companyId) throws SystemException {
4310 Object[] finderArgs = new Object[] { companyId };
4311
4312 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4313 finderArgs, this);
4314
4315 if (count == null) {
4316 Session session = null;
4317
4318 try {
4319 session = openSession();
4320
4321 StringBundler query = new StringBundler(2);
4322
4323 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4324
4325 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4326
4327 String sql = query.toString();
4328
4329 Query q = session.createQuery(sql);
4330
4331 QueryPos qPos = QueryPos.getInstance(q);
4332
4333 qPos.add(companyId);
4334
4335 count = (Long)q.uniqueResult();
4336 }
4337 catch (Exception e) {
4338 throw processException(e);
4339 }
4340 finally {
4341 if (count == null) {
4342 count = Long.valueOf(0);
4343 }
4344
4345 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4346 finderArgs, count);
4347
4348 closeSession(session);
4349 }
4350 }
4351
4352 return count.intValue();
4353 }
4354
4355
4362 public int countByUserId(long userId) throws SystemException {
4363 Object[] finderArgs = new Object[] { userId };
4364
4365 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
4366 finderArgs, this);
4367
4368 if (count == null) {
4369 Session session = null;
4370
4371 try {
4372 session = openSession();
4373
4374 StringBundler query = new StringBundler(2);
4375
4376 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4377
4378 query.append(_FINDER_COLUMN_USERID_USERID_2);
4379
4380 String sql = query.toString();
4381
4382 Query q = session.createQuery(sql);
4383
4384 QueryPos qPos = QueryPos.getInstance(q);
4385
4386 qPos.add(userId);
4387
4388 count = (Long)q.uniqueResult();
4389 }
4390 catch (Exception e) {
4391 throw processException(e);
4392 }
4393 finally {
4394 if (count == null) {
4395 count = Long.valueOf(0);
4396 }
4397
4398 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
4399 finderArgs, count);
4400
4401 closeSession(session);
4402 }
4403 }
4404
4405 return count.intValue();
4406 }
4407
4408
4415 public int countByReceiverUserId(long receiverUserId)
4416 throws SystemException {
4417 Object[] finderArgs = new Object[] { receiverUserId };
4418
4419 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
4420 finderArgs, this);
4421
4422 if (count == null) {
4423 Session session = null;
4424
4425 try {
4426 session = openSession();
4427
4428 StringBundler query = new StringBundler(2);
4429
4430 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4431
4432 query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
4433
4434 String sql = query.toString();
4435
4436 Query q = session.createQuery(sql);
4437
4438 QueryPos qPos = QueryPos.getInstance(q);
4439
4440 qPos.add(receiverUserId);
4441
4442 count = (Long)q.uniqueResult();
4443 }
4444 catch (Exception e) {
4445 throw processException(e);
4446 }
4447 finally {
4448 if (count == null) {
4449 count = Long.valueOf(0);
4450 }
4451
4452 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
4453 finderArgs, count);
4454
4455 closeSession(session);
4456 }
4457 }
4458
4459 return count.intValue();
4460 }
4461
4462
4470 public int countByU_S(long userId, int status) throws SystemException {
4471 Object[] finderArgs = new Object[] { userId, status };
4472
4473 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_S,
4474 finderArgs, this);
4475
4476 if (count == null) {
4477 Session session = null;
4478
4479 try {
4480 session = openSession();
4481
4482 StringBundler query = new StringBundler(3);
4483
4484 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4485
4486 query.append(_FINDER_COLUMN_U_S_USERID_2);
4487
4488 query.append(_FINDER_COLUMN_U_S_STATUS_2);
4489
4490 String sql = query.toString();
4491
4492 Query q = session.createQuery(sql);
4493
4494 QueryPos qPos = QueryPos.getInstance(q);
4495
4496 qPos.add(userId);
4497
4498 qPos.add(status);
4499
4500 count = (Long)q.uniqueResult();
4501 }
4502 catch (Exception e) {
4503 throw processException(e);
4504 }
4505 finally {
4506 if (count == null) {
4507 count = Long.valueOf(0);
4508 }
4509
4510 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_S, finderArgs,
4511 count);
4512
4513 closeSession(session);
4514 }
4515 }
4516
4517 return count.intValue();
4518 }
4519
4520
4528 public int countByR_S(long receiverUserId, int status)
4529 throws SystemException {
4530 Object[] finderArgs = new Object[] { receiverUserId, status };
4531
4532 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_S,
4533 finderArgs, this);
4534
4535 if (count == null) {
4536 Session session = null;
4537
4538 try {
4539 session = openSession();
4540
4541 StringBundler query = new StringBundler(3);
4542
4543 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4544
4545 query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
4546
4547 query.append(_FINDER_COLUMN_R_S_STATUS_2);
4548
4549 String sql = query.toString();
4550
4551 Query q = session.createQuery(sql);
4552
4553 QueryPos qPos = QueryPos.getInstance(q);
4554
4555 qPos.add(receiverUserId);
4556
4557 qPos.add(status);
4558
4559 count = (Long)q.uniqueResult();
4560 }
4561 catch (Exception e) {
4562 throw processException(e);
4563 }
4564 finally {
4565 if (count == null) {
4566 count = Long.valueOf(0);
4567 }
4568
4569 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_S, finderArgs,
4570 count);
4571
4572 closeSession(session);
4573 }
4574 }
4575
4576 return count.intValue();
4577 }
4578
4579
4590 public int countByU_C_C_T_R(long userId, long classNameId, long classPK,
4591 int type, long receiverUserId) throws SystemException {
4592 Object[] finderArgs = new Object[] {
4593 userId, classNameId, classPK, type, receiverUserId
4594 };
4595
4596 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C_T_R,
4597 finderArgs, this);
4598
4599 if (count == null) {
4600 Session session = null;
4601
4602 try {
4603 session = openSession();
4604
4605 StringBundler query = new StringBundler(6);
4606
4607 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4608
4609 query.append(_FINDER_COLUMN_U_C_C_T_R_USERID_2);
4610
4611 query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2);
4612
4613 query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSPK_2);
4614
4615 query.append(_FINDER_COLUMN_U_C_C_T_R_TYPE_2);
4616
4617 query.append(_FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2);
4618
4619 String sql = query.toString();
4620
4621 Query q = session.createQuery(sql);
4622
4623 QueryPos qPos = QueryPos.getInstance(q);
4624
4625 qPos.add(userId);
4626
4627 qPos.add(classNameId);
4628
4629 qPos.add(classPK);
4630
4631 qPos.add(type);
4632
4633 qPos.add(receiverUserId);
4634
4635 count = (Long)q.uniqueResult();
4636 }
4637 catch (Exception e) {
4638 throw processException(e);
4639 }
4640 finally {
4641 if (count == null) {
4642 count = Long.valueOf(0);
4643 }
4644
4645 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C_T_R,
4646 finderArgs, count);
4647
4648 closeSession(session);
4649 }
4650 }
4651
4652 return count.intValue();
4653 }
4654
4655
4666 public int countByU_C_C_T_S(long userId, long classNameId, long classPK,
4667 int type, int status) throws SystemException {
4668 Object[] finderArgs = new Object[] {
4669 userId, classNameId, classPK, type, status
4670 };
4671
4672 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
4673 finderArgs, this);
4674
4675 if (count == null) {
4676 Session session = null;
4677
4678 try {
4679 session = openSession();
4680
4681 StringBundler query = new StringBundler(6);
4682
4683 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4684
4685 query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
4686
4687 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
4688
4689 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
4690
4691 query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
4692
4693 query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
4694
4695 String sql = query.toString();
4696
4697 Query q = session.createQuery(sql);
4698
4699 QueryPos qPos = QueryPos.getInstance(q);
4700
4701 qPos.add(userId);
4702
4703 qPos.add(classNameId);
4704
4705 qPos.add(classPK);
4706
4707 qPos.add(type);
4708
4709 qPos.add(status);
4710
4711 count = (Long)q.uniqueResult();
4712 }
4713 catch (Exception e) {
4714 throw processException(e);
4715 }
4716 finally {
4717 if (count == null) {
4718 count = Long.valueOf(0);
4719 }
4720
4721 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
4722 finderArgs, count);
4723
4724 closeSession(session);
4725 }
4726 }
4727
4728 return count.intValue();
4729 }
4730
4731
4742 public int countByC_C_T_R_S(long classNameId, long classPK, int type,
4743 long receiverUserId, int status) throws SystemException {
4744 Object[] finderArgs = new Object[] {
4745 classNameId, classPK, type, receiverUserId, status
4746 };
4747
4748 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
4749 finderArgs, this);
4750
4751 if (count == null) {
4752 Session session = null;
4753
4754 try {
4755 session = openSession();
4756
4757 StringBundler query = new StringBundler(6);
4758
4759 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4760
4761 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
4762
4763 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
4764
4765 query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
4766
4767 query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
4768
4769 query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
4770
4771 String sql = query.toString();
4772
4773 Query q = session.createQuery(sql);
4774
4775 QueryPos qPos = QueryPos.getInstance(q);
4776
4777 qPos.add(classNameId);
4778
4779 qPos.add(classPK);
4780
4781 qPos.add(type);
4782
4783 qPos.add(receiverUserId);
4784
4785 qPos.add(status);
4786
4787 count = (Long)q.uniqueResult();
4788 }
4789 catch (Exception e) {
4790 throw processException(e);
4791 }
4792 finally {
4793 if (count == null) {
4794 count = Long.valueOf(0);
4795 }
4796
4797 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
4798 finderArgs, count);
4799
4800 closeSession(session);
4801 }
4802 }
4803
4804 return count.intValue();
4805 }
4806
4807
4813 public int countAll() throws SystemException {
4814 Object[] finderArgs = new Object[0];
4815
4816 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4817 finderArgs, this);
4818
4819 if (count == null) {
4820 Session session = null;
4821
4822 try {
4823 session = openSession();
4824
4825 Query q = session.createQuery(_SQL_COUNT_SOCIALREQUEST);
4826
4827 count = (Long)q.uniqueResult();
4828 }
4829 catch (Exception e) {
4830 throw processException(e);
4831 }
4832 finally {
4833 if (count == null) {
4834 count = Long.valueOf(0);
4835 }
4836
4837 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
4838 count);
4839
4840 closeSession(session);
4841 }
4842 }
4843
4844 return count.intValue();
4845 }
4846
4847
4850 public void afterPropertiesSet() {
4851 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4852 com.liferay.portal.util.PropsUtil.get(
4853 "value.object.listener.com.liferay.portlet.social.model.SocialRequest")));
4854
4855 if (listenerClassNames.length > 0) {
4856 try {
4857 List<ModelListener<SocialRequest>> listenersList = new ArrayList<ModelListener<SocialRequest>>();
4858
4859 for (String listenerClassName : listenerClassNames) {
4860 listenersList.add((ModelListener<SocialRequest>)InstanceFactory.newInstance(
4861 listenerClassName));
4862 }
4863
4864 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4865 }
4866 catch (Exception e) {
4867 _log.error(e);
4868 }
4869 }
4870 }
4871
4872 public void destroy() {
4873 EntityCacheUtil.removeCache(SocialRequestImpl.class.getName());
4874 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4875 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
4876 }
4877
4878 @BeanReference(type = SocialActivityPersistence.class)
4879 protected SocialActivityPersistence socialActivityPersistence;
4880 @BeanReference(type = SocialEquityAssetEntryPersistence.class)
4881 protected SocialEquityAssetEntryPersistence socialEquityAssetEntryPersistence;
4882 @BeanReference(type = SocialEquityGroupSettingPersistence.class)
4883 protected SocialEquityGroupSettingPersistence socialEquityGroupSettingPersistence;
4884 @BeanReference(type = SocialEquityHistoryPersistence.class)
4885 protected SocialEquityHistoryPersistence socialEquityHistoryPersistence;
4886 @BeanReference(type = SocialEquityLogPersistence.class)
4887 protected SocialEquityLogPersistence socialEquityLogPersistence;
4888 @BeanReference(type = SocialEquitySettingPersistence.class)
4889 protected SocialEquitySettingPersistence socialEquitySettingPersistence;
4890 @BeanReference(type = SocialEquityUserPersistence.class)
4891 protected SocialEquityUserPersistence socialEquityUserPersistence;
4892 @BeanReference(type = SocialRelationPersistence.class)
4893 protected SocialRelationPersistence socialRelationPersistence;
4894 @BeanReference(type = SocialRequestPersistence.class)
4895 protected SocialRequestPersistence socialRequestPersistence;
4896 @BeanReference(type = ResourcePersistence.class)
4897 protected ResourcePersistence resourcePersistence;
4898 @BeanReference(type = UserPersistence.class)
4899 protected UserPersistence userPersistence;
4900 private static final String _SQL_SELECT_SOCIALREQUEST = "SELECT socialRequest FROM SocialRequest socialRequest";
4901 private static final String _SQL_SELECT_SOCIALREQUEST_WHERE = "SELECT socialRequest FROM SocialRequest socialRequest WHERE ";
4902 private static final String _SQL_COUNT_SOCIALREQUEST = "SELECT COUNT(socialRequest) FROM SocialRequest socialRequest";
4903 private static final String _SQL_COUNT_SOCIALREQUEST_WHERE = "SELECT COUNT(socialRequest) FROM SocialRequest socialRequest WHERE ";
4904 private static final String _FINDER_COLUMN_UUID_UUID_1 = "socialRequest.uuid IS NULL";
4905 private static final String _FINDER_COLUMN_UUID_UUID_2 = "socialRequest.uuid = ?";
4906 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(socialRequest.uuid IS NULL OR socialRequest.uuid = ?)";
4907 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "socialRequest.uuid IS NULL AND ";
4908 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "socialRequest.uuid = ? AND ";
4909 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(socialRequest.uuid IS NULL OR socialRequest.uuid = ?) AND ";
4910 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "socialRequest.groupId = ?";
4911 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "socialRequest.companyId = ?";
4912 private static final String _FINDER_COLUMN_USERID_USERID_2 = "socialRequest.userId = ?";
4913 private static final String _FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ?";
4914 private static final String _FINDER_COLUMN_U_S_USERID_2 = "socialRequest.userId = ? AND ";
4915 private static final String _FINDER_COLUMN_U_S_STATUS_2 = "socialRequest.status = ?";
4916 private static final String _FINDER_COLUMN_R_S_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ? AND ";
4917 private static final String _FINDER_COLUMN_R_S_STATUS_2 = "socialRequest.status = ?";
4918 private static final String _FINDER_COLUMN_U_C_C_T_R_USERID_2 = "socialRequest.userId = ? AND ";
4919 private static final String _FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
4920 private static final String _FINDER_COLUMN_U_C_C_T_R_CLASSPK_2 = "socialRequest.classPK = ? AND ";
4921 private static final String _FINDER_COLUMN_U_C_C_T_R_TYPE_2 = "socialRequest.type = ? AND ";
4922 private static final String _FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ?";
4923 private static final String _FINDER_COLUMN_U_C_C_T_S_USERID_2 = "socialRequest.userId = ? AND ";
4924 private static final String _FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
4925 private static final String _FINDER_COLUMN_U_C_C_T_S_CLASSPK_2 = "socialRequest.classPK = ? AND ";
4926 private static final String _FINDER_COLUMN_U_C_C_T_S_TYPE_2 = "socialRequest.type = ? AND ";
4927 private static final String _FINDER_COLUMN_U_C_C_T_S_STATUS_2 = "socialRequest.status = ?";
4928 private static final String _FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
4929 private static final String _FINDER_COLUMN_C_C_T_R_S_CLASSPK_2 = "socialRequest.classPK = ? AND ";
4930 private static final String _FINDER_COLUMN_C_C_T_R_S_TYPE_2 = "socialRequest.type = ? AND ";
4931 private static final String _FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ? AND ";
4932 private static final String _FINDER_COLUMN_C_C_T_R_S_STATUS_2 = "socialRequest.status = ?";
4933 private static final String _ORDER_BY_ENTITY_ALIAS = "socialRequest.";
4934 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialRequest exists with the primary key ";
4935 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialRequest exists with the key {";
4936 private static Log _log = LogFactoryUtil.getLog(SocialRequestPersistenceImpl.class);
4937 }