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