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