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