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