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