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.getUuid(),
397 new Long(socialRequestModelImpl.getGroupId())
398 });
399
400 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
401 new Object[] {
402 new Long(socialRequestModelImpl.getUserId()),
403 new Long(socialRequestModelImpl.getClassNameId()),
404 new Long(socialRequestModelImpl.getClassPK()),
405 new Integer(socialRequestModelImpl.getType()),
406 new Long(socialRequestModelImpl.getReceiverUserId())
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 StringBundler query = null;
679
680 if (orderByComparator != null) {
681 query = new StringBundler(3 +
682 (orderByComparator.getOrderByFields().length * 3));
683 }
684 else {
685 query = new StringBundler(3);
686 }
687
688 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
689
690 if (uuid == null) {
691 query.append(_FINDER_COLUMN_UUID_UUID_1);
692 }
693 else {
694 if (uuid.equals(StringPool.BLANK)) {
695 query.append(_FINDER_COLUMN_UUID_UUID_3);
696 }
697 else {
698 query.append(_FINDER_COLUMN_UUID_UUID_2);
699 }
700 }
701
702 if (orderByComparator != null) {
703 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
704 orderByComparator);
705 }
706
707 else {
708 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
709 }
710
711 String sql = query.toString();
712
713 Session session = null;
714
715 try {
716 session = openSession();
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 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_UUID,
735 finderArgs);
736 }
737 else {
738 cacheResult(list);
739
740 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID,
741 finderArgs, list);
742 }
743
744 closeSession(session);
745 }
746 }
747
748 return list;
749 }
750
751
764 public SocialRequest findByUuid_First(String uuid,
765 OrderByComparator orderByComparator)
766 throws NoSuchRequestException, SystemException {
767 List<SocialRequest> list = findByUuid(uuid, 0, 1, orderByComparator);
768
769 if (list.isEmpty()) {
770 StringBundler msg = new StringBundler(4);
771
772 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
773
774 msg.append("uuid=");
775 msg.append(uuid);
776
777 msg.append(StringPool.CLOSE_CURLY_BRACE);
778
779 throw new NoSuchRequestException(msg.toString());
780 }
781 else {
782 return list.get(0);
783 }
784 }
785
786
799 public SocialRequest findByUuid_Last(String uuid,
800 OrderByComparator orderByComparator)
801 throws NoSuchRequestException, SystemException {
802 int count = countByUuid(uuid);
803
804 List<SocialRequest> list = findByUuid(uuid, count - 1, count,
805 orderByComparator);
806
807 if (list.isEmpty()) {
808 StringBundler msg = new StringBundler(4);
809
810 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
811
812 msg.append("uuid=");
813 msg.append(uuid);
814
815 msg.append(StringPool.CLOSE_CURLY_BRACE);
816
817 throw new NoSuchRequestException(msg.toString());
818 }
819 else {
820 return list.get(0);
821 }
822 }
823
824
838 public SocialRequest[] findByUuid_PrevAndNext(long requestId, String uuid,
839 OrderByComparator orderByComparator)
840 throws NoSuchRequestException, SystemException {
841 SocialRequest socialRequest = findByPrimaryKey(requestId);
842
843 Session session = null;
844
845 try {
846 session = openSession();
847
848 SocialRequest[] array = new SocialRequestImpl[3];
849
850 array[0] = getByUuid_PrevAndNext(session, socialRequest, uuid,
851 orderByComparator, true);
852
853 array[1] = socialRequest;
854
855 array[2] = getByUuid_PrevAndNext(session, socialRequest, uuid,
856 orderByComparator, false);
857
858 return array;
859 }
860 catch (Exception e) {
861 throw processException(e);
862 }
863 finally {
864 closeSession(session);
865 }
866 }
867
868 protected SocialRequest getByUuid_PrevAndNext(Session session,
869 SocialRequest socialRequest, String uuid,
870 OrderByComparator orderByComparator, boolean previous) {
871 StringBundler query = null;
872
873 if (orderByComparator != null) {
874 query = new StringBundler(6 +
875 (orderByComparator.getOrderByFields().length * 6));
876 }
877 else {
878 query = new StringBundler(3);
879 }
880
881 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
882
883 if (uuid == null) {
884 query.append(_FINDER_COLUMN_UUID_UUID_1);
885 }
886 else {
887 if (uuid.equals(StringPool.BLANK)) {
888 query.append(_FINDER_COLUMN_UUID_UUID_3);
889 }
890 else {
891 query.append(_FINDER_COLUMN_UUID_UUID_2);
892 }
893 }
894
895 if (orderByComparator != null) {
896 String[] orderByFields = orderByComparator.getOrderByFields();
897
898 if (orderByFields.length > 0) {
899 query.append(WHERE_AND);
900 }
901
902 for (int i = 0; i < orderByFields.length; i++) {
903 query.append(_ORDER_BY_ENTITY_ALIAS);
904 query.append(orderByFields[i]);
905
906 if ((i + 1) < orderByFields.length) {
907 if (orderByComparator.isAscending() ^ previous) {
908 query.append(WHERE_GREATER_THAN_HAS_NEXT);
909 }
910 else {
911 query.append(WHERE_LESSER_THAN_HAS_NEXT);
912 }
913 }
914 else {
915 if (orderByComparator.isAscending() ^ previous) {
916 query.append(WHERE_GREATER_THAN);
917 }
918 else {
919 query.append(WHERE_LESSER_THAN);
920 }
921 }
922 }
923
924 query.append(ORDER_BY_CLAUSE);
925
926 for (int i = 0; i < orderByFields.length; i++) {
927 query.append(_ORDER_BY_ENTITY_ALIAS);
928 query.append(orderByFields[i]);
929
930 if ((i + 1) < orderByFields.length) {
931 if (orderByComparator.isAscending() ^ previous) {
932 query.append(ORDER_BY_ASC_HAS_NEXT);
933 }
934 else {
935 query.append(ORDER_BY_DESC_HAS_NEXT);
936 }
937 }
938 else {
939 if (orderByComparator.isAscending() ^ previous) {
940 query.append(ORDER_BY_ASC);
941 }
942 else {
943 query.append(ORDER_BY_DESC);
944 }
945 }
946 }
947 }
948
949 else {
950 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
951 }
952
953 String sql = query.toString();
954
955 Query q = session.createQuery(sql);
956
957 q.setFirstResult(0);
958 q.setMaxResults(2);
959
960 QueryPos qPos = QueryPos.getInstance(q);
961
962 if (uuid != null) {
963 qPos.add(uuid);
964 }
965
966 if (orderByComparator != null) {
967 Object[] values = orderByComparator.getOrderByValues(socialRequest);
968
969 for (Object value : values) {
970 qPos.add(value);
971 }
972 }
973
974 List<SocialRequest> list = q.list();
975
976 if (list.size() == 2) {
977 return list.get(1);
978 }
979 else {
980 return null;
981 }
982 }
983
984
993 public SocialRequest findByUUID_G(String uuid, long groupId)
994 throws NoSuchRequestException, SystemException {
995 SocialRequest socialRequest = fetchByUUID_G(uuid, groupId);
996
997 if (socialRequest == null) {
998 StringBundler msg = new StringBundler(6);
999
1000 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1001
1002 msg.append("uuid=");
1003 msg.append(uuid);
1004
1005 msg.append(", groupId=");
1006 msg.append(groupId);
1007
1008 msg.append(StringPool.CLOSE_CURLY_BRACE);
1009
1010 if (_log.isWarnEnabled()) {
1011 _log.warn(msg.toString());
1012 }
1013
1014 throw new NoSuchRequestException(msg.toString());
1015 }
1016
1017 return socialRequest;
1018 }
1019
1020
1028 public SocialRequest fetchByUUID_G(String uuid, long groupId)
1029 throws SystemException {
1030 return fetchByUUID_G(uuid, groupId, true);
1031 }
1032
1033
1041 public SocialRequest fetchByUUID_G(String uuid, long groupId,
1042 boolean retrieveFromCache) throws SystemException {
1043 Object[] finderArgs = new Object[] { uuid, groupId };
1044
1045 Object result = null;
1046
1047 if (retrieveFromCache) {
1048 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1049 finderArgs, this);
1050 }
1051
1052 if (result == null) {
1053 StringBundler query = new StringBundler(4);
1054
1055 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1056
1057 if (uuid == null) {
1058 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1059 }
1060 else {
1061 if (uuid.equals(StringPool.BLANK)) {
1062 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1063 }
1064 else {
1065 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1066 }
1067 }
1068
1069 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1070
1071 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1072
1073 String sql = query.toString();
1074
1075 Session session = null;
1076
1077 try {
1078 session = openSession();
1079
1080 Query q = session.createQuery(sql);
1081
1082 QueryPos qPos = QueryPos.getInstance(q);
1083
1084 if (uuid != null) {
1085 qPos.add(uuid);
1086 }
1087
1088 qPos.add(groupId);
1089
1090 List<SocialRequest> list = q.list();
1091
1092 result = list;
1093
1094 SocialRequest socialRequest = null;
1095
1096 if (list.isEmpty()) {
1097 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1098 finderArgs, list);
1099 }
1100 else {
1101 socialRequest = list.get(0);
1102
1103 cacheResult(socialRequest);
1104
1105 if ((socialRequest.getUuid() == null) ||
1106 !socialRequest.getUuid().equals(uuid) ||
1107 (socialRequest.getGroupId() != groupId)) {
1108 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1109 finderArgs, socialRequest);
1110 }
1111 }
1112
1113 return socialRequest;
1114 }
1115 catch (Exception e) {
1116 throw processException(e);
1117 }
1118 finally {
1119 if (result == null) {
1120 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1121 finderArgs);
1122 }
1123
1124 closeSession(session);
1125 }
1126 }
1127 else {
1128 if (result instanceof List<?>) {
1129 return null;
1130 }
1131 else {
1132 return (SocialRequest)result;
1133 }
1134 }
1135 }
1136
1137
1144 public List<SocialRequest> findByCompanyId(long companyId)
1145 throws SystemException {
1146 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1147 null);
1148 }
1149
1150
1163 public List<SocialRequest> findByCompanyId(long companyId, int start,
1164 int end) throws SystemException {
1165 return findByCompanyId(companyId, start, end, null);
1166 }
1167
1168
1182 public List<SocialRequest> findByCompanyId(long companyId, int start,
1183 int end, OrderByComparator orderByComparator) throws SystemException {
1184 Object[] finderArgs = new Object[] {
1185 companyId,
1186
1187 String.valueOf(start), String.valueOf(end),
1188 String.valueOf(orderByComparator)
1189 };
1190
1191 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1192 finderArgs, this);
1193
1194 if (list == null) {
1195 StringBundler query = null;
1196
1197 if (orderByComparator != null) {
1198 query = new StringBundler(3 +
1199 (orderByComparator.getOrderByFields().length * 3));
1200 }
1201 else {
1202 query = new StringBundler(3);
1203 }
1204
1205 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1206
1207 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1208
1209 if (orderByComparator != null) {
1210 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1211 orderByComparator);
1212 }
1213
1214 else {
1215 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1216 }
1217
1218 String sql = query.toString();
1219
1220 Session session = null;
1221
1222 try {
1223 session = openSession();
1224
1225 Query q = session.createQuery(sql);
1226
1227 QueryPos qPos = QueryPos.getInstance(q);
1228
1229 qPos.add(companyId);
1230
1231 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1232 start, end);
1233 }
1234 catch (Exception e) {
1235 throw processException(e);
1236 }
1237 finally {
1238 if (list == null) {
1239 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_COMPANYID,
1240 finderArgs);
1241 }
1242 else {
1243 cacheResult(list);
1244
1245 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1246 finderArgs, list);
1247 }
1248
1249 closeSession(session);
1250 }
1251 }
1252
1253 return list;
1254 }
1255
1256
1269 public SocialRequest findByCompanyId_First(long companyId,
1270 OrderByComparator orderByComparator)
1271 throws NoSuchRequestException, SystemException {
1272 List<SocialRequest> list = findByCompanyId(companyId, 0, 1,
1273 orderByComparator);
1274
1275 if (list.isEmpty()) {
1276 StringBundler msg = new StringBundler(4);
1277
1278 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1279
1280 msg.append("companyId=");
1281 msg.append(companyId);
1282
1283 msg.append(StringPool.CLOSE_CURLY_BRACE);
1284
1285 throw new NoSuchRequestException(msg.toString());
1286 }
1287 else {
1288 return list.get(0);
1289 }
1290 }
1291
1292
1305 public SocialRequest findByCompanyId_Last(long companyId,
1306 OrderByComparator orderByComparator)
1307 throws NoSuchRequestException, SystemException {
1308 int count = countByCompanyId(companyId);
1309
1310 List<SocialRequest> list = findByCompanyId(companyId, count - 1, count,
1311 orderByComparator);
1312
1313 if (list.isEmpty()) {
1314 StringBundler msg = new StringBundler(4);
1315
1316 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1317
1318 msg.append("companyId=");
1319 msg.append(companyId);
1320
1321 msg.append(StringPool.CLOSE_CURLY_BRACE);
1322
1323 throw new NoSuchRequestException(msg.toString());
1324 }
1325 else {
1326 return list.get(0);
1327 }
1328 }
1329
1330
1344 public SocialRequest[] findByCompanyId_PrevAndNext(long requestId,
1345 long companyId, OrderByComparator orderByComparator)
1346 throws NoSuchRequestException, SystemException {
1347 SocialRequest socialRequest = findByPrimaryKey(requestId);
1348
1349 Session session = null;
1350
1351 try {
1352 session = openSession();
1353
1354 SocialRequest[] array = new SocialRequestImpl[3];
1355
1356 array[0] = getByCompanyId_PrevAndNext(session, socialRequest,
1357 companyId, orderByComparator, true);
1358
1359 array[1] = socialRequest;
1360
1361 array[2] = getByCompanyId_PrevAndNext(session, socialRequest,
1362 companyId, orderByComparator, false);
1363
1364 return array;
1365 }
1366 catch (Exception e) {
1367 throw processException(e);
1368 }
1369 finally {
1370 closeSession(session);
1371 }
1372 }
1373
1374 protected SocialRequest getByCompanyId_PrevAndNext(Session session,
1375 SocialRequest socialRequest, long companyId,
1376 OrderByComparator orderByComparator, boolean previous) {
1377 StringBundler query = null;
1378
1379 if (orderByComparator != null) {
1380 query = new StringBundler(6 +
1381 (orderByComparator.getOrderByFields().length * 6));
1382 }
1383 else {
1384 query = new StringBundler(3);
1385 }
1386
1387 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1388
1389 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1390
1391 if (orderByComparator != null) {
1392 String[] orderByFields = orderByComparator.getOrderByFields();
1393
1394 if (orderByFields.length > 0) {
1395 query.append(WHERE_AND);
1396 }
1397
1398 for (int i = 0; i < orderByFields.length; i++) {
1399 query.append(_ORDER_BY_ENTITY_ALIAS);
1400 query.append(orderByFields[i]);
1401
1402 if ((i + 1) < orderByFields.length) {
1403 if (orderByComparator.isAscending() ^ previous) {
1404 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1405 }
1406 else {
1407 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1408 }
1409 }
1410 else {
1411 if (orderByComparator.isAscending() ^ previous) {
1412 query.append(WHERE_GREATER_THAN);
1413 }
1414 else {
1415 query.append(WHERE_LESSER_THAN);
1416 }
1417 }
1418 }
1419
1420 query.append(ORDER_BY_CLAUSE);
1421
1422 for (int i = 0; i < orderByFields.length; i++) {
1423 query.append(_ORDER_BY_ENTITY_ALIAS);
1424 query.append(orderByFields[i]);
1425
1426 if ((i + 1) < orderByFields.length) {
1427 if (orderByComparator.isAscending() ^ previous) {
1428 query.append(ORDER_BY_ASC_HAS_NEXT);
1429 }
1430 else {
1431 query.append(ORDER_BY_DESC_HAS_NEXT);
1432 }
1433 }
1434 else {
1435 if (orderByComparator.isAscending() ^ previous) {
1436 query.append(ORDER_BY_ASC);
1437 }
1438 else {
1439 query.append(ORDER_BY_DESC);
1440 }
1441 }
1442 }
1443 }
1444
1445 else {
1446 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1447 }
1448
1449 String sql = query.toString();
1450
1451 Query q = session.createQuery(sql);
1452
1453 q.setFirstResult(0);
1454 q.setMaxResults(2);
1455
1456 QueryPos qPos = QueryPos.getInstance(q);
1457
1458 qPos.add(companyId);
1459
1460 if (orderByComparator != null) {
1461 Object[] values = orderByComparator.getOrderByValues(socialRequest);
1462
1463 for (Object value : values) {
1464 qPos.add(value);
1465 }
1466 }
1467
1468 List<SocialRequest> list = q.list();
1469
1470 if (list.size() == 2) {
1471 return list.get(1);
1472 }
1473 else {
1474 return null;
1475 }
1476 }
1477
1478
1485 public List<SocialRequest> findByUserId(long userId)
1486 throws SystemException {
1487 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1488 }
1489
1490
1503 public List<SocialRequest> findByUserId(long userId, int start, int end)
1504 throws SystemException {
1505 return findByUserId(userId, start, end, null);
1506 }
1507
1508
1522 public List<SocialRequest> findByUserId(long userId, int start, int end,
1523 OrderByComparator orderByComparator) throws SystemException {
1524 Object[] finderArgs = new Object[] {
1525 userId,
1526
1527 String.valueOf(start), String.valueOf(end),
1528 String.valueOf(orderByComparator)
1529 };
1530
1531 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
1532 finderArgs, this);
1533
1534 if (list == null) {
1535 StringBundler query = null;
1536
1537 if (orderByComparator != null) {
1538 query = new StringBundler(3 +
1539 (orderByComparator.getOrderByFields().length * 3));
1540 }
1541 else {
1542 query = new StringBundler(3);
1543 }
1544
1545 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1546
1547 query.append(_FINDER_COLUMN_USERID_USERID_2);
1548
1549 if (orderByComparator != null) {
1550 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1551 orderByComparator);
1552 }
1553
1554 else {
1555 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1556 }
1557
1558 String sql = query.toString();
1559
1560 Session session = null;
1561
1562 try {
1563 session = openSession();
1564
1565 Query q = session.createQuery(sql);
1566
1567 QueryPos qPos = QueryPos.getInstance(q);
1568
1569 qPos.add(userId);
1570
1571 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1572 start, end);
1573 }
1574 catch (Exception e) {
1575 throw processException(e);
1576 }
1577 finally {
1578 if (list == null) {
1579 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_USERID,
1580 finderArgs);
1581 }
1582 else {
1583 cacheResult(list);
1584
1585 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
1586 finderArgs, list);
1587 }
1588
1589 closeSession(session);
1590 }
1591 }
1592
1593 return list;
1594 }
1595
1596
1609 public SocialRequest findByUserId_First(long userId,
1610 OrderByComparator orderByComparator)
1611 throws NoSuchRequestException, SystemException {
1612 List<SocialRequest> list = findByUserId(userId, 0, 1, orderByComparator);
1613
1614 if (list.isEmpty()) {
1615 StringBundler msg = new StringBundler(4);
1616
1617 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1618
1619 msg.append("userId=");
1620 msg.append(userId);
1621
1622 msg.append(StringPool.CLOSE_CURLY_BRACE);
1623
1624 throw new NoSuchRequestException(msg.toString());
1625 }
1626 else {
1627 return list.get(0);
1628 }
1629 }
1630
1631
1644 public SocialRequest findByUserId_Last(long userId,
1645 OrderByComparator orderByComparator)
1646 throws NoSuchRequestException, SystemException {
1647 int count = countByUserId(userId);
1648
1649 List<SocialRequest> list = findByUserId(userId, count - 1, count,
1650 orderByComparator);
1651
1652 if (list.isEmpty()) {
1653 StringBundler msg = new StringBundler(4);
1654
1655 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1656
1657 msg.append("userId=");
1658 msg.append(userId);
1659
1660 msg.append(StringPool.CLOSE_CURLY_BRACE);
1661
1662 throw new NoSuchRequestException(msg.toString());
1663 }
1664 else {
1665 return list.get(0);
1666 }
1667 }
1668
1669
1683 public SocialRequest[] findByUserId_PrevAndNext(long requestId,
1684 long userId, OrderByComparator orderByComparator)
1685 throws NoSuchRequestException, SystemException {
1686 SocialRequest socialRequest = findByPrimaryKey(requestId);
1687
1688 Session session = null;
1689
1690 try {
1691 session = openSession();
1692
1693 SocialRequest[] array = new SocialRequestImpl[3];
1694
1695 array[0] = getByUserId_PrevAndNext(session, socialRequest, userId,
1696 orderByComparator, true);
1697
1698 array[1] = socialRequest;
1699
1700 array[2] = getByUserId_PrevAndNext(session, socialRequest, userId,
1701 orderByComparator, false);
1702
1703 return array;
1704 }
1705 catch (Exception e) {
1706 throw processException(e);
1707 }
1708 finally {
1709 closeSession(session);
1710 }
1711 }
1712
1713 protected SocialRequest getByUserId_PrevAndNext(Session session,
1714 SocialRequest socialRequest, long userId,
1715 OrderByComparator orderByComparator, boolean previous) {
1716 StringBundler query = null;
1717
1718 if (orderByComparator != null) {
1719 query = new StringBundler(6 +
1720 (orderByComparator.getOrderByFields().length * 6));
1721 }
1722 else {
1723 query = new StringBundler(3);
1724 }
1725
1726 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1727
1728 query.append(_FINDER_COLUMN_USERID_USERID_2);
1729
1730 if (orderByComparator != null) {
1731 String[] orderByFields = orderByComparator.getOrderByFields();
1732
1733 if (orderByFields.length > 0) {
1734 query.append(WHERE_AND);
1735 }
1736
1737 for (int i = 0; i < orderByFields.length; i++) {
1738 query.append(_ORDER_BY_ENTITY_ALIAS);
1739 query.append(orderByFields[i]);
1740
1741 if ((i + 1) < orderByFields.length) {
1742 if (orderByComparator.isAscending() ^ previous) {
1743 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1744 }
1745 else {
1746 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1747 }
1748 }
1749 else {
1750 if (orderByComparator.isAscending() ^ previous) {
1751 query.append(WHERE_GREATER_THAN);
1752 }
1753 else {
1754 query.append(WHERE_LESSER_THAN);
1755 }
1756 }
1757 }
1758
1759 query.append(ORDER_BY_CLAUSE);
1760
1761 for (int i = 0; i < orderByFields.length; i++) {
1762 query.append(_ORDER_BY_ENTITY_ALIAS);
1763 query.append(orderByFields[i]);
1764
1765 if ((i + 1) < orderByFields.length) {
1766 if (orderByComparator.isAscending() ^ previous) {
1767 query.append(ORDER_BY_ASC_HAS_NEXT);
1768 }
1769 else {
1770 query.append(ORDER_BY_DESC_HAS_NEXT);
1771 }
1772 }
1773 else {
1774 if (orderByComparator.isAscending() ^ previous) {
1775 query.append(ORDER_BY_ASC);
1776 }
1777 else {
1778 query.append(ORDER_BY_DESC);
1779 }
1780 }
1781 }
1782 }
1783
1784 else {
1785 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1786 }
1787
1788 String sql = query.toString();
1789
1790 Query q = session.createQuery(sql);
1791
1792 q.setFirstResult(0);
1793 q.setMaxResults(2);
1794
1795 QueryPos qPos = QueryPos.getInstance(q);
1796
1797 qPos.add(userId);
1798
1799 if (orderByComparator != null) {
1800 Object[] values = orderByComparator.getOrderByValues(socialRequest);
1801
1802 for (Object value : values) {
1803 qPos.add(value);
1804 }
1805 }
1806
1807 List<SocialRequest> list = q.list();
1808
1809 if (list.size() == 2) {
1810 return list.get(1);
1811 }
1812 else {
1813 return null;
1814 }
1815 }
1816
1817
1824 public List<SocialRequest> findByReceiverUserId(long receiverUserId)
1825 throws SystemException {
1826 return findByReceiverUserId(receiverUserId, QueryUtil.ALL_POS,
1827 QueryUtil.ALL_POS, null);
1828 }
1829
1830
1843 public List<SocialRequest> findByReceiverUserId(long receiverUserId,
1844 int start, int end) throws SystemException {
1845 return findByReceiverUserId(receiverUserId, start, end, null);
1846 }
1847
1848
1862 public List<SocialRequest> findByReceiverUserId(long receiverUserId,
1863 int start, int end, OrderByComparator orderByComparator)
1864 throws SystemException {
1865 Object[] finderArgs = new Object[] {
1866 receiverUserId,
1867
1868 String.valueOf(start), String.valueOf(end),
1869 String.valueOf(orderByComparator)
1870 };
1871
1872 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_RECEIVERUSERID,
1873 finderArgs, this);
1874
1875 if (list == null) {
1876 StringBundler query = null;
1877
1878 if (orderByComparator != null) {
1879 query = new StringBundler(3 +
1880 (orderByComparator.getOrderByFields().length * 3));
1881 }
1882 else {
1883 query = new StringBundler(3);
1884 }
1885
1886 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
1887
1888 query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
1889
1890 if (orderByComparator != null) {
1891 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1892 orderByComparator);
1893 }
1894
1895 else {
1896 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
1897 }
1898
1899 String sql = query.toString();
1900
1901 Session session = null;
1902
1903 try {
1904 session = openSession();
1905
1906 Query q = session.createQuery(sql);
1907
1908 QueryPos qPos = QueryPos.getInstance(q);
1909
1910 qPos.add(receiverUserId);
1911
1912 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
1913 start, end);
1914 }
1915 catch (Exception e) {
1916 throw processException(e);
1917 }
1918 finally {
1919 if (list == null) {
1920 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_RECEIVERUSERID,
1921 finderArgs);
1922 }
1923 else {
1924 cacheResult(list);
1925
1926 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_RECEIVERUSERID,
1927 finderArgs, list);
1928 }
1929
1930 closeSession(session);
1931 }
1932 }
1933
1934 return list;
1935 }
1936
1937
1950 public SocialRequest findByReceiverUserId_First(long receiverUserId,
1951 OrderByComparator orderByComparator)
1952 throws NoSuchRequestException, SystemException {
1953 List<SocialRequest> list = findByReceiverUserId(receiverUserId, 0, 1,
1954 orderByComparator);
1955
1956 if (list.isEmpty()) {
1957 StringBundler msg = new StringBundler(4);
1958
1959 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1960
1961 msg.append("receiverUserId=");
1962 msg.append(receiverUserId);
1963
1964 msg.append(StringPool.CLOSE_CURLY_BRACE);
1965
1966 throw new NoSuchRequestException(msg.toString());
1967 }
1968 else {
1969 return list.get(0);
1970 }
1971 }
1972
1973
1986 public SocialRequest findByReceiverUserId_Last(long receiverUserId,
1987 OrderByComparator orderByComparator)
1988 throws NoSuchRequestException, SystemException {
1989 int count = countByReceiverUserId(receiverUserId);
1990
1991 List<SocialRequest> list = findByReceiverUserId(receiverUserId,
1992 count - 1, count, orderByComparator);
1993
1994 if (list.isEmpty()) {
1995 StringBundler msg = new StringBundler(4);
1996
1997 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1998
1999 msg.append("receiverUserId=");
2000 msg.append(receiverUserId);
2001
2002 msg.append(StringPool.CLOSE_CURLY_BRACE);
2003
2004 throw new NoSuchRequestException(msg.toString());
2005 }
2006 else {
2007 return list.get(0);
2008 }
2009 }
2010
2011
2025 public SocialRequest[] findByReceiverUserId_PrevAndNext(long requestId,
2026 long receiverUserId, OrderByComparator orderByComparator)
2027 throws NoSuchRequestException, SystemException {
2028 SocialRequest socialRequest = findByPrimaryKey(requestId);
2029
2030 Session session = null;
2031
2032 try {
2033 session = openSession();
2034
2035 SocialRequest[] array = new SocialRequestImpl[3];
2036
2037 array[0] = getByReceiverUserId_PrevAndNext(session, socialRequest,
2038 receiverUserId, orderByComparator, true);
2039
2040 array[1] = socialRequest;
2041
2042 array[2] = getByReceiverUserId_PrevAndNext(session, socialRequest,
2043 receiverUserId, orderByComparator, false);
2044
2045 return array;
2046 }
2047 catch (Exception e) {
2048 throw processException(e);
2049 }
2050 finally {
2051 closeSession(session);
2052 }
2053 }
2054
2055 protected SocialRequest getByReceiverUserId_PrevAndNext(Session session,
2056 SocialRequest socialRequest, long receiverUserId,
2057 OrderByComparator orderByComparator, boolean previous) {
2058 StringBundler query = null;
2059
2060 if (orderByComparator != null) {
2061 query = new StringBundler(6 +
2062 (orderByComparator.getOrderByFields().length * 6));
2063 }
2064 else {
2065 query = new StringBundler(3);
2066 }
2067
2068 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2069
2070 query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
2071
2072 if (orderByComparator != null) {
2073 String[] orderByFields = orderByComparator.getOrderByFields();
2074
2075 if (orderByFields.length > 0) {
2076 query.append(WHERE_AND);
2077 }
2078
2079 for (int i = 0; i < orderByFields.length; i++) {
2080 query.append(_ORDER_BY_ENTITY_ALIAS);
2081 query.append(orderByFields[i]);
2082
2083 if ((i + 1) < orderByFields.length) {
2084 if (orderByComparator.isAscending() ^ previous) {
2085 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2086 }
2087 else {
2088 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2089 }
2090 }
2091 else {
2092 if (orderByComparator.isAscending() ^ previous) {
2093 query.append(WHERE_GREATER_THAN);
2094 }
2095 else {
2096 query.append(WHERE_LESSER_THAN);
2097 }
2098 }
2099 }
2100
2101 query.append(ORDER_BY_CLAUSE);
2102
2103 for (int i = 0; i < orderByFields.length; i++) {
2104 query.append(_ORDER_BY_ENTITY_ALIAS);
2105 query.append(orderByFields[i]);
2106
2107 if ((i + 1) < orderByFields.length) {
2108 if (orderByComparator.isAscending() ^ previous) {
2109 query.append(ORDER_BY_ASC_HAS_NEXT);
2110 }
2111 else {
2112 query.append(ORDER_BY_DESC_HAS_NEXT);
2113 }
2114 }
2115 else {
2116 if (orderByComparator.isAscending() ^ previous) {
2117 query.append(ORDER_BY_ASC);
2118 }
2119 else {
2120 query.append(ORDER_BY_DESC);
2121 }
2122 }
2123 }
2124 }
2125
2126 else {
2127 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2128 }
2129
2130 String sql = query.toString();
2131
2132 Query q = session.createQuery(sql);
2133
2134 q.setFirstResult(0);
2135 q.setMaxResults(2);
2136
2137 QueryPos qPos = QueryPos.getInstance(q);
2138
2139 qPos.add(receiverUserId);
2140
2141 if (orderByComparator != null) {
2142 Object[] values = orderByComparator.getOrderByValues(socialRequest);
2143
2144 for (Object value : values) {
2145 qPos.add(value);
2146 }
2147 }
2148
2149 List<SocialRequest> list = q.list();
2150
2151 if (list.size() == 2) {
2152 return list.get(1);
2153 }
2154 else {
2155 return null;
2156 }
2157 }
2158
2159
2167 public List<SocialRequest> findByU_S(long userId, int status)
2168 throws SystemException {
2169 return findByU_S(userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2170 null);
2171 }
2172
2173
2187 public List<SocialRequest> findByU_S(long userId, int status, int start,
2188 int end) throws SystemException {
2189 return findByU_S(userId, status, start, end, null);
2190 }
2191
2192
2207 public List<SocialRequest> findByU_S(long userId, int status, int start,
2208 int end, OrderByComparator orderByComparator) throws SystemException {
2209 Object[] finderArgs = new Object[] {
2210 userId, status,
2211
2212 String.valueOf(start), String.valueOf(end),
2213 String.valueOf(orderByComparator)
2214 };
2215
2216 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_S,
2217 finderArgs, this);
2218
2219 if (list == null) {
2220 StringBundler query = null;
2221
2222 if (orderByComparator != null) {
2223 query = new StringBundler(4 +
2224 (orderByComparator.getOrderByFields().length * 3));
2225 }
2226 else {
2227 query = new StringBundler(4);
2228 }
2229
2230 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2231
2232 query.append(_FINDER_COLUMN_U_S_USERID_2);
2233
2234 query.append(_FINDER_COLUMN_U_S_STATUS_2);
2235
2236 if (orderByComparator != null) {
2237 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2238 orderByComparator);
2239 }
2240
2241 else {
2242 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2243 }
2244
2245 String sql = query.toString();
2246
2247 Session session = null;
2248
2249 try {
2250 session = openSession();
2251
2252 Query q = session.createQuery(sql);
2253
2254 QueryPos qPos = QueryPos.getInstance(q);
2255
2256 qPos.add(userId);
2257
2258 qPos.add(status);
2259
2260 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
2261 start, end);
2262 }
2263 catch (Exception e) {
2264 throw processException(e);
2265 }
2266 finally {
2267 if (list == null) {
2268 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_U_S,
2269 finderArgs);
2270 }
2271 else {
2272 cacheResult(list);
2273
2274 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_S,
2275 finderArgs, list);
2276 }
2277
2278 closeSession(session);
2279 }
2280 }
2281
2282 return list;
2283 }
2284
2285
2299 public SocialRequest findByU_S_First(long userId, int status,
2300 OrderByComparator orderByComparator)
2301 throws NoSuchRequestException, SystemException {
2302 List<SocialRequest> list = findByU_S(userId, status, 0, 1,
2303 orderByComparator);
2304
2305 if (list.isEmpty()) {
2306 StringBundler msg = new StringBundler(6);
2307
2308 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2309
2310 msg.append("userId=");
2311 msg.append(userId);
2312
2313 msg.append(", status=");
2314 msg.append(status);
2315
2316 msg.append(StringPool.CLOSE_CURLY_BRACE);
2317
2318 throw new NoSuchRequestException(msg.toString());
2319 }
2320 else {
2321 return list.get(0);
2322 }
2323 }
2324
2325
2339 public SocialRequest findByU_S_Last(long userId, int status,
2340 OrderByComparator orderByComparator)
2341 throws NoSuchRequestException, SystemException {
2342 int count = countByU_S(userId, status);
2343
2344 List<SocialRequest> list = findByU_S(userId, status, count - 1, count,
2345 orderByComparator);
2346
2347 if (list.isEmpty()) {
2348 StringBundler msg = new StringBundler(6);
2349
2350 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2351
2352 msg.append("userId=");
2353 msg.append(userId);
2354
2355 msg.append(", status=");
2356 msg.append(status);
2357
2358 msg.append(StringPool.CLOSE_CURLY_BRACE);
2359
2360 throw new NoSuchRequestException(msg.toString());
2361 }
2362 else {
2363 return list.get(0);
2364 }
2365 }
2366
2367
2382 public SocialRequest[] findByU_S_PrevAndNext(long requestId, long userId,
2383 int status, OrderByComparator orderByComparator)
2384 throws NoSuchRequestException, SystemException {
2385 SocialRequest socialRequest = findByPrimaryKey(requestId);
2386
2387 Session session = null;
2388
2389 try {
2390 session = openSession();
2391
2392 SocialRequest[] array = new SocialRequestImpl[3];
2393
2394 array[0] = getByU_S_PrevAndNext(session, socialRequest, userId,
2395 status, orderByComparator, true);
2396
2397 array[1] = socialRequest;
2398
2399 array[2] = getByU_S_PrevAndNext(session, socialRequest, userId,
2400 status, orderByComparator, false);
2401
2402 return array;
2403 }
2404 catch (Exception e) {
2405 throw processException(e);
2406 }
2407 finally {
2408 closeSession(session);
2409 }
2410 }
2411
2412 protected SocialRequest getByU_S_PrevAndNext(Session session,
2413 SocialRequest socialRequest, long userId, int status,
2414 OrderByComparator orderByComparator, boolean previous) {
2415 StringBundler query = null;
2416
2417 if (orderByComparator != null) {
2418 query = new StringBundler(6 +
2419 (orderByComparator.getOrderByFields().length * 6));
2420 }
2421 else {
2422 query = new StringBundler(3);
2423 }
2424
2425 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2426
2427 query.append(_FINDER_COLUMN_U_S_USERID_2);
2428
2429 query.append(_FINDER_COLUMN_U_S_STATUS_2);
2430
2431 if (orderByComparator != null) {
2432 String[] orderByFields = orderByComparator.getOrderByFields();
2433
2434 if (orderByFields.length > 0) {
2435 query.append(WHERE_AND);
2436 }
2437
2438 for (int i = 0; i < orderByFields.length; i++) {
2439 query.append(_ORDER_BY_ENTITY_ALIAS);
2440 query.append(orderByFields[i]);
2441
2442 if ((i + 1) < orderByFields.length) {
2443 if (orderByComparator.isAscending() ^ previous) {
2444 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2445 }
2446 else {
2447 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2448 }
2449 }
2450 else {
2451 if (orderByComparator.isAscending() ^ previous) {
2452 query.append(WHERE_GREATER_THAN);
2453 }
2454 else {
2455 query.append(WHERE_LESSER_THAN);
2456 }
2457 }
2458 }
2459
2460 query.append(ORDER_BY_CLAUSE);
2461
2462 for (int i = 0; i < orderByFields.length; i++) {
2463 query.append(_ORDER_BY_ENTITY_ALIAS);
2464 query.append(orderByFields[i]);
2465
2466 if ((i + 1) < orderByFields.length) {
2467 if (orderByComparator.isAscending() ^ previous) {
2468 query.append(ORDER_BY_ASC_HAS_NEXT);
2469 }
2470 else {
2471 query.append(ORDER_BY_DESC_HAS_NEXT);
2472 }
2473 }
2474 else {
2475 if (orderByComparator.isAscending() ^ previous) {
2476 query.append(ORDER_BY_ASC);
2477 }
2478 else {
2479 query.append(ORDER_BY_DESC);
2480 }
2481 }
2482 }
2483 }
2484
2485 else {
2486 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2487 }
2488
2489 String sql = query.toString();
2490
2491 Query q = session.createQuery(sql);
2492
2493 q.setFirstResult(0);
2494 q.setMaxResults(2);
2495
2496 QueryPos qPos = QueryPos.getInstance(q);
2497
2498 qPos.add(userId);
2499
2500 qPos.add(status);
2501
2502 if (orderByComparator != null) {
2503 Object[] values = orderByComparator.getOrderByValues(socialRequest);
2504
2505 for (Object value : values) {
2506 qPos.add(value);
2507 }
2508 }
2509
2510 List<SocialRequest> list = q.list();
2511
2512 if (list.size() == 2) {
2513 return list.get(1);
2514 }
2515 else {
2516 return null;
2517 }
2518 }
2519
2520
2528 public List<SocialRequest> findByR_S(long receiverUserId, int status)
2529 throws SystemException {
2530 return findByR_S(receiverUserId, status, QueryUtil.ALL_POS,
2531 QueryUtil.ALL_POS, null);
2532 }
2533
2534
2548 public List<SocialRequest> findByR_S(long receiverUserId, int status,
2549 int start, int end) throws SystemException {
2550 return findByR_S(receiverUserId, status, start, end, null);
2551 }
2552
2553
2568 public List<SocialRequest> findByR_S(long receiverUserId, int status,
2569 int start, int end, OrderByComparator orderByComparator)
2570 throws SystemException {
2571 Object[] finderArgs = new Object[] {
2572 receiverUserId, status,
2573
2574 String.valueOf(start), String.valueOf(end),
2575 String.valueOf(orderByComparator)
2576 };
2577
2578 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_R_S,
2579 finderArgs, this);
2580
2581 if (list == null) {
2582 StringBundler query = null;
2583
2584 if (orderByComparator != null) {
2585 query = new StringBundler(4 +
2586 (orderByComparator.getOrderByFields().length * 3));
2587 }
2588 else {
2589 query = new StringBundler(4);
2590 }
2591
2592 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2593
2594 query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
2595
2596 query.append(_FINDER_COLUMN_R_S_STATUS_2);
2597
2598 if (orderByComparator != null) {
2599 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2600 orderByComparator);
2601 }
2602
2603 else {
2604 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2605 }
2606
2607 String sql = query.toString();
2608
2609 Session session = null;
2610
2611 try {
2612 session = openSession();
2613
2614 Query q = session.createQuery(sql);
2615
2616 QueryPos qPos = QueryPos.getInstance(q);
2617
2618 qPos.add(receiverUserId);
2619
2620 qPos.add(status);
2621
2622 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
2623 start, end);
2624 }
2625 catch (Exception e) {
2626 throw processException(e);
2627 }
2628 finally {
2629 if (list == null) {
2630 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_R_S,
2631 finderArgs);
2632 }
2633 else {
2634 cacheResult(list);
2635
2636 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_R_S,
2637 finderArgs, list);
2638 }
2639
2640 closeSession(session);
2641 }
2642 }
2643
2644 return list;
2645 }
2646
2647
2661 public SocialRequest findByR_S_First(long receiverUserId, int status,
2662 OrderByComparator orderByComparator)
2663 throws NoSuchRequestException, SystemException {
2664 List<SocialRequest> list = findByR_S(receiverUserId, status, 0, 1,
2665 orderByComparator);
2666
2667 if (list.isEmpty()) {
2668 StringBundler msg = new StringBundler(6);
2669
2670 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2671
2672 msg.append("receiverUserId=");
2673 msg.append(receiverUserId);
2674
2675 msg.append(", status=");
2676 msg.append(status);
2677
2678 msg.append(StringPool.CLOSE_CURLY_BRACE);
2679
2680 throw new NoSuchRequestException(msg.toString());
2681 }
2682 else {
2683 return list.get(0);
2684 }
2685 }
2686
2687
2701 public SocialRequest findByR_S_Last(long receiverUserId, int status,
2702 OrderByComparator orderByComparator)
2703 throws NoSuchRequestException, SystemException {
2704 int count = countByR_S(receiverUserId, status);
2705
2706 List<SocialRequest> list = findByR_S(receiverUserId, status, count - 1,
2707 count, orderByComparator);
2708
2709 if (list.isEmpty()) {
2710 StringBundler msg = new StringBundler(6);
2711
2712 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2713
2714 msg.append("receiverUserId=");
2715 msg.append(receiverUserId);
2716
2717 msg.append(", status=");
2718 msg.append(status);
2719
2720 msg.append(StringPool.CLOSE_CURLY_BRACE);
2721
2722 throw new NoSuchRequestException(msg.toString());
2723 }
2724 else {
2725 return list.get(0);
2726 }
2727 }
2728
2729
2744 public SocialRequest[] findByR_S_PrevAndNext(long requestId,
2745 long receiverUserId, int status, OrderByComparator orderByComparator)
2746 throws NoSuchRequestException, SystemException {
2747 SocialRequest socialRequest = findByPrimaryKey(requestId);
2748
2749 Session session = null;
2750
2751 try {
2752 session = openSession();
2753
2754 SocialRequest[] array = new SocialRequestImpl[3];
2755
2756 array[0] = getByR_S_PrevAndNext(session, socialRequest,
2757 receiverUserId, status, orderByComparator, true);
2758
2759 array[1] = socialRequest;
2760
2761 array[2] = getByR_S_PrevAndNext(session, socialRequest,
2762 receiverUserId, status, orderByComparator, false);
2763
2764 return array;
2765 }
2766 catch (Exception e) {
2767 throw processException(e);
2768 }
2769 finally {
2770 closeSession(session);
2771 }
2772 }
2773
2774 protected SocialRequest getByR_S_PrevAndNext(Session session,
2775 SocialRequest socialRequest, long receiverUserId, int status,
2776 OrderByComparator orderByComparator, boolean previous) {
2777 StringBundler query = null;
2778
2779 if (orderByComparator != null) {
2780 query = new StringBundler(6 +
2781 (orderByComparator.getOrderByFields().length * 6));
2782 }
2783 else {
2784 query = new StringBundler(3);
2785 }
2786
2787 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2788
2789 query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
2790
2791 query.append(_FINDER_COLUMN_R_S_STATUS_2);
2792
2793 if (orderByComparator != null) {
2794 String[] orderByFields = orderByComparator.getOrderByFields();
2795
2796 if (orderByFields.length > 0) {
2797 query.append(WHERE_AND);
2798 }
2799
2800 for (int i = 0; i < orderByFields.length; i++) {
2801 query.append(_ORDER_BY_ENTITY_ALIAS);
2802 query.append(orderByFields[i]);
2803
2804 if ((i + 1) < orderByFields.length) {
2805 if (orderByComparator.isAscending() ^ previous) {
2806 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2807 }
2808 else {
2809 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2810 }
2811 }
2812 else {
2813 if (orderByComparator.isAscending() ^ previous) {
2814 query.append(WHERE_GREATER_THAN);
2815 }
2816 else {
2817 query.append(WHERE_LESSER_THAN);
2818 }
2819 }
2820 }
2821
2822 query.append(ORDER_BY_CLAUSE);
2823
2824 for (int i = 0; i < orderByFields.length; i++) {
2825 query.append(_ORDER_BY_ENTITY_ALIAS);
2826 query.append(orderByFields[i]);
2827
2828 if ((i + 1) < orderByFields.length) {
2829 if (orderByComparator.isAscending() ^ previous) {
2830 query.append(ORDER_BY_ASC_HAS_NEXT);
2831 }
2832 else {
2833 query.append(ORDER_BY_DESC_HAS_NEXT);
2834 }
2835 }
2836 else {
2837 if (orderByComparator.isAscending() ^ previous) {
2838 query.append(ORDER_BY_ASC);
2839 }
2840 else {
2841 query.append(ORDER_BY_DESC);
2842 }
2843 }
2844 }
2845 }
2846
2847 else {
2848 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2849 }
2850
2851 String sql = query.toString();
2852
2853 Query q = session.createQuery(sql);
2854
2855 q.setFirstResult(0);
2856 q.setMaxResults(2);
2857
2858 QueryPos qPos = QueryPos.getInstance(q);
2859
2860 qPos.add(receiverUserId);
2861
2862 qPos.add(status);
2863
2864 if (orderByComparator != null) {
2865 Object[] values = orderByComparator.getOrderByValues(socialRequest);
2866
2867 for (Object value : values) {
2868 qPos.add(value);
2869 }
2870 }
2871
2872 List<SocialRequest> list = q.list();
2873
2874 if (list.size() == 2) {
2875 return list.get(1);
2876 }
2877 else {
2878 return null;
2879 }
2880 }
2881
2882
2894 public SocialRequest findByU_C_C_T_R(long userId, long classNameId,
2895 long classPK, int type, long receiverUserId)
2896 throws NoSuchRequestException, SystemException {
2897 SocialRequest socialRequest = fetchByU_C_C_T_R(userId, classNameId,
2898 classPK, type, receiverUserId);
2899
2900 if (socialRequest == null) {
2901 StringBundler msg = new StringBundler(12);
2902
2903 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2904
2905 msg.append("userId=");
2906 msg.append(userId);
2907
2908 msg.append(", classNameId=");
2909 msg.append(classNameId);
2910
2911 msg.append(", classPK=");
2912 msg.append(classPK);
2913
2914 msg.append(", type=");
2915 msg.append(type);
2916
2917 msg.append(", receiverUserId=");
2918 msg.append(receiverUserId);
2919
2920 msg.append(StringPool.CLOSE_CURLY_BRACE);
2921
2922 if (_log.isWarnEnabled()) {
2923 _log.warn(msg.toString());
2924 }
2925
2926 throw new NoSuchRequestException(msg.toString());
2927 }
2928
2929 return socialRequest;
2930 }
2931
2932
2943 public SocialRequest fetchByU_C_C_T_R(long userId, long classNameId,
2944 long classPK, int type, long receiverUserId) throws SystemException {
2945 return fetchByU_C_C_T_R(userId, classNameId, classPK, type,
2946 receiverUserId, true);
2947 }
2948
2949
2960 public SocialRequest fetchByU_C_C_T_R(long userId, long classNameId,
2961 long classPK, int type, long receiverUserId, boolean retrieveFromCache)
2962 throws SystemException {
2963 Object[] finderArgs = new Object[] {
2964 userId, classNameId, classPK, type, receiverUserId
2965 };
2966
2967 Object result = null;
2968
2969 if (retrieveFromCache) {
2970 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
2971 finderArgs, this);
2972 }
2973
2974 if (result == null) {
2975 StringBundler query = new StringBundler(7);
2976
2977 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
2978
2979 query.append(_FINDER_COLUMN_U_C_C_T_R_USERID_2);
2980
2981 query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2);
2982
2983 query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSPK_2);
2984
2985 query.append(_FINDER_COLUMN_U_C_C_T_R_TYPE_2);
2986
2987 query.append(_FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2);
2988
2989 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
2990
2991 String sql = query.toString();
2992
2993 Session session = null;
2994
2995 try {
2996 session = openSession();
2997
2998 Query q = session.createQuery(sql);
2999
3000 QueryPos qPos = QueryPos.getInstance(q);
3001
3002 qPos.add(userId);
3003
3004 qPos.add(classNameId);
3005
3006 qPos.add(classPK);
3007
3008 qPos.add(type);
3009
3010 qPos.add(receiverUserId);
3011
3012 List<SocialRequest> list = q.list();
3013
3014 result = list;
3015
3016 SocialRequest socialRequest = null;
3017
3018 if (list.isEmpty()) {
3019 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3020 finderArgs, list);
3021 }
3022 else {
3023 socialRequest = list.get(0);
3024
3025 cacheResult(socialRequest);
3026
3027 if ((socialRequest.getUserId() != userId) ||
3028 (socialRequest.getClassNameId() != classNameId) ||
3029 (socialRequest.getClassPK() != classPK) ||
3030 (socialRequest.getType() != type) ||
3031 (socialRequest.getReceiverUserId() != receiverUserId)) {
3032 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3033 finderArgs, socialRequest);
3034 }
3035 }
3036
3037 return socialRequest;
3038 }
3039 catch (Exception e) {
3040 throw processException(e);
3041 }
3042 finally {
3043 if (result == null) {
3044 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C_T_R,
3045 finderArgs);
3046 }
3047
3048 closeSession(session);
3049 }
3050 }
3051 else {
3052 if (result instanceof List<?>) {
3053 return null;
3054 }
3055 else {
3056 return (SocialRequest)result;
3057 }
3058 }
3059 }
3060
3061
3072 public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
3073 long classPK, int type, int status) throws SystemException {
3074 return findByU_C_C_T_S(userId, classNameId, classPK, type, status,
3075 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3076 }
3077
3078
3095 public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
3096 long classPK, int type, int status, int start, int end)
3097 throws SystemException {
3098 return findByU_C_C_T_S(userId, classNameId, classPK, type, status,
3099 start, end, null);
3100 }
3101
3102
3120 public List<SocialRequest> findByU_C_C_T_S(long userId, long classNameId,
3121 long classPK, int type, int status, int start, int end,
3122 OrderByComparator orderByComparator) throws SystemException {
3123 Object[] finderArgs = new Object[] {
3124 userId, classNameId, classPK, type, status,
3125
3126 String.valueOf(start), String.valueOf(end),
3127 String.valueOf(orderByComparator)
3128 };
3129
3130 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_C_C_T_S,
3131 finderArgs, this);
3132
3133 if (list == null) {
3134 StringBundler query = null;
3135
3136 if (orderByComparator != null) {
3137 query = new StringBundler(7 +
3138 (orderByComparator.getOrderByFields().length * 3));
3139 }
3140 else {
3141 query = new StringBundler(7);
3142 }
3143
3144 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3145
3146 query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
3147
3148 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
3149
3150 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
3151
3152 query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
3153
3154 query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
3155
3156 if (orderByComparator != null) {
3157 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3158 orderByComparator);
3159 }
3160
3161 else {
3162 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3163 }
3164
3165 String sql = query.toString();
3166
3167 Session session = null;
3168
3169 try {
3170 session = openSession();
3171
3172 Query q = session.createQuery(sql);
3173
3174 QueryPos qPos = QueryPos.getInstance(q);
3175
3176 qPos.add(userId);
3177
3178 qPos.add(classNameId);
3179
3180 qPos.add(classPK);
3181
3182 qPos.add(type);
3183
3184 qPos.add(status);
3185
3186 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3187 start, end);
3188 }
3189 catch (Exception e) {
3190 throw processException(e);
3191 }
3192 finally {
3193 if (list == null) {
3194 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_U_C_C_T_S,
3195 finderArgs);
3196 }
3197 else {
3198 cacheResult(list);
3199
3200 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_C_C_T_S,
3201 finderArgs, list);
3202 }
3203
3204 closeSession(session);
3205 }
3206 }
3207
3208 return list;
3209 }
3210
3211
3228 public SocialRequest findByU_C_C_T_S_First(long userId, long classNameId,
3229 long classPK, int type, int status, OrderByComparator orderByComparator)
3230 throws NoSuchRequestException, SystemException {
3231 List<SocialRequest> list = findByU_C_C_T_S(userId, classNameId,
3232 classPK, type, status, 0, 1, orderByComparator);
3233
3234 if (list.isEmpty()) {
3235 StringBundler msg = new StringBundler(12);
3236
3237 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3238
3239 msg.append("userId=");
3240 msg.append(userId);
3241
3242 msg.append(", classNameId=");
3243 msg.append(classNameId);
3244
3245 msg.append(", classPK=");
3246 msg.append(classPK);
3247
3248 msg.append(", type=");
3249 msg.append(type);
3250
3251 msg.append(", status=");
3252 msg.append(status);
3253
3254 msg.append(StringPool.CLOSE_CURLY_BRACE);
3255
3256 throw new NoSuchRequestException(msg.toString());
3257 }
3258 else {
3259 return list.get(0);
3260 }
3261 }
3262
3263
3280 public SocialRequest findByU_C_C_T_S_Last(long userId, long classNameId,
3281 long classPK, int type, int status, OrderByComparator orderByComparator)
3282 throws NoSuchRequestException, SystemException {
3283 int count = countByU_C_C_T_S(userId, classNameId, classPK, type, status);
3284
3285 List<SocialRequest> list = findByU_C_C_T_S(userId, classNameId,
3286 classPK, type, status, count - 1, count, orderByComparator);
3287
3288 if (list.isEmpty()) {
3289 StringBundler msg = new StringBundler(12);
3290
3291 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3292
3293 msg.append("userId=");
3294 msg.append(userId);
3295
3296 msg.append(", classNameId=");
3297 msg.append(classNameId);
3298
3299 msg.append(", classPK=");
3300 msg.append(classPK);
3301
3302 msg.append(", type=");
3303 msg.append(type);
3304
3305 msg.append(", status=");
3306 msg.append(status);
3307
3308 msg.append(StringPool.CLOSE_CURLY_BRACE);
3309
3310 throw new NoSuchRequestException(msg.toString());
3311 }
3312 else {
3313 return list.get(0);
3314 }
3315 }
3316
3317
3335 public SocialRequest[] findByU_C_C_T_S_PrevAndNext(long requestId,
3336 long userId, long classNameId, long classPK, int type, int status,
3337 OrderByComparator orderByComparator)
3338 throws NoSuchRequestException, SystemException {
3339 SocialRequest socialRequest = findByPrimaryKey(requestId);
3340
3341 Session session = null;
3342
3343 try {
3344 session = openSession();
3345
3346 SocialRequest[] array = new SocialRequestImpl[3];
3347
3348 array[0] = getByU_C_C_T_S_PrevAndNext(session, socialRequest,
3349 userId, classNameId, classPK, type, status,
3350 orderByComparator, true);
3351
3352 array[1] = socialRequest;
3353
3354 array[2] = getByU_C_C_T_S_PrevAndNext(session, socialRequest,
3355 userId, classNameId, classPK, type, status,
3356 orderByComparator, false);
3357
3358 return array;
3359 }
3360 catch (Exception e) {
3361 throw processException(e);
3362 }
3363 finally {
3364 closeSession(session);
3365 }
3366 }
3367
3368 protected SocialRequest getByU_C_C_T_S_PrevAndNext(Session session,
3369 SocialRequest socialRequest, long userId, long classNameId,
3370 long classPK, int type, int status,
3371 OrderByComparator orderByComparator, boolean previous) {
3372 StringBundler query = null;
3373
3374 if (orderByComparator != null) {
3375 query = new StringBundler(6 +
3376 (orderByComparator.getOrderByFields().length * 6));
3377 }
3378 else {
3379 query = new StringBundler(3);
3380 }
3381
3382 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3383
3384 query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
3385
3386 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
3387
3388 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
3389
3390 query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
3391
3392 query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
3393
3394 if (orderByComparator != null) {
3395 String[] orderByFields = orderByComparator.getOrderByFields();
3396
3397 if (orderByFields.length > 0) {
3398 query.append(WHERE_AND);
3399 }
3400
3401 for (int i = 0; i < orderByFields.length; i++) {
3402 query.append(_ORDER_BY_ENTITY_ALIAS);
3403 query.append(orderByFields[i]);
3404
3405 if ((i + 1) < orderByFields.length) {
3406 if (orderByComparator.isAscending() ^ previous) {
3407 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3408 }
3409 else {
3410 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3411 }
3412 }
3413 else {
3414 if (orderByComparator.isAscending() ^ previous) {
3415 query.append(WHERE_GREATER_THAN);
3416 }
3417 else {
3418 query.append(WHERE_LESSER_THAN);
3419 }
3420 }
3421 }
3422
3423 query.append(ORDER_BY_CLAUSE);
3424
3425 for (int i = 0; i < orderByFields.length; i++) {
3426 query.append(_ORDER_BY_ENTITY_ALIAS);
3427 query.append(orderByFields[i]);
3428
3429 if ((i + 1) < orderByFields.length) {
3430 if (orderByComparator.isAscending() ^ previous) {
3431 query.append(ORDER_BY_ASC_HAS_NEXT);
3432 }
3433 else {
3434 query.append(ORDER_BY_DESC_HAS_NEXT);
3435 }
3436 }
3437 else {
3438 if (orderByComparator.isAscending() ^ previous) {
3439 query.append(ORDER_BY_ASC);
3440 }
3441 else {
3442 query.append(ORDER_BY_DESC);
3443 }
3444 }
3445 }
3446 }
3447
3448 else {
3449 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3450 }
3451
3452 String sql = query.toString();
3453
3454 Query q = session.createQuery(sql);
3455
3456 q.setFirstResult(0);
3457 q.setMaxResults(2);
3458
3459 QueryPos qPos = QueryPos.getInstance(q);
3460
3461 qPos.add(userId);
3462
3463 qPos.add(classNameId);
3464
3465 qPos.add(classPK);
3466
3467 qPos.add(type);
3468
3469 qPos.add(status);
3470
3471 if (orderByComparator != null) {
3472 Object[] values = orderByComparator.getOrderByValues(socialRequest);
3473
3474 for (Object value : values) {
3475 qPos.add(value);
3476 }
3477 }
3478
3479 List<SocialRequest> list = q.list();
3480
3481 if (list.size() == 2) {
3482 return list.get(1);
3483 }
3484 else {
3485 return null;
3486 }
3487 }
3488
3489
3500 public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
3501 int type, long receiverUserId, int status) throws SystemException {
3502 return findByC_C_T_R_S(classNameId, classPK, type, receiverUserId,
3503 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3504 }
3505
3506
3523 public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
3524 int type, long receiverUserId, int status, int start, int end)
3525 throws SystemException {
3526 return findByC_C_T_R_S(classNameId, classPK, type, receiverUserId,
3527 status, start, end, null);
3528 }
3529
3530
3548 public List<SocialRequest> findByC_C_T_R_S(long classNameId, long classPK,
3549 int type, long receiverUserId, int status, int start, int end,
3550 OrderByComparator orderByComparator) throws SystemException {
3551 Object[] finderArgs = new Object[] {
3552 classNameId, classPK, type, receiverUserId, status,
3553
3554 String.valueOf(start), String.valueOf(end),
3555 String.valueOf(orderByComparator)
3556 };
3557
3558 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C_T_R_S,
3559 finderArgs, this);
3560
3561 if (list == null) {
3562 StringBundler query = null;
3563
3564 if (orderByComparator != null) {
3565 query = new StringBundler(7 +
3566 (orderByComparator.getOrderByFields().length * 3));
3567 }
3568 else {
3569 query = new StringBundler(7);
3570 }
3571
3572 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3573
3574 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
3575
3576 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
3577
3578 query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
3579
3580 query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
3581
3582 query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
3583
3584 if (orderByComparator != null) {
3585 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3586 orderByComparator);
3587 }
3588
3589 else {
3590 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3591 }
3592
3593 String sql = query.toString();
3594
3595 Session session = null;
3596
3597 try {
3598 session = openSession();
3599
3600 Query q = session.createQuery(sql);
3601
3602 QueryPos qPos = QueryPos.getInstance(q);
3603
3604 qPos.add(classNameId);
3605
3606 qPos.add(classPK);
3607
3608 qPos.add(type);
3609
3610 qPos.add(receiverUserId);
3611
3612 qPos.add(status);
3613
3614 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3615 start, end);
3616 }
3617 catch (Exception e) {
3618 throw processException(e);
3619 }
3620 finally {
3621 if (list == null) {
3622 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_C_C_T_R_S,
3623 finderArgs);
3624 }
3625 else {
3626 cacheResult(list);
3627
3628 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C_T_R_S,
3629 finderArgs, list);
3630 }
3631
3632 closeSession(session);
3633 }
3634 }
3635
3636 return list;
3637 }
3638
3639
3656 public SocialRequest findByC_C_T_R_S_First(long classNameId, long classPK,
3657 int type, long receiverUserId, int status,
3658 OrderByComparator orderByComparator)
3659 throws NoSuchRequestException, SystemException {
3660 List<SocialRequest> list = findByC_C_T_R_S(classNameId, classPK, type,
3661 receiverUserId, status, 0, 1, orderByComparator);
3662
3663 if (list.isEmpty()) {
3664 StringBundler msg = new StringBundler(12);
3665
3666 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3667
3668 msg.append("classNameId=");
3669 msg.append(classNameId);
3670
3671 msg.append(", classPK=");
3672 msg.append(classPK);
3673
3674 msg.append(", type=");
3675 msg.append(type);
3676
3677 msg.append(", receiverUserId=");
3678 msg.append(receiverUserId);
3679
3680 msg.append(", status=");
3681 msg.append(status);
3682
3683 msg.append(StringPool.CLOSE_CURLY_BRACE);
3684
3685 throw new NoSuchRequestException(msg.toString());
3686 }
3687 else {
3688 return list.get(0);
3689 }
3690 }
3691
3692
3709 public SocialRequest findByC_C_T_R_S_Last(long classNameId, long classPK,
3710 int type, long receiverUserId, int status,
3711 OrderByComparator orderByComparator)
3712 throws NoSuchRequestException, SystemException {
3713 int count = countByC_C_T_R_S(classNameId, classPK, type,
3714 receiverUserId, status);
3715
3716 List<SocialRequest> list = findByC_C_T_R_S(classNameId, classPK, type,
3717 receiverUserId, status, count - 1, count, orderByComparator);
3718
3719 if (list.isEmpty()) {
3720 StringBundler msg = new StringBundler(12);
3721
3722 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3723
3724 msg.append("classNameId=");
3725 msg.append(classNameId);
3726
3727 msg.append(", classPK=");
3728 msg.append(classPK);
3729
3730 msg.append(", type=");
3731 msg.append(type);
3732
3733 msg.append(", receiverUserId=");
3734 msg.append(receiverUserId);
3735
3736 msg.append(", status=");
3737 msg.append(status);
3738
3739 msg.append(StringPool.CLOSE_CURLY_BRACE);
3740
3741 throw new NoSuchRequestException(msg.toString());
3742 }
3743 else {
3744 return list.get(0);
3745 }
3746 }
3747
3748
3766 public SocialRequest[] findByC_C_T_R_S_PrevAndNext(long requestId,
3767 long classNameId, long classPK, int type, long receiverUserId,
3768 int status, OrderByComparator orderByComparator)
3769 throws NoSuchRequestException, SystemException {
3770 SocialRequest socialRequest = findByPrimaryKey(requestId);
3771
3772 Session session = null;
3773
3774 try {
3775 session = openSession();
3776
3777 SocialRequest[] array = new SocialRequestImpl[3];
3778
3779 array[0] = getByC_C_T_R_S_PrevAndNext(session, socialRequest,
3780 classNameId, classPK, type, receiverUserId, status,
3781 orderByComparator, true);
3782
3783 array[1] = socialRequest;
3784
3785 array[2] = getByC_C_T_R_S_PrevAndNext(session, socialRequest,
3786 classNameId, classPK, type, receiverUserId, status,
3787 orderByComparator, false);
3788
3789 return array;
3790 }
3791 catch (Exception e) {
3792 throw processException(e);
3793 }
3794 finally {
3795 closeSession(session);
3796 }
3797 }
3798
3799 protected SocialRequest getByC_C_T_R_S_PrevAndNext(Session session,
3800 SocialRequest socialRequest, long classNameId, long classPK, int type,
3801 long receiverUserId, int status, OrderByComparator orderByComparator,
3802 boolean previous) {
3803 StringBundler query = null;
3804
3805 if (orderByComparator != null) {
3806 query = new StringBundler(6 +
3807 (orderByComparator.getOrderByFields().length * 6));
3808 }
3809 else {
3810 query = new StringBundler(3);
3811 }
3812
3813 query.append(_SQL_SELECT_SOCIALREQUEST_WHERE);
3814
3815 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
3816
3817 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
3818
3819 query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
3820
3821 query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
3822
3823 query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
3824
3825 if (orderByComparator != null) {
3826 String[] orderByFields = orderByComparator.getOrderByFields();
3827
3828 if (orderByFields.length > 0) {
3829 query.append(WHERE_AND);
3830 }
3831
3832 for (int i = 0; i < orderByFields.length; i++) {
3833 query.append(_ORDER_BY_ENTITY_ALIAS);
3834 query.append(orderByFields[i]);
3835
3836 if ((i + 1) < orderByFields.length) {
3837 if (orderByComparator.isAscending() ^ previous) {
3838 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3839 }
3840 else {
3841 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3842 }
3843 }
3844 else {
3845 if (orderByComparator.isAscending() ^ previous) {
3846 query.append(WHERE_GREATER_THAN);
3847 }
3848 else {
3849 query.append(WHERE_LESSER_THAN);
3850 }
3851 }
3852 }
3853
3854 query.append(ORDER_BY_CLAUSE);
3855
3856 for (int i = 0; i < orderByFields.length; i++) {
3857 query.append(_ORDER_BY_ENTITY_ALIAS);
3858 query.append(orderByFields[i]);
3859
3860 if ((i + 1) < orderByFields.length) {
3861 if (orderByComparator.isAscending() ^ previous) {
3862 query.append(ORDER_BY_ASC_HAS_NEXT);
3863 }
3864 else {
3865 query.append(ORDER_BY_DESC_HAS_NEXT);
3866 }
3867 }
3868 else {
3869 if (orderByComparator.isAscending() ^ previous) {
3870 query.append(ORDER_BY_ASC);
3871 }
3872 else {
3873 query.append(ORDER_BY_DESC);
3874 }
3875 }
3876 }
3877 }
3878
3879 else {
3880 query.append(SocialRequestModelImpl.ORDER_BY_JPQL);
3881 }
3882
3883 String sql = query.toString();
3884
3885 Query q = session.createQuery(sql);
3886
3887 q.setFirstResult(0);
3888 q.setMaxResults(2);
3889
3890 QueryPos qPos = QueryPos.getInstance(q);
3891
3892 qPos.add(classNameId);
3893
3894 qPos.add(classPK);
3895
3896 qPos.add(type);
3897
3898 qPos.add(receiverUserId);
3899
3900 qPos.add(status);
3901
3902 if (orderByComparator != null) {
3903 Object[] values = orderByComparator.getOrderByValues(socialRequest);
3904
3905 for (Object value : values) {
3906 qPos.add(value);
3907 }
3908 }
3909
3910 List<SocialRequest> list = q.list();
3911
3912 if (list.size() == 2) {
3913 return list.get(1);
3914 }
3915 else {
3916 return null;
3917 }
3918 }
3919
3920
3926 public List<SocialRequest> findAll() throws SystemException {
3927 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3928 }
3929
3930
3942 public List<SocialRequest> findAll(int start, int end)
3943 throws SystemException {
3944 return findAll(start, end, null);
3945 }
3946
3947
3960 public List<SocialRequest> findAll(int start, int end,
3961 OrderByComparator orderByComparator) throws SystemException {
3962 Object[] finderArgs = new Object[] {
3963 String.valueOf(start), String.valueOf(end),
3964 String.valueOf(orderByComparator)
3965 };
3966
3967 List<SocialRequest> list = (List<SocialRequest>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3968 finderArgs, this);
3969
3970 if (list == null) {
3971 StringBundler query = null;
3972 String sql = null;
3973
3974 if (orderByComparator != null) {
3975 query = new StringBundler(2 +
3976 (orderByComparator.getOrderByFields().length * 3));
3977
3978 query.append(_SQL_SELECT_SOCIALREQUEST);
3979
3980 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3981 orderByComparator);
3982
3983 sql = query.toString();
3984 }
3985 else {
3986 sql = _SQL_SELECT_SOCIALREQUEST.concat(SocialRequestModelImpl.ORDER_BY_JPQL);
3987 }
3988
3989 Session session = null;
3990
3991 try {
3992 session = openSession();
3993
3994 Query q = session.createQuery(sql);
3995
3996 if (orderByComparator == null) {
3997 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
3998 start, end, false);
3999
4000 Collections.sort(list);
4001 }
4002 else {
4003 list = (List<SocialRequest>)QueryUtil.list(q, getDialect(),
4004 start, end);
4005 }
4006 }
4007 catch (Exception e) {
4008 throw processException(e);
4009 }
4010 finally {
4011 if (list == null) {
4012 FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
4013 finderArgs);
4014 }
4015 else {
4016 cacheResult(list);
4017
4018 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
4019 list);
4020 }
4021
4022 closeSession(session);
4023 }
4024 }
4025
4026 return list;
4027 }
4028
4029
4035 public void removeByUuid(String uuid) throws SystemException {
4036 for (SocialRequest socialRequest : findByUuid(uuid)) {
4037 remove(socialRequest);
4038 }
4039 }
4040
4041
4048 public void removeByUUID_G(String uuid, long groupId)
4049 throws NoSuchRequestException, SystemException {
4050 SocialRequest socialRequest = findByUUID_G(uuid, groupId);
4051
4052 remove(socialRequest);
4053 }
4054
4055
4061 public void removeByCompanyId(long companyId) throws SystemException {
4062 for (SocialRequest socialRequest : findByCompanyId(companyId)) {
4063 remove(socialRequest);
4064 }
4065 }
4066
4067
4073 public void removeByUserId(long userId) throws SystemException {
4074 for (SocialRequest socialRequest : findByUserId(userId)) {
4075 remove(socialRequest);
4076 }
4077 }
4078
4079
4085 public void removeByReceiverUserId(long receiverUserId)
4086 throws SystemException {
4087 for (SocialRequest socialRequest : findByReceiverUserId(receiverUserId)) {
4088 remove(socialRequest);
4089 }
4090 }
4091
4092
4099 public void removeByU_S(long userId, int status) throws SystemException {
4100 for (SocialRequest socialRequest : findByU_S(userId, status)) {
4101 remove(socialRequest);
4102 }
4103 }
4104
4105
4112 public void removeByR_S(long receiverUserId, int status)
4113 throws SystemException {
4114 for (SocialRequest socialRequest : findByR_S(receiverUserId, status)) {
4115 remove(socialRequest);
4116 }
4117 }
4118
4119
4129 public void removeByU_C_C_T_R(long userId, long classNameId, long classPK,
4130 int type, long receiverUserId)
4131 throws NoSuchRequestException, SystemException {
4132 SocialRequest socialRequest = findByU_C_C_T_R(userId, classNameId,
4133 classPK, type, receiverUserId);
4134
4135 remove(socialRequest);
4136 }
4137
4138
4148 public void removeByU_C_C_T_S(long userId, long classNameId, long classPK,
4149 int type, int status) throws SystemException {
4150 for (SocialRequest socialRequest : findByU_C_C_T_S(userId, classNameId,
4151 classPK, type, status)) {
4152 remove(socialRequest);
4153 }
4154 }
4155
4156
4166 public void removeByC_C_T_R_S(long classNameId, long classPK, int type,
4167 long receiverUserId, int status) throws SystemException {
4168 for (SocialRequest socialRequest : findByC_C_T_R_S(classNameId,
4169 classPK, type, receiverUserId, status)) {
4170 remove(socialRequest);
4171 }
4172 }
4173
4174
4179 public void removeAll() throws SystemException {
4180 for (SocialRequest socialRequest : findAll()) {
4181 remove(socialRequest);
4182 }
4183 }
4184
4185
4192 public int countByUuid(String uuid) throws SystemException {
4193 Object[] finderArgs = new Object[] { uuid };
4194
4195 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4196 finderArgs, this);
4197
4198 if (count == null) {
4199 StringBundler query = new StringBundler(2);
4200
4201 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4202
4203 if (uuid == null) {
4204 query.append(_FINDER_COLUMN_UUID_UUID_1);
4205 }
4206 else {
4207 if (uuid.equals(StringPool.BLANK)) {
4208 query.append(_FINDER_COLUMN_UUID_UUID_3);
4209 }
4210 else {
4211 query.append(_FINDER_COLUMN_UUID_UUID_2);
4212 }
4213 }
4214
4215 String sql = query.toString();
4216
4217 Session session = null;
4218
4219 try {
4220 session = openSession();
4221
4222 Query q = session.createQuery(sql);
4223
4224 QueryPos qPos = QueryPos.getInstance(q);
4225
4226 if (uuid != null) {
4227 qPos.add(uuid);
4228 }
4229
4230 count = (Long)q.uniqueResult();
4231 }
4232 catch (Exception e) {
4233 throw processException(e);
4234 }
4235 finally {
4236 if (count == null) {
4237 count = Long.valueOf(0);
4238 }
4239
4240 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4241 finderArgs, count);
4242
4243 closeSession(session);
4244 }
4245 }
4246
4247 return count.intValue();
4248 }
4249
4250
4258 public int countByUUID_G(String uuid, long groupId)
4259 throws SystemException {
4260 Object[] finderArgs = new Object[] { uuid, groupId };
4261
4262 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4263 finderArgs, this);
4264
4265 if (count == null) {
4266 StringBundler query = new StringBundler(3);
4267
4268 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4269
4270 if (uuid == null) {
4271 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4272 }
4273 else {
4274 if (uuid.equals(StringPool.BLANK)) {
4275 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4276 }
4277 else {
4278 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4279 }
4280 }
4281
4282 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4283
4284 String sql = query.toString();
4285
4286 Session session = null;
4287
4288 try {
4289 session = openSession();
4290
4291 Query q = session.createQuery(sql);
4292
4293 QueryPos qPos = QueryPos.getInstance(q);
4294
4295 if (uuid != null) {
4296 qPos.add(uuid);
4297 }
4298
4299 qPos.add(groupId);
4300
4301 count = (Long)q.uniqueResult();
4302 }
4303 catch (Exception e) {
4304 throw processException(e);
4305 }
4306 finally {
4307 if (count == null) {
4308 count = Long.valueOf(0);
4309 }
4310
4311 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4312 finderArgs, count);
4313
4314 closeSession(session);
4315 }
4316 }
4317
4318 return count.intValue();
4319 }
4320
4321
4328 public int countByCompanyId(long companyId) throws SystemException {
4329 Object[] finderArgs = new Object[] { companyId };
4330
4331 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4332 finderArgs, this);
4333
4334 if (count == null) {
4335 StringBundler query = new StringBundler(2);
4336
4337 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4338
4339 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4340
4341 String sql = query.toString();
4342
4343 Session session = null;
4344
4345 try {
4346 session = openSession();
4347
4348 Query q = session.createQuery(sql);
4349
4350 QueryPos qPos = QueryPos.getInstance(q);
4351
4352 qPos.add(companyId);
4353
4354 count = (Long)q.uniqueResult();
4355 }
4356 catch (Exception e) {
4357 throw processException(e);
4358 }
4359 finally {
4360 if (count == null) {
4361 count = Long.valueOf(0);
4362 }
4363
4364 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4365 finderArgs, count);
4366
4367 closeSession(session);
4368 }
4369 }
4370
4371 return count.intValue();
4372 }
4373
4374
4381 public int countByUserId(long userId) throws SystemException {
4382 Object[] finderArgs = new Object[] { userId };
4383
4384 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
4385 finderArgs, this);
4386
4387 if (count == null) {
4388 StringBundler query = new StringBundler(2);
4389
4390 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4391
4392 query.append(_FINDER_COLUMN_USERID_USERID_2);
4393
4394 String sql = query.toString();
4395
4396 Session session = null;
4397
4398 try {
4399 session = openSession();
4400
4401 Query q = session.createQuery(sql);
4402
4403 QueryPos qPos = QueryPos.getInstance(q);
4404
4405 qPos.add(userId);
4406
4407 count = (Long)q.uniqueResult();
4408 }
4409 catch (Exception e) {
4410 throw processException(e);
4411 }
4412 finally {
4413 if (count == null) {
4414 count = Long.valueOf(0);
4415 }
4416
4417 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
4418 finderArgs, count);
4419
4420 closeSession(session);
4421 }
4422 }
4423
4424 return count.intValue();
4425 }
4426
4427
4434 public int countByReceiverUserId(long receiverUserId)
4435 throws SystemException {
4436 Object[] finderArgs = new Object[] { receiverUserId };
4437
4438 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
4439 finderArgs, this);
4440
4441 if (count == null) {
4442 StringBundler query = new StringBundler(2);
4443
4444 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4445
4446 query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
4447
4448 String sql = query.toString();
4449
4450 Session session = null;
4451
4452 try {
4453 session = openSession();
4454
4455 Query q = session.createQuery(sql);
4456
4457 QueryPos qPos = QueryPos.getInstance(q);
4458
4459 qPos.add(receiverUserId);
4460
4461 count = (Long)q.uniqueResult();
4462 }
4463 catch (Exception e) {
4464 throw processException(e);
4465 }
4466 finally {
4467 if (count == null) {
4468 count = Long.valueOf(0);
4469 }
4470
4471 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
4472 finderArgs, count);
4473
4474 closeSession(session);
4475 }
4476 }
4477
4478 return count.intValue();
4479 }
4480
4481
4489 public int countByU_S(long userId, int status) throws SystemException {
4490 Object[] finderArgs = new Object[] { userId, status };
4491
4492 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_S,
4493 finderArgs, this);
4494
4495 if (count == null) {
4496 StringBundler query = new StringBundler(3);
4497
4498 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4499
4500 query.append(_FINDER_COLUMN_U_S_USERID_2);
4501
4502 query.append(_FINDER_COLUMN_U_S_STATUS_2);
4503
4504 String sql = query.toString();
4505
4506 Session session = null;
4507
4508 try {
4509 session = openSession();
4510
4511 Query q = session.createQuery(sql);
4512
4513 QueryPos qPos = QueryPos.getInstance(q);
4514
4515 qPos.add(userId);
4516
4517 qPos.add(status);
4518
4519 count = (Long)q.uniqueResult();
4520 }
4521 catch (Exception e) {
4522 throw processException(e);
4523 }
4524 finally {
4525 if (count == null) {
4526 count = Long.valueOf(0);
4527 }
4528
4529 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_S, finderArgs,
4530 count);
4531
4532 closeSession(session);
4533 }
4534 }
4535
4536 return count.intValue();
4537 }
4538
4539
4547 public int countByR_S(long receiverUserId, int status)
4548 throws SystemException {
4549 Object[] finderArgs = new Object[] { receiverUserId, status };
4550
4551 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_S,
4552 finderArgs, this);
4553
4554 if (count == null) {
4555 StringBundler query = new StringBundler(3);
4556
4557 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4558
4559 query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2);
4560
4561 query.append(_FINDER_COLUMN_R_S_STATUS_2);
4562
4563 String sql = query.toString();
4564
4565 Session session = null;
4566
4567 try {
4568 session = openSession();
4569
4570 Query q = session.createQuery(sql);
4571
4572 QueryPos qPos = QueryPos.getInstance(q);
4573
4574 qPos.add(receiverUserId);
4575
4576 qPos.add(status);
4577
4578 count = (Long)q.uniqueResult();
4579 }
4580 catch (Exception e) {
4581 throw processException(e);
4582 }
4583 finally {
4584 if (count == null) {
4585 count = Long.valueOf(0);
4586 }
4587
4588 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_S, finderArgs,
4589 count);
4590
4591 closeSession(session);
4592 }
4593 }
4594
4595 return count.intValue();
4596 }
4597
4598
4609 public int countByU_C_C_T_R(long userId, long classNameId, long classPK,
4610 int type, long receiverUserId) throws SystemException {
4611 Object[] finderArgs = new Object[] {
4612 userId, classNameId, classPK, type, receiverUserId
4613 };
4614
4615 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C_T_R,
4616 finderArgs, this);
4617
4618 if (count == null) {
4619 StringBundler query = new StringBundler(6);
4620
4621 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4622
4623 query.append(_FINDER_COLUMN_U_C_C_T_R_USERID_2);
4624
4625 query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2);
4626
4627 query.append(_FINDER_COLUMN_U_C_C_T_R_CLASSPK_2);
4628
4629 query.append(_FINDER_COLUMN_U_C_C_T_R_TYPE_2);
4630
4631 query.append(_FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2);
4632
4633 String sql = query.toString();
4634
4635 Session session = null;
4636
4637 try {
4638 session = openSession();
4639
4640 Query q = session.createQuery(sql);
4641
4642 QueryPos qPos = QueryPos.getInstance(q);
4643
4644 qPos.add(userId);
4645
4646 qPos.add(classNameId);
4647
4648 qPos.add(classPK);
4649
4650 qPos.add(type);
4651
4652 qPos.add(receiverUserId);
4653
4654 count = (Long)q.uniqueResult();
4655 }
4656 catch (Exception e) {
4657 throw processException(e);
4658 }
4659 finally {
4660 if (count == null) {
4661 count = Long.valueOf(0);
4662 }
4663
4664 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C_T_R,
4665 finderArgs, count);
4666
4667 closeSession(session);
4668 }
4669 }
4670
4671 return count.intValue();
4672 }
4673
4674
4685 public int countByU_C_C_T_S(long userId, long classNameId, long classPK,
4686 int type, int status) throws SystemException {
4687 Object[] finderArgs = new Object[] {
4688 userId, classNameId, classPK, type, status
4689 };
4690
4691 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
4692 finderArgs, this);
4693
4694 if (count == null) {
4695 StringBundler query = new StringBundler(6);
4696
4697 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4698
4699 query.append(_FINDER_COLUMN_U_C_C_T_S_USERID_2);
4700
4701 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2);
4702
4703 query.append(_FINDER_COLUMN_U_C_C_T_S_CLASSPK_2);
4704
4705 query.append(_FINDER_COLUMN_U_C_C_T_S_TYPE_2);
4706
4707 query.append(_FINDER_COLUMN_U_C_C_T_S_STATUS_2);
4708
4709 String sql = query.toString();
4710
4711 Session session = null;
4712
4713 try {
4714 session = openSession();
4715
4716 Query q = session.createQuery(sql);
4717
4718 QueryPos qPos = QueryPos.getInstance(q);
4719
4720 qPos.add(userId);
4721
4722 qPos.add(classNameId);
4723
4724 qPos.add(classPK);
4725
4726 qPos.add(type);
4727
4728 qPos.add(status);
4729
4730 count = (Long)q.uniqueResult();
4731 }
4732 catch (Exception e) {
4733 throw processException(e);
4734 }
4735 finally {
4736 if (count == null) {
4737 count = Long.valueOf(0);
4738 }
4739
4740 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C_T_S,
4741 finderArgs, count);
4742
4743 closeSession(session);
4744 }
4745 }
4746
4747 return count.intValue();
4748 }
4749
4750
4761 public int countByC_C_T_R_S(long classNameId, long classPK, int type,
4762 long receiverUserId, int status) throws SystemException {
4763 Object[] finderArgs = new Object[] {
4764 classNameId, classPK, type, receiverUserId, status
4765 };
4766
4767 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
4768 finderArgs, this);
4769
4770 if (count == null) {
4771 StringBundler query = new StringBundler(6);
4772
4773 query.append(_SQL_COUNT_SOCIALREQUEST_WHERE);
4774
4775 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2);
4776
4777 query.append(_FINDER_COLUMN_C_C_T_R_S_CLASSPK_2);
4778
4779 query.append(_FINDER_COLUMN_C_C_T_R_S_TYPE_2);
4780
4781 query.append(_FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2);
4782
4783 query.append(_FINDER_COLUMN_C_C_T_R_S_STATUS_2);
4784
4785 String sql = query.toString();
4786
4787 Session session = null;
4788
4789 try {
4790 session = openSession();
4791
4792 Query q = session.createQuery(sql);
4793
4794 QueryPos qPos = QueryPos.getInstance(q);
4795
4796 qPos.add(classNameId);
4797
4798 qPos.add(classPK);
4799
4800 qPos.add(type);
4801
4802 qPos.add(receiverUserId);
4803
4804 qPos.add(status);
4805
4806 count = (Long)q.uniqueResult();
4807 }
4808 catch (Exception e) {
4809 throw processException(e);
4810 }
4811 finally {
4812 if (count == null) {
4813 count = Long.valueOf(0);
4814 }
4815
4816 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_T_R_S,
4817 finderArgs, count);
4818
4819 closeSession(session);
4820 }
4821 }
4822
4823 return count.intValue();
4824 }
4825
4826
4832 public int countAll() throws SystemException {
4833 Object[] finderArgs = new Object[0];
4834
4835 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4836 finderArgs, this);
4837
4838 if (count == null) {
4839 Session session = null;
4840
4841 try {
4842 session = openSession();
4843
4844 Query q = session.createQuery(_SQL_COUNT_SOCIALREQUEST);
4845
4846 count = (Long)q.uniqueResult();
4847 }
4848 catch (Exception e) {
4849 throw processException(e);
4850 }
4851 finally {
4852 if (count == null) {
4853 count = Long.valueOf(0);
4854 }
4855
4856 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
4857 count);
4858
4859 closeSession(session);
4860 }
4861 }
4862
4863 return count.intValue();
4864 }
4865
4866
4869 public void afterPropertiesSet() {
4870 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4871 com.liferay.portal.util.PropsUtil.get(
4872 "value.object.listener.com.liferay.portlet.social.model.SocialRequest")));
4873
4874 if (listenerClassNames.length > 0) {
4875 try {
4876 List<ModelListener<SocialRequest>> listenersList = new ArrayList<ModelListener<SocialRequest>>();
4877
4878 for (String listenerClassName : listenerClassNames) {
4879 listenersList.add((ModelListener<SocialRequest>)InstanceFactory.newInstance(
4880 listenerClassName));
4881 }
4882
4883 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4884 }
4885 catch (Exception e) {
4886 _log.error(e);
4887 }
4888 }
4889 }
4890
4891 public void destroy() {
4892 EntityCacheUtil.removeCache(SocialRequestImpl.class.getName());
4893 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4894 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
4895 }
4896
4897 @BeanReference(type = SocialActivityPersistence.class)
4898 protected SocialActivityPersistence socialActivityPersistence;
4899 @BeanReference(type = SocialEquityAssetEntryPersistence.class)
4900 protected SocialEquityAssetEntryPersistence socialEquityAssetEntryPersistence;
4901 @BeanReference(type = SocialEquityGroupSettingPersistence.class)
4902 protected SocialEquityGroupSettingPersistence socialEquityGroupSettingPersistence;
4903 @BeanReference(type = SocialEquityHistoryPersistence.class)
4904 protected SocialEquityHistoryPersistence socialEquityHistoryPersistence;
4905 @BeanReference(type = SocialEquityLogPersistence.class)
4906 protected SocialEquityLogPersistence socialEquityLogPersistence;
4907 @BeanReference(type = SocialEquitySettingPersistence.class)
4908 protected SocialEquitySettingPersistence socialEquitySettingPersistence;
4909 @BeanReference(type = SocialEquityUserPersistence.class)
4910 protected SocialEquityUserPersistence socialEquityUserPersistence;
4911 @BeanReference(type = SocialRelationPersistence.class)
4912 protected SocialRelationPersistence socialRelationPersistence;
4913 @BeanReference(type = SocialRequestPersistence.class)
4914 protected SocialRequestPersistence socialRequestPersistence;
4915 @BeanReference(type = ResourcePersistence.class)
4916 protected ResourcePersistence resourcePersistence;
4917 @BeanReference(type = UserPersistence.class)
4918 protected UserPersistence userPersistence;
4919 private static final String _SQL_SELECT_SOCIALREQUEST = "SELECT socialRequest FROM SocialRequest socialRequest";
4920 private static final String _SQL_SELECT_SOCIALREQUEST_WHERE = "SELECT socialRequest FROM SocialRequest socialRequest WHERE ";
4921 private static final String _SQL_COUNT_SOCIALREQUEST = "SELECT COUNT(socialRequest) FROM SocialRequest socialRequest";
4922 private static final String _SQL_COUNT_SOCIALREQUEST_WHERE = "SELECT COUNT(socialRequest) FROM SocialRequest socialRequest WHERE ";
4923 private static final String _FINDER_COLUMN_UUID_UUID_1 = "socialRequest.uuid IS NULL";
4924 private static final String _FINDER_COLUMN_UUID_UUID_2 = "socialRequest.uuid = ?";
4925 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(socialRequest.uuid IS NULL OR socialRequest.uuid = ?)";
4926 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "socialRequest.uuid IS NULL AND ";
4927 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "socialRequest.uuid = ? AND ";
4928 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(socialRequest.uuid IS NULL OR socialRequest.uuid = ?) AND ";
4929 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "socialRequest.groupId = ?";
4930 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "socialRequest.companyId = ?";
4931 private static final String _FINDER_COLUMN_USERID_USERID_2 = "socialRequest.userId = ?";
4932 private static final String _FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ?";
4933 private static final String _FINDER_COLUMN_U_S_USERID_2 = "socialRequest.userId = ? AND ";
4934 private static final String _FINDER_COLUMN_U_S_STATUS_2 = "socialRequest.status = ?";
4935 private static final String _FINDER_COLUMN_R_S_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ? AND ";
4936 private static final String _FINDER_COLUMN_R_S_STATUS_2 = "socialRequest.status = ?";
4937 private static final String _FINDER_COLUMN_U_C_C_T_R_USERID_2 = "socialRequest.userId = ? AND ";
4938 private static final String _FINDER_COLUMN_U_C_C_T_R_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
4939 private static final String _FINDER_COLUMN_U_C_C_T_R_CLASSPK_2 = "socialRequest.classPK = ? AND ";
4940 private static final String _FINDER_COLUMN_U_C_C_T_R_TYPE_2 = "socialRequest.type = ? AND ";
4941 private static final String _FINDER_COLUMN_U_C_C_T_R_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ?";
4942 private static final String _FINDER_COLUMN_U_C_C_T_S_USERID_2 = "socialRequest.userId = ? AND ";
4943 private static final String _FINDER_COLUMN_U_C_C_T_S_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
4944 private static final String _FINDER_COLUMN_U_C_C_T_S_CLASSPK_2 = "socialRequest.classPK = ? AND ";
4945 private static final String _FINDER_COLUMN_U_C_C_T_S_TYPE_2 = "socialRequest.type = ? AND ";
4946 private static final String _FINDER_COLUMN_U_C_C_T_S_STATUS_2 = "socialRequest.status = ?";
4947 private static final String _FINDER_COLUMN_C_C_T_R_S_CLASSNAMEID_2 = "socialRequest.classNameId = ? AND ";
4948 private static final String _FINDER_COLUMN_C_C_T_R_S_CLASSPK_2 = "socialRequest.classPK = ? AND ";
4949 private static final String _FINDER_COLUMN_C_C_T_R_S_TYPE_2 = "socialRequest.type = ? AND ";
4950 private static final String _FINDER_COLUMN_C_C_T_R_S_RECEIVERUSERID_2 = "socialRequest.receiverUserId = ? AND ";
4951 private static final String _FINDER_COLUMN_C_C_T_R_S_STATUS_2 = "socialRequest.status = ?";
4952 private static final String _ORDER_BY_ENTITY_ALIAS = "socialRequest.";
4953 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialRequest exists with the primary key ";
4954 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialRequest exists with the key {";
4955 private static Log _log = LogFactoryUtil.getLog(SocialRequestPersistenceImpl.class);
4956 }