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_WITHOUT_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_WITH_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
266 public Phone create(long phoneId) {
267 Phone phone = new PhoneImpl();
268
269 phone.setNew(true);
270 phone.setPrimaryKey(phoneId);
271
272 return phone;
273 }
274
275
283 @Override
284 public Phone remove(Serializable primaryKey)
285 throws NoSuchModelException, SystemException {
286 return remove(((Long)primaryKey).longValue());
287 }
288
289
297 public Phone remove(long phoneId)
298 throws NoSuchPhoneException, SystemException {
299 Session session = null;
300
301 try {
302 session = openSession();
303
304 Phone phone = (Phone)session.get(PhoneImpl.class,
305 Long.valueOf(phoneId));
306
307 if (phone == null) {
308 if (_log.isWarnEnabled()) {
309 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + phoneId);
310 }
311
312 throw new NoSuchPhoneException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
313 phoneId);
314 }
315
316 return phonePersistence.remove(phone);
317 }
318 catch (NoSuchPhoneException nsee) {
319 throw nsee;
320 }
321 catch (Exception e) {
322 throw processException(e);
323 }
324 finally {
325 closeSession(session);
326 }
327 }
328
329
336 @Override
337 public Phone remove(Phone phone) throws SystemException {
338 return super.remove(phone);
339 }
340
341 @Override
342 protected Phone removeImpl(Phone phone) throws SystemException {
343 phone = toUnwrappedModel(phone);
344
345 Session session = null;
346
347 try {
348 session = openSession();
349
350 BatchSessionUtil.delete(session, phone);
351 }
352 catch (Exception e) {
353 throw processException(e);
354 }
355 finally {
356 closeSession(session);
357 }
358
359 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
360 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
361
362 EntityCacheUtil.removeResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
363 PhoneImpl.class, phone.getPrimaryKey());
364
365 return phone;
366 }
367
368 @Override
369 public Phone updateImpl(com.liferay.portal.model.Phone phone, boolean merge)
370 throws SystemException {
371 phone = toUnwrappedModel(phone);
372
373 boolean isNew = phone.isNew();
374
375 PhoneModelImpl phoneModelImpl = (PhoneModelImpl)phone;
376
377 Session session = null;
378
379 try {
380 session = openSession();
381
382 BatchSessionUtil.update(session, phone, merge);
383
384 phone.setNew(false);
385 }
386 catch (Exception e) {
387 throw processException(e);
388 }
389 finally {
390 closeSession(session);
391 }
392
393 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
394
395 if (isNew || !PhoneModelImpl.COLUMN_BITMASK_ENABLED) {
396 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
397 }
398
399 else {
400 if ((phoneModelImpl.getColumnBitmask() &
401 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
402 Object[] args = new Object[] {
403 Long.valueOf(phoneModelImpl.getOriginalCompanyId())
404 };
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 args = new Object[] { Long.valueOf(phoneModelImpl.getCompanyId()) };
412
413 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
414 args);
415 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
416 args);
417 }
418
419 if ((phoneModelImpl.getColumnBitmask() &
420 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
421 Object[] args = new Object[] {
422 Long.valueOf(phoneModelImpl.getOriginalUserId())
423 };
424
425 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
426 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
427 args);
428
429 args = new Object[] { Long.valueOf(phoneModelImpl.getUserId()) };
430
431 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
432 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
433 args);
434 }
435
436 if ((phoneModelImpl.getColumnBitmask() &
437 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
438 Object[] args = new Object[] {
439 Long.valueOf(phoneModelImpl.getOriginalCompanyId()),
440 Long.valueOf(phoneModelImpl.getOriginalClassNameId())
441 };
442
443 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
444 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
445 args);
446
447 args = new Object[] {
448 Long.valueOf(phoneModelImpl.getCompanyId()),
449 Long.valueOf(phoneModelImpl.getClassNameId())
450 };
451
452 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
453 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
454 args);
455 }
456
457 if ((phoneModelImpl.getColumnBitmask() &
458 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C.getColumnBitmask()) != 0) {
459 Object[] args = new Object[] {
460 Long.valueOf(phoneModelImpl.getOriginalCompanyId()),
461 Long.valueOf(phoneModelImpl.getOriginalClassNameId()),
462 Long.valueOf(phoneModelImpl.getOriginalClassPK())
463 };
464
465 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
466 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
467 args);
468
469 args = new Object[] {
470 Long.valueOf(phoneModelImpl.getCompanyId()),
471 Long.valueOf(phoneModelImpl.getClassNameId()),
472 Long.valueOf(phoneModelImpl.getClassPK())
473 };
474
475 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
476 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
477 args);
478 }
479
480 if ((phoneModelImpl.getColumnBitmask() &
481 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P.getColumnBitmask()) != 0) {
482 Object[] args = new Object[] {
483 Long.valueOf(phoneModelImpl.getOriginalCompanyId()),
484 Long.valueOf(phoneModelImpl.getOriginalClassNameId()),
485 Long.valueOf(phoneModelImpl.getOriginalClassPK()),
486 Boolean.valueOf(phoneModelImpl.getOriginalPrimary())
487 };
488
489 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
490 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
491 args);
492
493 args = new Object[] {
494 Long.valueOf(phoneModelImpl.getCompanyId()),
495 Long.valueOf(phoneModelImpl.getClassNameId()),
496 Long.valueOf(phoneModelImpl.getClassPK()),
497 Boolean.valueOf(phoneModelImpl.getPrimary())
498 };
499
500 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
501 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
502 args);
503 }
504 }
505
506 EntityCacheUtil.putResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
507 PhoneImpl.class, phone.getPrimaryKey(), phone);
508
509 return phone;
510 }
511
512 protected Phone toUnwrappedModel(Phone phone) {
513 if (phone instanceof PhoneImpl) {
514 return phone;
515 }
516
517 PhoneImpl phoneImpl = new PhoneImpl();
518
519 phoneImpl.setNew(phone.isNew());
520 phoneImpl.setPrimaryKey(phone.getPrimaryKey());
521
522 phoneImpl.setPhoneId(phone.getPhoneId());
523 phoneImpl.setCompanyId(phone.getCompanyId());
524 phoneImpl.setUserId(phone.getUserId());
525 phoneImpl.setUserName(phone.getUserName());
526 phoneImpl.setCreateDate(phone.getCreateDate());
527 phoneImpl.setModifiedDate(phone.getModifiedDate());
528 phoneImpl.setClassNameId(phone.getClassNameId());
529 phoneImpl.setClassPK(phone.getClassPK());
530 phoneImpl.setNumber(phone.getNumber());
531 phoneImpl.setExtension(phone.getExtension());
532 phoneImpl.setTypeId(phone.getTypeId());
533 phoneImpl.setPrimary(phone.isPrimary());
534
535 return phoneImpl;
536 }
537
538
546 @Override
547 public Phone findByPrimaryKey(Serializable primaryKey)
548 throws NoSuchModelException, SystemException {
549 return findByPrimaryKey(((Long)primaryKey).longValue());
550 }
551
552
560 public Phone findByPrimaryKey(long phoneId)
561 throws NoSuchPhoneException, SystemException {
562 Phone phone = fetchByPrimaryKey(phoneId);
563
564 if (phone == null) {
565 if (_log.isWarnEnabled()) {
566 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + phoneId);
567 }
568
569 throw new NoSuchPhoneException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
570 phoneId);
571 }
572
573 return phone;
574 }
575
576
583 @Override
584 public Phone fetchByPrimaryKey(Serializable primaryKey)
585 throws SystemException {
586 return fetchByPrimaryKey(((Long)primaryKey).longValue());
587 }
588
589
596 public Phone fetchByPrimaryKey(long phoneId) throws SystemException {
597 Phone phone = (Phone)EntityCacheUtil.getResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
598 PhoneImpl.class, phoneId);
599
600 if (phone == _nullPhone) {
601 return null;
602 }
603
604 if (phone == null) {
605 Session session = null;
606
607 boolean hasException = false;
608
609 try {
610 session = openSession();
611
612 phone = (Phone)session.get(PhoneImpl.class,
613 Long.valueOf(phoneId));
614 }
615 catch (Exception e) {
616 hasException = true;
617
618 throw processException(e);
619 }
620 finally {
621 if (phone != null) {
622 cacheResult(phone);
623 }
624 else if (!hasException) {
625 EntityCacheUtil.putResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
626 PhoneImpl.class, phoneId, _nullPhone);
627 }
628
629 closeSession(session);
630 }
631 }
632
633 return phone;
634 }
635
636
643 public List<Phone> findByCompanyId(long companyId)
644 throws SystemException {
645 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
646 null);
647 }
648
649
662 public List<Phone> findByCompanyId(long companyId, int start, int end)
663 throws SystemException {
664 return findByCompanyId(companyId, start, end, null);
665 }
666
667
681 public List<Phone> findByCompanyId(long companyId, int start, int end,
682 OrderByComparator orderByComparator) throws SystemException {
683 FinderPath finderPath = null;
684 Object[] finderArgs = null;
685
686 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
687 (orderByComparator == null)) {
688 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
689 finderArgs = new Object[] { companyId };
690 }
691 else {
692 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
693 finderArgs = new Object[] { companyId, start, end, orderByComparator };
694 }
695
696 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
697 finderArgs, this);
698
699 if (list == null) {
700 StringBundler query = null;
701
702 if (orderByComparator != null) {
703 query = new StringBundler(3 +
704 (orderByComparator.getOrderByFields().length * 3));
705 }
706 else {
707 query = new StringBundler(3);
708 }
709
710 query.append(_SQL_SELECT_PHONE_WHERE);
711
712 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
713
714 if (orderByComparator != null) {
715 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
716 orderByComparator);
717 }
718
719 else {
720 query.append(PhoneModelImpl.ORDER_BY_JPQL);
721 }
722
723 String sql = query.toString();
724
725 Session session = null;
726
727 try {
728 session = openSession();
729
730 Query q = session.createQuery(sql);
731
732 QueryPos qPos = QueryPos.getInstance(q);
733
734 qPos.add(companyId);
735
736 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
737 }
738 catch (Exception e) {
739 throw processException(e);
740 }
741 finally {
742 if (list == null) {
743 FinderCacheUtil.removeResult(finderPath, finderArgs);
744 }
745 else {
746 cacheResult(list);
747
748 FinderCacheUtil.putResult(finderPath, finderArgs, list);
749 }
750
751 closeSession(session);
752 }
753 }
754
755 return list;
756 }
757
758
771 public Phone findByCompanyId_First(long companyId,
772 OrderByComparator orderByComparator)
773 throws NoSuchPhoneException, SystemException {
774 List<Phone> list = findByCompanyId(companyId, 0, 1, orderByComparator);
775
776 if (list.isEmpty()) {
777 StringBundler msg = new StringBundler(4);
778
779 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
780
781 msg.append("companyId=");
782 msg.append(companyId);
783
784 msg.append(StringPool.CLOSE_CURLY_BRACE);
785
786 throw new NoSuchPhoneException(msg.toString());
787 }
788 else {
789 return list.get(0);
790 }
791 }
792
793
806 public Phone findByCompanyId_Last(long companyId,
807 OrderByComparator orderByComparator)
808 throws NoSuchPhoneException, SystemException {
809 int count = countByCompanyId(companyId);
810
811 List<Phone> list = findByCompanyId(companyId, count - 1, count,
812 orderByComparator);
813
814 if (list.isEmpty()) {
815 StringBundler msg = new StringBundler(4);
816
817 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
818
819 msg.append("companyId=");
820 msg.append(companyId);
821
822 msg.append(StringPool.CLOSE_CURLY_BRACE);
823
824 throw new NoSuchPhoneException(msg.toString());
825 }
826 else {
827 return list.get(0);
828 }
829 }
830
831
845 public Phone[] findByCompanyId_PrevAndNext(long phoneId, long companyId,
846 OrderByComparator orderByComparator)
847 throws NoSuchPhoneException, SystemException {
848 Phone phone = findByPrimaryKey(phoneId);
849
850 Session session = null;
851
852 try {
853 session = openSession();
854
855 Phone[] array = new PhoneImpl[3];
856
857 array[0] = getByCompanyId_PrevAndNext(session, phone, companyId,
858 orderByComparator, true);
859
860 array[1] = phone;
861
862 array[2] = getByCompanyId_PrevAndNext(session, phone, companyId,
863 orderByComparator, false);
864
865 return array;
866 }
867 catch (Exception e) {
868 throw processException(e);
869 }
870 finally {
871 closeSession(session);
872 }
873 }
874
875 protected Phone getByCompanyId_PrevAndNext(Session session, Phone phone,
876 long companyId, OrderByComparator orderByComparator, boolean previous) {
877 StringBundler query = null;
878
879 if (orderByComparator != null) {
880 query = new StringBundler(6 +
881 (orderByComparator.getOrderByFields().length * 6));
882 }
883 else {
884 query = new StringBundler(3);
885 }
886
887 query.append(_SQL_SELECT_PHONE_WHERE);
888
889 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
890
891 if (orderByComparator != null) {
892 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
893
894 if (orderByConditionFields.length > 0) {
895 query.append(WHERE_AND);
896 }
897
898 for (int i = 0; i < orderByConditionFields.length; i++) {
899 query.append(_ORDER_BY_ENTITY_ALIAS);
900 query.append(orderByConditionFields[i]);
901
902 if ((i + 1) < orderByConditionFields.length) {
903 if (orderByComparator.isAscending() ^ previous) {
904 query.append(WHERE_GREATER_THAN_HAS_NEXT);
905 }
906 else {
907 query.append(WHERE_LESSER_THAN_HAS_NEXT);
908 }
909 }
910 else {
911 if (orderByComparator.isAscending() ^ previous) {
912 query.append(WHERE_GREATER_THAN);
913 }
914 else {
915 query.append(WHERE_LESSER_THAN);
916 }
917 }
918 }
919
920 query.append(ORDER_BY_CLAUSE);
921
922 String[] orderByFields = orderByComparator.getOrderByFields();
923
924 for (int i = 0; i < orderByFields.length; i++) {
925 query.append(_ORDER_BY_ENTITY_ALIAS);
926 query.append(orderByFields[i]);
927
928 if ((i + 1) < orderByFields.length) {
929 if (orderByComparator.isAscending() ^ previous) {
930 query.append(ORDER_BY_ASC_HAS_NEXT);
931 }
932 else {
933 query.append(ORDER_BY_DESC_HAS_NEXT);
934 }
935 }
936 else {
937 if (orderByComparator.isAscending() ^ previous) {
938 query.append(ORDER_BY_ASC);
939 }
940 else {
941 query.append(ORDER_BY_DESC);
942 }
943 }
944 }
945 }
946
947 else {
948 query.append(PhoneModelImpl.ORDER_BY_JPQL);
949 }
950
951 String sql = query.toString();
952
953 Query q = session.createQuery(sql);
954
955 q.setFirstResult(0);
956 q.setMaxResults(2);
957
958 QueryPos qPos = QueryPos.getInstance(q);
959
960 qPos.add(companyId);
961
962 if (orderByComparator != null) {
963 Object[] values = orderByComparator.getOrderByConditionValues(phone);
964
965 for (Object value : values) {
966 qPos.add(value);
967 }
968 }
969
970 List<Phone> list = q.list();
971
972 if (list.size() == 2) {
973 return list.get(1);
974 }
975 else {
976 return null;
977 }
978 }
979
980
987 public List<Phone> findByUserId(long userId) throws SystemException {
988 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
989 }
990
991
1004 public List<Phone> findByUserId(long userId, int start, int end)
1005 throws SystemException {
1006 return findByUserId(userId, start, end, null);
1007 }
1008
1009
1023 public List<Phone> findByUserId(long userId, int start, int end,
1024 OrderByComparator orderByComparator) throws SystemException {
1025 FinderPath finderPath = null;
1026 Object[] finderArgs = null;
1027
1028 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1029 (orderByComparator == null)) {
1030 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1031 finderArgs = new Object[] { userId };
1032 }
1033 else {
1034 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1035 finderArgs = new Object[] { userId, start, end, orderByComparator };
1036 }
1037
1038 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
1039 finderArgs, this);
1040
1041 if (list == null) {
1042 StringBundler query = null;
1043
1044 if (orderByComparator != null) {
1045 query = new StringBundler(3 +
1046 (orderByComparator.getOrderByFields().length * 3));
1047 }
1048 else {
1049 query = new StringBundler(3);
1050 }
1051
1052 query.append(_SQL_SELECT_PHONE_WHERE);
1053
1054 query.append(_FINDER_COLUMN_USERID_USERID_2);
1055
1056 if (orderByComparator != null) {
1057 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1058 orderByComparator);
1059 }
1060
1061 else {
1062 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1063 }
1064
1065 String sql = query.toString();
1066
1067 Session session = null;
1068
1069 try {
1070 session = openSession();
1071
1072 Query q = session.createQuery(sql);
1073
1074 QueryPos qPos = QueryPos.getInstance(q);
1075
1076 qPos.add(userId);
1077
1078 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
1079 }
1080 catch (Exception e) {
1081 throw processException(e);
1082 }
1083 finally {
1084 if (list == null) {
1085 FinderCacheUtil.removeResult(finderPath, finderArgs);
1086 }
1087 else {
1088 cacheResult(list);
1089
1090 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1091 }
1092
1093 closeSession(session);
1094 }
1095 }
1096
1097 return list;
1098 }
1099
1100
1113 public Phone findByUserId_First(long userId,
1114 OrderByComparator orderByComparator)
1115 throws NoSuchPhoneException, SystemException {
1116 List<Phone> list = findByUserId(userId, 0, 1, orderByComparator);
1117
1118 if (list.isEmpty()) {
1119 StringBundler msg = new StringBundler(4);
1120
1121 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1122
1123 msg.append("userId=");
1124 msg.append(userId);
1125
1126 msg.append(StringPool.CLOSE_CURLY_BRACE);
1127
1128 throw new NoSuchPhoneException(msg.toString());
1129 }
1130 else {
1131 return list.get(0);
1132 }
1133 }
1134
1135
1148 public Phone findByUserId_Last(long userId,
1149 OrderByComparator orderByComparator)
1150 throws NoSuchPhoneException, SystemException {
1151 int count = countByUserId(userId);
1152
1153 List<Phone> list = findByUserId(userId, count - 1, count,
1154 orderByComparator);
1155
1156 if (list.isEmpty()) {
1157 StringBundler msg = new StringBundler(4);
1158
1159 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1160
1161 msg.append("userId=");
1162 msg.append(userId);
1163
1164 msg.append(StringPool.CLOSE_CURLY_BRACE);
1165
1166 throw new NoSuchPhoneException(msg.toString());
1167 }
1168 else {
1169 return list.get(0);
1170 }
1171 }
1172
1173
1187 public Phone[] findByUserId_PrevAndNext(long phoneId, long userId,
1188 OrderByComparator orderByComparator)
1189 throws NoSuchPhoneException, SystemException {
1190 Phone phone = findByPrimaryKey(phoneId);
1191
1192 Session session = null;
1193
1194 try {
1195 session = openSession();
1196
1197 Phone[] array = new PhoneImpl[3];
1198
1199 array[0] = getByUserId_PrevAndNext(session, phone, userId,
1200 orderByComparator, true);
1201
1202 array[1] = phone;
1203
1204 array[2] = getByUserId_PrevAndNext(session, phone, userId,
1205 orderByComparator, false);
1206
1207 return array;
1208 }
1209 catch (Exception e) {
1210 throw processException(e);
1211 }
1212 finally {
1213 closeSession(session);
1214 }
1215 }
1216
1217 protected Phone getByUserId_PrevAndNext(Session session, Phone phone,
1218 long userId, OrderByComparator orderByComparator, boolean previous) {
1219 StringBundler query = null;
1220
1221 if (orderByComparator != null) {
1222 query = new StringBundler(6 +
1223 (orderByComparator.getOrderByFields().length * 6));
1224 }
1225 else {
1226 query = new StringBundler(3);
1227 }
1228
1229 query.append(_SQL_SELECT_PHONE_WHERE);
1230
1231 query.append(_FINDER_COLUMN_USERID_USERID_2);
1232
1233 if (orderByComparator != null) {
1234 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1235
1236 if (orderByConditionFields.length > 0) {
1237 query.append(WHERE_AND);
1238 }
1239
1240 for (int i = 0; i < orderByConditionFields.length; i++) {
1241 query.append(_ORDER_BY_ENTITY_ALIAS);
1242 query.append(orderByConditionFields[i]);
1243
1244 if ((i + 1) < orderByConditionFields.length) {
1245 if (orderByComparator.isAscending() ^ previous) {
1246 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1247 }
1248 else {
1249 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1250 }
1251 }
1252 else {
1253 if (orderByComparator.isAscending() ^ previous) {
1254 query.append(WHERE_GREATER_THAN);
1255 }
1256 else {
1257 query.append(WHERE_LESSER_THAN);
1258 }
1259 }
1260 }
1261
1262 query.append(ORDER_BY_CLAUSE);
1263
1264 String[] orderByFields = orderByComparator.getOrderByFields();
1265
1266 for (int i = 0; i < orderByFields.length; i++) {
1267 query.append(_ORDER_BY_ENTITY_ALIAS);
1268 query.append(orderByFields[i]);
1269
1270 if ((i + 1) < orderByFields.length) {
1271 if (orderByComparator.isAscending() ^ previous) {
1272 query.append(ORDER_BY_ASC_HAS_NEXT);
1273 }
1274 else {
1275 query.append(ORDER_BY_DESC_HAS_NEXT);
1276 }
1277 }
1278 else {
1279 if (orderByComparator.isAscending() ^ previous) {
1280 query.append(ORDER_BY_ASC);
1281 }
1282 else {
1283 query.append(ORDER_BY_DESC);
1284 }
1285 }
1286 }
1287 }
1288
1289 else {
1290 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1291 }
1292
1293 String sql = query.toString();
1294
1295 Query q = session.createQuery(sql);
1296
1297 q.setFirstResult(0);
1298 q.setMaxResults(2);
1299
1300 QueryPos qPos = QueryPos.getInstance(q);
1301
1302 qPos.add(userId);
1303
1304 if (orderByComparator != null) {
1305 Object[] values = orderByComparator.getOrderByConditionValues(phone);
1306
1307 for (Object value : values) {
1308 qPos.add(value);
1309 }
1310 }
1311
1312 List<Phone> list = q.list();
1313
1314 if (list.size() == 2) {
1315 return list.get(1);
1316 }
1317 else {
1318 return null;
1319 }
1320 }
1321
1322
1330 public List<Phone> findByC_C(long companyId, long classNameId)
1331 throws SystemException {
1332 return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
1333 QueryUtil.ALL_POS, null);
1334 }
1335
1336
1350 public List<Phone> findByC_C(long companyId, long classNameId, int start,
1351 int end) throws SystemException {
1352 return findByC_C(companyId, classNameId, start, end, null);
1353 }
1354
1355
1370 public List<Phone> findByC_C(long companyId, long classNameId, int start,
1371 int end, OrderByComparator orderByComparator) throws SystemException {
1372 FinderPath finderPath = null;
1373 Object[] finderArgs = null;
1374
1375 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1376 (orderByComparator == null)) {
1377 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
1378 finderArgs = new Object[] { companyId, classNameId };
1379 }
1380 else {
1381 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
1382 finderArgs = new Object[] {
1383 companyId, classNameId,
1384
1385 start, end, orderByComparator
1386 };
1387 }
1388
1389 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
1390 finderArgs, this);
1391
1392 if (list == null) {
1393 StringBundler query = null;
1394
1395 if (orderByComparator != null) {
1396 query = new StringBundler(4 +
1397 (orderByComparator.getOrderByFields().length * 3));
1398 }
1399 else {
1400 query = new StringBundler(4);
1401 }
1402
1403 query.append(_SQL_SELECT_PHONE_WHERE);
1404
1405 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1406
1407 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1408
1409 if (orderByComparator != null) {
1410 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1411 orderByComparator);
1412 }
1413
1414 else {
1415 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1416 }
1417
1418 String sql = query.toString();
1419
1420 Session session = null;
1421
1422 try {
1423 session = openSession();
1424
1425 Query q = session.createQuery(sql);
1426
1427 QueryPos qPos = QueryPos.getInstance(q);
1428
1429 qPos.add(companyId);
1430
1431 qPos.add(classNameId);
1432
1433 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
1434 }
1435 catch (Exception e) {
1436 throw processException(e);
1437 }
1438 finally {
1439 if (list == null) {
1440 FinderCacheUtil.removeResult(finderPath, finderArgs);
1441 }
1442 else {
1443 cacheResult(list);
1444
1445 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1446 }
1447
1448 closeSession(session);
1449 }
1450 }
1451
1452 return list;
1453 }
1454
1455
1469 public Phone findByC_C_First(long companyId, long classNameId,
1470 OrderByComparator orderByComparator)
1471 throws NoSuchPhoneException, SystemException {
1472 List<Phone> list = findByC_C(companyId, classNameId, 0, 1,
1473 orderByComparator);
1474
1475 if (list.isEmpty()) {
1476 StringBundler msg = new StringBundler(6);
1477
1478 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1479
1480 msg.append("companyId=");
1481 msg.append(companyId);
1482
1483 msg.append(", classNameId=");
1484 msg.append(classNameId);
1485
1486 msg.append(StringPool.CLOSE_CURLY_BRACE);
1487
1488 throw new NoSuchPhoneException(msg.toString());
1489 }
1490 else {
1491 return list.get(0);
1492 }
1493 }
1494
1495
1509 public Phone findByC_C_Last(long companyId, long classNameId,
1510 OrderByComparator orderByComparator)
1511 throws NoSuchPhoneException, SystemException {
1512 int count = countByC_C(companyId, classNameId);
1513
1514 List<Phone> list = findByC_C(companyId, classNameId, count - 1, count,
1515 orderByComparator);
1516
1517 if (list.isEmpty()) {
1518 StringBundler msg = new StringBundler(6);
1519
1520 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1521
1522 msg.append("companyId=");
1523 msg.append(companyId);
1524
1525 msg.append(", classNameId=");
1526 msg.append(classNameId);
1527
1528 msg.append(StringPool.CLOSE_CURLY_BRACE);
1529
1530 throw new NoSuchPhoneException(msg.toString());
1531 }
1532 else {
1533 return list.get(0);
1534 }
1535 }
1536
1537
1552 public Phone[] findByC_C_PrevAndNext(long phoneId, long companyId,
1553 long classNameId, OrderByComparator orderByComparator)
1554 throws NoSuchPhoneException, SystemException {
1555 Phone phone = findByPrimaryKey(phoneId);
1556
1557 Session session = null;
1558
1559 try {
1560 session = openSession();
1561
1562 Phone[] array = new PhoneImpl[3];
1563
1564 array[0] = getByC_C_PrevAndNext(session, phone, companyId,
1565 classNameId, orderByComparator, true);
1566
1567 array[1] = phone;
1568
1569 array[2] = getByC_C_PrevAndNext(session, phone, companyId,
1570 classNameId, orderByComparator, false);
1571
1572 return array;
1573 }
1574 catch (Exception e) {
1575 throw processException(e);
1576 }
1577 finally {
1578 closeSession(session);
1579 }
1580 }
1581
1582 protected Phone getByC_C_PrevAndNext(Session session, Phone phone,
1583 long companyId, long classNameId, OrderByComparator orderByComparator,
1584 boolean previous) {
1585 StringBundler query = null;
1586
1587 if (orderByComparator != null) {
1588 query = new StringBundler(6 +
1589 (orderByComparator.getOrderByFields().length * 6));
1590 }
1591 else {
1592 query = new StringBundler(3);
1593 }
1594
1595 query.append(_SQL_SELECT_PHONE_WHERE);
1596
1597 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1598
1599 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1600
1601 if (orderByComparator != null) {
1602 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1603
1604 if (orderByConditionFields.length > 0) {
1605 query.append(WHERE_AND);
1606 }
1607
1608 for (int i = 0; i < orderByConditionFields.length; i++) {
1609 query.append(_ORDER_BY_ENTITY_ALIAS);
1610 query.append(orderByConditionFields[i]);
1611
1612 if ((i + 1) < orderByConditionFields.length) {
1613 if (orderByComparator.isAscending() ^ previous) {
1614 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1615 }
1616 else {
1617 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1618 }
1619 }
1620 else {
1621 if (orderByComparator.isAscending() ^ previous) {
1622 query.append(WHERE_GREATER_THAN);
1623 }
1624 else {
1625 query.append(WHERE_LESSER_THAN);
1626 }
1627 }
1628 }
1629
1630 query.append(ORDER_BY_CLAUSE);
1631
1632 String[] orderByFields = orderByComparator.getOrderByFields();
1633
1634 for (int i = 0; i < orderByFields.length; i++) {
1635 query.append(_ORDER_BY_ENTITY_ALIAS);
1636 query.append(orderByFields[i]);
1637
1638 if ((i + 1) < orderByFields.length) {
1639 if (orderByComparator.isAscending() ^ previous) {
1640 query.append(ORDER_BY_ASC_HAS_NEXT);
1641 }
1642 else {
1643 query.append(ORDER_BY_DESC_HAS_NEXT);
1644 }
1645 }
1646 else {
1647 if (orderByComparator.isAscending() ^ previous) {
1648 query.append(ORDER_BY_ASC);
1649 }
1650 else {
1651 query.append(ORDER_BY_DESC);
1652 }
1653 }
1654 }
1655 }
1656
1657 else {
1658 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1659 }
1660
1661 String sql = query.toString();
1662
1663 Query q = session.createQuery(sql);
1664
1665 q.setFirstResult(0);
1666 q.setMaxResults(2);
1667
1668 QueryPos qPos = QueryPos.getInstance(q);
1669
1670 qPos.add(companyId);
1671
1672 qPos.add(classNameId);
1673
1674 if (orderByComparator != null) {
1675 Object[] values = orderByComparator.getOrderByConditionValues(phone);
1676
1677 for (Object value : values) {
1678 qPos.add(value);
1679 }
1680 }
1681
1682 List<Phone> list = q.list();
1683
1684 if (list.size() == 2) {
1685 return list.get(1);
1686 }
1687 else {
1688 return null;
1689 }
1690 }
1691
1692
1701 public List<Phone> findByC_C_C(long companyId, long classNameId,
1702 long classPK) throws SystemException {
1703 return findByC_C_C(companyId, classNameId, classPK, QueryUtil.ALL_POS,
1704 QueryUtil.ALL_POS, null);
1705 }
1706
1707
1722 public List<Phone> findByC_C_C(long companyId, long classNameId,
1723 long classPK, int start, int end) throws SystemException {
1724 return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1725 }
1726
1727
1743 public List<Phone> findByC_C_C(long companyId, long classNameId,
1744 long classPK, int start, int end, OrderByComparator orderByComparator)
1745 throws SystemException {
1746 FinderPath finderPath = null;
1747 Object[] finderArgs = null;
1748
1749 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1750 (orderByComparator == null)) {
1751 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C;
1752 finderArgs = new Object[] { companyId, classNameId, classPK };
1753 }
1754 else {
1755 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C;
1756 finderArgs = new Object[] {
1757 companyId, classNameId, classPK,
1758
1759 start, end, orderByComparator
1760 };
1761 }
1762
1763 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
1764 finderArgs, this);
1765
1766 if (list == null) {
1767 StringBundler query = null;
1768
1769 if (orderByComparator != null) {
1770 query = new StringBundler(5 +
1771 (orderByComparator.getOrderByFields().length * 3));
1772 }
1773 else {
1774 query = new StringBundler(5);
1775 }
1776
1777 query.append(_SQL_SELECT_PHONE_WHERE);
1778
1779 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1780
1781 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1782
1783 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1784
1785 if (orderByComparator != null) {
1786 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1787 orderByComparator);
1788 }
1789
1790 else {
1791 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1792 }
1793
1794 String sql = query.toString();
1795
1796 Session session = null;
1797
1798 try {
1799 session = openSession();
1800
1801 Query q = session.createQuery(sql);
1802
1803 QueryPos qPos = QueryPos.getInstance(q);
1804
1805 qPos.add(companyId);
1806
1807 qPos.add(classNameId);
1808
1809 qPos.add(classPK);
1810
1811 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
1812 }
1813 catch (Exception e) {
1814 throw processException(e);
1815 }
1816 finally {
1817 if (list == null) {
1818 FinderCacheUtil.removeResult(finderPath, finderArgs);
1819 }
1820 else {
1821 cacheResult(list);
1822
1823 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1824 }
1825
1826 closeSession(session);
1827 }
1828 }
1829
1830 return list;
1831 }
1832
1833
1848 public Phone findByC_C_C_First(long companyId, long classNameId,
1849 long classPK, OrderByComparator orderByComparator)
1850 throws NoSuchPhoneException, SystemException {
1851 List<Phone> list = findByC_C_C(companyId, classNameId, classPK, 0, 1,
1852 orderByComparator);
1853
1854 if (list.isEmpty()) {
1855 StringBundler msg = new StringBundler(8);
1856
1857 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1858
1859 msg.append("companyId=");
1860 msg.append(companyId);
1861
1862 msg.append(", classNameId=");
1863 msg.append(classNameId);
1864
1865 msg.append(", classPK=");
1866 msg.append(classPK);
1867
1868 msg.append(StringPool.CLOSE_CURLY_BRACE);
1869
1870 throw new NoSuchPhoneException(msg.toString());
1871 }
1872 else {
1873 return list.get(0);
1874 }
1875 }
1876
1877
1892 public Phone findByC_C_C_Last(long companyId, long classNameId,
1893 long classPK, OrderByComparator orderByComparator)
1894 throws NoSuchPhoneException, SystemException {
1895 int count = countByC_C_C(companyId, classNameId, classPK);
1896
1897 List<Phone> list = findByC_C_C(companyId, classNameId, classPK,
1898 count - 1, count, orderByComparator);
1899
1900 if (list.isEmpty()) {
1901 StringBundler msg = new StringBundler(8);
1902
1903 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1904
1905 msg.append("companyId=");
1906 msg.append(companyId);
1907
1908 msg.append(", classNameId=");
1909 msg.append(classNameId);
1910
1911 msg.append(", classPK=");
1912 msg.append(classPK);
1913
1914 msg.append(StringPool.CLOSE_CURLY_BRACE);
1915
1916 throw new NoSuchPhoneException(msg.toString());
1917 }
1918 else {
1919 return list.get(0);
1920 }
1921 }
1922
1923
1939 public Phone[] findByC_C_C_PrevAndNext(long phoneId, long companyId,
1940 long classNameId, long classPK, OrderByComparator orderByComparator)
1941 throws NoSuchPhoneException, SystemException {
1942 Phone phone = findByPrimaryKey(phoneId);
1943
1944 Session session = null;
1945
1946 try {
1947 session = openSession();
1948
1949 Phone[] array = new PhoneImpl[3];
1950
1951 array[0] = getByC_C_C_PrevAndNext(session, phone, companyId,
1952 classNameId, classPK, orderByComparator, true);
1953
1954 array[1] = phone;
1955
1956 array[2] = getByC_C_C_PrevAndNext(session, phone, companyId,
1957 classNameId, classPK, orderByComparator, false);
1958
1959 return array;
1960 }
1961 catch (Exception e) {
1962 throw processException(e);
1963 }
1964 finally {
1965 closeSession(session);
1966 }
1967 }
1968
1969 protected Phone getByC_C_C_PrevAndNext(Session session, Phone phone,
1970 long companyId, long classNameId, long classPK,
1971 OrderByComparator orderByComparator, boolean previous) {
1972 StringBundler query = null;
1973
1974 if (orderByComparator != null) {
1975 query = new StringBundler(6 +
1976 (orderByComparator.getOrderByFields().length * 6));
1977 }
1978 else {
1979 query = new StringBundler(3);
1980 }
1981
1982 query.append(_SQL_SELECT_PHONE_WHERE);
1983
1984 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1985
1986 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1987
1988 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1989
1990 if (orderByComparator != null) {
1991 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1992
1993 if (orderByConditionFields.length > 0) {
1994 query.append(WHERE_AND);
1995 }
1996
1997 for (int i = 0; i < orderByConditionFields.length; i++) {
1998 query.append(_ORDER_BY_ENTITY_ALIAS);
1999 query.append(orderByConditionFields[i]);
2000
2001 if ((i + 1) < orderByConditionFields.length) {
2002 if (orderByComparator.isAscending() ^ previous) {
2003 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2004 }
2005 else {
2006 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2007 }
2008 }
2009 else {
2010 if (orderByComparator.isAscending() ^ previous) {
2011 query.append(WHERE_GREATER_THAN);
2012 }
2013 else {
2014 query.append(WHERE_LESSER_THAN);
2015 }
2016 }
2017 }
2018
2019 query.append(ORDER_BY_CLAUSE);
2020
2021 String[] orderByFields = orderByComparator.getOrderByFields();
2022
2023 for (int i = 0; i < orderByFields.length; i++) {
2024 query.append(_ORDER_BY_ENTITY_ALIAS);
2025 query.append(orderByFields[i]);
2026
2027 if ((i + 1) < orderByFields.length) {
2028 if (orderByComparator.isAscending() ^ previous) {
2029 query.append(ORDER_BY_ASC_HAS_NEXT);
2030 }
2031 else {
2032 query.append(ORDER_BY_DESC_HAS_NEXT);
2033 }
2034 }
2035 else {
2036 if (orderByComparator.isAscending() ^ previous) {
2037 query.append(ORDER_BY_ASC);
2038 }
2039 else {
2040 query.append(ORDER_BY_DESC);
2041 }
2042 }
2043 }
2044 }
2045
2046 else {
2047 query.append(PhoneModelImpl.ORDER_BY_JPQL);
2048 }
2049
2050 String sql = query.toString();
2051
2052 Query q = session.createQuery(sql);
2053
2054 q.setFirstResult(0);
2055 q.setMaxResults(2);
2056
2057 QueryPos qPos = QueryPos.getInstance(q);
2058
2059 qPos.add(companyId);
2060
2061 qPos.add(classNameId);
2062
2063 qPos.add(classPK);
2064
2065 if (orderByComparator != null) {
2066 Object[] values = orderByComparator.getOrderByConditionValues(phone);
2067
2068 for (Object value : values) {
2069 qPos.add(value);
2070 }
2071 }
2072
2073 List<Phone> list = q.list();
2074
2075 if (list.size() == 2) {
2076 return list.get(1);
2077 }
2078 else {
2079 return null;
2080 }
2081 }
2082
2083
2093 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
2094 long classPK, boolean primary) throws SystemException {
2095 return findByC_C_C_P(companyId, classNameId, classPK, primary,
2096 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2097 }
2098
2099
2115 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
2116 long classPK, boolean primary, int start, int end)
2117 throws SystemException {
2118 return findByC_C_C_P(companyId, classNameId, classPK, primary, start,
2119 end, null);
2120 }
2121
2122
2139 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
2140 long classPK, boolean primary, int start, int end,
2141 OrderByComparator orderByComparator) throws SystemException {
2142 FinderPath finderPath = null;
2143 Object[] finderArgs = null;
2144
2145 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2146 (orderByComparator == null)) {
2147 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P;
2148 finderArgs = new Object[] { companyId, classNameId, classPK, primary };
2149 }
2150 else {
2151 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C_P;
2152 finderArgs = new Object[] {
2153 companyId, classNameId, classPK, primary,
2154
2155 start, end, orderByComparator
2156 };
2157 }
2158
2159 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
2160 finderArgs, this);
2161
2162 if (list == null) {
2163 StringBundler query = null;
2164
2165 if (orderByComparator != null) {
2166 query = new StringBundler(6 +
2167 (orderByComparator.getOrderByFields().length * 3));
2168 }
2169 else {
2170 query = new StringBundler(6);
2171 }
2172
2173 query.append(_SQL_SELECT_PHONE_WHERE);
2174
2175 query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2176
2177 query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2178
2179 query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2180
2181 query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2182
2183 if (orderByComparator != null) {
2184 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2185 orderByComparator);
2186 }
2187
2188 else {
2189 query.append(PhoneModelImpl.ORDER_BY_JPQL);
2190 }
2191
2192 String sql = query.toString();
2193
2194 Session session = null;
2195
2196 try {
2197 session = openSession();
2198
2199 Query q = session.createQuery(sql);
2200
2201 QueryPos qPos = QueryPos.getInstance(q);
2202
2203 qPos.add(companyId);
2204
2205 qPos.add(classNameId);
2206
2207 qPos.add(classPK);
2208
2209 qPos.add(primary);
2210
2211 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
2212 }
2213 catch (Exception e) {
2214 throw processException(e);
2215 }
2216 finally {
2217 if (list == null) {
2218 FinderCacheUtil.removeResult(finderPath, finderArgs);
2219 }
2220 else {
2221 cacheResult(list);
2222
2223 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2224 }
2225
2226 closeSession(session);
2227 }
2228 }
2229
2230 return list;
2231 }
2232
2233
2249 public Phone findByC_C_C_P_First(long companyId, long classNameId,
2250 long classPK, boolean primary, OrderByComparator orderByComparator)
2251 throws NoSuchPhoneException, SystemException {
2252 List<Phone> list = findByC_C_C_P(companyId, classNameId, classPK,
2253 primary, 0, 1, orderByComparator);
2254
2255 if (list.isEmpty()) {
2256 StringBundler msg = new StringBundler(10);
2257
2258 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2259
2260 msg.append("companyId=");
2261 msg.append(companyId);
2262
2263 msg.append(", classNameId=");
2264 msg.append(classNameId);
2265
2266 msg.append(", classPK=");
2267 msg.append(classPK);
2268
2269 msg.append(", primary=");
2270 msg.append(primary);
2271
2272 msg.append(StringPool.CLOSE_CURLY_BRACE);
2273
2274 throw new NoSuchPhoneException(msg.toString());
2275 }
2276 else {
2277 return list.get(0);
2278 }
2279 }
2280
2281
2297 public Phone findByC_C_C_P_Last(long companyId, long classNameId,
2298 long classPK, boolean primary, OrderByComparator orderByComparator)
2299 throws NoSuchPhoneException, SystemException {
2300 int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
2301
2302 List<Phone> list = findByC_C_C_P(companyId, classNameId, classPK,
2303 primary, count - 1, count, orderByComparator);
2304
2305 if (list.isEmpty()) {
2306 StringBundler msg = new StringBundler(10);
2307
2308 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2309
2310 msg.append("companyId=");
2311 msg.append(companyId);
2312
2313 msg.append(", classNameId=");
2314 msg.append(classNameId);
2315
2316 msg.append(", classPK=");
2317 msg.append(classPK);
2318
2319 msg.append(", primary=");
2320 msg.append(primary);
2321
2322 msg.append(StringPool.CLOSE_CURLY_BRACE);
2323
2324 throw new NoSuchPhoneException(msg.toString());
2325 }
2326 else {
2327 return list.get(0);
2328 }
2329 }
2330
2331
2348 public Phone[] findByC_C_C_P_PrevAndNext(long phoneId, long companyId,
2349 long classNameId, long classPK, boolean primary,
2350 OrderByComparator orderByComparator)
2351 throws NoSuchPhoneException, SystemException {
2352 Phone phone = findByPrimaryKey(phoneId);
2353
2354 Session session = null;
2355
2356 try {
2357 session = openSession();
2358
2359 Phone[] array = new PhoneImpl[3];
2360
2361 array[0] = getByC_C_C_P_PrevAndNext(session, phone, companyId,
2362 classNameId, classPK, primary, orderByComparator, true);
2363
2364 array[1] = phone;
2365
2366 array[2] = getByC_C_C_P_PrevAndNext(session, phone, companyId,
2367 classNameId, classPK, primary, orderByComparator, false);
2368
2369 return array;
2370 }
2371 catch (Exception e) {
2372 throw processException(e);
2373 }
2374 finally {
2375 closeSession(session);
2376 }
2377 }
2378
2379 protected Phone getByC_C_C_P_PrevAndNext(Session session, Phone phone,
2380 long companyId, long classNameId, long classPK, boolean primary,
2381 OrderByComparator orderByComparator, boolean previous) {
2382 StringBundler query = null;
2383
2384 if (orderByComparator != null) {
2385 query = new StringBundler(6 +
2386 (orderByComparator.getOrderByFields().length * 6));
2387 }
2388 else {
2389 query = new StringBundler(3);
2390 }
2391
2392 query.append(_SQL_SELECT_PHONE_WHERE);
2393
2394 query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2395
2396 query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2397
2398 query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2399
2400 query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2401
2402 if (orderByComparator != null) {
2403 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2404
2405 if (orderByConditionFields.length > 0) {
2406 query.append(WHERE_AND);
2407 }
2408
2409 for (int i = 0; i < orderByConditionFields.length; i++) {
2410 query.append(_ORDER_BY_ENTITY_ALIAS);
2411 query.append(orderByConditionFields[i]);
2412
2413 if ((i + 1) < orderByConditionFields.length) {
2414 if (orderByComparator.isAscending() ^ previous) {
2415 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2416 }
2417 else {
2418 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2419 }
2420 }
2421 else {
2422 if (orderByComparator.isAscending() ^ previous) {
2423 query.append(WHERE_GREATER_THAN);
2424 }
2425 else {
2426 query.append(WHERE_LESSER_THAN);
2427 }
2428 }
2429 }
2430
2431 query.append(ORDER_BY_CLAUSE);
2432
2433 String[] orderByFields = orderByComparator.getOrderByFields();
2434
2435 for (int i = 0; i < orderByFields.length; i++) {
2436 query.append(_ORDER_BY_ENTITY_ALIAS);
2437 query.append(orderByFields[i]);
2438
2439 if ((i + 1) < orderByFields.length) {
2440 if (orderByComparator.isAscending() ^ previous) {
2441 query.append(ORDER_BY_ASC_HAS_NEXT);
2442 }
2443 else {
2444 query.append(ORDER_BY_DESC_HAS_NEXT);
2445 }
2446 }
2447 else {
2448 if (orderByComparator.isAscending() ^ previous) {
2449 query.append(ORDER_BY_ASC);
2450 }
2451 else {
2452 query.append(ORDER_BY_DESC);
2453 }
2454 }
2455 }
2456 }
2457
2458 else {
2459 query.append(PhoneModelImpl.ORDER_BY_JPQL);
2460 }
2461
2462 String sql = query.toString();
2463
2464 Query q = session.createQuery(sql);
2465
2466 q.setFirstResult(0);
2467 q.setMaxResults(2);
2468
2469 QueryPos qPos = QueryPos.getInstance(q);
2470
2471 qPos.add(companyId);
2472
2473 qPos.add(classNameId);
2474
2475 qPos.add(classPK);
2476
2477 qPos.add(primary);
2478
2479 if (orderByComparator != null) {
2480 Object[] values = orderByComparator.getOrderByConditionValues(phone);
2481
2482 for (Object value : values) {
2483 qPos.add(value);
2484 }
2485 }
2486
2487 List<Phone> list = q.list();
2488
2489 if (list.size() == 2) {
2490 return list.get(1);
2491 }
2492 else {
2493 return null;
2494 }
2495 }
2496
2497
2503 public List<Phone> findAll() throws SystemException {
2504 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2505 }
2506
2507
2519 public List<Phone> findAll(int start, int end) throws SystemException {
2520 return findAll(start, end, null);
2521 }
2522
2523
2536 public List<Phone> findAll(int start, int end,
2537 OrderByComparator orderByComparator) throws SystemException {
2538 FinderPath finderPath = null;
2539 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2540
2541 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2542 (orderByComparator == null)) {
2543 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2544 finderArgs = FINDER_ARGS_EMPTY;
2545 }
2546 else {
2547 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2548 finderArgs = new Object[] { start, end, orderByComparator };
2549 }
2550
2551 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
2552 finderArgs, this);
2553
2554 if (list == null) {
2555 StringBundler query = null;
2556 String sql = null;
2557
2558 if (orderByComparator != null) {
2559 query = new StringBundler(2 +
2560 (orderByComparator.getOrderByFields().length * 3));
2561
2562 query.append(_SQL_SELECT_PHONE);
2563
2564 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2565 orderByComparator);
2566
2567 sql = query.toString();
2568 }
2569 else {
2570 sql = _SQL_SELECT_PHONE.concat(PhoneModelImpl.ORDER_BY_JPQL);
2571 }
2572
2573 Session session = null;
2574
2575 try {
2576 session = openSession();
2577
2578 Query q = session.createQuery(sql);
2579
2580 if (orderByComparator == null) {
2581 list = (List<Phone>)QueryUtil.list(q, getDialect(), start,
2582 end, false);
2583
2584 Collections.sort(list);
2585 }
2586 else {
2587 list = (List<Phone>)QueryUtil.list(q, getDialect(), start,
2588 end);
2589 }
2590 }
2591 catch (Exception e) {
2592 throw processException(e);
2593 }
2594 finally {
2595 if (list == null) {
2596 FinderCacheUtil.removeResult(finderPath, finderArgs);
2597 }
2598 else {
2599 cacheResult(list);
2600
2601 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2602 }
2603
2604 closeSession(session);
2605 }
2606 }
2607
2608 return list;
2609 }
2610
2611
2617 public void removeByCompanyId(long companyId) throws SystemException {
2618 for (Phone phone : findByCompanyId(companyId)) {
2619 phonePersistence.remove(phone);
2620 }
2621 }
2622
2623
2629 public void removeByUserId(long userId) throws SystemException {
2630 for (Phone phone : findByUserId(userId)) {
2631 phonePersistence.remove(phone);
2632 }
2633 }
2634
2635
2642 public void removeByC_C(long companyId, long classNameId)
2643 throws SystemException {
2644 for (Phone phone : findByC_C(companyId, classNameId)) {
2645 phonePersistence.remove(phone);
2646 }
2647 }
2648
2649
2657 public void removeByC_C_C(long companyId, long classNameId, long classPK)
2658 throws SystemException {
2659 for (Phone phone : findByC_C_C(companyId, classNameId, classPK)) {
2660 phonePersistence.remove(phone);
2661 }
2662 }
2663
2664
2673 public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
2674 boolean primary) throws SystemException {
2675 for (Phone phone : findByC_C_C_P(companyId, classNameId, classPK,
2676 primary)) {
2677 phonePersistence.remove(phone);
2678 }
2679 }
2680
2681
2686 public void removeAll() throws SystemException {
2687 for (Phone phone : findAll()) {
2688 phonePersistence.remove(phone);
2689 }
2690 }
2691
2692
2699 public int countByCompanyId(long companyId) throws SystemException {
2700 Object[] finderArgs = new Object[] { companyId };
2701
2702 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2703 finderArgs, this);
2704
2705 if (count == null) {
2706 StringBundler query = new StringBundler(2);
2707
2708 query.append(_SQL_COUNT_PHONE_WHERE);
2709
2710 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2711
2712 String sql = query.toString();
2713
2714 Session session = null;
2715
2716 try {
2717 session = openSession();
2718
2719 Query q = session.createQuery(sql);
2720
2721 QueryPos qPos = QueryPos.getInstance(q);
2722
2723 qPos.add(companyId);
2724
2725 count = (Long)q.uniqueResult();
2726 }
2727 catch (Exception e) {
2728 throw processException(e);
2729 }
2730 finally {
2731 if (count == null) {
2732 count = Long.valueOf(0);
2733 }
2734
2735 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2736 finderArgs, count);
2737
2738 closeSession(session);
2739 }
2740 }
2741
2742 return count.intValue();
2743 }
2744
2745
2752 public int countByUserId(long userId) throws SystemException {
2753 Object[] finderArgs = new Object[] { userId };
2754
2755 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2756 finderArgs, this);
2757
2758 if (count == null) {
2759 StringBundler query = new StringBundler(2);
2760
2761 query.append(_SQL_COUNT_PHONE_WHERE);
2762
2763 query.append(_FINDER_COLUMN_USERID_USERID_2);
2764
2765 String sql = query.toString();
2766
2767 Session session = null;
2768
2769 try {
2770 session = openSession();
2771
2772 Query q = session.createQuery(sql);
2773
2774 QueryPos qPos = QueryPos.getInstance(q);
2775
2776 qPos.add(userId);
2777
2778 count = (Long)q.uniqueResult();
2779 }
2780 catch (Exception e) {
2781 throw processException(e);
2782 }
2783 finally {
2784 if (count == null) {
2785 count = Long.valueOf(0);
2786 }
2787
2788 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2789 finderArgs, count);
2790
2791 closeSession(session);
2792 }
2793 }
2794
2795 return count.intValue();
2796 }
2797
2798
2806 public int countByC_C(long companyId, long classNameId)
2807 throws SystemException {
2808 Object[] finderArgs = new Object[] { companyId, classNameId };
2809
2810 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
2811 finderArgs, this);
2812
2813 if (count == null) {
2814 StringBundler query = new StringBundler(3);
2815
2816 query.append(_SQL_COUNT_PHONE_WHERE);
2817
2818 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2819
2820 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2821
2822 String sql = query.toString();
2823
2824 Session session = null;
2825
2826 try {
2827 session = openSession();
2828
2829 Query q = session.createQuery(sql);
2830
2831 QueryPos qPos = QueryPos.getInstance(q);
2832
2833 qPos.add(companyId);
2834
2835 qPos.add(classNameId);
2836
2837 count = (Long)q.uniqueResult();
2838 }
2839 catch (Exception e) {
2840 throw processException(e);
2841 }
2842 finally {
2843 if (count == null) {
2844 count = Long.valueOf(0);
2845 }
2846
2847 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
2848 count);
2849
2850 closeSession(session);
2851 }
2852 }
2853
2854 return count.intValue();
2855 }
2856
2857
2866 public int countByC_C_C(long companyId, long classNameId, long classPK)
2867 throws SystemException {
2868 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2869
2870 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
2871 finderArgs, this);
2872
2873 if (count == null) {
2874 StringBundler query = new StringBundler(4);
2875
2876 query.append(_SQL_COUNT_PHONE_WHERE);
2877
2878 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2879
2880 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2881
2882 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2883
2884 String sql = query.toString();
2885
2886 Session session = null;
2887
2888 try {
2889 session = openSession();
2890
2891 Query q = session.createQuery(sql);
2892
2893 QueryPos qPos = QueryPos.getInstance(q);
2894
2895 qPos.add(companyId);
2896
2897 qPos.add(classNameId);
2898
2899 qPos.add(classPK);
2900
2901 count = (Long)q.uniqueResult();
2902 }
2903 catch (Exception e) {
2904 throw processException(e);
2905 }
2906 finally {
2907 if (count == null) {
2908 count = Long.valueOf(0);
2909 }
2910
2911 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
2912 finderArgs, count);
2913
2914 closeSession(session);
2915 }
2916 }
2917
2918 return count.intValue();
2919 }
2920
2921
2931 public int countByC_C_C_P(long companyId, long classNameId, long classPK,
2932 boolean primary) throws SystemException {
2933 Object[] finderArgs = new Object[] {
2934 companyId, classNameId, classPK, primary
2935 };
2936
2937 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C_P,
2938 finderArgs, this);
2939
2940 if (count == null) {
2941 StringBundler query = new StringBundler(5);
2942
2943 query.append(_SQL_COUNT_PHONE_WHERE);
2944
2945 query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2946
2947 query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2948
2949 query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2950
2951 query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2952
2953 String sql = query.toString();
2954
2955 Session session = null;
2956
2957 try {
2958 session = openSession();
2959
2960 Query q = session.createQuery(sql);
2961
2962 QueryPos qPos = QueryPos.getInstance(q);
2963
2964 qPos.add(companyId);
2965
2966 qPos.add(classNameId);
2967
2968 qPos.add(classPK);
2969
2970 qPos.add(primary);
2971
2972 count = (Long)q.uniqueResult();
2973 }
2974 catch (Exception e) {
2975 throw processException(e);
2976 }
2977 finally {
2978 if (count == null) {
2979 count = Long.valueOf(0);
2980 }
2981
2982 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C_P,
2983 finderArgs, count);
2984
2985 closeSession(session);
2986 }
2987 }
2988
2989 return count.intValue();
2990 }
2991
2992
2998 public int countAll() throws SystemException {
2999 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3000 FINDER_ARGS_EMPTY, this);
3001
3002 if (count == null) {
3003 Session session = null;
3004
3005 try {
3006 session = openSession();
3007
3008 Query q = session.createQuery(_SQL_COUNT_PHONE);
3009
3010 count = (Long)q.uniqueResult();
3011 }
3012 catch (Exception e) {
3013 throw processException(e);
3014 }
3015 finally {
3016 if (count == null) {
3017 count = Long.valueOf(0);
3018 }
3019
3020 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3021 FINDER_ARGS_EMPTY, count);
3022
3023 closeSession(session);
3024 }
3025 }
3026
3027 return count.intValue();
3028 }
3029
3030
3033 public void afterPropertiesSet() {
3034 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3035 com.liferay.portal.util.PropsUtil.get(
3036 "value.object.listener.com.liferay.portal.model.Phone")));
3037
3038 if (listenerClassNames.length > 0) {
3039 try {
3040 List<ModelListener<Phone>> listenersList = new ArrayList<ModelListener<Phone>>();
3041
3042 for (String listenerClassName : listenerClassNames) {
3043 listenersList.add((ModelListener<Phone>)InstanceFactory.newInstance(
3044 listenerClassName));
3045 }
3046
3047 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3048 }
3049 catch (Exception e) {
3050 _log.error(e);
3051 }
3052 }
3053 }
3054
3055 public void destroy() {
3056 EntityCacheUtil.removeCache(PhoneImpl.class.getName());
3057 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3058 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3059 }
3060
3061 @BeanReference(type = AccountPersistence.class)
3062 protected AccountPersistence accountPersistence;
3063 @BeanReference(type = AddressPersistence.class)
3064 protected AddressPersistence addressPersistence;
3065 @BeanReference(type = BrowserTrackerPersistence.class)
3066 protected BrowserTrackerPersistence browserTrackerPersistence;
3067 @BeanReference(type = ClassNamePersistence.class)
3068 protected ClassNamePersistence classNamePersistence;
3069 @BeanReference(type = ClusterGroupPersistence.class)
3070 protected ClusterGroupPersistence clusterGroupPersistence;
3071 @BeanReference(type = CompanyPersistence.class)
3072 protected CompanyPersistence companyPersistence;
3073 @BeanReference(type = ContactPersistence.class)
3074 protected ContactPersistence contactPersistence;
3075 @BeanReference(type = CountryPersistence.class)
3076 protected CountryPersistence countryPersistence;
3077 @BeanReference(type = EmailAddressPersistence.class)
3078 protected EmailAddressPersistence emailAddressPersistence;
3079 @BeanReference(type = GroupPersistence.class)
3080 protected GroupPersistence groupPersistence;
3081 @BeanReference(type = ImagePersistence.class)
3082 protected ImagePersistence imagePersistence;
3083 @BeanReference(type = LayoutPersistence.class)
3084 protected LayoutPersistence layoutPersistence;
3085 @BeanReference(type = LayoutBranchPersistence.class)
3086 protected LayoutBranchPersistence layoutBranchPersistence;
3087 @BeanReference(type = LayoutPrototypePersistence.class)
3088 protected LayoutPrototypePersistence layoutPrototypePersistence;
3089 @BeanReference(type = LayoutRevisionPersistence.class)
3090 protected LayoutRevisionPersistence layoutRevisionPersistence;
3091 @BeanReference(type = LayoutSetPersistence.class)
3092 protected LayoutSetPersistence layoutSetPersistence;
3093 @BeanReference(type = LayoutSetBranchPersistence.class)
3094 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
3095 @BeanReference(type = LayoutSetPrototypePersistence.class)
3096 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
3097 @BeanReference(type = ListTypePersistence.class)
3098 protected ListTypePersistence listTypePersistence;
3099 @BeanReference(type = LockPersistence.class)
3100 protected LockPersistence lockPersistence;
3101 @BeanReference(type = MembershipRequestPersistence.class)
3102 protected MembershipRequestPersistence membershipRequestPersistence;
3103 @BeanReference(type = OrganizationPersistence.class)
3104 protected OrganizationPersistence organizationPersistence;
3105 @BeanReference(type = OrgGroupPermissionPersistence.class)
3106 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
3107 @BeanReference(type = OrgGroupRolePersistence.class)
3108 protected OrgGroupRolePersistence orgGroupRolePersistence;
3109 @BeanReference(type = OrgLaborPersistence.class)
3110 protected OrgLaborPersistence orgLaborPersistence;
3111 @BeanReference(type = PasswordPolicyPersistence.class)
3112 protected PasswordPolicyPersistence passwordPolicyPersistence;
3113 @BeanReference(type = PasswordPolicyRelPersistence.class)
3114 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
3115 @BeanReference(type = PasswordTrackerPersistence.class)
3116 protected PasswordTrackerPersistence passwordTrackerPersistence;
3117 @BeanReference(type = PermissionPersistence.class)
3118 protected PermissionPersistence permissionPersistence;
3119 @BeanReference(type = PhonePersistence.class)
3120 protected PhonePersistence phonePersistence;
3121 @BeanReference(type = PluginSettingPersistence.class)
3122 protected PluginSettingPersistence pluginSettingPersistence;
3123 @BeanReference(type = PortalPreferencesPersistence.class)
3124 protected PortalPreferencesPersistence portalPreferencesPersistence;
3125 @BeanReference(type = PortletPersistence.class)
3126 protected PortletPersistence portletPersistence;
3127 @BeanReference(type = PortletItemPersistence.class)
3128 protected PortletItemPersistence portletItemPersistence;
3129 @BeanReference(type = PortletPreferencesPersistence.class)
3130 protected PortletPreferencesPersistence portletPreferencesPersistence;
3131 @BeanReference(type = RegionPersistence.class)
3132 protected RegionPersistence regionPersistence;
3133 @BeanReference(type = ReleasePersistence.class)
3134 protected ReleasePersistence releasePersistence;
3135 @BeanReference(type = RepositoryPersistence.class)
3136 protected RepositoryPersistence repositoryPersistence;
3137 @BeanReference(type = RepositoryEntryPersistence.class)
3138 protected RepositoryEntryPersistence repositoryEntryPersistence;
3139 @BeanReference(type = ResourcePersistence.class)
3140 protected ResourcePersistence resourcePersistence;
3141 @BeanReference(type = ResourceActionPersistence.class)
3142 protected ResourceActionPersistence resourceActionPersistence;
3143 @BeanReference(type = ResourceBlockPersistence.class)
3144 protected ResourceBlockPersistence resourceBlockPersistence;
3145 @BeanReference(type = ResourceBlockPermissionPersistence.class)
3146 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
3147 @BeanReference(type = ResourceCodePersistence.class)
3148 protected ResourceCodePersistence resourceCodePersistence;
3149 @BeanReference(type = ResourcePermissionPersistence.class)
3150 protected ResourcePermissionPersistence resourcePermissionPersistence;
3151 @BeanReference(type = ResourceTypePermissionPersistence.class)
3152 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
3153 @BeanReference(type = RolePersistence.class)
3154 protected RolePersistence rolePersistence;
3155 @BeanReference(type = ServiceComponentPersistence.class)
3156 protected ServiceComponentPersistence serviceComponentPersistence;
3157 @BeanReference(type = ShardPersistence.class)
3158 protected ShardPersistence shardPersistence;
3159 @BeanReference(type = SubscriptionPersistence.class)
3160 protected SubscriptionPersistence subscriptionPersistence;
3161 @BeanReference(type = TeamPersistence.class)
3162 protected TeamPersistence teamPersistence;
3163 @BeanReference(type = TicketPersistence.class)
3164 protected TicketPersistence ticketPersistence;
3165 @BeanReference(type = UserPersistence.class)
3166 protected UserPersistence userPersistence;
3167 @BeanReference(type = UserGroupPersistence.class)
3168 protected UserGroupPersistence userGroupPersistence;
3169 @BeanReference(type = UserGroupGroupRolePersistence.class)
3170 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3171 @BeanReference(type = UserGroupRolePersistence.class)
3172 protected UserGroupRolePersistence userGroupRolePersistence;
3173 @BeanReference(type = UserIdMapperPersistence.class)
3174 protected UserIdMapperPersistence userIdMapperPersistence;
3175 @BeanReference(type = UserNotificationEventPersistence.class)
3176 protected UserNotificationEventPersistence userNotificationEventPersistence;
3177 @BeanReference(type = UserTrackerPersistence.class)
3178 protected UserTrackerPersistence userTrackerPersistence;
3179 @BeanReference(type = UserTrackerPathPersistence.class)
3180 protected UserTrackerPathPersistence userTrackerPathPersistence;
3181 @BeanReference(type = VirtualHostPersistence.class)
3182 protected VirtualHostPersistence virtualHostPersistence;
3183 @BeanReference(type = WebDAVPropsPersistence.class)
3184 protected WebDAVPropsPersistence webDAVPropsPersistence;
3185 @BeanReference(type = WebsitePersistence.class)
3186 protected WebsitePersistence websitePersistence;
3187 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3188 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3189 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3190 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3191 private static final String _SQL_SELECT_PHONE = "SELECT phone FROM Phone phone";
3192 private static final String _SQL_SELECT_PHONE_WHERE = "SELECT phone FROM Phone phone WHERE ";
3193 private static final String _SQL_COUNT_PHONE = "SELECT COUNT(phone) FROM Phone phone";
3194 private static final String _SQL_COUNT_PHONE_WHERE = "SELECT COUNT(phone) FROM Phone phone WHERE ";
3195 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "phone.companyId = ?";
3196 private static final String _FINDER_COLUMN_USERID_USERID_2 = "phone.userId = ?";
3197 private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "phone.companyId = ? AND ";
3198 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "phone.classNameId = ?";
3199 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "phone.companyId = ? AND ";
3200 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "phone.classNameId = ? AND ";
3201 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "phone.classPK = ?";
3202 private static final String _FINDER_COLUMN_C_C_C_P_COMPANYID_2 = "phone.companyId = ? AND ";
3203 private static final String _FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2 = "phone.classNameId = ? AND ";
3204 private static final String _FINDER_COLUMN_C_C_C_P_CLASSPK_2 = "phone.classPK = ? AND ";
3205 private static final String _FINDER_COLUMN_C_C_C_P_PRIMARY_2 = "phone.primary = ?";
3206 private static final String _ORDER_BY_ENTITY_ALIAS = "phone.";
3207 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Phone exists with the primary key ";
3208 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Phone exists with the key {";
3209 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3210 private static Log _log = LogFactoryUtil.getLog(PhonePersistenceImpl.class);
3211 private static Phone _nullPhone = new PhoneImpl() {
3212 @Override
3213 public Object clone() {
3214 return this;
3215 }
3216
3217 @Override
3218 public CacheModel<Phone> toCacheModel() {
3219 return _nullPhoneCacheModel;
3220 }
3221 };
3222
3223 private static CacheModel<Phone> _nullPhoneCacheModel = new CacheModel<Phone>() {
3224 public Phone toEntityModel() {
3225 return _nullPhone;
3226 }
3227 };
3228 }