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