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