001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchPhoneException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.Phone;
040 import com.liferay.portal.model.impl.PhoneImpl;
041 import com.liferay.portal.model.impl.PhoneModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049
050
062 public class PhonePersistenceImpl extends BasePersistenceImpl<Phone>
063 implements PhonePersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = PhoneImpl.class.getName();
070 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071 ".List1";
072 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List2";
074 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
075 new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
076 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
078 new String[] {
079 Long.class.getName(),
080
081 "java.lang.Integer", "java.lang.Integer",
082 "com.liferay.portal.kernel.util.OrderByComparator"
083 });
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
085 new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
086 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
088 new String[] { Long.class.getName() },
089 PhoneModelImpl.COMPANYID_COLUMN_BITMASK);
090 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
091 PhoneModelImpl.FINDER_CACHE_ENABLED, Long.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
093 new String[] { Long.class.getName() });
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
095 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
096 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
097 new String[] {
098 Long.class.getName(),
099
100 "java.lang.Integer", "java.lang.Integer",
101 "com.liferay.portal.kernel.util.OrderByComparator"
102 });
103 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
104 new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
105 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
107 new String[] { Long.class.getName() },
108 PhoneModelImpl.USERID_COLUMN_BITMASK);
109 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
110 PhoneModelImpl.FINDER_CACHE_ENABLED, Long.class,
111 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
112 new String[] { Long.class.getName() });
113 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
114 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
115 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
116 new String[] {
117 Long.class.getName(), Long.class.getName(),
118
119 "java.lang.Integer", "java.lang.Integer",
120 "com.liferay.portal.kernel.util.OrderByComparator"
121 });
122 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
123 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
124 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
125 new String[] { Long.class.getName(), Long.class.getName() },
126 PhoneModelImpl.COMPANYID_COLUMN_BITMASK |
127 PhoneModelImpl.CLASSNAMEID_COLUMN_BITMASK);
128 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
129 PhoneModelImpl.FINDER_CACHE_ENABLED, Long.class,
130 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
131 new String[] { Long.class.getName(), Long.class.getName() });
132 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
133 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
134 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_C",
135 new String[] {
136 Long.class.getName(), Long.class.getName(), Long.class.getName(),
137
138 "java.lang.Integer", "java.lang.Integer",
139 "com.liferay.portal.kernel.util.OrderByComparator"
140 });
141 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
142 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
143 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_C",
144 new String[] {
145 Long.class.getName(), Long.class.getName(), Long.class.getName()
146 },
147 PhoneModelImpl.COMPANYID_COLUMN_BITMASK |
148 PhoneModelImpl.CLASSNAMEID_COLUMN_BITMASK |
149 PhoneModelImpl.CLASSPK_COLUMN_BITMASK);
150 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
151 PhoneModelImpl.FINDER_CACHE_ENABLED, Long.class,
152 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
153 new String[] {
154 Long.class.getName(), Long.class.getName(), Long.class.getName()
155 });
156 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C_P = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
157 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
158 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_C_P",
159 new String[] {
160 Long.class.getName(), Long.class.getName(), Long.class.getName(),
161 Boolean.class.getName(),
162
163 "java.lang.Integer", "java.lang.Integer",
164 "com.liferay.portal.kernel.util.OrderByComparator"
165 });
166 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P =
167 new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
168 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
169 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_C_P",
170 new String[] {
171 Long.class.getName(), Long.class.getName(), Long.class.getName(),
172 Boolean.class.getName()
173 },
174 PhoneModelImpl.COMPANYID_COLUMN_BITMASK |
175 PhoneModelImpl.CLASSNAMEID_COLUMN_BITMASK |
176 PhoneModelImpl.CLASSPK_COLUMN_BITMASK |
177 PhoneModelImpl.PRIMARY_COLUMN_BITMASK);
178 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C_P = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
179 PhoneModelImpl.FINDER_CACHE_ENABLED, Long.class,
180 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C_P",
181 new String[] {
182 Long.class.getName(), Long.class.getName(), Long.class.getName(),
183 Boolean.class.getName()
184 });
185 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
186 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
187 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
188 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
189 PhoneModelImpl.FINDER_CACHE_ENABLED, PhoneImpl.class,
190 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
191 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PhoneModelImpl.ENTITY_CACHE_ENABLED,
192 PhoneModelImpl.FINDER_CACHE_ENABLED, Long.class,
193 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
194
195
200 public void cacheResult(Phone phone) {
201 EntityCacheUtil.putResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
202 PhoneImpl.class, phone.getPrimaryKey(), phone);
203
204 phone.resetOriginalValues();
205 }
206
207
212 public void cacheResult(List<Phone> phones) {
213 for (Phone phone : phones) {
214 if (EntityCacheUtil.getResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
215 PhoneImpl.class, phone.getPrimaryKey()) == null) {
216 cacheResult(phone);
217 }
218 else {
219 phone.resetOriginalValues();
220 }
221 }
222 }
223
224
231 @Override
232 public void clearCache() {
233 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
234 CacheRegistryUtil.clear(PhoneImpl.class.getName());
235 }
236
237 EntityCacheUtil.clearCache(PhoneImpl.class.getName());
238
239 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
240 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
241 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
242 }
243
244
251 @Override
252 public void clearCache(Phone phone) {
253 EntityCacheUtil.removeResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
254 PhoneImpl.class, phone.getPrimaryKey());
255
256 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
257 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
258 }
259
260 @Override
261 public void clearCache(List<Phone> phones) {
262 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
263 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
264
265 for (Phone phone : phones) {
266 EntityCacheUtil.removeResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
267 PhoneImpl.class, phone.getPrimaryKey());
268 }
269 }
270
271
277 public Phone create(long phoneId) {
278 Phone phone = new PhoneImpl();
279
280 phone.setNew(true);
281 phone.setPrimaryKey(phoneId);
282
283 return phone;
284 }
285
286
294 public Phone remove(long phoneId)
295 throws NoSuchPhoneException, SystemException {
296 return remove(Long.valueOf(phoneId));
297 }
298
299
307 @Override
308 public Phone remove(Serializable primaryKey)
309 throws NoSuchPhoneException, SystemException {
310 Session session = null;
311
312 try {
313 session = openSession();
314
315 Phone phone = (Phone)session.get(PhoneImpl.class, primaryKey);
316
317 if (phone == null) {
318 if (_log.isWarnEnabled()) {
319 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
320 }
321
322 throw new NoSuchPhoneException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
323 primaryKey);
324 }
325
326 return remove(phone);
327 }
328 catch (NoSuchPhoneException nsee) {
329 throw nsee;
330 }
331 catch (Exception e) {
332 throw processException(e);
333 }
334 finally {
335 closeSession(session);
336 }
337 }
338
339 @Override
340 protected Phone removeImpl(Phone phone) throws SystemException {
341 phone = toUnwrappedModel(phone);
342
343 Session session = null;
344
345 try {
346 session = openSession();
347
348 BatchSessionUtil.delete(session, phone);
349 }
350 catch (Exception e) {
351 throw processException(e);
352 }
353 finally {
354 closeSession(session);
355 }
356
357 clearCache(phone);
358
359 return phone;
360 }
361
362 @Override
363 public Phone updateImpl(com.liferay.portal.model.Phone phone, boolean merge)
364 throws SystemException {
365 phone = toUnwrappedModel(phone);
366
367 boolean isNew = phone.isNew();
368
369 PhoneModelImpl phoneModelImpl = (PhoneModelImpl)phone;
370
371 Session session = null;
372
373 try {
374 session = openSession();
375
376 BatchSessionUtil.update(session, phone, merge);
377
378 phone.setNew(false);
379 }
380 catch (Exception e) {
381 throw processException(e);
382 }
383 finally {
384 closeSession(session);
385 }
386
387 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
388
389 if (isNew || !PhoneModelImpl.COLUMN_BITMASK_ENABLED) {
390 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
391 }
392 else {
393 if ((phoneModelImpl.getColumnBitmask() &
394 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
395 Object[] args = new Object[] {
396 Long.valueOf(phoneModelImpl.getOriginalCompanyId())
397 };
398
399 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
400 args);
401 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
402 args);
403
404 args = new Object[] { Long.valueOf(phoneModelImpl.getCompanyId()) };
405
406 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
407 args);
408 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
409 args);
410 }
411
412 if ((phoneModelImpl.getColumnBitmask() &
413 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
414 Object[] args = new Object[] {
415 Long.valueOf(phoneModelImpl.getOriginalUserId())
416 };
417
418 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
419 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
420 args);
421
422 args = new Object[] { Long.valueOf(phoneModelImpl.getUserId()) };
423
424 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
425 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
426 args);
427 }
428
429 if ((phoneModelImpl.getColumnBitmask() &
430 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
431 Object[] args = new Object[] {
432 Long.valueOf(phoneModelImpl.getOriginalCompanyId()),
433 Long.valueOf(phoneModelImpl.getOriginalClassNameId())
434 };
435
436 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
437 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
438 args);
439
440 args = new Object[] {
441 Long.valueOf(phoneModelImpl.getCompanyId()),
442 Long.valueOf(phoneModelImpl.getClassNameId())
443 };
444
445 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
446 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
447 args);
448 }
449
450 if ((phoneModelImpl.getColumnBitmask() &
451 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C.getColumnBitmask()) != 0) {
452 Object[] args = new Object[] {
453 Long.valueOf(phoneModelImpl.getOriginalCompanyId()),
454 Long.valueOf(phoneModelImpl.getOriginalClassNameId()),
455 Long.valueOf(phoneModelImpl.getOriginalClassPK())
456 };
457
458 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
459 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
460 args);
461
462 args = new Object[] {
463 Long.valueOf(phoneModelImpl.getCompanyId()),
464 Long.valueOf(phoneModelImpl.getClassNameId()),
465 Long.valueOf(phoneModelImpl.getClassPK())
466 };
467
468 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
469 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
470 args);
471 }
472
473 if ((phoneModelImpl.getColumnBitmask() &
474 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P.getColumnBitmask()) != 0) {
475 Object[] args = new Object[] {
476 Long.valueOf(phoneModelImpl.getOriginalCompanyId()),
477 Long.valueOf(phoneModelImpl.getOriginalClassNameId()),
478 Long.valueOf(phoneModelImpl.getOriginalClassPK()),
479 Boolean.valueOf(phoneModelImpl.getOriginalPrimary())
480 };
481
482 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
483 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
484 args);
485
486 args = new Object[] {
487 Long.valueOf(phoneModelImpl.getCompanyId()),
488 Long.valueOf(phoneModelImpl.getClassNameId()),
489 Long.valueOf(phoneModelImpl.getClassPK()),
490 Boolean.valueOf(phoneModelImpl.getPrimary())
491 };
492
493 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
494 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
495 args);
496 }
497 }
498
499 EntityCacheUtil.putResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
500 PhoneImpl.class, phone.getPrimaryKey(), phone);
501
502 return phone;
503 }
504
505 protected Phone toUnwrappedModel(Phone phone) {
506 if (phone instanceof PhoneImpl) {
507 return phone;
508 }
509
510 PhoneImpl phoneImpl = new PhoneImpl();
511
512 phoneImpl.setNew(phone.isNew());
513 phoneImpl.setPrimaryKey(phone.getPrimaryKey());
514
515 phoneImpl.setPhoneId(phone.getPhoneId());
516 phoneImpl.setCompanyId(phone.getCompanyId());
517 phoneImpl.setUserId(phone.getUserId());
518 phoneImpl.setUserName(phone.getUserName());
519 phoneImpl.setCreateDate(phone.getCreateDate());
520 phoneImpl.setModifiedDate(phone.getModifiedDate());
521 phoneImpl.setClassNameId(phone.getClassNameId());
522 phoneImpl.setClassPK(phone.getClassPK());
523 phoneImpl.setNumber(phone.getNumber());
524 phoneImpl.setExtension(phone.getExtension());
525 phoneImpl.setTypeId(phone.getTypeId());
526 phoneImpl.setPrimary(phone.isPrimary());
527
528 return phoneImpl;
529 }
530
531
539 @Override
540 public Phone findByPrimaryKey(Serializable primaryKey)
541 throws NoSuchModelException, SystemException {
542 return findByPrimaryKey(((Long)primaryKey).longValue());
543 }
544
545
553 public Phone findByPrimaryKey(long phoneId)
554 throws NoSuchPhoneException, SystemException {
555 Phone phone = fetchByPrimaryKey(phoneId);
556
557 if (phone == null) {
558 if (_log.isWarnEnabled()) {
559 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + phoneId);
560 }
561
562 throw new NoSuchPhoneException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
563 phoneId);
564 }
565
566 return phone;
567 }
568
569
576 @Override
577 public Phone fetchByPrimaryKey(Serializable primaryKey)
578 throws SystemException {
579 return fetchByPrimaryKey(((Long)primaryKey).longValue());
580 }
581
582
589 public Phone fetchByPrimaryKey(long phoneId) throws SystemException {
590 Phone phone = (Phone)EntityCacheUtil.getResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
591 PhoneImpl.class, phoneId);
592
593 if (phone == _nullPhone) {
594 return null;
595 }
596
597 if (phone == null) {
598 Session session = null;
599
600 boolean hasException = false;
601
602 try {
603 session = openSession();
604
605 phone = (Phone)session.get(PhoneImpl.class,
606 Long.valueOf(phoneId));
607 }
608 catch (Exception e) {
609 hasException = true;
610
611 throw processException(e);
612 }
613 finally {
614 if (phone != null) {
615 cacheResult(phone);
616 }
617 else if (!hasException) {
618 EntityCacheUtil.putResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
619 PhoneImpl.class, phoneId, _nullPhone);
620 }
621
622 closeSession(session);
623 }
624 }
625
626 return phone;
627 }
628
629
636 public List<Phone> findByCompanyId(long companyId)
637 throws SystemException {
638 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
639 null);
640 }
641
642
655 public List<Phone> findByCompanyId(long companyId, int start, int end)
656 throws SystemException {
657 return findByCompanyId(companyId, start, end, null);
658 }
659
660
674 public List<Phone> findByCompanyId(long companyId, int start, int end,
675 OrderByComparator orderByComparator) throws SystemException {
676 FinderPath finderPath = null;
677 Object[] finderArgs = null;
678
679 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
680 (orderByComparator == null)) {
681 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
682 finderArgs = new Object[] { companyId };
683 }
684 else {
685 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
686 finderArgs = new Object[] { companyId, start, end, orderByComparator };
687 }
688
689 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
690 finderArgs, this);
691
692 if ((list != null) && !list.isEmpty()) {
693 for (Phone phone : list) {
694 if ((companyId != phone.getCompanyId())) {
695 list = null;
696
697 break;
698 }
699 }
700 }
701
702 if (list == null) {
703 StringBundler query = null;
704
705 if (orderByComparator != null) {
706 query = new StringBundler(3 +
707 (orderByComparator.getOrderByFields().length * 3));
708 }
709 else {
710 query = new StringBundler(3);
711 }
712
713 query.append(_SQL_SELECT_PHONE_WHERE);
714
715 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
716
717 if (orderByComparator != null) {
718 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
719 orderByComparator);
720 }
721
722 else {
723 query.append(PhoneModelImpl.ORDER_BY_JPQL);
724 }
725
726 String sql = query.toString();
727
728 Session session = null;
729
730 try {
731 session = openSession();
732
733 Query q = session.createQuery(sql);
734
735 QueryPos qPos = QueryPos.getInstance(q);
736
737 qPos.add(companyId);
738
739 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
740 }
741 catch (Exception e) {
742 throw processException(e);
743 }
744 finally {
745 if (list == null) {
746 FinderCacheUtil.removeResult(finderPath, finderArgs);
747 }
748 else {
749 cacheResult(list);
750
751 FinderCacheUtil.putResult(finderPath, finderArgs, list);
752 }
753
754 closeSession(session);
755 }
756 }
757
758 return list;
759 }
760
761
774 public Phone findByCompanyId_First(long companyId,
775 OrderByComparator orderByComparator)
776 throws NoSuchPhoneException, SystemException {
777 List<Phone> list = findByCompanyId(companyId, 0, 1, orderByComparator);
778
779 if (list.isEmpty()) {
780 StringBundler msg = new StringBundler(4);
781
782 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
783
784 msg.append("companyId=");
785 msg.append(companyId);
786
787 msg.append(StringPool.CLOSE_CURLY_BRACE);
788
789 throw new NoSuchPhoneException(msg.toString());
790 }
791 else {
792 return list.get(0);
793 }
794 }
795
796
809 public Phone findByCompanyId_Last(long companyId,
810 OrderByComparator orderByComparator)
811 throws NoSuchPhoneException, SystemException {
812 int count = countByCompanyId(companyId);
813
814 List<Phone> list = findByCompanyId(companyId, count - 1, count,
815 orderByComparator);
816
817 if (list.isEmpty()) {
818 StringBundler msg = new StringBundler(4);
819
820 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
821
822 msg.append("companyId=");
823 msg.append(companyId);
824
825 msg.append(StringPool.CLOSE_CURLY_BRACE);
826
827 throw new NoSuchPhoneException(msg.toString());
828 }
829 else {
830 return list.get(0);
831 }
832 }
833
834
848 public Phone[] findByCompanyId_PrevAndNext(long phoneId, long companyId,
849 OrderByComparator orderByComparator)
850 throws NoSuchPhoneException, SystemException {
851 Phone phone = findByPrimaryKey(phoneId);
852
853 Session session = null;
854
855 try {
856 session = openSession();
857
858 Phone[] array = new PhoneImpl[3];
859
860 array[0] = getByCompanyId_PrevAndNext(session, phone, companyId,
861 orderByComparator, true);
862
863 array[1] = phone;
864
865 array[2] = getByCompanyId_PrevAndNext(session, phone, companyId,
866 orderByComparator, false);
867
868 return array;
869 }
870 catch (Exception e) {
871 throw processException(e);
872 }
873 finally {
874 closeSession(session);
875 }
876 }
877
878 protected Phone getByCompanyId_PrevAndNext(Session session, Phone phone,
879 long companyId, OrderByComparator orderByComparator, boolean previous) {
880 StringBundler query = null;
881
882 if (orderByComparator != null) {
883 query = new StringBundler(6 +
884 (orderByComparator.getOrderByFields().length * 6));
885 }
886 else {
887 query = new StringBundler(3);
888 }
889
890 query.append(_SQL_SELECT_PHONE_WHERE);
891
892 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
893
894 if (orderByComparator != null) {
895 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
896
897 if (orderByConditionFields.length > 0) {
898 query.append(WHERE_AND);
899 }
900
901 for (int i = 0; i < orderByConditionFields.length; i++) {
902 query.append(_ORDER_BY_ENTITY_ALIAS);
903 query.append(orderByConditionFields[i]);
904
905 if ((i + 1) < orderByConditionFields.length) {
906 if (orderByComparator.isAscending() ^ previous) {
907 query.append(WHERE_GREATER_THAN_HAS_NEXT);
908 }
909 else {
910 query.append(WHERE_LESSER_THAN_HAS_NEXT);
911 }
912 }
913 else {
914 if (orderByComparator.isAscending() ^ previous) {
915 query.append(WHERE_GREATER_THAN);
916 }
917 else {
918 query.append(WHERE_LESSER_THAN);
919 }
920 }
921 }
922
923 query.append(ORDER_BY_CLAUSE);
924
925 String[] orderByFields = orderByComparator.getOrderByFields();
926
927 for (int i = 0; i < orderByFields.length; i++) {
928 query.append(_ORDER_BY_ENTITY_ALIAS);
929 query.append(orderByFields[i]);
930
931 if ((i + 1) < orderByFields.length) {
932 if (orderByComparator.isAscending() ^ previous) {
933 query.append(ORDER_BY_ASC_HAS_NEXT);
934 }
935 else {
936 query.append(ORDER_BY_DESC_HAS_NEXT);
937 }
938 }
939 else {
940 if (orderByComparator.isAscending() ^ previous) {
941 query.append(ORDER_BY_ASC);
942 }
943 else {
944 query.append(ORDER_BY_DESC);
945 }
946 }
947 }
948 }
949
950 else {
951 query.append(PhoneModelImpl.ORDER_BY_JPQL);
952 }
953
954 String sql = query.toString();
955
956 Query q = session.createQuery(sql);
957
958 q.setFirstResult(0);
959 q.setMaxResults(2);
960
961 QueryPos qPos = QueryPos.getInstance(q);
962
963 qPos.add(companyId);
964
965 if (orderByComparator != null) {
966 Object[] values = orderByComparator.getOrderByConditionValues(phone);
967
968 for (Object value : values) {
969 qPos.add(value);
970 }
971 }
972
973 List<Phone> list = q.list();
974
975 if (list.size() == 2) {
976 return list.get(1);
977 }
978 else {
979 return null;
980 }
981 }
982
983
990 public List<Phone> findByUserId(long userId) throws SystemException {
991 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
992 }
993
994
1007 public List<Phone> findByUserId(long userId, int start, int end)
1008 throws SystemException {
1009 return findByUserId(userId, start, end, null);
1010 }
1011
1012
1026 public List<Phone> findByUserId(long userId, int start, int end,
1027 OrderByComparator orderByComparator) throws SystemException {
1028 FinderPath finderPath = null;
1029 Object[] finderArgs = null;
1030
1031 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1032 (orderByComparator == null)) {
1033 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1034 finderArgs = new Object[] { userId };
1035 }
1036 else {
1037 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1038 finderArgs = new Object[] { userId, start, end, orderByComparator };
1039 }
1040
1041 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
1042 finderArgs, this);
1043
1044 if ((list != null) && !list.isEmpty()) {
1045 for (Phone phone : list) {
1046 if ((userId != phone.getUserId())) {
1047 list = null;
1048
1049 break;
1050 }
1051 }
1052 }
1053
1054 if (list == null) {
1055 StringBundler query = null;
1056
1057 if (orderByComparator != null) {
1058 query = new StringBundler(3 +
1059 (orderByComparator.getOrderByFields().length * 3));
1060 }
1061 else {
1062 query = new StringBundler(3);
1063 }
1064
1065 query.append(_SQL_SELECT_PHONE_WHERE);
1066
1067 query.append(_FINDER_COLUMN_USERID_USERID_2);
1068
1069 if (orderByComparator != null) {
1070 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1071 orderByComparator);
1072 }
1073
1074 else {
1075 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1076 }
1077
1078 String sql = query.toString();
1079
1080 Session session = null;
1081
1082 try {
1083 session = openSession();
1084
1085 Query q = session.createQuery(sql);
1086
1087 QueryPos qPos = QueryPos.getInstance(q);
1088
1089 qPos.add(userId);
1090
1091 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
1092 }
1093 catch (Exception e) {
1094 throw processException(e);
1095 }
1096 finally {
1097 if (list == null) {
1098 FinderCacheUtil.removeResult(finderPath, finderArgs);
1099 }
1100 else {
1101 cacheResult(list);
1102
1103 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1104 }
1105
1106 closeSession(session);
1107 }
1108 }
1109
1110 return list;
1111 }
1112
1113
1126 public Phone findByUserId_First(long userId,
1127 OrderByComparator orderByComparator)
1128 throws NoSuchPhoneException, SystemException {
1129 List<Phone> list = findByUserId(userId, 0, 1, orderByComparator);
1130
1131 if (list.isEmpty()) {
1132 StringBundler msg = new StringBundler(4);
1133
1134 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1135
1136 msg.append("userId=");
1137 msg.append(userId);
1138
1139 msg.append(StringPool.CLOSE_CURLY_BRACE);
1140
1141 throw new NoSuchPhoneException(msg.toString());
1142 }
1143 else {
1144 return list.get(0);
1145 }
1146 }
1147
1148
1161 public Phone findByUserId_Last(long userId,
1162 OrderByComparator orderByComparator)
1163 throws NoSuchPhoneException, SystemException {
1164 int count = countByUserId(userId);
1165
1166 List<Phone> list = findByUserId(userId, count - 1, count,
1167 orderByComparator);
1168
1169 if (list.isEmpty()) {
1170 StringBundler msg = new StringBundler(4);
1171
1172 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1173
1174 msg.append("userId=");
1175 msg.append(userId);
1176
1177 msg.append(StringPool.CLOSE_CURLY_BRACE);
1178
1179 throw new NoSuchPhoneException(msg.toString());
1180 }
1181 else {
1182 return list.get(0);
1183 }
1184 }
1185
1186
1200 public Phone[] findByUserId_PrevAndNext(long phoneId, long userId,
1201 OrderByComparator orderByComparator)
1202 throws NoSuchPhoneException, SystemException {
1203 Phone phone = findByPrimaryKey(phoneId);
1204
1205 Session session = null;
1206
1207 try {
1208 session = openSession();
1209
1210 Phone[] array = new PhoneImpl[3];
1211
1212 array[0] = getByUserId_PrevAndNext(session, phone, userId,
1213 orderByComparator, true);
1214
1215 array[1] = phone;
1216
1217 array[2] = getByUserId_PrevAndNext(session, phone, userId,
1218 orderByComparator, false);
1219
1220 return array;
1221 }
1222 catch (Exception e) {
1223 throw processException(e);
1224 }
1225 finally {
1226 closeSession(session);
1227 }
1228 }
1229
1230 protected Phone getByUserId_PrevAndNext(Session session, Phone phone,
1231 long userId, OrderByComparator orderByComparator, boolean previous) {
1232 StringBundler query = null;
1233
1234 if (orderByComparator != null) {
1235 query = new StringBundler(6 +
1236 (orderByComparator.getOrderByFields().length * 6));
1237 }
1238 else {
1239 query = new StringBundler(3);
1240 }
1241
1242 query.append(_SQL_SELECT_PHONE_WHERE);
1243
1244 query.append(_FINDER_COLUMN_USERID_USERID_2);
1245
1246 if (orderByComparator != null) {
1247 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1248
1249 if (orderByConditionFields.length > 0) {
1250 query.append(WHERE_AND);
1251 }
1252
1253 for (int i = 0; i < orderByConditionFields.length; i++) {
1254 query.append(_ORDER_BY_ENTITY_ALIAS);
1255 query.append(orderByConditionFields[i]);
1256
1257 if ((i + 1) < orderByConditionFields.length) {
1258 if (orderByComparator.isAscending() ^ previous) {
1259 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1260 }
1261 else {
1262 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1263 }
1264 }
1265 else {
1266 if (orderByComparator.isAscending() ^ previous) {
1267 query.append(WHERE_GREATER_THAN);
1268 }
1269 else {
1270 query.append(WHERE_LESSER_THAN);
1271 }
1272 }
1273 }
1274
1275 query.append(ORDER_BY_CLAUSE);
1276
1277 String[] orderByFields = orderByComparator.getOrderByFields();
1278
1279 for (int i = 0; i < orderByFields.length; i++) {
1280 query.append(_ORDER_BY_ENTITY_ALIAS);
1281 query.append(orderByFields[i]);
1282
1283 if ((i + 1) < orderByFields.length) {
1284 if (orderByComparator.isAscending() ^ previous) {
1285 query.append(ORDER_BY_ASC_HAS_NEXT);
1286 }
1287 else {
1288 query.append(ORDER_BY_DESC_HAS_NEXT);
1289 }
1290 }
1291 else {
1292 if (orderByComparator.isAscending() ^ previous) {
1293 query.append(ORDER_BY_ASC);
1294 }
1295 else {
1296 query.append(ORDER_BY_DESC);
1297 }
1298 }
1299 }
1300 }
1301
1302 else {
1303 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1304 }
1305
1306 String sql = query.toString();
1307
1308 Query q = session.createQuery(sql);
1309
1310 q.setFirstResult(0);
1311 q.setMaxResults(2);
1312
1313 QueryPos qPos = QueryPos.getInstance(q);
1314
1315 qPos.add(userId);
1316
1317 if (orderByComparator != null) {
1318 Object[] values = orderByComparator.getOrderByConditionValues(phone);
1319
1320 for (Object value : values) {
1321 qPos.add(value);
1322 }
1323 }
1324
1325 List<Phone> list = q.list();
1326
1327 if (list.size() == 2) {
1328 return list.get(1);
1329 }
1330 else {
1331 return null;
1332 }
1333 }
1334
1335
1343 public List<Phone> findByC_C(long companyId, long classNameId)
1344 throws SystemException {
1345 return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
1346 QueryUtil.ALL_POS, null);
1347 }
1348
1349
1363 public List<Phone> findByC_C(long companyId, long classNameId, int start,
1364 int end) throws SystemException {
1365 return findByC_C(companyId, classNameId, start, end, null);
1366 }
1367
1368
1383 public List<Phone> findByC_C(long companyId, long classNameId, int start,
1384 int end, OrderByComparator orderByComparator) throws SystemException {
1385 FinderPath finderPath = null;
1386 Object[] finderArgs = null;
1387
1388 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1389 (orderByComparator == null)) {
1390 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
1391 finderArgs = new Object[] { companyId, classNameId };
1392 }
1393 else {
1394 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
1395 finderArgs = new Object[] {
1396 companyId, classNameId,
1397
1398 start, end, orderByComparator
1399 };
1400 }
1401
1402 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
1403 finderArgs, this);
1404
1405 if ((list != null) && !list.isEmpty()) {
1406 for (Phone phone : list) {
1407 if ((companyId != phone.getCompanyId()) ||
1408 (classNameId != phone.getClassNameId())) {
1409 list = null;
1410
1411 break;
1412 }
1413 }
1414 }
1415
1416 if (list == null) {
1417 StringBundler query = null;
1418
1419 if (orderByComparator != null) {
1420 query = new StringBundler(4 +
1421 (orderByComparator.getOrderByFields().length * 3));
1422 }
1423 else {
1424 query = new StringBundler(4);
1425 }
1426
1427 query.append(_SQL_SELECT_PHONE_WHERE);
1428
1429 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1430
1431 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1432
1433 if (orderByComparator != null) {
1434 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1435 orderByComparator);
1436 }
1437
1438 else {
1439 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1440 }
1441
1442 String sql = query.toString();
1443
1444 Session session = null;
1445
1446 try {
1447 session = openSession();
1448
1449 Query q = session.createQuery(sql);
1450
1451 QueryPos qPos = QueryPos.getInstance(q);
1452
1453 qPos.add(companyId);
1454
1455 qPos.add(classNameId);
1456
1457 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
1458 }
1459 catch (Exception e) {
1460 throw processException(e);
1461 }
1462 finally {
1463 if (list == null) {
1464 FinderCacheUtil.removeResult(finderPath, finderArgs);
1465 }
1466 else {
1467 cacheResult(list);
1468
1469 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1470 }
1471
1472 closeSession(session);
1473 }
1474 }
1475
1476 return list;
1477 }
1478
1479
1493 public Phone findByC_C_First(long companyId, long classNameId,
1494 OrderByComparator orderByComparator)
1495 throws NoSuchPhoneException, SystemException {
1496 List<Phone> list = findByC_C(companyId, classNameId, 0, 1,
1497 orderByComparator);
1498
1499 if (list.isEmpty()) {
1500 StringBundler msg = new StringBundler(6);
1501
1502 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1503
1504 msg.append("companyId=");
1505 msg.append(companyId);
1506
1507 msg.append(", classNameId=");
1508 msg.append(classNameId);
1509
1510 msg.append(StringPool.CLOSE_CURLY_BRACE);
1511
1512 throw new NoSuchPhoneException(msg.toString());
1513 }
1514 else {
1515 return list.get(0);
1516 }
1517 }
1518
1519
1533 public Phone findByC_C_Last(long companyId, long classNameId,
1534 OrderByComparator orderByComparator)
1535 throws NoSuchPhoneException, SystemException {
1536 int count = countByC_C(companyId, classNameId);
1537
1538 List<Phone> list = findByC_C(companyId, classNameId, count - 1, count,
1539 orderByComparator);
1540
1541 if (list.isEmpty()) {
1542 StringBundler msg = new StringBundler(6);
1543
1544 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1545
1546 msg.append("companyId=");
1547 msg.append(companyId);
1548
1549 msg.append(", classNameId=");
1550 msg.append(classNameId);
1551
1552 msg.append(StringPool.CLOSE_CURLY_BRACE);
1553
1554 throw new NoSuchPhoneException(msg.toString());
1555 }
1556 else {
1557 return list.get(0);
1558 }
1559 }
1560
1561
1576 public Phone[] findByC_C_PrevAndNext(long phoneId, long companyId,
1577 long classNameId, OrderByComparator orderByComparator)
1578 throws NoSuchPhoneException, SystemException {
1579 Phone phone = findByPrimaryKey(phoneId);
1580
1581 Session session = null;
1582
1583 try {
1584 session = openSession();
1585
1586 Phone[] array = new PhoneImpl[3];
1587
1588 array[0] = getByC_C_PrevAndNext(session, phone, companyId,
1589 classNameId, orderByComparator, true);
1590
1591 array[1] = phone;
1592
1593 array[2] = getByC_C_PrevAndNext(session, phone, companyId,
1594 classNameId, orderByComparator, false);
1595
1596 return array;
1597 }
1598 catch (Exception e) {
1599 throw processException(e);
1600 }
1601 finally {
1602 closeSession(session);
1603 }
1604 }
1605
1606 protected Phone getByC_C_PrevAndNext(Session session, Phone phone,
1607 long companyId, long classNameId, OrderByComparator orderByComparator,
1608 boolean previous) {
1609 StringBundler query = null;
1610
1611 if (orderByComparator != null) {
1612 query = new StringBundler(6 +
1613 (orderByComparator.getOrderByFields().length * 6));
1614 }
1615 else {
1616 query = new StringBundler(3);
1617 }
1618
1619 query.append(_SQL_SELECT_PHONE_WHERE);
1620
1621 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1622
1623 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1624
1625 if (orderByComparator != null) {
1626 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1627
1628 if (orderByConditionFields.length > 0) {
1629 query.append(WHERE_AND);
1630 }
1631
1632 for (int i = 0; i < orderByConditionFields.length; i++) {
1633 query.append(_ORDER_BY_ENTITY_ALIAS);
1634 query.append(orderByConditionFields[i]);
1635
1636 if ((i + 1) < orderByConditionFields.length) {
1637 if (orderByComparator.isAscending() ^ previous) {
1638 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1639 }
1640 else {
1641 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1642 }
1643 }
1644 else {
1645 if (orderByComparator.isAscending() ^ previous) {
1646 query.append(WHERE_GREATER_THAN);
1647 }
1648 else {
1649 query.append(WHERE_LESSER_THAN);
1650 }
1651 }
1652 }
1653
1654 query.append(ORDER_BY_CLAUSE);
1655
1656 String[] orderByFields = orderByComparator.getOrderByFields();
1657
1658 for (int i = 0; i < orderByFields.length; i++) {
1659 query.append(_ORDER_BY_ENTITY_ALIAS);
1660 query.append(orderByFields[i]);
1661
1662 if ((i + 1) < orderByFields.length) {
1663 if (orderByComparator.isAscending() ^ previous) {
1664 query.append(ORDER_BY_ASC_HAS_NEXT);
1665 }
1666 else {
1667 query.append(ORDER_BY_DESC_HAS_NEXT);
1668 }
1669 }
1670 else {
1671 if (orderByComparator.isAscending() ^ previous) {
1672 query.append(ORDER_BY_ASC);
1673 }
1674 else {
1675 query.append(ORDER_BY_DESC);
1676 }
1677 }
1678 }
1679 }
1680
1681 else {
1682 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1683 }
1684
1685 String sql = query.toString();
1686
1687 Query q = session.createQuery(sql);
1688
1689 q.setFirstResult(0);
1690 q.setMaxResults(2);
1691
1692 QueryPos qPos = QueryPos.getInstance(q);
1693
1694 qPos.add(companyId);
1695
1696 qPos.add(classNameId);
1697
1698 if (orderByComparator != null) {
1699 Object[] values = orderByComparator.getOrderByConditionValues(phone);
1700
1701 for (Object value : values) {
1702 qPos.add(value);
1703 }
1704 }
1705
1706 List<Phone> list = q.list();
1707
1708 if (list.size() == 2) {
1709 return list.get(1);
1710 }
1711 else {
1712 return null;
1713 }
1714 }
1715
1716
1725 public List<Phone> findByC_C_C(long companyId, long classNameId,
1726 long classPK) throws SystemException {
1727 return findByC_C_C(companyId, classNameId, classPK, QueryUtil.ALL_POS,
1728 QueryUtil.ALL_POS, null);
1729 }
1730
1731
1746 public List<Phone> findByC_C_C(long companyId, long classNameId,
1747 long classPK, int start, int end) throws SystemException {
1748 return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1749 }
1750
1751
1767 public List<Phone> findByC_C_C(long companyId, long classNameId,
1768 long classPK, int start, int end, OrderByComparator orderByComparator)
1769 throws SystemException {
1770 FinderPath finderPath = null;
1771 Object[] finderArgs = null;
1772
1773 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1774 (orderByComparator == null)) {
1775 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C;
1776 finderArgs = new Object[] { companyId, classNameId, classPK };
1777 }
1778 else {
1779 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C;
1780 finderArgs = new Object[] {
1781 companyId, classNameId, classPK,
1782
1783 start, end, orderByComparator
1784 };
1785 }
1786
1787 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
1788 finderArgs, this);
1789
1790 if ((list != null) && !list.isEmpty()) {
1791 for (Phone phone : list) {
1792 if ((companyId != phone.getCompanyId()) ||
1793 (classNameId != phone.getClassNameId()) ||
1794 (classPK != phone.getClassPK())) {
1795 list = null;
1796
1797 break;
1798 }
1799 }
1800 }
1801
1802 if (list == null) {
1803 StringBundler query = null;
1804
1805 if (orderByComparator != null) {
1806 query = new StringBundler(5 +
1807 (orderByComparator.getOrderByFields().length * 3));
1808 }
1809 else {
1810 query = new StringBundler(5);
1811 }
1812
1813 query.append(_SQL_SELECT_PHONE_WHERE);
1814
1815 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1816
1817 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1818
1819 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1820
1821 if (orderByComparator != null) {
1822 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1823 orderByComparator);
1824 }
1825
1826 else {
1827 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1828 }
1829
1830 String sql = query.toString();
1831
1832 Session session = null;
1833
1834 try {
1835 session = openSession();
1836
1837 Query q = session.createQuery(sql);
1838
1839 QueryPos qPos = QueryPos.getInstance(q);
1840
1841 qPos.add(companyId);
1842
1843 qPos.add(classNameId);
1844
1845 qPos.add(classPK);
1846
1847 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
1848 }
1849 catch (Exception e) {
1850 throw processException(e);
1851 }
1852 finally {
1853 if (list == null) {
1854 FinderCacheUtil.removeResult(finderPath, finderArgs);
1855 }
1856 else {
1857 cacheResult(list);
1858
1859 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1860 }
1861
1862 closeSession(session);
1863 }
1864 }
1865
1866 return list;
1867 }
1868
1869
1884 public Phone findByC_C_C_First(long companyId, long classNameId,
1885 long classPK, OrderByComparator orderByComparator)
1886 throws NoSuchPhoneException, SystemException {
1887 List<Phone> list = findByC_C_C(companyId, classNameId, classPK, 0, 1,
1888 orderByComparator);
1889
1890 if (list.isEmpty()) {
1891 StringBundler msg = new StringBundler(8);
1892
1893 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1894
1895 msg.append("companyId=");
1896 msg.append(companyId);
1897
1898 msg.append(", classNameId=");
1899 msg.append(classNameId);
1900
1901 msg.append(", classPK=");
1902 msg.append(classPK);
1903
1904 msg.append(StringPool.CLOSE_CURLY_BRACE);
1905
1906 throw new NoSuchPhoneException(msg.toString());
1907 }
1908 else {
1909 return list.get(0);
1910 }
1911 }
1912
1913
1928 public Phone findByC_C_C_Last(long companyId, long classNameId,
1929 long classPK, OrderByComparator orderByComparator)
1930 throws NoSuchPhoneException, SystemException {
1931 int count = countByC_C_C(companyId, classNameId, classPK);
1932
1933 List<Phone> list = findByC_C_C(companyId, classNameId, classPK,
1934 count - 1, count, orderByComparator);
1935
1936 if (list.isEmpty()) {
1937 StringBundler msg = new StringBundler(8);
1938
1939 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1940
1941 msg.append("companyId=");
1942 msg.append(companyId);
1943
1944 msg.append(", classNameId=");
1945 msg.append(classNameId);
1946
1947 msg.append(", classPK=");
1948 msg.append(classPK);
1949
1950 msg.append(StringPool.CLOSE_CURLY_BRACE);
1951
1952 throw new NoSuchPhoneException(msg.toString());
1953 }
1954 else {
1955 return list.get(0);
1956 }
1957 }
1958
1959
1975 public Phone[] findByC_C_C_PrevAndNext(long phoneId, long companyId,
1976 long classNameId, long classPK, OrderByComparator orderByComparator)
1977 throws NoSuchPhoneException, SystemException {
1978 Phone phone = findByPrimaryKey(phoneId);
1979
1980 Session session = null;
1981
1982 try {
1983 session = openSession();
1984
1985 Phone[] array = new PhoneImpl[3];
1986
1987 array[0] = getByC_C_C_PrevAndNext(session, phone, companyId,
1988 classNameId, classPK, orderByComparator, true);
1989
1990 array[1] = phone;
1991
1992 array[2] = getByC_C_C_PrevAndNext(session, phone, companyId,
1993 classNameId, classPK, orderByComparator, false);
1994
1995 return array;
1996 }
1997 catch (Exception e) {
1998 throw processException(e);
1999 }
2000 finally {
2001 closeSession(session);
2002 }
2003 }
2004
2005 protected Phone getByC_C_C_PrevAndNext(Session session, Phone phone,
2006 long companyId, long classNameId, long classPK,
2007 OrderByComparator orderByComparator, boolean previous) {
2008 StringBundler query = null;
2009
2010 if (orderByComparator != null) {
2011 query = new StringBundler(6 +
2012 (orderByComparator.getOrderByFields().length * 6));
2013 }
2014 else {
2015 query = new StringBundler(3);
2016 }
2017
2018 query.append(_SQL_SELECT_PHONE_WHERE);
2019
2020 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2021
2022 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2023
2024 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2025
2026 if (orderByComparator != null) {
2027 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2028
2029 if (orderByConditionFields.length > 0) {
2030 query.append(WHERE_AND);
2031 }
2032
2033 for (int i = 0; i < orderByConditionFields.length; i++) {
2034 query.append(_ORDER_BY_ENTITY_ALIAS);
2035 query.append(orderByConditionFields[i]);
2036
2037 if ((i + 1) < orderByConditionFields.length) {
2038 if (orderByComparator.isAscending() ^ previous) {
2039 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2040 }
2041 else {
2042 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2043 }
2044 }
2045 else {
2046 if (orderByComparator.isAscending() ^ previous) {
2047 query.append(WHERE_GREATER_THAN);
2048 }
2049 else {
2050 query.append(WHERE_LESSER_THAN);
2051 }
2052 }
2053 }
2054
2055 query.append(ORDER_BY_CLAUSE);
2056
2057 String[] orderByFields = orderByComparator.getOrderByFields();
2058
2059 for (int i = 0; i < orderByFields.length; i++) {
2060 query.append(_ORDER_BY_ENTITY_ALIAS);
2061 query.append(orderByFields[i]);
2062
2063 if ((i + 1) < orderByFields.length) {
2064 if (orderByComparator.isAscending() ^ previous) {
2065 query.append(ORDER_BY_ASC_HAS_NEXT);
2066 }
2067 else {
2068 query.append(ORDER_BY_DESC_HAS_NEXT);
2069 }
2070 }
2071 else {
2072 if (orderByComparator.isAscending() ^ previous) {
2073 query.append(ORDER_BY_ASC);
2074 }
2075 else {
2076 query.append(ORDER_BY_DESC);
2077 }
2078 }
2079 }
2080 }
2081
2082 else {
2083 query.append(PhoneModelImpl.ORDER_BY_JPQL);
2084 }
2085
2086 String sql = query.toString();
2087
2088 Query q = session.createQuery(sql);
2089
2090 q.setFirstResult(0);
2091 q.setMaxResults(2);
2092
2093 QueryPos qPos = QueryPos.getInstance(q);
2094
2095 qPos.add(companyId);
2096
2097 qPos.add(classNameId);
2098
2099 qPos.add(classPK);
2100
2101 if (orderByComparator != null) {
2102 Object[] values = orderByComparator.getOrderByConditionValues(phone);
2103
2104 for (Object value : values) {
2105 qPos.add(value);
2106 }
2107 }
2108
2109 List<Phone> list = q.list();
2110
2111 if (list.size() == 2) {
2112 return list.get(1);
2113 }
2114 else {
2115 return null;
2116 }
2117 }
2118
2119
2129 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
2130 long classPK, boolean primary) throws SystemException {
2131 return findByC_C_C_P(companyId, classNameId, classPK, primary,
2132 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2133 }
2134
2135
2151 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
2152 long classPK, boolean primary, int start, int end)
2153 throws SystemException {
2154 return findByC_C_C_P(companyId, classNameId, classPK, primary, start,
2155 end, null);
2156 }
2157
2158
2175 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
2176 long classPK, boolean primary, int start, int end,
2177 OrderByComparator orderByComparator) throws SystemException {
2178 FinderPath finderPath = null;
2179 Object[] finderArgs = null;
2180
2181 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2182 (orderByComparator == null)) {
2183 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P;
2184 finderArgs = new Object[] { companyId, classNameId, classPK, primary };
2185 }
2186 else {
2187 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C_P;
2188 finderArgs = new Object[] {
2189 companyId, classNameId, classPK, primary,
2190
2191 start, end, orderByComparator
2192 };
2193 }
2194
2195 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
2196 finderArgs, this);
2197
2198 if ((list != null) && !list.isEmpty()) {
2199 for (Phone phone : list) {
2200 if ((companyId != phone.getCompanyId()) ||
2201 (classNameId != phone.getClassNameId()) ||
2202 (classPK != phone.getClassPK()) ||
2203 (primary != phone.getPrimary())) {
2204 list = null;
2205
2206 break;
2207 }
2208 }
2209 }
2210
2211 if (list == null) {
2212 StringBundler query = null;
2213
2214 if (orderByComparator != null) {
2215 query = new StringBundler(6 +
2216 (orderByComparator.getOrderByFields().length * 3));
2217 }
2218 else {
2219 query = new StringBundler(6);
2220 }
2221
2222 query.append(_SQL_SELECT_PHONE_WHERE);
2223
2224 query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2225
2226 query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2227
2228 query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2229
2230 query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2231
2232 if (orderByComparator != null) {
2233 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2234 orderByComparator);
2235 }
2236
2237 else {
2238 query.append(PhoneModelImpl.ORDER_BY_JPQL);
2239 }
2240
2241 String sql = query.toString();
2242
2243 Session session = null;
2244
2245 try {
2246 session = openSession();
2247
2248 Query q = session.createQuery(sql);
2249
2250 QueryPos qPos = QueryPos.getInstance(q);
2251
2252 qPos.add(companyId);
2253
2254 qPos.add(classNameId);
2255
2256 qPos.add(classPK);
2257
2258 qPos.add(primary);
2259
2260 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
2261 }
2262 catch (Exception e) {
2263 throw processException(e);
2264 }
2265 finally {
2266 if (list == null) {
2267 FinderCacheUtil.removeResult(finderPath, finderArgs);
2268 }
2269 else {
2270 cacheResult(list);
2271
2272 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2273 }
2274
2275 closeSession(session);
2276 }
2277 }
2278
2279 return list;
2280 }
2281
2282
2298 public Phone findByC_C_C_P_First(long companyId, long classNameId,
2299 long classPK, boolean primary, OrderByComparator orderByComparator)
2300 throws NoSuchPhoneException, SystemException {
2301 List<Phone> list = findByC_C_C_P(companyId, classNameId, classPK,
2302 primary, 0, 1, orderByComparator);
2303
2304 if (list.isEmpty()) {
2305 StringBundler msg = new StringBundler(10);
2306
2307 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2308
2309 msg.append("companyId=");
2310 msg.append(companyId);
2311
2312 msg.append(", classNameId=");
2313 msg.append(classNameId);
2314
2315 msg.append(", classPK=");
2316 msg.append(classPK);
2317
2318 msg.append(", primary=");
2319 msg.append(primary);
2320
2321 msg.append(StringPool.CLOSE_CURLY_BRACE);
2322
2323 throw new NoSuchPhoneException(msg.toString());
2324 }
2325 else {
2326 return list.get(0);
2327 }
2328 }
2329
2330
2346 public Phone findByC_C_C_P_Last(long companyId, long classNameId,
2347 long classPK, boolean primary, OrderByComparator orderByComparator)
2348 throws NoSuchPhoneException, SystemException {
2349 int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
2350
2351 List<Phone> list = findByC_C_C_P(companyId, classNameId, classPK,
2352 primary, count - 1, count, orderByComparator);
2353
2354 if (list.isEmpty()) {
2355 StringBundler msg = new StringBundler(10);
2356
2357 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2358
2359 msg.append("companyId=");
2360 msg.append(companyId);
2361
2362 msg.append(", classNameId=");
2363 msg.append(classNameId);
2364
2365 msg.append(", classPK=");
2366 msg.append(classPK);
2367
2368 msg.append(", primary=");
2369 msg.append(primary);
2370
2371 msg.append(StringPool.CLOSE_CURLY_BRACE);
2372
2373 throw new NoSuchPhoneException(msg.toString());
2374 }
2375 else {
2376 return list.get(0);
2377 }
2378 }
2379
2380
2397 public Phone[] findByC_C_C_P_PrevAndNext(long phoneId, long companyId,
2398 long classNameId, long classPK, boolean primary,
2399 OrderByComparator orderByComparator)
2400 throws NoSuchPhoneException, SystemException {
2401 Phone phone = findByPrimaryKey(phoneId);
2402
2403 Session session = null;
2404
2405 try {
2406 session = openSession();
2407
2408 Phone[] array = new PhoneImpl[3];
2409
2410 array[0] = getByC_C_C_P_PrevAndNext(session, phone, companyId,
2411 classNameId, classPK, primary, orderByComparator, true);
2412
2413 array[1] = phone;
2414
2415 array[2] = getByC_C_C_P_PrevAndNext(session, phone, companyId,
2416 classNameId, classPK, primary, orderByComparator, false);
2417
2418 return array;
2419 }
2420 catch (Exception e) {
2421 throw processException(e);
2422 }
2423 finally {
2424 closeSession(session);
2425 }
2426 }
2427
2428 protected Phone getByC_C_C_P_PrevAndNext(Session session, Phone phone,
2429 long companyId, long classNameId, long classPK, boolean primary,
2430 OrderByComparator orderByComparator, boolean previous) {
2431 StringBundler query = null;
2432
2433 if (orderByComparator != null) {
2434 query = new StringBundler(6 +
2435 (orderByComparator.getOrderByFields().length * 6));
2436 }
2437 else {
2438 query = new StringBundler(3);
2439 }
2440
2441 query.append(_SQL_SELECT_PHONE_WHERE);
2442
2443 query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2444
2445 query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2446
2447 query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2448
2449 query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2450
2451 if (orderByComparator != null) {
2452 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2453
2454 if (orderByConditionFields.length > 0) {
2455 query.append(WHERE_AND);
2456 }
2457
2458 for (int i = 0; i < orderByConditionFields.length; i++) {
2459 query.append(_ORDER_BY_ENTITY_ALIAS);
2460 query.append(orderByConditionFields[i]);
2461
2462 if ((i + 1) < orderByConditionFields.length) {
2463 if (orderByComparator.isAscending() ^ previous) {
2464 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2465 }
2466 else {
2467 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2468 }
2469 }
2470 else {
2471 if (orderByComparator.isAscending() ^ previous) {
2472 query.append(WHERE_GREATER_THAN);
2473 }
2474 else {
2475 query.append(WHERE_LESSER_THAN);
2476 }
2477 }
2478 }
2479
2480 query.append(ORDER_BY_CLAUSE);
2481
2482 String[] orderByFields = orderByComparator.getOrderByFields();
2483
2484 for (int i = 0; i < orderByFields.length; i++) {
2485 query.append(_ORDER_BY_ENTITY_ALIAS);
2486 query.append(orderByFields[i]);
2487
2488 if ((i + 1) < orderByFields.length) {
2489 if (orderByComparator.isAscending() ^ previous) {
2490 query.append(ORDER_BY_ASC_HAS_NEXT);
2491 }
2492 else {
2493 query.append(ORDER_BY_DESC_HAS_NEXT);
2494 }
2495 }
2496 else {
2497 if (orderByComparator.isAscending() ^ previous) {
2498 query.append(ORDER_BY_ASC);
2499 }
2500 else {
2501 query.append(ORDER_BY_DESC);
2502 }
2503 }
2504 }
2505 }
2506
2507 else {
2508 query.append(PhoneModelImpl.ORDER_BY_JPQL);
2509 }
2510
2511 String sql = query.toString();
2512
2513 Query q = session.createQuery(sql);
2514
2515 q.setFirstResult(0);
2516 q.setMaxResults(2);
2517
2518 QueryPos qPos = QueryPos.getInstance(q);
2519
2520 qPos.add(companyId);
2521
2522 qPos.add(classNameId);
2523
2524 qPos.add(classPK);
2525
2526 qPos.add(primary);
2527
2528 if (orderByComparator != null) {
2529 Object[] values = orderByComparator.getOrderByConditionValues(phone);
2530
2531 for (Object value : values) {
2532 qPos.add(value);
2533 }
2534 }
2535
2536 List<Phone> list = q.list();
2537
2538 if (list.size() == 2) {
2539 return list.get(1);
2540 }
2541 else {
2542 return null;
2543 }
2544 }
2545
2546
2552 public List<Phone> findAll() throws SystemException {
2553 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2554 }
2555
2556
2568 public List<Phone> findAll(int start, int end) throws SystemException {
2569 return findAll(start, end, null);
2570 }
2571
2572
2585 public List<Phone> findAll(int start, int end,
2586 OrderByComparator orderByComparator) throws SystemException {
2587 FinderPath finderPath = null;
2588 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2589
2590 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2591 (orderByComparator == null)) {
2592 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2593 finderArgs = FINDER_ARGS_EMPTY;
2594 }
2595 else {
2596 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2597 finderArgs = new Object[] { start, end, orderByComparator };
2598 }
2599
2600 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
2601 finderArgs, this);
2602
2603 if (list == null) {
2604 StringBundler query = null;
2605 String sql = null;
2606
2607 if (orderByComparator != null) {
2608 query = new StringBundler(2 +
2609 (orderByComparator.getOrderByFields().length * 3));
2610
2611 query.append(_SQL_SELECT_PHONE);
2612
2613 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2614 orderByComparator);
2615
2616 sql = query.toString();
2617 }
2618 else {
2619 sql = _SQL_SELECT_PHONE.concat(PhoneModelImpl.ORDER_BY_JPQL);
2620 }
2621
2622 Session session = null;
2623
2624 try {
2625 session = openSession();
2626
2627 Query q = session.createQuery(sql);
2628
2629 if (orderByComparator == null) {
2630 list = (List<Phone>)QueryUtil.list(q, getDialect(), start,
2631 end, false);
2632
2633 Collections.sort(list);
2634 }
2635 else {
2636 list = (List<Phone>)QueryUtil.list(q, getDialect(), start,
2637 end);
2638 }
2639 }
2640 catch (Exception e) {
2641 throw processException(e);
2642 }
2643 finally {
2644 if (list == null) {
2645 FinderCacheUtil.removeResult(finderPath, finderArgs);
2646 }
2647 else {
2648 cacheResult(list);
2649
2650 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2651 }
2652
2653 closeSession(session);
2654 }
2655 }
2656
2657 return list;
2658 }
2659
2660
2666 public void removeByCompanyId(long companyId) throws SystemException {
2667 for (Phone phone : findByCompanyId(companyId)) {
2668 remove(phone);
2669 }
2670 }
2671
2672
2678 public void removeByUserId(long userId) throws SystemException {
2679 for (Phone phone : findByUserId(userId)) {
2680 remove(phone);
2681 }
2682 }
2683
2684
2691 public void removeByC_C(long companyId, long classNameId)
2692 throws SystemException {
2693 for (Phone phone : findByC_C(companyId, classNameId)) {
2694 remove(phone);
2695 }
2696 }
2697
2698
2706 public void removeByC_C_C(long companyId, long classNameId, long classPK)
2707 throws SystemException {
2708 for (Phone phone : findByC_C_C(companyId, classNameId, classPK)) {
2709 remove(phone);
2710 }
2711 }
2712
2713
2722 public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
2723 boolean primary) throws SystemException {
2724 for (Phone phone : findByC_C_C_P(companyId, classNameId, classPK,
2725 primary)) {
2726 remove(phone);
2727 }
2728 }
2729
2730
2735 public void removeAll() throws SystemException {
2736 for (Phone phone : findAll()) {
2737 remove(phone);
2738 }
2739 }
2740
2741
2748 public int countByCompanyId(long companyId) throws SystemException {
2749 Object[] finderArgs = new Object[] { companyId };
2750
2751 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2752 finderArgs, this);
2753
2754 if (count == null) {
2755 StringBundler query = new StringBundler(2);
2756
2757 query.append(_SQL_COUNT_PHONE_WHERE);
2758
2759 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2760
2761 String sql = query.toString();
2762
2763 Session session = null;
2764
2765 try {
2766 session = openSession();
2767
2768 Query q = session.createQuery(sql);
2769
2770 QueryPos qPos = QueryPos.getInstance(q);
2771
2772 qPos.add(companyId);
2773
2774 count = (Long)q.uniqueResult();
2775 }
2776 catch (Exception e) {
2777 throw processException(e);
2778 }
2779 finally {
2780 if (count == null) {
2781 count = Long.valueOf(0);
2782 }
2783
2784 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2785 finderArgs, count);
2786
2787 closeSession(session);
2788 }
2789 }
2790
2791 return count.intValue();
2792 }
2793
2794
2801 public int countByUserId(long userId) throws SystemException {
2802 Object[] finderArgs = new Object[] { userId };
2803
2804 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2805 finderArgs, this);
2806
2807 if (count == null) {
2808 StringBundler query = new StringBundler(2);
2809
2810 query.append(_SQL_COUNT_PHONE_WHERE);
2811
2812 query.append(_FINDER_COLUMN_USERID_USERID_2);
2813
2814 String sql = query.toString();
2815
2816 Session session = null;
2817
2818 try {
2819 session = openSession();
2820
2821 Query q = session.createQuery(sql);
2822
2823 QueryPos qPos = QueryPos.getInstance(q);
2824
2825 qPos.add(userId);
2826
2827 count = (Long)q.uniqueResult();
2828 }
2829 catch (Exception e) {
2830 throw processException(e);
2831 }
2832 finally {
2833 if (count == null) {
2834 count = Long.valueOf(0);
2835 }
2836
2837 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2838 finderArgs, count);
2839
2840 closeSession(session);
2841 }
2842 }
2843
2844 return count.intValue();
2845 }
2846
2847
2855 public int countByC_C(long companyId, long classNameId)
2856 throws SystemException {
2857 Object[] finderArgs = new Object[] { companyId, classNameId };
2858
2859 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
2860 finderArgs, this);
2861
2862 if (count == null) {
2863 StringBundler query = new StringBundler(3);
2864
2865 query.append(_SQL_COUNT_PHONE_WHERE);
2866
2867 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2868
2869 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2870
2871 String sql = query.toString();
2872
2873 Session session = null;
2874
2875 try {
2876 session = openSession();
2877
2878 Query q = session.createQuery(sql);
2879
2880 QueryPos qPos = QueryPos.getInstance(q);
2881
2882 qPos.add(companyId);
2883
2884 qPos.add(classNameId);
2885
2886 count = (Long)q.uniqueResult();
2887 }
2888 catch (Exception e) {
2889 throw processException(e);
2890 }
2891 finally {
2892 if (count == null) {
2893 count = Long.valueOf(0);
2894 }
2895
2896 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
2897 count);
2898
2899 closeSession(session);
2900 }
2901 }
2902
2903 return count.intValue();
2904 }
2905
2906
2915 public int countByC_C_C(long companyId, long classNameId, long classPK)
2916 throws SystemException {
2917 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2918
2919 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
2920 finderArgs, this);
2921
2922 if (count == null) {
2923 StringBundler query = new StringBundler(4);
2924
2925 query.append(_SQL_COUNT_PHONE_WHERE);
2926
2927 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2928
2929 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2930
2931 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2932
2933 String sql = query.toString();
2934
2935 Session session = null;
2936
2937 try {
2938 session = openSession();
2939
2940 Query q = session.createQuery(sql);
2941
2942 QueryPos qPos = QueryPos.getInstance(q);
2943
2944 qPos.add(companyId);
2945
2946 qPos.add(classNameId);
2947
2948 qPos.add(classPK);
2949
2950 count = (Long)q.uniqueResult();
2951 }
2952 catch (Exception e) {
2953 throw processException(e);
2954 }
2955 finally {
2956 if (count == null) {
2957 count = Long.valueOf(0);
2958 }
2959
2960 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
2961 finderArgs, count);
2962
2963 closeSession(session);
2964 }
2965 }
2966
2967 return count.intValue();
2968 }
2969
2970
2980 public int countByC_C_C_P(long companyId, long classNameId, long classPK,
2981 boolean primary) throws SystemException {
2982 Object[] finderArgs = new Object[] {
2983 companyId, classNameId, classPK, primary
2984 };
2985
2986 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C_P,
2987 finderArgs, this);
2988
2989 if (count == null) {
2990 StringBundler query = new StringBundler(5);
2991
2992 query.append(_SQL_COUNT_PHONE_WHERE);
2993
2994 query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2995
2996 query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2997
2998 query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2999
3000 query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
3001
3002 String sql = query.toString();
3003
3004 Session session = null;
3005
3006 try {
3007 session = openSession();
3008
3009 Query q = session.createQuery(sql);
3010
3011 QueryPos qPos = QueryPos.getInstance(q);
3012
3013 qPos.add(companyId);
3014
3015 qPos.add(classNameId);
3016
3017 qPos.add(classPK);
3018
3019 qPos.add(primary);
3020
3021 count = (Long)q.uniqueResult();
3022 }
3023 catch (Exception e) {
3024 throw processException(e);
3025 }
3026 finally {
3027 if (count == null) {
3028 count = Long.valueOf(0);
3029 }
3030
3031 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C_P,
3032 finderArgs, count);
3033
3034 closeSession(session);
3035 }
3036 }
3037
3038 return count.intValue();
3039 }
3040
3041
3047 public int countAll() throws SystemException {
3048 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3049 FINDER_ARGS_EMPTY, this);
3050
3051 if (count == null) {
3052 Session session = null;
3053
3054 try {
3055 session = openSession();
3056
3057 Query q = session.createQuery(_SQL_COUNT_PHONE);
3058
3059 count = (Long)q.uniqueResult();
3060 }
3061 catch (Exception e) {
3062 throw processException(e);
3063 }
3064 finally {
3065 if (count == null) {
3066 count = Long.valueOf(0);
3067 }
3068
3069 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3070 FINDER_ARGS_EMPTY, count);
3071
3072 closeSession(session);
3073 }
3074 }
3075
3076 return count.intValue();
3077 }
3078
3079
3082 public void afterPropertiesSet() {
3083 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3084 com.liferay.portal.util.PropsUtil.get(
3085 "value.object.listener.com.liferay.portal.model.Phone")));
3086
3087 if (listenerClassNames.length > 0) {
3088 try {
3089 List<ModelListener<Phone>> listenersList = new ArrayList<ModelListener<Phone>>();
3090
3091 for (String listenerClassName : listenerClassNames) {
3092 listenersList.add((ModelListener<Phone>)InstanceFactory.newInstance(
3093 listenerClassName));
3094 }
3095
3096 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3097 }
3098 catch (Exception e) {
3099 _log.error(e);
3100 }
3101 }
3102 }
3103
3104 public void destroy() {
3105 EntityCacheUtil.removeCache(PhoneImpl.class.getName());
3106 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3107 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3108 }
3109
3110 @BeanReference(type = AccountPersistence.class)
3111 protected AccountPersistence accountPersistence;
3112 @BeanReference(type = AddressPersistence.class)
3113 protected AddressPersistence addressPersistence;
3114 @BeanReference(type = BrowserTrackerPersistence.class)
3115 protected BrowserTrackerPersistence browserTrackerPersistence;
3116 @BeanReference(type = ClassNamePersistence.class)
3117 protected ClassNamePersistence classNamePersistence;
3118 @BeanReference(type = ClusterGroupPersistence.class)
3119 protected ClusterGroupPersistence clusterGroupPersistence;
3120 @BeanReference(type = CompanyPersistence.class)
3121 protected CompanyPersistence companyPersistence;
3122 @BeanReference(type = ContactPersistence.class)
3123 protected ContactPersistence contactPersistence;
3124 @BeanReference(type = CountryPersistence.class)
3125 protected CountryPersistence countryPersistence;
3126 @BeanReference(type = EmailAddressPersistence.class)
3127 protected EmailAddressPersistence emailAddressPersistence;
3128 @BeanReference(type = GroupPersistence.class)
3129 protected GroupPersistence groupPersistence;
3130 @BeanReference(type = ImagePersistence.class)
3131 protected ImagePersistence imagePersistence;
3132 @BeanReference(type = LayoutPersistence.class)
3133 protected LayoutPersistence layoutPersistence;
3134 @BeanReference(type = LayoutBranchPersistence.class)
3135 protected LayoutBranchPersistence layoutBranchPersistence;
3136 @BeanReference(type = LayoutPrototypePersistence.class)
3137 protected LayoutPrototypePersistence layoutPrototypePersistence;
3138 @BeanReference(type = LayoutRevisionPersistence.class)
3139 protected LayoutRevisionPersistence layoutRevisionPersistence;
3140 @BeanReference(type = LayoutSetPersistence.class)
3141 protected LayoutSetPersistence layoutSetPersistence;
3142 @BeanReference(type = LayoutSetBranchPersistence.class)
3143 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
3144 @BeanReference(type = LayoutSetPrototypePersistence.class)
3145 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
3146 @BeanReference(type = ListTypePersistence.class)
3147 protected ListTypePersistence listTypePersistence;
3148 @BeanReference(type = LockPersistence.class)
3149 protected LockPersistence lockPersistence;
3150 @BeanReference(type = MembershipRequestPersistence.class)
3151 protected MembershipRequestPersistence membershipRequestPersistence;
3152 @BeanReference(type = OrganizationPersistence.class)
3153 protected OrganizationPersistence organizationPersistence;
3154 @BeanReference(type = OrgGroupPermissionPersistence.class)
3155 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
3156 @BeanReference(type = OrgGroupRolePersistence.class)
3157 protected OrgGroupRolePersistence orgGroupRolePersistence;
3158 @BeanReference(type = OrgLaborPersistence.class)
3159 protected OrgLaborPersistence orgLaborPersistence;
3160 @BeanReference(type = PasswordPolicyPersistence.class)
3161 protected PasswordPolicyPersistence passwordPolicyPersistence;
3162 @BeanReference(type = PasswordPolicyRelPersistence.class)
3163 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
3164 @BeanReference(type = PasswordTrackerPersistence.class)
3165 protected PasswordTrackerPersistence passwordTrackerPersistence;
3166 @BeanReference(type = PermissionPersistence.class)
3167 protected PermissionPersistence permissionPersistence;
3168 @BeanReference(type = PhonePersistence.class)
3169 protected PhonePersistence phonePersistence;
3170 @BeanReference(type = PluginSettingPersistence.class)
3171 protected PluginSettingPersistence pluginSettingPersistence;
3172 @BeanReference(type = PortalPreferencesPersistence.class)
3173 protected PortalPreferencesPersistence portalPreferencesPersistence;
3174 @BeanReference(type = PortletPersistence.class)
3175 protected PortletPersistence portletPersistence;
3176 @BeanReference(type = PortletItemPersistence.class)
3177 protected PortletItemPersistence portletItemPersistence;
3178 @BeanReference(type = PortletPreferencesPersistence.class)
3179 protected PortletPreferencesPersistence portletPreferencesPersistence;
3180 @BeanReference(type = RegionPersistence.class)
3181 protected RegionPersistence regionPersistence;
3182 @BeanReference(type = ReleasePersistence.class)
3183 protected ReleasePersistence releasePersistence;
3184 @BeanReference(type = RepositoryPersistence.class)
3185 protected RepositoryPersistence repositoryPersistence;
3186 @BeanReference(type = RepositoryEntryPersistence.class)
3187 protected RepositoryEntryPersistence repositoryEntryPersistence;
3188 @BeanReference(type = ResourcePersistence.class)
3189 protected ResourcePersistence resourcePersistence;
3190 @BeanReference(type = ResourceActionPersistence.class)
3191 protected ResourceActionPersistence resourceActionPersistence;
3192 @BeanReference(type = ResourceBlockPersistence.class)
3193 protected ResourceBlockPersistence resourceBlockPersistence;
3194 @BeanReference(type = ResourceBlockPermissionPersistence.class)
3195 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
3196 @BeanReference(type = ResourceCodePersistence.class)
3197 protected ResourceCodePersistence resourceCodePersistence;
3198 @BeanReference(type = ResourcePermissionPersistence.class)
3199 protected ResourcePermissionPersistence resourcePermissionPersistence;
3200 @BeanReference(type = ResourceTypePermissionPersistence.class)
3201 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
3202 @BeanReference(type = RolePersistence.class)
3203 protected RolePersistence rolePersistence;
3204 @BeanReference(type = ServiceComponentPersistence.class)
3205 protected ServiceComponentPersistence serviceComponentPersistence;
3206 @BeanReference(type = ShardPersistence.class)
3207 protected ShardPersistence shardPersistence;
3208 @BeanReference(type = SubscriptionPersistence.class)
3209 protected SubscriptionPersistence subscriptionPersistence;
3210 @BeanReference(type = TeamPersistence.class)
3211 protected TeamPersistence teamPersistence;
3212 @BeanReference(type = TicketPersistence.class)
3213 protected TicketPersistence ticketPersistence;
3214 @BeanReference(type = UserPersistence.class)
3215 protected UserPersistence userPersistence;
3216 @BeanReference(type = UserGroupPersistence.class)
3217 protected UserGroupPersistence userGroupPersistence;
3218 @BeanReference(type = UserGroupGroupRolePersistence.class)
3219 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3220 @BeanReference(type = UserGroupRolePersistence.class)
3221 protected UserGroupRolePersistence userGroupRolePersistence;
3222 @BeanReference(type = UserIdMapperPersistence.class)
3223 protected UserIdMapperPersistence userIdMapperPersistence;
3224 @BeanReference(type = UserNotificationEventPersistence.class)
3225 protected UserNotificationEventPersistence userNotificationEventPersistence;
3226 @BeanReference(type = UserTrackerPersistence.class)
3227 protected UserTrackerPersistence userTrackerPersistence;
3228 @BeanReference(type = UserTrackerPathPersistence.class)
3229 protected UserTrackerPathPersistence userTrackerPathPersistence;
3230 @BeanReference(type = VirtualHostPersistence.class)
3231 protected VirtualHostPersistence virtualHostPersistence;
3232 @BeanReference(type = WebDAVPropsPersistence.class)
3233 protected WebDAVPropsPersistence webDAVPropsPersistence;
3234 @BeanReference(type = WebsitePersistence.class)
3235 protected WebsitePersistence websitePersistence;
3236 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3237 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3238 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3239 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3240 private static final String _SQL_SELECT_PHONE = "SELECT phone FROM Phone phone";
3241 private static final String _SQL_SELECT_PHONE_WHERE = "SELECT phone FROM Phone phone WHERE ";
3242 private static final String _SQL_COUNT_PHONE = "SELECT COUNT(phone) FROM Phone phone";
3243 private static final String _SQL_COUNT_PHONE_WHERE = "SELECT COUNT(phone) FROM Phone phone WHERE ";
3244 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "phone.companyId = ?";
3245 private static final String _FINDER_COLUMN_USERID_USERID_2 = "phone.userId = ?";
3246 private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "phone.companyId = ? AND ";
3247 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "phone.classNameId = ?";
3248 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "phone.companyId = ? AND ";
3249 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "phone.classNameId = ? AND ";
3250 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "phone.classPK = ?";
3251 private static final String _FINDER_COLUMN_C_C_C_P_COMPANYID_2 = "phone.companyId = ? AND ";
3252 private static final String _FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2 = "phone.classNameId = ? AND ";
3253 private static final String _FINDER_COLUMN_C_C_C_P_CLASSPK_2 = "phone.classPK = ? AND ";
3254 private static final String _FINDER_COLUMN_C_C_C_P_PRIMARY_2 = "phone.primary = ?";
3255 private static final String _ORDER_BY_ENTITY_ALIAS = "phone.";
3256 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Phone exists with the primary key ";
3257 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Phone exists with the key {";
3258 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3259 private static Log _log = LogFactoryUtil.getLog(PhonePersistenceImpl.class);
3260 private static Phone _nullPhone = new PhoneImpl() {
3261 @Override
3262 public Object clone() {
3263 return this;
3264 }
3265
3266 @Override
3267 public CacheModel<Phone> toCacheModel() {
3268 return _nullPhoneCacheModel;
3269 }
3270 };
3271
3272 private static CacheModel<Phone> _nullPhoneCacheModel = new CacheModel<Phone>() {
3273 public Phone toEntityModel() {
3274 return _nullPhone;
3275 }
3276 };
3277 }