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 @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
393 else {
394 if ((phoneModelImpl.getColumnBitmask() &
395 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
396 Object[] args = new Object[] {
397 Long.valueOf(phoneModelImpl.getOriginalCompanyId())
398 };
399
400 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
401 args);
402 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
403 args);
404
405 args = new Object[] { Long.valueOf(phoneModelImpl.getCompanyId()) };
406
407 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
408 args);
409 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
410 args);
411 }
412
413 if ((phoneModelImpl.getColumnBitmask() &
414 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
415 Object[] args = new Object[] {
416 Long.valueOf(phoneModelImpl.getOriginalUserId())
417 };
418
419 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
420 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
421 args);
422
423 args = new Object[] { Long.valueOf(phoneModelImpl.getUserId()) };
424
425 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
426 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
427 args);
428 }
429
430 if ((phoneModelImpl.getColumnBitmask() &
431 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
432 Object[] args = new Object[] {
433 Long.valueOf(phoneModelImpl.getOriginalCompanyId()),
434 Long.valueOf(phoneModelImpl.getOriginalClassNameId())
435 };
436
437 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
438 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
439 args);
440
441 args = new Object[] {
442 Long.valueOf(phoneModelImpl.getCompanyId()),
443 Long.valueOf(phoneModelImpl.getClassNameId())
444 };
445
446 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
447 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
448 args);
449 }
450
451 if ((phoneModelImpl.getColumnBitmask() &
452 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C.getColumnBitmask()) != 0) {
453 Object[] args = new Object[] {
454 Long.valueOf(phoneModelImpl.getOriginalCompanyId()),
455 Long.valueOf(phoneModelImpl.getOriginalClassNameId()),
456 Long.valueOf(phoneModelImpl.getOriginalClassPK())
457 };
458
459 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
460 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
461 args);
462
463 args = new Object[] {
464 Long.valueOf(phoneModelImpl.getCompanyId()),
465 Long.valueOf(phoneModelImpl.getClassNameId()),
466 Long.valueOf(phoneModelImpl.getClassPK())
467 };
468
469 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
470 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
471 args);
472 }
473
474 if ((phoneModelImpl.getColumnBitmask() &
475 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P.getColumnBitmask()) != 0) {
476 Object[] args = new Object[] {
477 Long.valueOf(phoneModelImpl.getOriginalCompanyId()),
478 Long.valueOf(phoneModelImpl.getOriginalClassNameId()),
479 Long.valueOf(phoneModelImpl.getOriginalClassPK()),
480 Boolean.valueOf(phoneModelImpl.getOriginalPrimary())
481 };
482
483 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
484 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
485 args);
486
487 args = new Object[] {
488 Long.valueOf(phoneModelImpl.getCompanyId()),
489 Long.valueOf(phoneModelImpl.getClassNameId()),
490 Long.valueOf(phoneModelImpl.getClassPK()),
491 Boolean.valueOf(phoneModelImpl.getPrimary())
492 };
493
494 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
495 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
496 args);
497 }
498 }
499
500 EntityCacheUtil.putResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
501 PhoneImpl.class, phone.getPrimaryKey(), phone);
502
503 return phone;
504 }
505
506 protected Phone toUnwrappedModel(Phone phone) {
507 if (phone instanceof PhoneImpl) {
508 return phone;
509 }
510
511 PhoneImpl phoneImpl = new PhoneImpl();
512
513 phoneImpl.setNew(phone.isNew());
514 phoneImpl.setPrimaryKey(phone.getPrimaryKey());
515
516 phoneImpl.setPhoneId(phone.getPhoneId());
517 phoneImpl.setCompanyId(phone.getCompanyId());
518 phoneImpl.setUserId(phone.getUserId());
519 phoneImpl.setUserName(phone.getUserName());
520 phoneImpl.setCreateDate(phone.getCreateDate());
521 phoneImpl.setModifiedDate(phone.getModifiedDate());
522 phoneImpl.setClassNameId(phone.getClassNameId());
523 phoneImpl.setClassPK(phone.getClassPK());
524 phoneImpl.setNumber(phone.getNumber());
525 phoneImpl.setExtension(phone.getExtension());
526 phoneImpl.setTypeId(phone.getTypeId());
527 phoneImpl.setPrimary(phone.isPrimary());
528
529 return phoneImpl;
530 }
531
532
540 @Override
541 public Phone findByPrimaryKey(Serializable primaryKey)
542 throws NoSuchModelException, SystemException {
543 return findByPrimaryKey(((Long)primaryKey).longValue());
544 }
545
546
554 public Phone findByPrimaryKey(long phoneId)
555 throws NoSuchPhoneException, SystemException {
556 Phone phone = fetchByPrimaryKey(phoneId);
557
558 if (phone == null) {
559 if (_log.isWarnEnabled()) {
560 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + phoneId);
561 }
562
563 throw new NoSuchPhoneException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
564 phoneId);
565 }
566
567 return phone;
568 }
569
570
577 @Override
578 public Phone fetchByPrimaryKey(Serializable primaryKey)
579 throws SystemException {
580 return fetchByPrimaryKey(((Long)primaryKey).longValue());
581 }
582
583
590 public Phone fetchByPrimaryKey(long phoneId) throws SystemException {
591 Phone phone = (Phone)EntityCacheUtil.getResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
592 PhoneImpl.class, phoneId);
593
594 if (phone == _nullPhone) {
595 return null;
596 }
597
598 if (phone == null) {
599 Session session = null;
600
601 boolean hasException = false;
602
603 try {
604 session = openSession();
605
606 phone = (Phone)session.get(PhoneImpl.class,
607 Long.valueOf(phoneId));
608 }
609 catch (Exception e) {
610 hasException = true;
611
612 throw processException(e);
613 }
614 finally {
615 if (phone != null) {
616 cacheResult(phone);
617 }
618 else if (!hasException) {
619 EntityCacheUtil.putResult(PhoneModelImpl.ENTITY_CACHE_ENABLED,
620 PhoneImpl.class, phoneId, _nullPhone);
621 }
622
623 closeSession(session);
624 }
625 }
626
627 return phone;
628 }
629
630
637 public List<Phone> findByCompanyId(long companyId)
638 throws SystemException {
639 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
640 null);
641 }
642
643
656 public List<Phone> findByCompanyId(long companyId, int start, int end)
657 throws SystemException {
658 return findByCompanyId(companyId, start, end, null);
659 }
660
661
675 public List<Phone> findByCompanyId(long companyId, int start, int end,
676 OrderByComparator orderByComparator) throws SystemException {
677 FinderPath finderPath = null;
678 Object[] finderArgs = null;
679
680 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
681 (orderByComparator == null)) {
682 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
683 finderArgs = new Object[] { companyId };
684 }
685 else {
686 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
687 finderArgs = new Object[] { companyId, start, end, orderByComparator };
688 }
689
690 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
691 finderArgs, this);
692
693 if (list == null) {
694 StringBundler query = null;
695
696 if (orderByComparator != null) {
697 query = new StringBundler(3 +
698 (orderByComparator.getOrderByFields().length * 3));
699 }
700 else {
701 query = new StringBundler(3);
702 }
703
704 query.append(_SQL_SELECT_PHONE_WHERE);
705
706 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
707
708 if (orderByComparator != null) {
709 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
710 orderByComparator);
711 }
712
713 else {
714 query.append(PhoneModelImpl.ORDER_BY_JPQL);
715 }
716
717 String sql = query.toString();
718
719 Session session = null;
720
721 try {
722 session = openSession();
723
724 Query q = session.createQuery(sql);
725
726 QueryPos qPos = QueryPos.getInstance(q);
727
728 qPos.add(companyId);
729
730 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
731 }
732 catch (Exception e) {
733 throw processException(e);
734 }
735 finally {
736 if (list == null) {
737 FinderCacheUtil.removeResult(finderPath, finderArgs);
738 }
739 else {
740 cacheResult(list);
741
742 FinderCacheUtil.putResult(finderPath, finderArgs, list);
743 }
744
745 closeSession(session);
746 }
747 }
748
749 return list;
750 }
751
752
765 public Phone findByCompanyId_First(long companyId,
766 OrderByComparator orderByComparator)
767 throws NoSuchPhoneException, SystemException {
768 List<Phone> list = findByCompanyId(companyId, 0, 1, orderByComparator);
769
770 if (list.isEmpty()) {
771 StringBundler msg = new StringBundler(4);
772
773 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
774
775 msg.append("companyId=");
776 msg.append(companyId);
777
778 msg.append(StringPool.CLOSE_CURLY_BRACE);
779
780 throw new NoSuchPhoneException(msg.toString());
781 }
782 else {
783 return list.get(0);
784 }
785 }
786
787
800 public Phone findByCompanyId_Last(long companyId,
801 OrderByComparator orderByComparator)
802 throws NoSuchPhoneException, SystemException {
803 int count = countByCompanyId(companyId);
804
805 List<Phone> list = findByCompanyId(companyId, count - 1, count,
806 orderByComparator);
807
808 if (list.isEmpty()) {
809 StringBundler msg = new StringBundler(4);
810
811 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
812
813 msg.append("companyId=");
814 msg.append(companyId);
815
816 msg.append(StringPool.CLOSE_CURLY_BRACE);
817
818 throw new NoSuchPhoneException(msg.toString());
819 }
820 else {
821 return list.get(0);
822 }
823 }
824
825
839 public Phone[] findByCompanyId_PrevAndNext(long phoneId, long companyId,
840 OrderByComparator orderByComparator)
841 throws NoSuchPhoneException, SystemException {
842 Phone phone = findByPrimaryKey(phoneId);
843
844 Session session = null;
845
846 try {
847 session = openSession();
848
849 Phone[] array = new PhoneImpl[3];
850
851 array[0] = getByCompanyId_PrevAndNext(session, phone, companyId,
852 orderByComparator, true);
853
854 array[1] = phone;
855
856 array[2] = getByCompanyId_PrevAndNext(session, phone, companyId,
857 orderByComparator, false);
858
859 return array;
860 }
861 catch (Exception e) {
862 throw processException(e);
863 }
864 finally {
865 closeSession(session);
866 }
867 }
868
869 protected Phone getByCompanyId_PrevAndNext(Session session, Phone phone,
870 long companyId, OrderByComparator orderByComparator, boolean previous) {
871 StringBundler query = null;
872
873 if (orderByComparator != null) {
874 query = new StringBundler(6 +
875 (orderByComparator.getOrderByFields().length * 6));
876 }
877 else {
878 query = new StringBundler(3);
879 }
880
881 query.append(_SQL_SELECT_PHONE_WHERE);
882
883 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
884
885 if (orderByComparator != null) {
886 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
887
888 if (orderByConditionFields.length > 0) {
889 query.append(WHERE_AND);
890 }
891
892 for (int i = 0; i < orderByConditionFields.length; i++) {
893 query.append(_ORDER_BY_ENTITY_ALIAS);
894 query.append(orderByConditionFields[i]);
895
896 if ((i + 1) < orderByConditionFields.length) {
897 if (orderByComparator.isAscending() ^ previous) {
898 query.append(WHERE_GREATER_THAN_HAS_NEXT);
899 }
900 else {
901 query.append(WHERE_LESSER_THAN_HAS_NEXT);
902 }
903 }
904 else {
905 if (orderByComparator.isAscending() ^ previous) {
906 query.append(WHERE_GREATER_THAN);
907 }
908 else {
909 query.append(WHERE_LESSER_THAN);
910 }
911 }
912 }
913
914 query.append(ORDER_BY_CLAUSE);
915
916 String[] orderByFields = orderByComparator.getOrderByFields();
917
918 for (int i = 0; i < orderByFields.length; i++) {
919 query.append(_ORDER_BY_ENTITY_ALIAS);
920 query.append(orderByFields[i]);
921
922 if ((i + 1) < orderByFields.length) {
923 if (orderByComparator.isAscending() ^ previous) {
924 query.append(ORDER_BY_ASC_HAS_NEXT);
925 }
926 else {
927 query.append(ORDER_BY_DESC_HAS_NEXT);
928 }
929 }
930 else {
931 if (orderByComparator.isAscending() ^ previous) {
932 query.append(ORDER_BY_ASC);
933 }
934 else {
935 query.append(ORDER_BY_DESC);
936 }
937 }
938 }
939 }
940
941 else {
942 query.append(PhoneModelImpl.ORDER_BY_JPQL);
943 }
944
945 String sql = query.toString();
946
947 Query q = session.createQuery(sql);
948
949 q.setFirstResult(0);
950 q.setMaxResults(2);
951
952 QueryPos qPos = QueryPos.getInstance(q);
953
954 qPos.add(companyId);
955
956 if (orderByComparator != null) {
957 Object[] values = orderByComparator.getOrderByConditionValues(phone);
958
959 for (Object value : values) {
960 qPos.add(value);
961 }
962 }
963
964 List<Phone> list = q.list();
965
966 if (list.size() == 2) {
967 return list.get(1);
968 }
969 else {
970 return null;
971 }
972 }
973
974
981 public List<Phone> findByUserId(long userId) throws SystemException {
982 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
983 }
984
985
998 public List<Phone> findByUserId(long userId, int start, int end)
999 throws SystemException {
1000 return findByUserId(userId, start, end, null);
1001 }
1002
1003
1017 public List<Phone> findByUserId(long userId, int start, int end,
1018 OrderByComparator orderByComparator) throws SystemException {
1019 FinderPath finderPath = null;
1020 Object[] finderArgs = null;
1021
1022 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1023 (orderByComparator == null)) {
1024 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1025 finderArgs = new Object[] { userId };
1026 }
1027 else {
1028 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1029 finderArgs = new Object[] { userId, start, end, orderByComparator };
1030 }
1031
1032 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
1033 finderArgs, this);
1034
1035 if (list == null) {
1036 StringBundler query = null;
1037
1038 if (orderByComparator != null) {
1039 query = new StringBundler(3 +
1040 (orderByComparator.getOrderByFields().length * 3));
1041 }
1042 else {
1043 query = new StringBundler(3);
1044 }
1045
1046 query.append(_SQL_SELECT_PHONE_WHERE);
1047
1048 query.append(_FINDER_COLUMN_USERID_USERID_2);
1049
1050 if (orderByComparator != null) {
1051 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1052 orderByComparator);
1053 }
1054
1055 else {
1056 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1057 }
1058
1059 String sql = query.toString();
1060
1061 Session session = null;
1062
1063 try {
1064 session = openSession();
1065
1066 Query q = session.createQuery(sql);
1067
1068 QueryPos qPos = QueryPos.getInstance(q);
1069
1070 qPos.add(userId);
1071
1072 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
1073 }
1074 catch (Exception e) {
1075 throw processException(e);
1076 }
1077 finally {
1078 if (list == null) {
1079 FinderCacheUtil.removeResult(finderPath, finderArgs);
1080 }
1081 else {
1082 cacheResult(list);
1083
1084 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1085 }
1086
1087 closeSession(session);
1088 }
1089 }
1090
1091 return list;
1092 }
1093
1094
1107 public Phone findByUserId_First(long userId,
1108 OrderByComparator orderByComparator)
1109 throws NoSuchPhoneException, SystemException {
1110 List<Phone> list = findByUserId(userId, 0, 1, orderByComparator);
1111
1112 if (list.isEmpty()) {
1113 StringBundler msg = new StringBundler(4);
1114
1115 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1116
1117 msg.append("userId=");
1118 msg.append(userId);
1119
1120 msg.append(StringPool.CLOSE_CURLY_BRACE);
1121
1122 throw new NoSuchPhoneException(msg.toString());
1123 }
1124 else {
1125 return list.get(0);
1126 }
1127 }
1128
1129
1142 public Phone findByUserId_Last(long userId,
1143 OrderByComparator orderByComparator)
1144 throws NoSuchPhoneException, SystemException {
1145 int count = countByUserId(userId);
1146
1147 List<Phone> list = findByUserId(userId, count - 1, count,
1148 orderByComparator);
1149
1150 if (list.isEmpty()) {
1151 StringBundler msg = new StringBundler(4);
1152
1153 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1154
1155 msg.append("userId=");
1156 msg.append(userId);
1157
1158 msg.append(StringPool.CLOSE_CURLY_BRACE);
1159
1160 throw new NoSuchPhoneException(msg.toString());
1161 }
1162 else {
1163 return list.get(0);
1164 }
1165 }
1166
1167
1181 public Phone[] findByUserId_PrevAndNext(long phoneId, long userId,
1182 OrderByComparator orderByComparator)
1183 throws NoSuchPhoneException, SystemException {
1184 Phone phone = findByPrimaryKey(phoneId);
1185
1186 Session session = null;
1187
1188 try {
1189 session = openSession();
1190
1191 Phone[] array = new PhoneImpl[3];
1192
1193 array[0] = getByUserId_PrevAndNext(session, phone, userId,
1194 orderByComparator, true);
1195
1196 array[1] = phone;
1197
1198 array[2] = getByUserId_PrevAndNext(session, phone, userId,
1199 orderByComparator, false);
1200
1201 return array;
1202 }
1203 catch (Exception e) {
1204 throw processException(e);
1205 }
1206 finally {
1207 closeSession(session);
1208 }
1209 }
1210
1211 protected Phone getByUserId_PrevAndNext(Session session, Phone phone,
1212 long userId, OrderByComparator orderByComparator, boolean previous) {
1213 StringBundler query = null;
1214
1215 if (orderByComparator != null) {
1216 query = new StringBundler(6 +
1217 (orderByComparator.getOrderByFields().length * 6));
1218 }
1219 else {
1220 query = new StringBundler(3);
1221 }
1222
1223 query.append(_SQL_SELECT_PHONE_WHERE);
1224
1225 query.append(_FINDER_COLUMN_USERID_USERID_2);
1226
1227 if (orderByComparator != null) {
1228 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1229
1230 if (orderByConditionFields.length > 0) {
1231 query.append(WHERE_AND);
1232 }
1233
1234 for (int i = 0; i < orderByConditionFields.length; i++) {
1235 query.append(_ORDER_BY_ENTITY_ALIAS);
1236 query.append(orderByConditionFields[i]);
1237
1238 if ((i + 1) < orderByConditionFields.length) {
1239 if (orderByComparator.isAscending() ^ previous) {
1240 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1241 }
1242 else {
1243 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1244 }
1245 }
1246 else {
1247 if (orderByComparator.isAscending() ^ previous) {
1248 query.append(WHERE_GREATER_THAN);
1249 }
1250 else {
1251 query.append(WHERE_LESSER_THAN);
1252 }
1253 }
1254 }
1255
1256 query.append(ORDER_BY_CLAUSE);
1257
1258 String[] orderByFields = orderByComparator.getOrderByFields();
1259
1260 for (int i = 0; i < orderByFields.length; i++) {
1261 query.append(_ORDER_BY_ENTITY_ALIAS);
1262 query.append(orderByFields[i]);
1263
1264 if ((i + 1) < orderByFields.length) {
1265 if (orderByComparator.isAscending() ^ previous) {
1266 query.append(ORDER_BY_ASC_HAS_NEXT);
1267 }
1268 else {
1269 query.append(ORDER_BY_DESC_HAS_NEXT);
1270 }
1271 }
1272 else {
1273 if (orderByComparator.isAscending() ^ previous) {
1274 query.append(ORDER_BY_ASC);
1275 }
1276 else {
1277 query.append(ORDER_BY_DESC);
1278 }
1279 }
1280 }
1281 }
1282
1283 else {
1284 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1285 }
1286
1287 String sql = query.toString();
1288
1289 Query q = session.createQuery(sql);
1290
1291 q.setFirstResult(0);
1292 q.setMaxResults(2);
1293
1294 QueryPos qPos = QueryPos.getInstance(q);
1295
1296 qPos.add(userId);
1297
1298 if (orderByComparator != null) {
1299 Object[] values = orderByComparator.getOrderByConditionValues(phone);
1300
1301 for (Object value : values) {
1302 qPos.add(value);
1303 }
1304 }
1305
1306 List<Phone> list = q.list();
1307
1308 if (list.size() == 2) {
1309 return list.get(1);
1310 }
1311 else {
1312 return null;
1313 }
1314 }
1315
1316
1324 public List<Phone> findByC_C(long companyId, long classNameId)
1325 throws SystemException {
1326 return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
1327 QueryUtil.ALL_POS, null);
1328 }
1329
1330
1344 public List<Phone> findByC_C(long companyId, long classNameId, int start,
1345 int end) throws SystemException {
1346 return findByC_C(companyId, classNameId, start, end, null);
1347 }
1348
1349
1364 public List<Phone> findByC_C(long companyId, long classNameId, int start,
1365 int end, OrderByComparator orderByComparator) throws SystemException {
1366 FinderPath finderPath = null;
1367 Object[] finderArgs = null;
1368
1369 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1370 (orderByComparator == null)) {
1371 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
1372 finderArgs = new Object[] { companyId, classNameId };
1373 }
1374 else {
1375 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
1376 finderArgs = new Object[] {
1377 companyId, classNameId,
1378
1379 start, end, orderByComparator
1380 };
1381 }
1382
1383 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
1384 finderArgs, this);
1385
1386 if (list == null) {
1387 StringBundler query = null;
1388
1389 if (orderByComparator != null) {
1390 query = new StringBundler(4 +
1391 (orderByComparator.getOrderByFields().length * 3));
1392 }
1393 else {
1394 query = new StringBundler(4);
1395 }
1396
1397 query.append(_SQL_SELECT_PHONE_WHERE);
1398
1399 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1400
1401 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1402
1403 if (orderByComparator != null) {
1404 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1405 orderByComparator);
1406 }
1407
1408 else {
1409 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1410 }
1411
1412 String sql = query.toString();
1413
1414 Session session = null;
1415
1416 try {
1417 session = openSession();
1418
1419 Query q = session.createQuery(sql);
1420
1421 QueryPos qPos = QueryPos.getInstance(q);
1422
1423 qPos.add(companyId);
1424
1425 qPos.add(classNameId);
1426
1427 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
1428 }
1429 catch (Exception e) {
1430 throw processException(e);
1431 }
1432 finally {
1433 if (list == null) {
1434 FinderCacheUtil.removeResult(finderPath, finderArgs);
1435 }
1436 else {
1437 cacheResult(list);
1438
1439 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1440 }
1441
1442 closeSession(session);
1443 }
1444 }
1445
1446 return list;
1447 }
1448
1449
1463 public Phone findByC_C_First(long companyId, long classNameId,
1464 OrderByComparator orderByComparator)
1465 throws NoSuchPhoneException, SystemException {
1466 List<Phone> list = findByC_C(companyId, classNameId, 0, 1,
1467 orderByComparator);
1468
1469 if (list.isEmpty()) {
1470 StringBundler msg = new StringBundler(6);
1471
1472 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1473
1474 msg.append("companyId=");
1475 msg.append(companyId);
1476
1477 msg.append(", classNameId=");
1478 msg.append(classNameId);
1479
1480 msg.append(StringPool.CLOSE_CURLY_BRACE);
1481
1482 throw new NoSuchPhoneException(msg.toString());
1483 }
1484 else {
1485 return list.get(0);
1486 }
1487 }
1488
1489
1503 public Phone findByC_C_Last(long companyId, long classNameId,
1504 OrderByComparator orderByComparator)
1505 throws NoSuchPhoneException, SystemException {
1506 int count = countByC_C(companyId, classNameId);
1507
1508 List<Phone> list = findByC_C(companyId, classNameId, count - 1, count,
1509 orderByComparator);
1510
1511 if (list.isEmpty()) {
1512 StringBundler msg = new StringBundler(6);
1513
1514 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1515
1516 msg.append("companyId=");
1517 msg.append(companyId);
1518
1519 msg.append(", classNameId=");
1520 msg.append(classNameId);
1521
1522 msg.append(StringPool.CLOSE_CURLY_BRACE);
1523
1524 throw new NoSuchPhoneException(msg.toString());
1525 }
1526 else {
1527 return list.get(0);
1528 }
1529 }
1530
1531
1546 public Phone[] findByC_C_PrevAndNext(long phoneId, long companyId,
1547 long classNameId, OrderByComparator orderByComparator)
1548 throws NoSuchPhoneException, SystemException {
1549 Phone phone = findByPrimaryKey(phoneId);
1550
1551 Session session = null;
1552
1553 try {
1554 session = openSession();
1555
1556 Phone[] array = new PhoneImpl[3];
1557
1558 array[0] = getByC_C_PrevAndNext(session, phone, companyId,
1559 classNameId, orderByComparator, true);
1560
1561 array[1] = phone;
1562
1563 array[2] = getByC_C_PrevAndNext(session, phone, companyId,
1564 classNameId, orderByComparator, false);
1565
1566 return array;
1567 }
1568 catch (Exception e) {
1569 throw processException(e);
1570 }
1571 finally {
1572 closeSession(session);
1573 }
1574 }
1575
1576 protected Phone getByC_C_PrevAndNext(Session session, Phone phone,
1577 long companyId, long classNameId, OrderByComparator orderByComparator,
1578 boolean previous) {
1579 StringBundler query = null;
1580
1581 if (orderByComparator != null) {
1582 query = new StringBundler(6 +
1583 (orderByComparator.getOrderByFields().length * 6));
1584 }
1585 else {
1586 query = new StringBundler(3);
1587 }
1588
1589 query.append(_SQL_SELECT_PHONE_WHERE);
1590
1591 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1592
1593 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1594
1595 if (orderByComparator != null) {
1596 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1597
1598 if (orderByConditionFields.length > 0) {
1599 query.append(WHERE_AND);
1600 }
1601
1602 for (int i = 0; i < orderByConditionFields.length; i++) {
1603 query.append(_ORDER_BY_ENTITY_ALIAS);
1604 query.append(orderByConditionFields[i]);
1605
1606 if ((i + 1) < orderByConditionFields.length) {
1607 if (orderByComparator.isAscending() ^ previous) {
1608 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1609 }
1610 else {
1611 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1612 }
1613 }
1614 else {
1615 if (orderByComparator.isAscending() ^ previous) {
1616 query.append(WHERE_GREATER_THAN);
1617 }
1618 else {
1619 query.append(WHERE_LESSER_THAN);
1620 }
1621 }
1622 }
1623
1624 query.append(ORDER_BY_CLAUSE);
1625
1626 String[] orderByFields = orderByComparator.getOrderByFields();
1627
1628 for (int i = 0; i < orderByFields.length; i++) {
1629 query.append(_ORDER_BY_ENTITY_ALIAS);
1630 query.append(orderByFields[i]);
1631
1632 if ((i + 1) < orderByFields.length) {
1633 if (orderByComparator.isAscending() ^ previous) {
1634 query.append(ORDER_BY_ASC_HAS_NEXT);
1635 }
1636 else {
1637 query.append(ORDER_BY_DESC_HAS_NEXT);
1638 }
1639 }
1640 else {
1641 if (orderByComparator.isAscending() ^ previous) {
1642 query.append(ORDER_BY_ASC);
1643 }
1644 else {
1645 query.append(ORDER_BY_DESC);
1646 }
1647 }
1648 }
1649 }
1650
1651 else {
1652 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1653 }
1654
1655 String sql = query.toString();
1656
1657 Query q = session.createQuery(sql);
1658
1659 q.setFirstResult(0);
1660 q.setMaxResults(2);
1661
1662 QueryPos qPos = QueryPos.getInstance(q);
1663
1664 qPos.add(companyId);
1665
1666 qPos.add(classNameId);
1667
1668 if (orderByComparator != null) {
1669 Object[] values = orderByComparator.getOrderByConditionValues(phone);
1670
1671 for (Object value : values) {
1672 qPos.add(value);
1673 }
1674 }
1675
1676 List<Phone> list = q.list();
1677
1678 if (list.size() == 2) {
1679 return list.get(1);
1680 }
1681 else {
1682 return null;
1683 }
1684 }
1685
1686
1695 public List<Phone> findByC_C_C(long companyId, long classNameId,
1696 long classPK) throws SystemException {
1697 return findByC_C_C(companyId, classNameId, classPK, QueryUtil.ALL_POS,
1698 QueryUtil.ALL_POS, null);
1699 }
1700
1701
1716 public List<Phone> findByC_C_C(long companyId, long classNameId,
1717 long classPK, int start, int end) throws SystemException {
1718 return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1719 }
1720
1721
1737 public List<Phone> findByC_C_C(long companyId, long classNameId,
1738 long classPK, int start, int end, OrderByComparator orderByComparator)
1739 throws SystemException {
1740 FinderPath finderPath = null;
1741 Object[] finderArgs = null;
1742
1743 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1744 (orderByComparator == null)) {
1745 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C;
1746 finderArgs = new Object[] { companyId, classNameId, classPK };
1747 }
1748 else {
1749 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C;
1750 finderArgs = new Object[] {
1751 companyId, classNameId, classPK,
1752
1753 start, end, orderByComparator
1754 };
1755 }
1756
1757 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
1758 finderArgs, this);
1759
1760 if (list == null) {
1761 StringBundler query = null;
1762
1763 if (orderByComparator != null) {
1764 query = new StringBundler(5 +
1765 (orderByComparator.getOrderByFields().length * 3));
1766 }
1767 else {
1768 query = new StringBundler(5);
1769 }
1770
1771 query.append(_SQL_SELECT_PHONE_WHERE);
1772
1773 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1774
1775 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1776
1777 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1778
1779 if (orderByComparator != null) {
1780 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1781 orderByComparator);
1782 }
1783
1784 else {
1785 query.append(PhoneModelImpl.ORDER_BY_JPQL);
1786 }
1787
1788 String sql = query.toString();
1789
1790 Session session = null;
1791
1792 try {
1793 session = openSession();
1794
1795 Query q = session.createQuery(sql);
1796
1797 QueryPos qPos = QueryPos.getInstance(q);
1798
1799 qPos.add(companyId);
1800
1801 qPos.add(classNameId);
1802
1803 qPos.add(classPK);
1804
1805 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
1806 }
1807 catch (Exception e) {
1808 throw processException(e);
1809 }
1810 finally {
1811 if (list == null) {
1812 FinderCacheUtil.removeResult(finderPath, finderArgs);
1813 }
1814 else {
1815 cacheResult(list);
1816
1817 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1818 }
1819
1820 closeSession(session);
1821 }
1822 }
1823
1824 return list;
1825 }
1826
1827
1842 public Phone findByC_C_C_First(long companyId, long classNameId,
1843 long classPK, OrderByComparator orderByComparator)
1844 throws NoSuchPhoneException, SystemException {
1845 List<Phone> list = findByC_C_C(companyId, classNameId, classPK, 0, 1,
1846 orderByComparator);
1847
1848 if (list.isEmpty()) {
1849 StringBundler msg = new StringBundler(8);
1850
1851 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1852
1853 msg.append("companyId=");
1854 msg.append(companyId);
1855
1856 msg.append(", classNameId=");
1857 msg.append(classNameId);
1858
1859 msg.append(", classPK=");
1860 msg.append(classPK);
1861
1862 msg.append(StringPool.CLOSE_CURLY_BRACE);
1863
1864 throw new NoSuchPhoneException(msg.toString());
1865 }
1866 else {
1867 return list.get(0);
1868 }
1869 }
1870
1871
1886 public Phone findByC_C_C_Last(long companyId, long classNameId,
1887 long classPK, OrderByComparator orderByComparator)
1888 throws NoSuchPhoneException, SystemException {
1889 int count = countByC_C_C(companyId, classNameId, classPK);
1890
1891 List<Phone> list = findByC_C_C(companyId, classNameId, classPK,
1892 count - 1, count, orderByComparator);
1893
1894 if (list.isEmpty()) {
1895 StringBundler msg = new StringBundler(8);
1896
1897 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1898
1899 msg.append("companyId=");
1900 msg.append(companyId);
1901
1902 msg.append(", classNameId=");
1903 msg.append(classNameId);
1904
1905 msg.append(", classPK=");
1906 msg.append(classPK);
1907
1908 msg.append(StringPool.CLOSE_CURLY_BRACE);
1909
1910 throw new NoSuchPhoneException(msg.toString());
1911 }
1912 else {
1913 return list.get(0);
1914 }
1915 }
1916
1917
1933 public Phone[] findByC_C_C_PrevAndNext(long phoneId, long companyId,
1934 long classNameId, long classPK, OrderByComparator orderByComparator)
1935 throws NoSuchPhoneException, SystemException {
1936 Phone phone = findByPrimaryKey(phoneId);
1937
1938 Session session = null;
1939
1940 try {
1941 session = openSession();
1942
1943 Phone[] array = new PhoneImpl[3];
1944
1945 array[0] = getByC_C_C_PrevAndNext(session, phone, companyId,
1946 classNameId, classPK, orderByComparator, true);
1947
1948 array[1] = phone;
1949
1950 array[2] = getByC_C_C_PrevAndNext(session, phone, companyId,
1951 classNameId, classPK, orderByComparator, false);
1952
1953 return array;
1954 }
1955 catch (Exception e) {
1956 throw processException(e);
1957 }
1958 finally {
1959 closeSession(session);
1960 }
1961 }
1962
1963 protected Phone getByC_C_C_PrevAndNext(Session session, Phone phone,
1964 long companyId, long classNameId, long classPK,
1965 OrderByComparator orderByComparator, boolean previous) {
1966 StringBundler query = null;
1967
1968 if (orderByComparator != null) {
1969 query = new StringBundler(6 +
1970 (orderByComparator.getOrderByFields().length * 6));
1971 }
1972 else {
1973 query = new StringBundler(3);
1974 }
1975
1976 query.append(_SQL_SELECT_PHONE_WHERE);
1977
1978 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1979
1980 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1981
1982 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1983
1984 if (orderByComparator != null) {
1985 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1986
1987 if (orderByConditionFields.length > 0) {
1988 query.append(WHERE_AND);
1989 }
1990
1991 for (int i = 0; i < orderByConditionFields.length; i++) {
1992 query.append(_ORDER_BY_ENTITY_ALIAS);
1993 query.append(orderByConditionFields[i]);
1994
1995 if ((i + 1) < orderByConditionFields.length) {
1996 if (orderByComparator.isAscending() ^ previous) {
1997 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1998 }
1999 else {
2000 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2001 }
2002 }
2003 else {
2004 if (orderByComparator.isAscending() ^ previous) {
2005 query.append(WHERE_GREATER_THAN);
2006 }
2007 else {
2008 query.append(WHERE_LESSER_THAN);
2009 }
2010 }
2011 }
2012
2013 query.append(ORDER_BY_CLAUSE);
2014
2015 String[] orderByFields = orderByComparator.getOrderByFields();
2016
2017 for (int i = 0; i < orderByFields.length; i++) {
2018 query.append(_ORDER_BY_ENTITY_ALIAS);
2019 query.append(orderByFields[i]);
2020
2021 if ((i + 1) < orderByFields.length) {
2022 if (orderByComparator.isAscending() ^ previous) {
2023 query.append(ORDER_BY_ASC_HAS_NEXT);
2024 }
2025 else {
2026 query.append(ORDER_BY_DESC_HAS_NEXT);
2027 }
2028 }
2029 else {
2030 if (orderByComparator.isAscending() ^ previous) {
2031 query.append(ORDER_BY_ASC);
2032 }
2033 else {
2034 query.append(ORDER_BY_DESC);
2035 }
2036 }
2037 }
2038 }
2039
2040 else {
2041 query.append(PhoneModelImpl.ORDER_BY_JPQL);
2042 }
2043
2044 String sql = query.toString();
2045
2046 Query q = session.createQuery(sql);
2047
2048 q.setFirstResult(0);
2049 q.setMaxResults(2);
2050
2051 QueryPos qPos = QueryPos.getInstance(q);
2052
2053 qPos.add(companyId);
2054
2055 qPos.add(classNameId);
2056
2057 qPos.add(classPK);
2058
2059 if (orderByComparator != null) {
2060 Object[] values = orderByComparator.getOrderByConditionValues(phone);
2061
2062 for (Object value : values) {
2063 qPos.add(value);
2064 }
2065 }
2066
2067 List<Phone> list = q.list();
2068
2069 if (list.size() == 2) {
2070 return list.get(1);
2071 }
2072 else {
2073 return null;
2074 }
2075 }
2076
2077
2087 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
2088 long classPK, boolean primary) throws SystemException {
2089 return findByC_C_C_P(companyId, classNameId, classPK, primary,
2090 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2091 }
2092
2093
2109 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
2110 long classPK, boolean primary, int start, int end)
2111 throws SystemException {
2112 return findByC_C_C_P(companyId, classNameId, classPK, primary, start,
2113 end, null);
2114 }
2115
2116
2133 public List<Phone> findByC_C_C_P(long companyId, long classNameId,
2134 long classPK, boolean primary, int start, int end,
2135 OrderByComparator orderByComparator) throws SystemException {
2136 FinderPath finderPath = null;
2137 Object[] finderArgs = null;
2138
2139 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2140 (orderByComparator == null)) {
2141 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P;
2142 finderArgs = new Object[] { companyId, classNameId, classPK, primary };
2143 }
2144 else {
2145 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C_P;
2146 finderArgs = new Object[] {
2147 companyId, classNameId, classPK, primary,
2148
2149 start, end, orderByComparator
2150 };
2151 }
2152
2153 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
2154 finderArgs, this);
2155
2156 if (list == null) {
2157 StringBundler query = null;
2158
2159 if (orderByComparator != null) {
2160 query = new StringBundler(6 +
2161 (orderByComparator.getOrderByFields().length * 3));
2162 }
2163 else {
2164 query = new StringBundler(6);
2165 }
2166
2167 query.append(_SQL_SELECT_PHONE_WHERE);
2168
2169 query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2170
2171 query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2172
2173 query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2174
2175 query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2176
2177 if (orderByComparator != null) {
2178 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2179 orderByComparator);
2180 }
2181
2182 else {
2183 query.append(PhoneModelImpl.ORDER_BY_JPQL);
2184 }
2185
2186 String sql = query.toString();
2187
2188 Session session = null;
2189
2190 try {
2191 session = openSession();
2192
2193 Query q = session.createQuery(sql);
2194
2195 QueryPos qPos = QueryPos.getInstance(q);
2196
2197 qPos.add(companyId);
2198
2199 qPos.add(classNameId);
2200
2201 qPos.add(classPK);
2202
2203 qPos.add(primary);
2204
2205 list = (List<Phone>)QueryUtil.list(q, getDialect(), start, end);
2206 }
2207 catch (Exception e) {
2208 throw processException(e);
2209 }
2210 finally {
2211 if (list == null) {
2212 FinderCacheUtil.removeResult(finderPath, finderArgs);
2213 }
2214 else {
2215 cacheResult(list);
2216
2217 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2218 }
2219
2220 closeSession(session);
2221 }
2222 }
2223
2224 return list;
2225 }
2226
2227
2243 public Phone findByC_C_C_P_First(long companyId, long classNameId,
2244 long classPK, boolean primary, OrderByComparator orderByComparator)
2245 throws NoSuchPhoneException, SystemException {
2246 List<Phone> list = findByC_C_C_P(companyId, classNameId, classPK,
2247 primary, 0, 1, orderByComparator);
2248
2249 if (list.isEmpty()) {
2250 StringBundler msg = new StringBundler(10);
2251
2252 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2253
2254 msg.append("companyId=");
2255 msg.append(companyId);
2256
2257 msg.append(", classNameId=");
2258 msg.append(classNameId);
2259
2260 msg.append(", classPK=");
2261 msg.append(classPK);
2262
2263 msg.append(", primary=");
2264 msg.append(primary);
2265
2266 msg.append(StringPool.CLOSE_CURLY_BRACE);
2267
2268 throw new NoSuchPhoneException(msg.toString());
2269 }
2270 else {
2271 return list.get(0);
2272 }
2273 }
2274
2275
2291 public Phone findByC_C_C_P_Last(long companyId, long classNameId,
2292 long classPK, boolean primary, OrderByComparator orderByComparator)
2293 throws NoSuchPhoneException, SystemException {
2294 int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
2295
2296 List<Phone> list = findByC_C_C_P(companyId, classNameId, classPK,
2297 primary, count - 1, count, orderByComparator);
2298
2299 if (list.isEmpty()) {
2300 StringBundler msg = new StringBundler(10);
2301
2302 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2303
2304 msg.append("companyId=");
2305 msg.append(companyId);
2306
2307 msg.append(", classNameId=");
2308 msg.append(classNameId);
2309
2310 msg.append(", classPK=");
2311 msg.append(classPK);
2312
2313 msg.append(", primary=");
2314 msg.append(primary);
2315
2316 msg.append(StringPool.CLOSE_CURLY_BRACE);
2317
2318 throw new NoSuchPhoneException(msg.toString());
2319 }
2320 else {
2321 return list.get(0);
2322 }
2323 }
2324
2325
2342 public Phone[] findByC_C_C_P_PrevAndNext(long phoneId, long companyId,
2343 long classNameId, long classPK, boolean primary,
2344 OrderByComparator orderByComparator)
2345 throws NoSuchPhoneException, SystemException {
2346 Phone phone = findByPrimaryKey(phoneId);
2347
2348 Session session = null;
2349
2350 try {
2351 session = openSession();
2352
2353 Phone[] array = new PhoneImpl[3];
2354
2355 array[0] = getByC_C_C_P_PrevAndNext(session, phone, companyId,
2356 classNameId, classPK, primary, orderByComparator, true);
2357
2358 array[1] = phone;
2359
2360 array[2] = getByC_C_C_P_PrevAndNext(session, phone, companyId,
2361 classNameId, classPK, primary, orderByComparator, false);
2362
2363 return array;
2364 }
2365 catch (Exception e) {
2366 throw processException(e);
2367 }
2368 finally {
2369 closeSession(session);
2370 }
2371 }
2372
2373 protected Phone getByC_C_C_P_PrevAndNext(Session session, Phone phone,
2374 long companyId, long classNameId, long classPK, boolean primary,
2375 OrderByComparator orderByComparator, boolean previous) {
2376 StringBundler query = null;
2377
2378 if (orderByComparator != null) {
2379 query = new StringBundler(6 +
2380 (orderByComparator.getOrderByFields().length * 6));
2381 }
2382 else {
2383 query = new StringBundler(3);
2384 }
2385
2386 query.append(_SQL_SELECT_PHONE_WHERE);
2387
2388 query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2389
2390 query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2391
2392 query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2393
2394 query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2395
2396 if (orderByComparator != null) {
2397 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2398
2399 if (orderByConditionFields.length > 0) {
2400 query.append(WHERE_AND);
2401 }
2402
2403 for (int i = 0; i < orderByConditionFields.length; i++) {
2404 query.append(_ORDER_BY_ENTITY_ALIAS);
2405 query.append(orderByConditionFields[i]);
2406
2407 if ((i + 1) < orderByConditionFields.length) {
2408 if (orderByComparator.isAscending() ^ previous) {
2409 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2410 }
2411 else {
2412 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2413 }
2414 }
2415 else {
2416 if (orderByComparator.isAscending() ^ previous) {
2417 query.append(WHERE_GREATER_THAN);
2418 }
2419 else {
2420 query.append(WHERE_LESSER_THAN);
2421 }
2422 }
2423 }
2424
2425 query.append(ORDER_BY_CLAUSE);
2426
2427 String[] orderByFields = orderByComparator.getOrderByFields();
2428
2429 for (int i = 0; i < orderByFields.length; i++) {
2430 query.append(_ORDER_BY_ENTITY_ALIAS);
2431 query.append(orderByFields[i]);
2432
2433 if ((i + 1) < orderByFields.length) {
2434 if (orderByComparator.isAscending() ^ previous) {
2435 query.append(ORDER_BY_ASC_HAS_NEXT);
2436 }
2437 else {
2438 query.append(ORDER_BY_DESC_HAS_NEXT);
2439 }
2440 }
2441 else {
2442 if (orderByComparator.isAscending() ^ previous) {
2443 query.append(ORDER_BY_ASC);
2444 }
2445 else {
2446 query.append(ORDER_BY_DESC);
2447 }
2448 }
2449 }
2450 }
2451
2452 else {
2453 query.append(PhoneModelImpl.ORDER_BY_JPQL);
2454 }
2455
2456 String sql = query.toString();
2457
2458 Query q = session.createQuery(sql);
2459
2460 q.setFirstResult(0);
2461 q.setMaxResults(2);
2462
2463 QueryPos qPos = QueryPos.getInstance(q);
2464
2465 qPos.add(companyId);
2466
2467 qPos.add(classNameId);
2468
2469 qPos.add(classPK);
2470
2471 qPos.add(primary);
2472
2473 if (orderByComparator != null) {
2474 Object[] values = orderByComparator.getOrderByConditionValues(phone);
2475
2476 for (Object value : values) {
2477 qPos.add(value);
2478 }
2479 }
2480
2481 List<Phone> list = q.list();
2482
2483 if (list.size() == 2) {
2484 return list.get(1);
2485 }
2486 else {
2487 return null;
2488 }
2489 }
2490
2491
2497 public List<Phone> findAll() throws SystemException {
2498 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2499 }
2500
2501
2513 public List<Phone> findAll(int start, int end) throws SystemException {
2514 return findAll(start, end, null);
2515 }
2516
2517
2530 public List<Phone> findAll(int start, int end,
2531 OrderByComparator orderByComparator) throws SystemException {
2532 FinderPath finderPath = null;
2533 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2534
2535 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2536 (orderByComparator == null)) {
2537 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2538 finderArgs = FINDER_ARGS_EMPTY;
2539 }
2540 else {
2541 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2542 finderArgs = new Object[] { start, end, orderByComparator };
2543 }
2544
2545 List<Phone> list = (List<Phone>)FinderCacheUtil.getResult(finderPath,
2546 finderArgs, this);
2547
2548 if (list == null) {
2549 StringBundler query = null;
2550 String sql = null;
2551
2552 if (orderByComparator != null) {
2553 query = new StringBundler(2 +
2554 (orderByComparator.getOrderByFields().length * 3));
2555
2556 query.append(_SQL_SELECT_PHONE);
2557
2558 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2559 orderByComparator);
2560
2561 sql = query.toString();
2562 }
2563 else {
2564 sql = _SQL_SELECT_PHONE.concat(PhoneModelImpl.ORDER_BY_JPQL);
2565 }
2566
2567 Session session = null;
2568
2569 try {
2570 session = openSession();
2571
2572 Query q = session.createQuery(sql);
2573
2574 if (orderByComparator == null) {
2575 list = (List<Phone>)QueryUtil.list(q, getDialect(), start,
2576 end, false);
2577
2578 Collections.sort(list);
2579 }
2580 else {
2581 list = (List<Phone>)QueryUtil.list(q, getDialect(), start,
2582 end);
2583 }
2584 }
2585 catch (Exception e) {
2586 throw processException(e);
2587 }
2588 finally {
2589 if (list == null) {
2590 FinderCacheUtil.removeResult(finderPath, finderArgs);
2591 }
2592 else {
2593 cacheResult(list);
2594
2595 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2596 }
2597
2598 closeSession(session);
2599 }
2600 }
2601
2602 return list;
2603 }
2604
2605
2611 public void removeByCompanyId(long companyId) throws SystemException {
2612 for (Phone phone : findByCompanyId(companyId)) {
2613 remove(phone);
2614 }
2615 }
2616
2617
2623 public void removeByUserId(long userId) throws SystemException {
2624 for (Phone phone : findByUserId(userId)) {
2625 remove(phone);
2626 }
2627 }
2628
2629
2636 public void removeByC_C(long companyId, long classNameId)
2637 throws SystemException {
2638 for (Phone phone : findByC_C(companyId, classNameId)) {
2639 remove(phone);
2640 }
2641 }
2642
2643
2651 public void removeByC_C_C(long companyId, long classNameId, long classPK)
2652 throws SystemException {
2653 for (Phone phone : findByC_C_C(companyId, classNameId, classPK)) {
2654 remove(phone);
2655 }
2656 }
2657
2658
2667 public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
2668 boolean primary) throws SystemException {
2669 for (Phone phone : findByC_C_C_P(companyId, classNameId, classPK,
2670 primary)) {
2671 remove(phone);
2672 }
2673 }
2674
2675
2680 public void removeAll() throws SystemException {
2681 for (Phone phone : findAll()) {
2682 remove(phone);
2683 }
2684 }
2685
2686
2693 public int countByCompanyId(long companyId) throws SystemException {
2694 Object[] finderArgs = new Object[] { companyId };
2695
2696 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2697 finderArgs, this);
2698
2699 if (count == null) {
2700 StringBundler query = new StringBundler(2);
2701
2702 query.append(_SQL_COUNT_PHONE_WHERE);
2703
2704 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2705
2706 String sql = query.toString();
2707
2708 Session session = null;
2709
2710 try {
2711 session = openSession();
2712
2713 Query q = session.createQuery(sql);
2714
2715 QueryPos qPos = QueryPos.getInstance(q);
2716
2717 qPos.add(companyId);
2718
2719 count = (Long)q.uniqueResult();
2720 }
2721 catch (Exception e) {
2722 throw processException(e);
2723 }
2724 finally {
2725 if (count == null) {
2726 count = Long.valueOf(0);
2727 }
2728
2729 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2730 finderArgs, count);
2731
2732 closeSession(session);
2733 }
2734 }
2735
2736 return count.intValue();
2737 }
2738
2739
2746 public int countByUserId(long userId) throws SystemException {
2747 Object[] finderArgs = new Object[] { userId };
2748
2749 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2750 finderArgs, this);
2751
2752 if (count == null) {
2753 StringBundler query = new StringBundler(2);
2754
2755 query.append(_SQL_COUNT_PHONE_WHERE);
2756
2757 query.append(_FINDER_COLUMN_USERID_USERID_2);
2758
2759 String sql = query.toString();
2760
2761 Session session = null;
2762
2763 try {
2764 session = openSession();
2765
2766 Query q = session.createQuery(sql);
2767
2768 QueryPos qPos = QueryPos.getInstance(q);
2769
2770 qPos.add(userId);
2771
2772 count = (Long)q.uniqueResult();
2773 }
2774 catch (Exception e) {
2775 throw processException(e);
2776 }
2777 finally {
2778 if (count == null) {
2779 count = Long.valueOf(0);
2780 }
2781
2782 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2783 finderArgs, count);
2784
2785 closeSession(session);
2786 }
2787 }
2788
2789 return count.intValue();
2790 }
2791
2792
2800 public int countByC_C(long companyId, long classNameId)
2801 throws SystemException {
2802 Object[] finderArgs = new Object[] { companyId, classNameId };
2803
2804 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
2805 finderArgs, this);
2806
2807 if (count == null) {
2808 StringBundler query = new StringBundler(3);
2809
2810 query.append(_SQL_COUNT_PHONE_WHERE);
2811
2812 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2813
2814 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2815
2816 String sql = query.toString();
2817
2818 Session session = null;
2819
2820 try {
2821 session = openSession();
2822
2823 Query q = session.createQuery(sql);
2824
2825 QueryPos qPos = QueryPos.getInstance(q);
2826
2827 qPos.add(companyId);
2828
2829 qPos.add(classNameId);
2830
2831 count = (Long)q.uniqueResult();
2832 }
2833 catch (Exception e) {
2834 throw processException(e);
2835 }
2836 finally {
2837 if (count == null) {
2838 count = Long.valueOf(0);
2839 }
2840
2841 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
2842 count);
2843
2844 closeSession(session);
2845 }
2846 }
2847
2848 return count.intValue();
2849 }
2850
2851
2860 public int countByC_C_C(long companyId, long classNameId, long classPK)
2861 throws SystemException {
2862 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2863
2864 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
2865 finderArgs, this);
2866
2867 if (count == null) {
2868 StringBundler query = new StringBundler(4);
2869
2870 query.append(_SQL_COUNT_PHONE_WHERE);
2871
2872 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2873
2874 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2875
2876 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2877
2878 String sql = query.toString();
2879
2880 Session session = null;
2881
2882 try {
2883 session = openSession();
2884
2885 Query q = session.createQuery(sql);
2886
2887 QueryPos qPos = QueryPos.getInstance(q);
2888
2889 qPos.add(companyId);
2890
2891 qPos.add(classNameId);
2892
2893 qPos.add(classPK);
2894
2895 count = (Long)q.uniqueResult();
2896 }
2897 catch (Exception e) {
2898 throw processException(e);
2899 }
2900 finally {
2901 if (count == null) {
2902 count = Long.valueOf(0);
2903 }
2904
2905 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
2906 finderArgs, count);
2907
2908 closeSession(session);
2909 }
2910 }
2911
2912 return count.intValue();
2913 }
2914
2915
2925 public int countByC_C_C_P(long companyId, long classNameId, long classPK,
2926 boolean primary) throws SystemException {
2927 Object[] finderArgs = new Object[] {
2928 companyId, classNameId, classPK, primary
2929 };
2930
2931 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C_P,
2932 finderArgs, this);
2933
2934 if (count == null) {
2935 StringBundler query = new StringBundler(5);
2936
2937 query.append(_SQL_COUNT_PHONE_WHERE);
2938
2939 query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2940
2941 query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2942
2943 query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2944
2945 query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2946
2947 String sql = query.toString();
2948
2949 Session session = null;
2950
2951 try {
2952 session = openSession();
2953
2954 Query q = session.createQuery(sql);
2955
2956 QueryPos qPos = QueryPos.getInstance(q);
2957
2958 qPos.add(companyId);
2959
2960 qPos.add(classNameId);
2961
2962 qPos.add(classPK);
2963
2964 qPos.add(primary);
2965
2966 count = (Long)q.uniqueResult();
2967 }
2968 catch (Exception e) {
2969 throw processException(e);
2970 }
2971 finally {
2972 if (count == null) {
2973 count = Long.valueOf(0);
2974 }
2975
2976 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C_P,
2977 finderArgs, count);
2978
2979 closeSession(session);
2980 }
2981 }
2982
2983 return count.intValue();
2984 }
2985
2986
2992 public int countAll() throws SystemException {
2993 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2994 FINDER_ARGS_EMPTY, this);
2995
2996 if (count == null) {
2997 Session session = null;
2998
2999 try {
3000 session = openSession();
3001
3002 Query q = session.createQuery(_SQL_COUNT_PHONE);
3003
3004 count = (Long)q.uniqueResult();
3005 }
3006 catch (Exception e) {
3007 throw processException(e);
3008 }
3009 finally {
3010 if (count == null) {
3011 count = Long.valueOf(0);
3012 }
3013
3014 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3015 FINDER_ARGS_EMPTY, count);
3016
3017 closeSession(session);
3018 }
3019 }
3020
3021 return count.intValue();
3022 }
3023
3024
3027 public void afterPropertiesSet() {
3028 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3029 com.liferay.portal.util.PropsUtil.get(
3030 "value.object.listener.com.liferay.portal.model.Phone")));
3031
3032 if (listenerClassNames.length > 0) {
3033 try {
3034 List<ModelListener<Phone>> listenersList = new ArrayList<ModelListener<Phone>>();
3035
3036 for (String listenerClassName : listenerClassNames) {
3037 listenersList.add((ModelListener<Phone>)InstanceFactory.newInstance(
3038 listenerClassName));
3039 }
3040
3041 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3042 }
3043 catch (Exception e) {
3044 _log.error(e);
3045 }
3046 }
3047 }
3048
3049 public void destroy() {
3050 EntityCacheUtil.removeCache(PhoneImpl.class.getName());
3051 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3052 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3053 }
3054
3055 @BeanReference(type = AccountPersistence.class)
3056 protected AccountPersistence accountPersistence;
3057 @BeanReference(type = AddressPersistence.class)
3058 protected AddressPersistence addressPersistence;
3059 @BeanReference(type = BrowserTrackerPersistence.class)
3060 protected BrowserTrackerPersistence browserTrackerPersistence;
3061 @BeanReference(type = ClassNamePersistence.class)
3062 protected ClassNamePersistence classNamePersistence;
3063 @BeanReference(type = ClusterGroupPersistence.class)
3064 protected ClusterGroupPersistence clusterGroupPersistence;
3065 @BeanReference(type = CompanyPersistence.class)
3066 protected CompanyPersistence companyPersistence;
3067 @BeanReference(type = ContactPersistence.class)
3068 protected ContactPersistence contactPersistence;
3069 @BeanReference(type = CountryPersistence.class)
3070 protected CountryPersistence countryPersistence;
3071 @BeanReference(type = EmailAddressPersistence.class)
3072 protected EmailAddressPersistence emailAddressPersistence;
3073 @BeanReference(type = GroupPersistence.class)
3074 protected GroupPersistence groupPersistence;
3075 @BeanReference(type = ImagePersistence.class)
3076 protected ImagePersistence imagePersistence;
3077 @BeanReference(type = LayoutPersistence.class)
3078 protected LayoutPersistence layoutPersistence;
3079 @BeanReference(type = LayoutBranchPersistence.class)
3080 protected LayoutBranchPersistence layoutBranchPersistence;
3081 @BeanReference(type = LayoutPrototypePersistence.class)
3082 protected LayoutPrototypePersistence layoutPrototypePersistence;
3083 @BeanReference(type = LayoutRevisionPersistence.class)
3084 protected LayoutRevisionPersistence layoutRevisionPersistence;
3085 @BeanReference(type = LayoutSetPersistence.class)
3086 protected LayoutSetPersistence layoutSetPersistence;
3087 @BeanReference(type = LayoutSetBranchPersistence.class)
3088 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
3089 @BeanReference(type = LayoutSetPrototypePersistence.class)
3090 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
3091 @BeanReference(type = ListTypePersistence.class)
3092 protected ListTypePersistence listTypePersistence;
3093 @BeanReference(type = LockPersistence.class)
3094 protected LockPersistence lockPersistence;
3095 @BeanReference(type = MembershipRequestPersistence.class)
3096 protected MembershipRequestPersistence membershipRequestPersistence;
3097 @BeanReference(type = OrganizationPersistence.class)
3098 protected OrganizationPersistence organizationPersistence;
3099 @BeanReference(type = OrgGroupPermissionPersistence.class)
3100 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
3101 @BeanReference(type = OrgGroupRolePersistence.class)
3102 protected OrgGroupRolePersistence orgGroupRolePersistence;
3103 @BeanReference(type = OrgLaborPersistence.class)
3104 protected OrgLaborPersistence orgLaborPersistence;
3105 @BeanReference(type = PasswordPolicyPersistence.class)
3106 protected PasswordPolicyPersistence passwordPolicyPersistence;
3107 @BeanReference(type = PasswordPolicyRelPersistence.class)
3108 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
3109 @BeanReference(type = PasswordTrackerPersistence.class)
3110 protected PasswordTrackerPersistence passwordTrackerPersistence;
3111 @BeanReference(type = PermissionPersistence.class)
3112 protected PermissionPersistence permissionPersistence;
3113 @BeanReference(type = PhonePersistence.class)
3114 protected PhonePersistence phonePersistence;
3115 @BeanReference(type = PluginSettingPersistence.class)
3116 protected PluginSettingPersistence pluginSettingPersistence;
3117 @BeanReference(type = PortalPreferencesPersistence.class)
3118 protected PortalPreferencesPersistence portalPreferencesPersistence;
3119 @BeanReference(type = PortletPersistence.class)
3120 protected PortletPersistence portletPersistence;
3121 @BeanReference(type = PortletItemPersistence.class)
3122 protected PortletItemPersistence portletItemPersistence;
3123 @BeanReference(type = PortletPreferencesPersistence.class)
3124 protected PortletPreferencesPersistence portletPreferencesPersistence;
3125 @BeanReference(type = RegionPersistence.class)
3126 protected RegionPersistence regionPersistence;
3127 @BeanReference(type = ReleasePersistence.class)
3128 protected ReleasePersistence releasePersistence;
3129 @BeanReference(type = RepositoryPersistence.class)
3130 protected RepositoryPersistence repositoryPersistence;
3131 @BeanReference(type = RepositoryEntryPersistence.class)
3132 protected RepositoryEntryPersistence repositoryEntryPersistence;
3133 @BeanReference(type = ResourcePersistence.class)
3134 protected ResourcePersistence resourcePersistence;
3135 @BeanReference(type = ResourceActionPersistence.class)
3136 protected ResourceActionPersistence resourceActionPersistence;
3137 @BeanReference(type = ResourceBlockPersistence.class)
3138 protected ResourceBlockPersistence resourceBlockPersistence;
3139 @BeanReference(type = ResourceBlockPermissionPersistence.class)
3140 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
3141 @BeanReference(type = ResourceCodePersistence.class)
3142 protected ResourceCodePersistence resourceCodePersistence;
3143 @BeanReference(type = ResourcePermissionPersistence.class)
3144 protected ResourcePermissionPersistence resourcePermissionPersistence;
3145 @BeanReference(type = ResourceTypePermissionPersistence.class)
3146 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
3147 @BeanReference(type = RolePersistence.class)
3148 protected RolePersistence rolePersistence;
3149 @BeanReference(type = ServiceComponentPersistence.class)
3150 protected ServiceComponentPersistence serviceComponentPersistence;
3151 @BeanReference(type = ShardPersistence.class)
3152 protected ShardPersistence shardPersistence;
3153 @BeanReference(type = SubscriptionPersistence.class)
3154 protected SubscriptionPersistence subscriptionPersistence;
3155 @BeanReference(type = TeamPersistence.class)
3156 protected TeamPersistence teamPersistence;
3157 @BeanReference(type = TicketPersistence.class)
3158 protected TicketPersistence ticketPersistence;
3159 @BeanReference(type = UserPersistence.class)
3160 protected UserPersistence userPersistence;
3161 @BeanReference(type = UserGroupPersistence.class)
3162 protected UserGroupPersistence userGroupPersistence;
3163 @BeanReference(type = UserGroupGroupRolePersistence.class)
3164 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3165 @BeanReference(type = UserGroupRolePersistence.class)
3166 protected UserGroupRolePersistence userGroupRolePersistence;
3167 @BeanReference(type = UserIdMapperPersistence.class)
3168 protected UserIdMapperPersistence userIdMapperPersistence;
3169 @BeanReference(type = UserNotificationEventPersistence.class)
3170 protected UserNotificationEventPersistence userNotificationEventPersistence;
3171 @BeanReference(type = UserTrackerPersistence.class)
3172 protected UserTrackerPersistence userTrackerPersistence;
3173 @BeanReference(type = UserTrackerPathPersistence.class)
3174 protected UserTrackerPathPersistence userTrackerPathPersistence;
3175 @BeanReference(type = VirtualHostPersistence.class)
3176 protected VirtualHostPersistence virtualHostPersistence;
3177 @BeanReference(type = WebDAVPropsPersistence.class)
3178 protected WebDAVPropsPersistence webDAVPropsPersistence;
3179 @BeanReference(type = WebsitePersistence.class)
3180 protected WebsitePersistence websitePersistence;
3181 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3182 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3183 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3184 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3185 private static final String _SQL_SELECT_PHONE = "SELECT phone FROM Phone phone";
3186 private static final String _SQL_SELECT_PHONE_WHERE = "SELECT phone FROM Phone phone WHERE ";
3187 private static final String _SQL_COUNT_PHONE = "SELECT COUNT(phone) FROM Phone phone";
3188 private static final String _SQL_COUNT_PHONE_WHERE = "SELECT COUNT(phone) FROM Phone phone WHERE ";
3189 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "phone.companyId = ?";
3190 private static final String _FINDER_COLUMN_USERID_USERID_2 = "phone.userId = ?";
3191 private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "phone.companyId = ? AND ";
3192 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "phone.classNameId = ?";
3193 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "phone.companyId = ? AND ";
3194 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "phone.classNameId = ? AND ";
3195 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "phone.classPK = ?";
3196 private static final String _FINDER_COLUMN_C_C_C_P_COMPANYID_2 = "phone.companyId = ? AND ";
3197 private static final String _FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2 = "phone.classNameId = ? AND ";
3198 private static final String _FINDER_COLUMN_C_C_C_P_CLASSPK_2 = "phone.classPK = ? AND ";
3199 private static final String _FINDER_COLUMN_C_C_C_P_PRIMARY_2 = "phone.primary = ?";
3200 private static final String _ORDER_BY_ENTITY_ALIAS = "phone.";
3201 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Phone exists with the primary key ";
3202 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Phone exists with the key {";
3203 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3204 private static Log _log = LogFactoryUtil.getLog(PhonePersistenceImpl.class);
3205 private static Phone _nullPhone = new PhoneImpl() {
3206 @Override
3207 public Object clone() {
3208 return this;
3209 }
3210
3211 @Override
3212 public CacheModel<Phone> toCacheModel() {
3213 return _nullPhoneCacheModel;
3214 }
3215 };
3216
3217 private static CacheModel<Phone> _nullPhoneCacheModel = new CacheModel<Phone>() {
3218 public Phone toEntityModel() {
3219 return _nullPhone;
3220 }
3221 };
3222 }