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