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