1
19
20 package com.liferay.portal.service.persistence;
21
22 import com.liferay.portal.NoSuchPhoneException;
23 import com.liferay.portal.SystemException;
24 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
25 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
26 import com.liferay.portal.kernel.dao.orm.Query;
27 import com.liferay.portal.kernel.dao.orm.QueryPos;
28 import com.liferay.portal.kernel.dao.orm.QueryUtil;
29 import com.liferay.portal.kernel.dao.orm.Session;
30 import com.liferay.portal.kernel.log.Log;
31 import com.liferay.portal.kernel.log.LogFactoryUtil;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.OrderByComparator;
34 import com.liferay.portal.kernel.util.StringPool;
35 import com.liferay.portal.kernel.util.StringUtil;
36 import com.liferay.portal.model.ModelListener;
37 import com.liferay.portal.model.Phone;
38 import com.liferay.portal.model.impl.PhoneImpl;
39 import com.liferay.portal.model.impl.PhoneModelImpl;
40 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41
42 import java.util.ArrayList;
43 import java.util.Collections;
44 import java.util.Iterator;
45 import java.util.List;
46
47
53 public class PhonePersistenceImpl extends BasePersistenceImpl
54 implements PhonePersistence {
55 public Phone create(long phoneId) {
56 Phone phone = new PhoneImpl();
57
58 phone.setNew(true);
59 phone.setPrimaryKey(phoneId);
60
61 return phone;
62 }
63
64 public Phone remove(long phoneId)
65 throws NoSuchPhoneException, SystemException {
66 Session session = null;
67
68 try {
69 session = openSession();
70
71 Phone phone = (Phone)session.get(PhoneImpl.class, new Long(phoneId));
72
73 if (phone == null) {
74 if (_log.isWarnEnabled()) {
75 _log.warn("No Phone exists with the primary key " +
76 phoneId);
77 }
78
79 throw new NoSuchPhoneException(
80 "No Phone exists with the primary key " + phoneId);
81 }
82
83 return remove(phone);
84 }
85 catch (NoSuchPhoneException nsee) {
86 throw nsee;
87 }
88 catch (Exception e) {
89 throw processException(e);
90 }
91 finally {
92 closeSession(session);
93 }
94 }
95
96 public Phone remove(Phone phone) throws SystemException {
97 for (ModelListener listener : listeners) {
98 listener.onBeforeRemove(phone);
99 }
100
101 phone = removeImpl(phone);
102
103 for (ModelListener listener : listeners) {
104 listener.onAfterRemove(phone);
105 }
106
107 return phone;
108 }
109
110 protected Phone removeImpl(Phone phone) throws SystemException {
111 Session session = null;
112
113 try {
114 session = openSession();
115
116 if (BatchSessionUtil.isEnabled()) {
117 Object staleObject = session.get(PhoneImpl.class,
118 phone.getPrimaryKeyObj());
119
120 if (staleObject != null) {
121 session.evict(staleObject);
122 }
123 }
124
125 session.delete(phone);
126
127 session.flush();
128
129 return phone;
130 }
131 catch (Exception e) {
132 throw processException(e);
133 }
134 finally {
135 closeSession(session);
136
137 FinderCacheUtil.clearCache(Phone.class.getName());
138 }
139 }
140
141
144 public Phone update(Phone phone) throws SystemException {
145 if (_log.isWarnEnabled()) {
146 _log.warn(
147 "Using the deprecated update(Phone phone) method. Use update(Phone phone, boolean merge) instead.");
148 }
149
150 return update(phone, false);
151 }
152
153
166 public Phone update(Phone phone, boolean merge) throws SystemException {
167 boolean isNew = phone.isNew();
168
169 for (ModelListener listener : listeners) {
170 if (isNew) {
171 listener.onBeforeCreate(phone);
172 }
173 else {
174 listener.onBeforeUpdate(phone);
175 }
176 }
177
178 phone = updateImpl(phone, merge);
179
180 for (ModelListener listener : listeners) {
181 if (isNew) {
182 listener.onAfterCreate(phone);
183 }
184 else {
185 listener.onAfterUpdate(phone);
186 }
187 }
188
189 return phone;
190 }
191
192 public Phone updateImpl(com.liferay.portal.model.Phone phone, boolean merge)
193 throws SystemException {
194 Session session = null;
195
196 try {
197 session = openSession();
198
199 BatchSessionUtil.update(session, phone, merge);
200
201 phone.setNew(false);
202
203 return phone;
204 }
205 catch (Exception e) {
206 throw processException(e);
207 }
208 finally {
209 closeSession(session);
210
211 FinderCacheUtil.clearCache(Phone.class.getName());
212 }
213 }
214
215 public Phone findByPrimaryKey(long phoneId)
216 throws NoSuchPhoneException, SystemException {
217 Phone phone = fetchByPrimaryKey(phoneId);
218
219 if (phone == null) {
220 if (_log.isWarnEnabled()) {
221 _log.warn("No Phone exists with the primary key " + phoneId);
222 }
223
224 throw new NoSuchPhoneException(
225 "No Phone exists with the primary key " + phoneId);
226 }
227
228 return phone;
229 }
230
231 public Phone fetchByPrimaryKey(long phoneId) throws SystemException {
232 Session session = null;
233
234 try {
235 session = openSession();
236
237 return (Phone)session.get(PhoneImpl.class, new Long(phoneId));
238 }
239 catch (Exception e) {
240 throw processException(e);
241 }
242 finally {
243 closeSession(session);
244 }
245 }
246
247 public List<Phone> findByCompanyId(long companyId)
248 throws SystemException {
249 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
250 String finderClassName = Phone.class.getName();
251 String finderMethodName = "findByCompanyId";
252 String[] finderParams = new String[] { Long.class.getName() };
253 Object[] finderArgs = new Object[] { new Long(companyId) };
254
255 Object result = null;
256
257 if (finderClassNameCacheEnabled) {
258 result = FinderCacheUtil.getResult(finderClassName,
259 finderMethodName, finderParams, finderArgs, this);
260 }
261
262 if (result == null) {
263 Session session = null;
264
265 try {
266 session = openSession();
267
268 StringBuilder query = new StringBuilder();
269
270 query.append("FROM com.liferay.portal.model.Phone WHERE ");
271
272 query.append("companyId = ?");
273
274 query.append(" ");
275
276 query.append("ORDER BY ");
277
278 query.append("createDate ASC");
279
280 Query q = session.createQuery(query.toString());
281
282 QueryPos qPos = QueryPos.getInstance(q);
283
284 qPos.add(companyId);
285
286 List<Phone> list = q.list();
287
288 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
289 finderClassName, finderMethodName, finderParams,
290 finderArgs, list);
291
292 return list;
293 }
294 catch (Exception e) {
295 throw processException(e);
296 }
297 finally {
298 closeSession(session);
299 }
300 }
301 else {
302 return (List<Phone>)result;
303 }
304 }
305
306 public List<Phone> findByCompanyId(long companyId, int start, int end)
307 throws SystemException {
308 return findByCompanyId(companyId, start, end, null);
309 }
310
311 public List<Phone> findByCompanyId(long companyId, int start, int end,
312 OrderByComparator obc) throws SystemException {
313 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
314 String finderClassName = Phone.class.getName();
315 String finderMethodName = "findByCompanyId";
316 String[] finderParams = new String[] {
317 Long.class.getName(),
318
319 "java.lang.Integer", "java.lang.Integer",
320 "com.liferay.portal.kernel.util.OrderByComparator"
321 };
322 Object[] finderArgs = new Object[] {
323 new Long(companyId),
324
325 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
326 };
327
328 Object result = null;
329
330 if (finderClassNameCacheEnabled) {
331 result = FinderCacheUtil.getResult(finderClassName,
332 finderMethodName, finderParams, finderArgs, this);
333 }
334
335 if (result == null) {
336 Session session = null;
337
338 try {
339 session = openSession();
340
341 StringBuilder query = new StringBuilder();
342
343 query.append("FROM com.liferay.portal.model.Phone WHERE ");
344
345 query.append("companyId = ?");
346
347 query.append(" ");
348
349 if (obc != null) {
350 query.append("ORDER BY ");
351 query.append(obc.getOrderBy());
352 }
353
354 else {
355 query.append("ORDER BY ");
356
357 query.append("createDate ASC");
358 }
359
360 Query q = session.createQuery(query.toString());
361
362 QueryPos qPos = QueryPos.getInstance(q);
363
364 qPos.add(companyId);
365
366 List<Phone> list = (List<Phone>)QueryUtil.list(q, getDialect(),
367 start, end);
368
369 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
370 finderClassName, finderMethodName, finderParams,
371 finderArgs, list);
372
373 return list;
374 }
375 catch (Exception e) {
376 throw processException(e);
377 }
378 finally {
379 closeSession(session);
380 }
381 }
382 else {
383 return (List<Phone>)result;
384 }
385 }
386
387 public Phone findByCompanyId_First(long companyId, OrderByComparator obc)
388 throws NoSuchPhoneException, SystemException {
389 List<Phone> list = findByCompanyId(companyId, 0, 1, obc);
390
391 if (list.size() == 0) {
392 StringBuilder msg = new StringBuilder();
393
394 msg.append("No Phone exists with the key {");
395
396 msg.append("companyId=" + companyId);
397
398 msg.append(StringPool.CLOSE_CURLY_BRACE);
399
400 throw new NoSuchPhoneException(msg.toString());
401 }
402 else {
403 return list.get(0);
404 }
405 }
406
407 public Phone findByCompanyId_Last(long companyId, OrderByComparator obc)
408 throws NoSuchPhoneException, SystemException {
409 int count = countByCompanyId(companyId);
410
411 List<Phone> list = findByCompanyId(companyId, count - 1, count, obc);
412
413 if (list.size() == 0) {
414 StringBuilder msg = new StringBuilder();
415
416 msg.append("No Phone exists with the key {");
417
418 msg.append("companyId=" + companyId);
419
420 msg.append(StringPool.CLOSE_CURLY_BRACE);
421
422 throw new NoSuchPhoneException(msg.toString());
423 }
424 else {
425 return list.get(0);
426 }
427 }
428
429 public Phone[] findByCompanyId_PrevAndNext(long phoneId, long companyId,
430 OrderByComparator obc) throws NoSuchPhoneException, SystemException {
431 Phone phone = findByPrimaryKey(phoneId);
432
433 int count = countByCompanyId(companyId);
434
435 Session session = null;
436
437 try {
438 session = openSession();
439
440 StringBuilder query = new StringBuilder();
441
442 query.append("FROM com.liferay.portal.model.Phone WHERE ");
443
444 query.append("companyId = ?");
445
446 query.append(" ");
447
448 if (obc != null) {
449 query.append("ORDER BY ");
450 query.append(obc.getOrderBy());
451 }
452
453 else {
454 query.append("ORDER BY ");
455
456 query.append("createDate ASC");
457 }
458
459 Query q = session.createQuery(query.toString());
460
461 QueryPos qPos = QueryPos.getInstance(q);
462
463 qPos.add(companyId);
464
465 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
466
467 Phone[] array = new PhoneImpl[3];
468
469 array[0] = (Phone)objArray[0];
470 array[1] = (Phone)objArray[1];
471 array[2] = (Phone)objArray[2];
472
473 return array;
474 }
475 catch (Exception e) {
476 throw processException(e);
477 }
478 finally {
479 closeSession(session);
480 }
481 }
482
483 public List<Phone> findByUserId(long userId) throws SystemException {
484 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
485 String finderClassName = Phone.class.getName();
486 String finderMethodName = "findByUserId";
487 String[] finderParams = new String[] { Long.class.getName() };
488 Object[] finderArgs = new Object[] { new Long(userId) };
489
490 Object result = null;
491
492 if (finderClassNameCacheEnabled) {
493 result = FinderCacheUtil.getResult(finderClassName,
494 finderMethodName, finderParams, finderArgs, this);
495 }
496
497 if (result == null) {
498 Session session = null;
499
500 try {
501 session = openSession();
502
503 StringBuilder query = new StringBuilder();
504
505 query.append("FROM com.liferay.portal.model.Phone WHERE ");
506
507 query.append("userId = ?");
508
509 query.append(" ");
510
511 query.append("ORDER BY ");
512
513 query.append("createDate ASC");
514
515 Query q = session.createQuery(query.toString());
516
517 QueryPos qPos = QueryPos.getInstance(q);
518
519 qPos.add(userId);
520
521 List<Phone> list = q.list();
522
523 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
524 finderClassName, finderMethodName, finderParams,
525 finderArgs, list);
526
527 return list;
528 }
529 catch (Exception e) {
530 throw processException(e);
531 }
532 finally {
533 closeSession(session);
534 }
535 }
536 else {
537 return (List<Phone>)result;
538 }
539 }
540
541 public List<Phone> findByUserId(long userId, int start, int end)
542 throws SystemException {
543 return findByUserId(userId, start, end, null);
544 }
545
546 public List<Phone> findByUserId(long userId, int start, int end,
547 OrderByComparator obc) throws SystemException {
548 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
549 String finderClassName = Phone.class.getName();
550 String finderMethodName = "findByUserId";
551 String[] finderParams = new String[] {
552 Long.class.getName(),
553
554 "java.lang.Integer", "java.lang.Integer",
555 "com.liferay.portal.kernel.util.OrderByComparator"
556 };
557 Object[] finderArgs = new Object[] {
558 new Long(userId),
559
560 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
561 };
562
563 Object result = null;
564
565 if (finderClassNameCacheEnabled) {
566 result = FinderCacheUtil.getResult(finderClassName,
567 finderMethodName, finderParams, finderArgs, this);
568 }
569
570 if (result == null) {
571 Session session = null;
572
573 try {
574 session = openSession();
575
576 StringBuilder query = new StringBuilder();
577
578 query.append("FROM com.liferay.portal.model.Phone WHERE ");
579
580 query.append("userId = ?");
581
582 query.append(" ");
583
584 if (obc != null) {
585 query.append("ORDER BY ");
586 query.append(obc.getOrderBy());
587 }
588
589 else {
590 query.append("ORDER BY ");
591
592 query.append("createDate ASC");
593 }
594
595 Query q = session.createQuery(query.toString());
596
597 QueryPos qPos = QueryPos.getInstance(q);
598
599 qPos.add(userId);
600
601 List<Phone> list = (List<Phone>)QueryUtil.list(q, getDialect(),
602 start, end);
603
604 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
605 finderClassName, finderMethodName, finderParams,
606 finderArgs, list);
607
608 return list;
609 }
610 catch (Exception e) {
611 throw processException(e);
612 }
613 finally {
614 closeSession(session);
615 }
616 }
617 else {
618 return (List<Phone>)result;
619 }
620 }
621
622 public Phone findByUserId_First(long userId, OrderByComparator obc)
623 throws NoSuchPhoneException, SystemException {
624 List<Phone> list = findByUserId(userId, 0, 1, obc);
625
626 if (list.size() == 0) {
627 StringBuilder msg = new StringBuilder();
628
629 msg.append("No Phone exists with the key {");
630
631 msg.append("userId=" + userId);
632
633 msg.append(StringPool.CLOSE_CURLY_BRACE);
634
635 throw new NoSuchPhoneException(msg.toString());
636 }
637 else {
638 return list.get(0);
639 }
640 }
641
642 public Phone findByUserId_Last(long userId, OrderByComparator obc)
643 throws NoSuchPhoneException, SystemException {
644 int count = countByUserId(userId);
645
646 List<Phone> list = findByUserId(userId, count - 1, count, obc);
647
648 if (list.size() == 0) {
649 StringBuilder msg = new StringBuilder();
650
651 msg.append("No Phone exists with the key {");
652
653 msg.append("userId=" + userId);
654
655 msg.append(StringPool.CLOSE_CURLY_BRACE);
656
657 throw new NoSuchPhoneException(msg.toString());
658 }
659 else {
660 return list.get(0);
661 }
662 }
663
664 public Phone[] findByUserId_PrevAndNext(long phoneId, long userId,
665 OrderByComparator obc) throws NoSuchPhoneException, SystemException {
666 Phone phone = findByPrimaryKey(phoneId);
667
668 int count = countByUserId(userId);
669
670 Session session = null;
671
672 try {
673 session = openSession();
674
675 StringBuilder query = new StringBuilder();
676
677 query.append("FROM com.liferay.portal.model.Phone WHERE ");
678
679 query.append("userId = ?");
680
681 query.append(" ");
682
683 if (obc != null) {
684 query.append("ORDER BY ");
685 query.append(obc.getOrderBy());
686 }
687
688 else {
689 query.append("ORDER BY ");
690
691 query.append("createDate ASC");
692 }
693
694 Query q = session.createQuery(query.toString());
695
696 QueryPos qPos = QueryPos.getInstance(q);
697
698 qPos.add(userId);
699
700 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
701
702 Phone[] array = new PhoneImpl[3];
703
704 array[0] = (Phone)objArray[0];
705 array[1] = (Phone)objArray[1];
706 array[2] = (Phone)objArray[2];
707
708 return array;
709 }
710 catch (Exception e) {
711 throw processException(e);
712 }
713 finally {
714 closeSession(session);
715 }
716 }
717
718 public List<Phone> findByC_C(long companyId, long classNameId)
719 throws SystemException {
720 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
721 String finderClassName = Phone.class.getName();
722 String finderMethodName = "findByC_C";
723 String[] finderParams = new String[] {
724 Long.class.getName(), Long.class.getName()
725 };
726 Object[] finderArgs = new Object[] {
727 new Long(companyId), new Long(classNameId)
728 };
729
730 Object result = null;
731
732 if (finderClassNameCacheEnabled) {
733 result = FinderCacheUtil.getResult(finderClassName,
734 finderMethodName, finderParams, finderArgs, this);
735 }
736
737 if (result == null) {
738 Session session = null;
739
740 try {
741 session = openSession();
742
743 StringBuilder query = new StringBuilder();
744
745 query.append("FROM com.liferay.portal.model.Phone WHERE ");
746
747 query.append("companyId = ?");
748
749 query.append(" AND ");
750
751 query.append("classNameId = ?");
752
753 query.append(" ");
754
755 query.append("ORDER BY ");
756
757 query.append("createDate ASC");
758
759 Query q = session.createQuery(query.toString());
760
761 QueryPos qPos = QueryPos.getInstance(q);
762
763 qPos.add(companyId);
764
765 qPos.add(classNameId);
766
767 List<Phone> list = q.list();
768
769 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
770 finderClassName, finderMethodName, finderParams,
771 finderArgs, list);
772
773 return list;
774 }
775 catch (Exception e) {
776 throw processException(e);
777 }
778 finally {
779 closeSession(session);
780 }
781 }
782 else {
783 return (List<Phone>)result;
784 }
785 }
786
787 public List<Phone> findByC_C(long companyId, long classNameId, int start,
788 int end) throws SystemException {
789 return findByC_C(companyId, classNameId, start, end, null);
790 }
791
792 public List<Phone> findByC_C(long companyId, long classNameId, int start,
793 int end, OrderByComparator obc) throws SystemException {
794 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
795 String finderClassName = Phone.class.getName();
796 String finderMethodName = "findByC_C";
797 String[] finderParams = new String[] {
798 Long.class.getName(), Long.class.getName(),
799
800 "java.lang.Integer", "java.lang.Integer",
801 "com.liferay.portal.kernel.util.OrderByComparator"
802 };
803 Object[] finderArgs = new Object[] {
804 new Long(companyId), new Long(classNameId),
805
806 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
807 };
808
809 Object result = null;
810
811 if (finderClassNameCacheEnabled) {
812 result = FinderCacheUtil.getResult(finderClassName,
813 finderMethodName, finderParams, finderArgs, this);
814 }
815
816 if (result == null) {
817 Session session = null;
818
819 try {
820 session = openSession();
821
822 StringBuilder query = new StringBuilder();
823
824 query.append("FROM com.liferay.portal.model.Phone WHERE ");
825
826 query.append("companyId = ?");
827
828 query.append(" AND ");
829
830 query.append("classNameId = ?");
831
832 query.append(" ");
833
834 if (obc != null) {
835 query.append("ORDER BY ");
836 query.append(obc.getOrderBy());
837 }
838
839 else {
840 query.append("ORDER BY ");
841
842 query.append("createDate ASC");
843 }
844
845 Query q = session.createQuery(query.toString());
846
847 QueryPos qPos = QueryPos.getInstance(q);
848
849 qPos.add(companyId);
850
851 qPos.add(classNameId);
852
853 List<Phone> list = (List<Phone>)QueryUtil.list(q, getDialect(),
854 start, end);
855
856 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
857 finderClassName, finderMethodName, finderParams,
858 finderArgs, list);
859
860 return list;
861 }
862 catch (Exception e) {
863 throw processException(e);
864 }
865 finally {
866 closeSession(session);
867 }
868 }
869 else {
870 return (List<Phone>)result;
871 }
872 }
873
874 public Phone findByC_C_First(long companyId, long classNameId,
875 OrderByComparator obc) throws NoSuchPhoneException, SystemException {
876 List<Phone> list = findByC_C(companyId, classNameId, 0, 1, obc);
877
878 if (list.size() == 0) {
879 StringBuilder msg = new StringBuilder();
880
881 msg.append("No Phone exists with the key {");
882
883 msg.append("companyId=" + companyId);
884
885 msg.append(", ");
886 msg.append("classNameId=" + classNameId);
887
888 msg.append(StringPool.CLOSE_CURLY_BRACE);
889
890 throw new NoSuchPhoneException(msg.toString());
891 }
892 else {
893 return list.get(0);
894 }
895 }
896
897 public Phone findByC_C_Last(long companyId, long classNameId,
898 OrderByComparator obc) throws NoSuchPhoneException, SystemException {
899 int count = countByC_C(companyId, classNameId);
900
901 List<Phone> list = findByC_C(companyId, classNameId, count - 1, count,
902 obc);
903
904 if (list.size() == 0) {
905 StringBuilder msg = new StringBuilder();
906
907 msg.append("No Phone exists with the key {");
908
909 msg.append("companyId=" + companyId);
910
911 msg.append(", ");
912 msg.append("classNameId=" + classNameId);
913
914 msg.append(StringPool.CLOSE_CURLY_BRACE);
915
916 throw new NoSuchPhoneException(msg.toString());
917 }
918 else {
919 return list.get(0);
920 }
921 }
922
923 public Phone[] findByC_C_PrevAndNext(long phoneId, long companyId,
924 long classNameId, OrderByComparator obc)
925 throws NoSuchPhoneException, SystemException {
926 Phone phone = findByPrimaryKey(phoneId);
927
928 int count = countByC_C(companyId, classNameId);
929
930 Session session = null;
931
932 try {
933 session = openSession();
934
935 StringBuilder query = new StringBuilder();
936
937 query.append("FROM com.liferay.portal.model.Phone WHERE ");
938
939 query.append("companyId = ?");
940
941 query.append(" AND ");
942
943 query.append("classNameId = ?");
944
945 query.append(" ");
946
947 if (obc != null) {
948 query.append("ORDER BY ");
949 query.append(obc.getOrderBy());
950 }
951
952 else {
953 query.append("ORDER BY ");
954
955 query.append("createDate ASC");
956 }
957
958 Query q = session.createQuery(query.toString());
959
960 QueryPos qPos = QueryPos.getInstance(q);
961
962 qPos.add(companyId);
963
964 qPos.add(classNameId);
965
966 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
967
968 Phone[] array = new PhoneImpl[3];
969
970 array[0] = (Phone)objArray[0];
971 array[1] = (Phone)objArray[1];
972 array[2] = (Phone)objArray[2];
973
974 return array;
975 }
976 catch (Exception e) {
977 throw processException(e);
978 }
979 finally {
980 closeSession(session);
981 }
982 }
983
984 public List<Phone> findByC_C_C(long companyId, long classNameId,
985 long classPK) throws SystemException {
986 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
987 String finderClassName = Phone.class.getName();
988 String finderMethodName = "findByC_C_C";
989 String[] finderParams = new String[] {
990 Long.class.getName(), Long.class.getName(), Long.class.getName()
991 };
992 Object[] finderArgs = new Object[] {
993 new Long(companyId), new Long(classNameId), new Long(classPK)
994 };
995
996 Object result = null;
997
998 if (finderClassNameCacheEnabled) {
999 result = FinderCacheUtil.getResult(finderClassName,
1000 finderMethodName, finderParams, finderArgs, this);
1001 }
1002
1003 if (result == null) {
1004 Session session = null;
1005
1006 try {
1007 session = openSession();
1008
1009 StringBuilder query = new StringBuilder();
1010
1011 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1012
1013 query.append("companyId = ?");
1014
1015 query.append(" AND ");
1016
1017 query.append("classNameId = ?");
1018
1019 query.append(" AND ");
1020
1021 query.append("classPK = ?");
1022
1023 query.append(" ");
1024
1025 query.append("ORDER BY ");
1026
1027 query.append("createDate ASC");
1028
1029 Query q = session.createQuery(query.toString());
1030
1031 QueryPos qPos = QueryPos.getInstance(q);
1032
1033 qPos.add(companyId);
1034
1035 qPos.add(classNameId);
1036
1037 qPos.add(classPK);
1038
1039 List<Phone> list = q.list();
1040
1041 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1042 finderClassName, finderMethodName, finderParams,
1043 finderArgs, list);
1044
1045 return list;
1046 }
1047 catch (Exception e) {
1048 throw processException(e);
1049 }
1050 finally {
1051 closeSession(session);
1052 }
1053 }
1054 else {
1055 return (List<Phone>)result;
1056 }
1057 }
1058
1059 public List<Phone> findByC_C_C(long companyId, long classNameId,
1060 long classPK, int start, int end) throws SystemException {
1061 return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1062 }
1063
1064 public List<Phone> findByC_C_C(long companyId, long classNameId,
1065 long classPK, int start, int end, OrderByComparator obc)
1066 throws SystemException {
1067 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
1068 String finderClassName = Phone.class.getName();
1069 String finderMethodName = "findByC_C_C";
1070 String[] finderParams = new String[] {
1071 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1072
1073 "java.lang.Integer", "java.lang.Integer",
1074 "com.liferay.portal.kernel.util.OrderByComparator"
1075 };
1076 Object[] finderArgs = new Object[] {
1077 new Long(companyId), new Long(classNameId), new Long(classPK),
1078
1079 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1080 };
1081
1082 Object result = null;
1083
1084 if (finderClassNameCacheEnabled) {
1085 result = FinderCacheUtil.getResult(finderClassName,
1086 finderMethodName, finderParams, finderArgs, this);
1087 }
1088
1089 if (result == null) {
1090 Session session = null;
1091
1092 try {
1093 session = openSession();
1094
1095 StringBuilder query = new StringBuilder();
1096
1097 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1098
1099 query.append("companyId = ?");
1100
1101 query.append(" AND ");
1102
1103 query.append("classNameId = ?");
1104
1105 query.append(" AND ");
1106
1107 query.append("classPK = ?");
1108
1109 query.append(" ");
1110
1111 if (obc != null) {
1112 query.append("ORDER BY ");
1113 query.append(obc.getOrderBy());
1114 }
1115
1116 else {
1117 query.append("ORDER BY ");
1118
1119 query.append("createDate ASC");
1120 }
1121
1122 Query q = session.createQuery(query.toString());
1123
1124 QueryPos qPos = QueryPos.getInstance(q);
1125
1126 qPos.add(companyId);
1127
1128 qPos.add(classNameId);
1129
1130 qPos.add(classPK);
1131
1132 List<Phone> list = (List<Phone>)QueryUtil.list(q, getDialect(),
1133 start, end);
1134
1135 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1136 finderClassName, finderMethodName, finderParams,
1137 finderArgs, list);
1138
1139 return list;
1140 }
1141 catch (Exception e) {
1142 throw processException(e);
1143 }
1144 finally {
1145 closeSession(session);
1146 }
1147 }
1148 else {
1149 return (List<Phone>)result;
1150 }
1151 }
1152
1153 public Phone findByC_C_C_First(long companyId, long classNameId,
1154 long classPK, OrderByComparator obc)
1155 throws NoSuchPhoneException, SystemException {
1156 List<Phone> list = findByC_C_C(companyId, classNameId, classPK, 0, 1,
1157 obc);
1158
1159 if (list.size() == 0) {
1160 StringBuilder msg = new StringBuilder();
1161
1162 msg.append("No Phone exists with the key {");
1163
1164 msg.append("companyId=" + companyId);
1165
1166 msg.append(", ");
1167 msg.append("classNameId=" + classNameId);
1168
1169 msg.append(", ");
1170 msg.append("classPK=" + classPK);
1171
1172 msg.append(StringPool.CLOSE_CURLY_BRACE);
1173
1174 throw new NoSuchPhoneException(msg.toString());
1175 }
1176 else {
1177 return list.get(0);
1178 }
1179 }
1180
1181 public Phone findByC_C_C_Last(long companyId, long classNameId,
1182 long classPK, OrderByComparator obc)
1183 throws NoSuchPhoneException, SystemException {
1184 int count = countByC_C_C(companyId, classNameId, classPK);
1185
1186 List<Phone> list = findByC_C_C(companyId, classNameId, classPK,
1187 count - 1, count, obc);
1188
1189 if (list.size() == 0) {
1190 StringBuilder msg = new StringBuilder();
1191
1192 msg.append("No Phone exists with the key {");
1193
1194 msg.append("companyId=" + companyId);
1195
1196 msg.append(", ");
1197 msg.append("classNameId=" + classNameId);
1198
1199 msg.append(", ");
1200 msg.append("classPK=" + classPK);
1201
1202 msg.append(StringPool.CLOSE_CURLY_BRACE);
1203
1204 throw new NoSuchPhoneException(msg.toString());
1205 }
1206 else {
1207 return list.get(0);
1208 }
1209 }
1210
1211 public Phone[] findByC_C_C_PrevAndNext(long phoneId, long companyId,
1212 long classNameId, long classPK, OrderByComparator obc)
1213 throws NoSuchPhoneException, SystemException {
1214 Phone phone = findByPrimaryKey(phoneId);
1215
1216 int count = countByC_C_C(companyId, classNameId, classPK);
1217
1218 Session session = null;
1219
1220 try {
1221 session = openSession();
1222
1223 StringBuilder query = new StringBuilder();
1224
1225 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1226
1227 query.append("companyId = ?");
1228
1229 query.append(" AND ");
1230
1231 query.append("classNameId = ?");
1232
1233 query.append(" AND ");
1234
1235 query.append("classPK = ?");
1236
1237 query.append(" ");
1238
1239 if (obc != null) {
1240 query.append("ORDER BY ");
1241 query.append(obc.getOrderBy());
1242 }
1243
1244 else {
1245 query.append("ORDER BY ");
1246
1247 query.append("createDate ASC");
1248 }
1249
1250 Query q = session.createQuery(query.toString());
1251
1252 QueryPos qPos = QueryPos.getInstance(q);
1253
1254 qPos.add(companyId);
1255
1256 qPos.add(classNameId);
1257
1258 qPos.add(classPK);
1259
1260 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
1261
1262 Phone[] array = new PhoneImpl[3];
1263
1264 array[0] = (Phone)objArray[0];
1265 array[1] = (Phone)objArray[1];
1266 array[2] = (Phone)objArray[2];
1267
1268 return array;
1269 }
1270 catch (Exception e) {
1271 throw processException(e);
1272 }
1273 finally {
1274 closeSession(session);
1275 }
1276 }
1277
1278 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
1279 long classPK, boolean primary) throws SystemException {
1280 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
1281 String finderClassName = Phone.class.getName();
1282 String finderMethodName = "findByC_C_C_P";
1283 String[] finderParams = new String[] {
1284 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1285 Boolean.class.getName()
1286 };
1287 Object[] finderArgs = new Object[] {
1288 new Long(companyId), new Long(classNameId), new Long(classPK),
1289 Boolean.valueOf(primary)
1290 };
1291
1292 Object result = null;
1293
1294 if (finderClassNameCacheEnabled) {
1295 result = FinderCacheUtil.getResult(finderClassName,
1296 finderMethodName, finderParams, finderArgs, this);
1297 }
1298
1299 if (result == null) {
1300 Session session = null;
1301
1302 try {
1303 session = openSession();
1304
1305 StringBuilder query = new StringBuilder();
1306
1307 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1308
1309 query.append("companyId = ?");
1310
1311 query.append(" AND ");
1312
1313 query.append("classNameId = ?");
1314
1315 query.append(" AND ");
1316
1317 query.append("classPK = ?");
1318
1319 query.append(" AND ");
1320
1321 query.append("primary_ = ?");
1322
1323 query.append(" ");
1324
1325 query.append("ORDER BY ");
1326
1327 query.append("createDate ASC");
1328
1329 Query q = session.createQuery(query.toString());
1330
1331 QueryPos qPos = QueryPos.getInstance(q);
1332
1333 qPos.add(companyId);
1334
1335 qPos.add(classNameId);
1336
1337 qPos.add(classPK);
1338
1339 qPos.add(primary);
1340
1341 List<Phone> list = q.list();
1342
1343 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1344 finderClassName, finderMethodName, finderParams,
1345 finderArgs, list);
1346
1347 return list;
1348 }
1349 catch (Exception e) {
1350 throw processException(e);
1351 }
1352 finally {
1353 closeSession(session);
1354 }
1355 }
1356 else {
1357 return (List<Phone>)result;
1358 }
1359 }
1360
1361 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
1362 long classPK, boolean primary, int start, int end)
1363 throws SystemException {
1364 return findByC_C_C_P(companyId, classNameId, classPK, primary, start,
1365 end, null);
1366 }
1367
1368 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
1369 long classPK, boolean primary, int start, int end, OrderByComparator obc)
1370 throws SystemException {
1371 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
1372 String finderClassName = Phone.class.getName();
1373 String finderMethodName = "findByC_C_C_P";
1374 String[] finderParams = new String[] {
1375 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1376 Boolean.class.getName(),
1377
1378 "java.lang.Integer", "java.lang.Integer",
1379 "com.liferay.portal.kernel.util.OrderByComparator"
1380 };
1381 Object[] finderArgs = new Object[] {
1382 new Long(companyId), new Long(classNameId), new Long(classPK),
1383 Boolean.valueOf(primary),
1384
1385 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1386 };
1387
1388 Object result = null;
1389
1390 if (finderClassNameCacheEnabled) {
1391 result = FinderCacheUtil.getResult(finderClassName,
1392 finderMethodName, finderParams, finderArgs, this);
1393 }
1394
1395 if (result == null) {
1396 Session session = null;
1397
1398 try {
1399 session = openSession();
1400
1401 StringBuilder query = new StringBuilder();
1402
1403 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1404
1405 query.append("companyId = ?");
1406
1407 query.append(" AND ");
1408
1409 query.append("classNameId = ?");
1410
1411 query.append(" AND ");
1412
1413 query.append("classPK = ?");
1414
1415 query.append(" AND ");
1416
1417 query.append("primary_ = ?");
1418
1419 query.append(" ");
1420
1421 if (obc != null) {
1422 query.append("ORDER BY ");
1423 query.append(obc.getOrderBy());
1424 }
1425
1426 else {
1427 query.append("ORDER BY ");
1428
1429 query.append("createDate ASC");
1430 }
1431
1432 Query q = session.createQuery(query.toString());
1433
1434 QueryPos qPos = QueryPos.getInstance(q);
1435
1436 qPos.add(companyId);
1437
1438 qPos.add(classNameId);
1439
1440 qPos.add(classPK);
1441
1442 qPos.add(primary);
1443
1444 List<Phone> list = (List<Phone>)QueryUtil.list(q, getDialect(),
1445 start, end);
1446
1447 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1448 finderClassName, finderMethodName, finderParams,
1449 finderArgs, list);
1450
1451 return list;
1452 }
1453 catch (Exception e) {
1454 throw processException(e);
1455 }
1456 finally {
1457 closeSession(session);
1458 }
1459 }
1460 else {
1461 return (List<Phone>)result;
1462 }
1463 }
1464
1465 public Phone findByC_C_C_P_First(long companyId, long classNameId,
1466 long classPK, boolean primary, OrderByComparator obc)
1467 throws NoSuchPhoneException, SystemException {
1468 List<Phone> list = findByC_C_C_P(companyId, classNameId, classPK,
1469 primary, 0, 1, obc);
1470
1471 if (list.size() == 0) {
1472 StringBuilder msg = new StringBuilder();
1473
1474 msg.append("No Phone exists with the key {");
1475
1476 msg.append("companyId=" + companyId);
1477
1478 msg.append(", ");
1479 msg.append("classNameId=" + classNameId);
1480
1481 msg.append(", ");
1482 msg.append("classPK=" + classPK);
1483
1484 msg.append(", ");
1485 msg.append("primary=" + primary);
1486
1487 msg.append(StringPool.CLOSE_CURLY_BRACE);
1488
1489 throw new NoSuchPhoneException(msg.toString());
1490 }
1491 else {
1492 return list.get(0);
1493 }
1494 }
1495
1496 public Phone findByC_C_C_P_Last(long companyId, long classNameId,
1497 long classPK, boolean primary, OrderByComparator obc)
1498 throws NoSuchPhoneException, SystemException {
1499 int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
1500
1501 List<Phone> list = findByC_C_C_P(companyId, classNameId, classPK,
1502 primary, count - 1, count, obc);
1503
1504 if (list.size() == 0) {
1505 StringBuilder msg = new StringBuilder();
1506
1507 msg.append("No Phone exists with the key {");
1508
1509 msg.append("companyId=" + companyId);
1510
1511 msg.append(", ");
1512 msg.append("classNameId=" + classNameId);
1513
1514 msg.append(", ");
1515 msg.append("classPK=" + classPK);
1516
1517 msg.append(", ");
1518 msg.append("primary=" + primary);
1519
1520 msg.append(StringPool.CLOSE_CURLY_BRACE);
1521
1522 throw new NoSuchPhoneException(msg.toString());
1523 }
1524 else {
1525 return list.get(0);
1526 }
1527 }
1528
1529 public Phone[] findByC_C_C_P_PrevAndNext(long phoneId, long companyId,
1530 long classNameId, long classPK, boolean primary, OrderByComparator obc)
1531 throws NoSuchPhoneException, SystemException {
1532 Phone phone = findByPrimaryKey(phoneId);
1533
1534 int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
1535
1536 Session session = null;
1537
1538 try {
1539 session = openSession();
1540
1541 StringBuilder query = new StringBuilder();
1542
1543 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1544
1545 query.append("companyId = ?");
1546
1547 query.append(" AND ");
1548
1549 query.append("classNameId = ?");
1550
1551 query.append(" AND ");
1552
1553 query.append("classPK = ?");
1554
1555 query.append(" AND ");
1556
1557 query.append("primary_ = ?");
1558
1559 query.append(" ");
1560
1561 if (obc != null) {
1562 query.append("ORDER BY ");
1563 query.append(obc.getOrderBy());
1564 }
1565
1566 else {
1567 query.append("ORDER BY ");
1568
1569 query.append("createDate ASC");
1570 }
1571
1572 Query q = session.createQuery(query.toString());
1573
1574 QueryPos qPos = QueryPos.getInstance(q);
1575
1576 qPos.add(companyId);
1577
1578 qPos.add(classNameId);
1579
1580 qPos.add(classPK);
1581
1582 qPos.add(primary);
1583
1584 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
1585
1586 Phone[] array = new PhoneImpl[3];
1587
1588 array[0] = (Phone)objArray[0];
1589 array[1] = (Phone)objArray[1];
1590 array[2] = (Phone)objArray[2];
1591
1592 return array;
1593 }
1594 catch (Exception e) {
1595 throw processException(e);
1596 }
1597 finally {
1598 closeSession(session);
1599 }
1600 }
1601
1602 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1603 throws SystemException {
1604 Session session = null;
1605
1606 try {
1607 session = openSession();
1608
1609 dynamicQuery.compile(session);
1610
1611 return dynamicQuery.list();
1612 }
1613 catch (Exception e) {
1614 throw processException(e);
1615 }
1616 finally {
1617 closeSession(session);
1618 }
1619 }
1620
1621 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1622 int start, int end) throws SystemException {
1623 Session session = null;
1624
1625 try {
1626 session = openSession();
1627
1628 dynamicQuery.setLimit(start, end);
1629
1630 dynamicQuery.compile(session);
1631
1632 return dynamicQuery.list();
1633 }
1634 catch (Exception e) {
1635 throw processException(e);
1636 }
1637 finally {
1638 closeSession(session);
1639 }
1640 }
1641
1642 public List<Phone> findAll() throws SystemException {
1643 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1644 }
1645
1646 public List<Phone> findAll(int start, int end) throws SystemException {
1647 return findAll(start, end, null);
1648 }
1649
1650 public List<Phone> findAll(int start, int end, OrderByComparator obc)
1651 throws SystemException {
1652 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
1653 String finderClassName = Phone.class.getName();
1654 String finderMethodName = "findAll";
1655 String[] finderParams = new String[] {
1656 "java.lang.Integer", "java.lang.Integer",
1657 "com.liferay.portal.kernel.util.OrderByComparator"
1658 };
1659 Object[] finderArgs = new Object[] {
1660 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1661 };
1662
1663 Object result = null;
1664
1665 if (finderClassNameCacheEnabled) {
1666 result = FinderCacheUtil.getResult(finderClassName,
1667 finderMethodName, finderParams, finderArgs, this);
1668 }
1669
1670 if (result == null) {
1671 Session session = null;
1672
1673 try {
1674 session = openSession();
1675
1676 StringBuilder query = new StringBuilder();
1677
1678 query.append("FROM com.liferay.portal.model.Phone ");
1679
1680 if (obc != null) {
1681 query.append("ORDER BY ");
1682 query.append(obc.getOrderBy());
1683 }
1684
1685 else {
1686 query.append("ORDER BY ");
1687
1688 query.append("createDate ASC");
1689 }
1690
1691 Query q = session.createQuery(query.toString());
1692
1693 List<Phone> list = null;
1694
1695 if (obc == null) {
1696 list = (List<Phone>)QueryUtil.list(q, getDialect(), start,
1697 end, false);
1698
1699 Collections.sort(list);
1700 }
1701 else {
1702 list = (List<Phone>)QueryUtil.list(q, getDialect(), start,
1703 end);
1704 }
1705
1706 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1707 finderClassName, finderMethodName, finderParams,
1708 finderArgs, list);
1709
1710 return list;
1711 }
1712 catch (Exception e) {
1713 throw processException(e);
1714 }
1715 finally {
1716 closeSession(session);
1717 }
1718 }
1719 else {
1720 return (List<Phone>)result;
1721 }
1722 }
1723
1724 public void removeByCompanyId(long companyId) throws SystemException {
1725 for (Phone phone : findByCompanyId(companyId)) {
1726 remove(phone);
1727 }
1728 }
1729
1730 public void removeByUserId(long userId) throws SystemException {
1731 for (Phone phone : findByUserId(userId)) {
1732 remove(phone);
1733 }
1734 }
1735
1736 public void removeByC_C(long companyId, long classNameId)
1737 throws SystemException {
1738 for (Phone phone : findByC_C(companyId, classNameId)) {
1739 remove(phone);
1740 }
1741 }
1742
1743 public void removeByC_C_C(long companyId, long classNameId, long classPK)
1744 throws SystemException {
1745 for (Phone phone : findByC_C_C(companyId, classNameId, classPK)) {
1746 remove(phone);
1747 }
1748 }
1749
1750 public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
1751 boolean primary) throws SystemException {
1752 for (Phone phone : findByC_C_C_P(companyId, classNameId, classPK,
1753 primary)) {
1754 remove(phone);
1755 }
1756 }
1757
1758 public void removeAll() throws SystemException {
1759 for (Phone phone : findAll()) {
1760 remove(phone);
1761 }
1762 }
1763
1764 public int countByCompanyId(long companyId) throws SystemException {
1765 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
1766 String finderClassName = Phone.class.getName();
1767 String finderMethodName = "countByCompanyId";
1768 String[] finderParams = new String[] { Long.class.getName() };
1769 Object[] finderArgs = new Object[] { new Long(companyId) };
1770
1771 Object result = null;
1772
1773 if (finderClassNameCacheEnabled) {
1774 result = FinderCacheUtil.getResult(finderClassName,
1775 finderMethodName, finderParams, finderArgs, this);
1776 }
1777
1778 if (result == null) {
1779 Session session = null;
1780
1781 try {
1782 session = openSession();
1783
1784 StringBuilder query = new StringBuilder();
1785
1786 query.append("SELECT COUNT(*) ");
1787 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1788
1789 query.append("companyId = ?");
1790
1791 query.append(" ");
1792
1793 Query q = session.createQuery(query.toString());
1794
1795 QueryPos qPos = QueryPos.getInstance(q);
1796
1797 qPos.add(companyId);
1798
1799 Long count = null;
1800
1801 Iterator<Long> itr = q.list().iterator();
1802
1803 if (itr.hasNext()) {
1804 count = itr.next();
1805 }
1806
1807 if (count == null) {
1808 count = new Long(0);
1809 }
1810
1811 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1812 finderClassName, finderMethodName, finderParams,
1813 finderArgs, count);
1814
1815 return count.intValue();
1816 }
1817 catch (Exception e) {
1818 throw processException(e);
1819 }
1820 finally {
1821 closeSession(session);
1822 }
1823 }
1824 else {
1825 return ((Long)result).intValue();
1826 }
1827 }
1828
1829 public int countByUserId(long userId) throws SystemException {
1830 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
1831 String finderClassName = Phone.class.getName();
1832 String finderMethodName = "countByUserId";
1833 String[] finderParams = new String[] { Long.class.getName() };
1834 Object[] finderArgs = new Object[] { new Long(userId) };
1835
1836 Object result = null;
1837
1838 if (finderClassNameCacheEnabled) {
1839 result = FinderCacheUtil.getResult(finderClassName,
1840 finderMethodName, finderParams, finderArgs, this);
1841 }
1842
1843 if (result == null) {
1844 Session session = null;
1845
1846 try {
1847 session = openSession();
1848
1849 StringBuilder query = new StringBuilder();
1850
1851 query.append("SELECT COUNT(*) ");
1852 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1853
1854 query.append("userId = ?");
1855
1856 query.append(" ");
1857
1858 Query q = session.createQuery(query.toString());
1859
1860 QueryPos qPos = QueryPos.getInstance(q);
1861
1862 qPos.add(userId);
1863
1864 Long count = null;
1865
1866 Iterator<Long> itr = q.list().iterator();
1867
1868 if (itr.hasNext()) {
1869 count = itr.next();
1870 }
1871
1872 if (count == null) {
1873 count = new Long(0);
1874 }
1875
1876 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1877 finderClassName, finderMethodName, finderParams,
1878 finderArgs, count);
1879
1880 return count.intValue();
1881 }
1882 catch (Exception e) {
1883 throw processException(e);
1884 }
1885 finally {
1886 closeSession(session);
1887 }
1888 }
1889 else {
1890 return ((Long)result).intValue();
1891 }
1892 }
1893
1894 public int countByC_C(long companyId, long classNameId)
1895 throws SystemException {
1896 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
1897 String finderClassName = Phone.class.getName();
1898 String finderMethodName = "countByC_C";
1899 String[] finderParams = new String[] {
1900 Long.class.getName(), Long.class.getName()
1901 };
1902 Object[] finderArgs = new Object[] {
1903 new Long(companyId), new Long(classNameId)
1904 };
1905
1906 Object result = null;
1907
1908 if (finderClassNameCacheEnabled) {
1909 result = FinderCacheUtil.getResult(finderClassName,
1910 finderMethodName, finderParams, finderArgs, this);
1911 }
1912
1913 if (result == null) {
1914 Session session = null;
1915
1916 try {
1917 session = openSession();
1918
1919 StringBuilder query = new StringBuilder();
1920
1921 query.append("SELECT COUNT(*) ");
1922 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1923
1924 query.append("companyId = ?");
1925
1926 query.append(" AND ");
1927
1928 query.append("classNameId = ?");
1929
1930 query.append(" ");
1931
1932 Query q = session.createQuery(query.toString());
1933
1934 QueryPos qPos = QueryPos.getInstance(q);
1935
1936 qPos.add(companyId);
1937
1938 qPos.add(classNameId);
1939
1940 Long count = null;
1941
1942 Iterator<Long> itr = q.list().iterator();
1943
1944 if (itr.hasNext()) {
1945 count = itr.next();
1946 }
1947
1948 if (count == null) {
1949 count = new Long(0);
1950 }
1951
1952 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1953 finderClassName, finderMethodName, finderParams,
1954 finderArgs, count);
1955
1956 return count.intValue();
1957 }
1958 catch (Exception e) {
1959 throw processException(e);
1960 }
1961 finally {
1962 closeSession(session);
1963 }
1964 }
1965 else {
1966 return ((Long)result).intValue();
1967 }
1968 }
1969
1970 public int countByC_C_C(long companyId, long classNameId, long classPK)
1971 throws SystemException {
1972 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
1973 String finderClassName = Phone.class.getName();
1974 String finderMethodName = "countByC_C_C";
1975 String[] finderParams = new String[] {
1976 Long.class.getName(), Long.class.getName(), Long.class.getName()
1977 };
1978 Object[] finderArgs = new Object[] {
1979 new Long(companyId), new Long(classNameId), new Long(classPK)
1980 };
1981
1982 Object result = null;
1983
1984 if (finderClassNameCacheEnabled) {
1985 result = FinderCacheUtil.getResult(finderClassName,
1986 finderMethodName, finderParams, finderArgs, this);
1987 }
1988
1989 if (result == null) {
1990 Session session = null;
1991
1992 try {
1993 session = openSession();
1994
1995 StringBuilder query = new StringBuilder();
1996
1997 query.append("SELECT COUNT(*) ");
1998 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1999
2000 query.append("companyId = ?");
2001
2002 query.append(" AND ");
2003
2004 query.append("classNameId = ?");
2005
2006 query.append(" AND ");
2007
2008 query.append("classPK = ?");
2009
2010 query.append(" ");
2011
2012 Query q = session.createQuery(query.toString());
2013
2014 QueryPos qPos = QueryPos.getInstance(q);
2015
2016 qPos.add(companyId);
2017
2018 qPos.add(classNameId);
2019
2020 qPos.add(classPK);
2021
2022 Long count = null;
2023
2024 Iterator<Long> itr = q.list().iterator();
2025
2026 if (itr.hasNext()) {
2027 count = itr.next();
2028 }
2029
2030 if (count == null) {
2031 count = new Long(0);
2032 }
2033
2034 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2035 finderClassName, finderMethodName, finderParams,
2036 finderArgs, count);
2037
2038 return count.intValue();
2039 }
2040 catch (Exception e) {
2041 throw processException(e);
2042 }
2043 finally {
2044 closeSession(session);
2045 }
2046 }
2047 else {
2048 return ((Long)result).intValue();
2049 }
2050 }
2051
2052 public int countByC_C_C_P(long companyId, long classNameId, long classPK,
2053 boolean primary) throws SystemException {
2054 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
2055 String finderClassName = Phone.class.getName();
2056 String finderMethodName = "countByC_C_C_P";
2057 String[] finderParams = new String[] {
2058 Long.class.getName(), Long.class.getName(), Long.class.getName(),
2059 Boolean.class.getName()
2060 };
2061 Object[] finderArgs = new Object[] {
2062 new Long(companyId), new Long(classNameId), new Long(classPK),
2063 Boolean.valueOf(primary)
2064 };
2065
2066 Object result = null;
2067
2068 if (finderClassNameCacheEnabled) {
2069 result = FinderCacheUtil.getResult(finderClassName,
2070 finderMethodName, finderParams, finderArgs, this);
2071 }
2072
2073 if (result == null) {
2074 Session session = null;
2075
2076 try {
2077 session = openSession();
2078
2079 StringBuilder query = new StringBuilder();
2080
2081 query.append("SELECT COUNT(*) ");
2082 query.append("FROM com.liferay.portal.model.Phone WHERE ");
2083
2084 query.append("companyId = ?");
2085
2086 query.append(" AND ");
2087
2088 query.append("classNameId = ?");
2089
2090 query.append(" AND ");
2091
2092 query.append("classPK = ?");
2093
2094 query.append(" AND ");
2095
2096 query.append("primary_ = ?");
2097
2098 query.append(" ");
2099
2100 Query q = session.createQuery(query.toString());
2101
2102 QueryPos qPos = QueryPos.getInstance(q);
2103
2104 qPos.add(companyId);
2105
2106 qPos.add(classNameId);
2107
2108 qPos.add(classPK);
2109
2110 qPos.add(primary);
2111
2112 Long count = null;
2113
2114 Iterator<Long> itr = q.list().iterator();
2115
2116 if (itr.hasNext()) {
2117 count = itr.next();
2118 }
2119
2120 if (count == null) {
2121 count = new Long(0);
2122 }
2123
2124 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2125 finderClassName, finderMethodName, finderParams,
2126 finderArgs, count);
2127
2128 return count.intValue();
2129 }
2130 catch (Exception e) {
2131 throw processException(e);
2132 }
2133 finally {
2134 closeSession(session);
2135 }
2136 }
2137 else {
2138 return ((Long)result).intValue();
2139 }
2140 }
2141
2142 public int countAll() throws SystemException {
2143 boolean finderClassNameCacheEnabled = PhoneModelImpl.CACHE_ENABLED;
2144 String finderClassName = Phone.class.getName();
2145 String finderMethodName = "countAll";
2146 String[] finderParams = new String[] { };
2147 Object[] finderArgs = new Object[] { };
2148
2149 Object result = null;
2150
2151 if (finderClassNameCacheEnabled) {
2152 result = FinderCacheUtil.getResult(finderClassName,
2153 finderMethodName, finderParams, finderArgs, this);
2154 }
2155
2156 if (result == null) {
2157 Session session = null;
2158
2159 try {
2160 session = openSession();
2161
2162 Query q = session.createQuery(
2163 "SELECT COUNT(*) FROM com.liferay.portal.model.Phone");
2164
2165 Long count = null;
2166
2167 Iterator<Long> itr = q.list().iterator();
2168
2169 if (itr.hasNext()) {
2170 count = itr.next();
2171 }
2172
2173 if (count == null) {
2174 count = new Long(0);
2175 }
2176
2177 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2178 finderClassName, finderMethodName, finderParams,
2179 finderArgs, count);
2180
2181 return count.intValue();
2182 }
2183 catch (Exception e) {
2184 throw processException(e);
2185 }
2186 finally {
2187 closeSession(session);
2188 }
2189 }
2190 else {
2191 return ((Long)result).intValue();
2192 }
2193 }
2194
2195 public void afterPropertiesSet() {
2196 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2197 com.liferay.portal.util.PropsUtil.get(
2198 "value.object.listener.com.liferay.portal.model.Phone")));
2199
2200 if (listenerClassNames.length > 0) {
2201 try {
2202 List<ModelListener> listenersList = new ArrayList<ModelListener>();
2203
2204 for (String listenerClassName : listenerClassNames) {
2205 listenersList.add((ModelListener)Class.forName(
2206 listenerClassName).newInstance());
2207 }
2208
2209 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2210 }
2211 catch (Exception e) {
2212 _log.error(e);
2213 }
2214 }
2215 }
2216
2217 private static Log _log = LogFactoryUtil.getLog(PhonePersistenceImpl.class);
2218}