1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.NoSuchContactException;
18  import com.liferay.portal.NoSuchModelException;
19  import com.liferay.portal.SystemException;
20  import com.liferay.portal.kernel.annotation.BeanReference;
21  import com.liferay.portal.kernel.cache.CacheRegistry;
22  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderPath;
25  import com.liferay.portal.kernel.dao.orm.Query;
26  import com.liferay.portal.kernel.dao.orm.QueryPos;
27  import com.liferay.portal.kernel.dao.orm.QueryUtil;
28  import com.liferay.portal.kernel.dao.orm.Session;
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.Contact;
38  import com.liferay.portal.model.ModelListener;
39  import com.liferay.portal.model.impl.ContactImpl;
40  import com.liferay.portal.model.impl.ContactModelImpl;
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="ContactPersistenceImpl.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       ContactPersistence
59   * @see       ContactUtil
60   * @generated
61   */
62  public class ContactPersistenceImpl extends BasePersistenceImpl<Contact>
63      implements ContactPersistence {
64      public static final String FINDER_CLASS_NAME_ENTITY = ContactImpl.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(ContactModelImpl.ENTITY_CACHE_ENABLED,
68              ContactModelImpl.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(ContactModelImpl.ENTITY_CACHE_ENABLED,
77              ContactModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
78              "countByCompanyId", new String[] { Long.class.getName() });
79      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ContactModelImpl.ENTITY_CACHE_ENABLED,
80              ContactModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
81              "findAll", new String[0]);
82      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ContactModelImpl.ENTITY_CACHE_ENABLED,
83              ContactModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84              "countAll", new String[0]);
85  
86      public void cacheResult(Contact contact) {
87          EntityCacheUtil.putResult(ContactModelImpl.ENTITY_CACHE_ENABLED,
88              ContactImpl.class, contact.getPrimaryKey(), contact);
89      }
90  
91      public void cacheResult(List<Contact> contacts) {
92          for (Contact contact : contacts) {
93              if (EntityCacheUtil.getResult(
94                          ContactModelImpl.ENTITY_CACHE_ENABLED,
95                          ContactImpl.class, contact.getPrimaryKey(), this) == null) {
96                  cacheResult(contact);
97              }
98          }
99      }
100 
101     public void clearCache() {
102         CacheRegistry.clear(ContactImpl.class.getName());
103         EntityCacheUtil.clearCache(ContactImpl.class.getName());
104         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
105         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
106     }
107 
108     public void clearCache(Contact contact) {
109         EntityCacheUtil.removeResult(ContactModelImpl.ENTITY_CACHE_ENABLED,
110             ContactImpl.class, contact.getPrimaryKey());
111     }
112 
113     public Contact create(long contactId) {
114         Contact contact = new ContactImpl();
115 
116         contact.setNew(true);
117         contact.setPrimaryKey(contactId);
118 
119         return contact;
120     }
121 
122     public Contact remove(Serializable primaryKey)
123         throws NoSuchModelException, SystemException {
124         return remove(((Long)primaryKey).longValue());
125     }
126 
127     public Contact remove(long contactId)
128         throws NoSuchContactException, SystemException {
129         Session session = null;
130 
131         try {
132             session = openSession();
133 
134             Contact contact = (Contact)session.get(ContactImpl.class,
135                     new Long(contactId));
136 
137             if (contact == null) {
138                 if (_log.isWarnEnabled()) {
139                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contactId);
140                 }
141 
142                 throw new NoSuchContactException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
143                     contactId);
144             }
145 
146             return remove(contact);
147         }
148         catch (NoSuchContactException nsee) {
149             throw nsee;
150         }
151         catch (Exception e) {
152             throw processException(e);
153         }
154         finally {
155             closeSession(session);
156         }
157     }
158 
159     protected Contact removeImpl(Contact contact) throws SystemException {
160         contact = toUnwrappedModel(contact);
161 
162         Session session = null;
163 
164         try {
165             session = openSession();
166 
167             BatchSessionUtil.delete(session, contact);
168         }
169         catch (Exception e) {
170             throw processException(e);
171         }
172         finally {
173             closeSession(session);
174         }
175 
176         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
177 
178         EntityCacheUtil.removeResult(ContactModelImpl.ENTITY_CACHE_ENABLED,
179             ContactImpl.class, contact.getPrimaryKey());
180 
181         return contact;
182     }
183 
184     /**
185      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
186      */
187     public Contact update(Contact contact) throws SystemException {
188         if (_log.isWarnEnabled()) {
189             _log.warn(
190                 "Using the deprecated update(Contact contact) method. Use update(Contact contact, boolean merge) instead.");
191         }
192 
193         return update(contact, false);
194     }
195 
196     public Contact updateImpl(com.liferay.portal.model.Contact contact,
197         boolean merge) throws SystemException {
198         contact = toUnwrappedModel(contact);
199 
200         Session session = null;
201 
202         try {
203             session = openSession();
204 
205             BatchSessionUtil.update(session, contact, merge);
206 
207             contact.setNew(false);
208         }
209         catch (Exception e) {
210             throw processException(e);
211         }
212         finally {
213             closeSession(session);
214         }
215 
216         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
217 
218         EntityCacheUtil.putResult(ContactModelImpl.ENTITY_CACHE_ENABLED,
219             ContactImpl.class, contact.getPrimaryKey(), contact);
220 
221         return contact;
222     }
223 
224     protected Contact toUnwrappedModel(Contact contact) {
225         if (contact instanceof ContactImpl) {
226             return contact;
227         }
228 
229         ContactImpl contactImpl = new ContactImpl();
230 
231         contactImpl.setNew(contact.isNew());
232         contactImpl.setPrimaryKey(contact.getPrimaryKey());
233 
234         contactImpl.setContactId(contact.getContactId());
235         contactImpl.setCompanyId(contact.getCompanyId());
236         contactImpl.setUserId(contact.getUserId());
237         contactImpl.setUserName(contact.getUserName());
238         contactImpl.setCreateDate(contact.getCreateDate());
239         contactImpl.setModifiedDate(contact.getModifiedDate());
240         contactImpl.setAccountId(contact.getAccountId());
241         contactImpl.setParentContactId(contact.getParentContactId());
242         contactImpl.setFirstName(contact.getFirstName());
243         contactImpl.setMiddleName(contact.getMiddleName());
244         contactImpl.setLastName(contact.getLastName());
245         contactImpl.setPrefixId(contact.getPrefixId());
246         contactImpl.setSuffixId(contact.getSuffixId());
247         contactImpl.setMale(contact.isMale());
248         contactImpl.setBirthday(contact.getBirthday());
249         contactImpl.setSmsSn(contact.getSmsSn());
250         contactImpl.setAimSn(contact.getAimSn());
251         contactImpl.setFacebookSn(contact.getFacebookSn());
252         contactImpl.setIcqSn(contact.getIcqSn());
253         contactImpl.setJabberSn(contact.getJabberSn());
254         contactImpl.setMsnSn(contact.getMsnSn());
255         contactImpl.setMySpaceSn(contact.getMySpaceSn());
256         contactImpl.setSkypeSn(contact.getSkypeSn());
257         contactImpl.setTwitterSn(contact.getTwitterSn());
258         contactImpl.setYmSn(contact.getYmSn());
259         contactImpl.setEmployeeStatusId(contact.getEmployeeStatusId());
260         contactImpl.setEmployeeNumber(contact.getEmployeeNumber());
261         contactImpl.setJobTitle(contact.getJobTitle());
262         contactImpl.setJobClass(contact.getJobClass());
263         contactImpl.setHoursOfOperation(contact.getHoursOfOperation());
264 
265         return contactImpl;
266     }
267 
268     public Contact findByPrimaryKey(Serializable primaryKey)
269         throws NoSuchModelException, SystemException {
270         return findByPrimaryKey(((Long)primaryKey).longValue());
271     }
272 
273     public Contact findByPrimaryKey(long contactId)
274         throws NoSuchContactException, SystemException {
275         Contact contact = fetchByPrimaryKey(contactId);
276 
277         if (contact == null) {
278             if (_log.isWarnEnabled()) {
279                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contactId);
280             }
281 
282             throw new NoSuchContactException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
283                 contactId);
284         }
285 
286         return contact;
287     }
288 
289     public Contact fetchByPrimaryKey(Serializable primaryKey)
290         throws SystemException {
291         return fetchByPrimaryKey(((Long)primaryKey).longValue());
292     }
293 
294     public Contact fetchByPrimaryKey(long contactId) throws SystemException {
295         Contact contact = (Contact)EntityCacheUtil.getResult(ContactModelImpl.ENTITY_CACHE_ENABLED,
296                 ContactImpl.class, contactId, this);
297 
298         if (contact == null) {
299             Session session = null;
300 
301             try {
302                 session = openSession();
303 
304                 contact = (Contact)session.get(ContactImpl.class,
305                         new Long(contactId));
306             }
307             catch (Exception e) {
308                 throw processException(e);
309             }
310             finally {
311                 if (contact != null) {
312                     cacheResult(contact);
313                 }
314 
315                 closeSession(session);
316             }
317         }
318 
319         return contact;
320     }
321 
322     public List<Contact> findByCompanyId(long companyId)
323         throws SystemException {
324         return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
325             null);
326     }
327 
328     public List<Contact> findByCompanyId(long companyId, int start, int end)
329         throws SystemException {
330         return findByCompanyId(companyId, start, end, null);
331     }
332 
333     public List<Contact> findByCompanyId(long companyId, int start, int end,
334         OrderByComparator orderByComparator) throws SystemException {
335         Object[] finderArgs = new Object[] {
336                 companyId,
337                 
338                 String.valueOf(start), String.valueOf(end),
339                 String.valueOf(orderByComparator)
340             };
341 
342         List<Contact> list = (List<Contact>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
343                 finderArgs, this);
344 
345         if (list == null) {
346             StringBundler query = null;
347 
348             if (orderByComparator != null) {
349                 query = new StringBundler(3 +
350                         (orderByComparator.getOrderByFields().length * 3));
351             }
352             else {
353                 query = new StringBundler(2);
354             }
355 
356             query.append(_SQL_SELECT_CONTACT_WHERE);
357 
358             query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
359 
360             if (orderByComparator != null) {
361                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
362                     orderByComparator);
363             }
364 
365             String sql = query.toString();
366 
367             Session session = null;
368 
369             try {
370                 session = openSession();
371 
372                 Query q = session.createQuery(sql);
373 
374                 QueryPos qPos = QueryPos.getInstance(q);
375 
376                 qPos.add(companyId);
377 
378                 list = (List<Contact>)QueryUtil.list(q, getDialect(), start, end);
379             }
380             catch (Exception e) {
381                 throw processException(e);
382             }
383             finally {
384                 if (list == null) {
385                     list = new ArrayList<Contact>();
386                 }
387 
388                 cacheResult(list);
389 
390                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
391                     finderArgs, list);
392 
393                 closeSession(session);
394             }
395         }
396 
397         return list;
398     }
399 
400     public Contact findByCompanyId_First(long companyId,
401         OrderByComparator orderByComparator)
402         throws NoSuchContactException, SystemException {
403         List<Contact> list = findByCompanyId(companyId, 0, 1, orderByComparator);
404 
405         if (list.isEmpty()) {
406             StringBundler msg = new StringBundler(4);
407 
408             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
409 
410             msg.append("companyId=");
411             msg.append(companyId);
412 
413             msg.append(StringPool.CLOSE_CURLY_BRACE);
414 
415             throw new NoSuchContactException(msg.toString());
416         }
417         else {
418             return list.get(0);
419         }
420     }
421 
422     public Contact findByCompanyId_Last(long companyId,
423         OrderByComparator orderByComparator)
424         throws NoSuchContactException, SystemException {
425         int count = countByCompanyId(companyId);
426 
427         List<Contact> list = findByCompanyId(companyId, count - 1, count,
428                 orderByComparator);
429 
430         if (list.isEmpty()) {
431             StringBundler msg = new StringBundler(4);
432 
433             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
434 
435             msg.append("companyId=");
436             msg.append(companyId);
437 
438             msg.append(StringPool.CLOSE_CURLY_BRACE);
439 
440             throw new NoSuchContactException(msg.toString());
441         }
442         else {
443             return list.get(0);
444         }
445     }
446 
447     public Contact[] findByCompanyId_PrevAndNext(long contactId,
448         long companyId, OrderByComparator orderByComparator)
449         throws NoSuchContactException, SystemException {
450         Contact contact = findByPrimaryKey(contactId);
451 
452         Session session = null;
453 
454         try {
455             session = openSession();
456 
457             Contact[] array = new ContactImpl[3];
458 
459             array[0] = getByCompanyId_PrevAndNext(session, contact, companyId,
460                     orderByComparator, true);
461 
462             array[1] = contact;
463 
464             array[2] = getByCompanyId_PrevAndNext(session, contact, companyId,
465                     orderByComparator, false);
466 
467             return array;
468         }
469         catch (Exception e) {
470             throw processException(e);
471         }
472         finally {
473             closeSession(session);
474         }
475     }
476 
477     protected Contact getByCompanyId_PrevAndNext(Session session,
478         Contact contact, long companyId, OrderByComparator orderByComparator,
479         boolean previous) {
480         StringBundler query = null;
481 
482         if (orderByComparator != null) {
483             query = new StringBundler(6 +
484                     (orderByComparator.getOrderByFields().length * 6));
485         }
486         else {
487             query = new StringBundler(3);
488         }
489 
490         query.append(_SQL_SELECT_CONTACT_WHERE);
491 
492         query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
493 
494         if (orderByComparator != null) {
495             String[] orderByFields = orderByComparator.getOrderByFields();
496 
497             if (orderByFields.length > 0) {
498                 query.append(WHERE_AND);
499             }
500 
501             for (int i = 0; i < orderByFields.length; i++) {
502                 query.append(_ORDER_BY_ENTITY_ALIAS);
503                 query.append(orderByFields[i]);
504 
505                 if ((i + 1) < orderByFields.length) {
506                     if (orderByComparator.isAscending() ^ previous) {
507                         query.append(WHERE_GREATER_THAN_HAS_NEXT);
508                     }
509                     else {
510                         query.append(WHERE_LESSER_THAN_HAS_NEXT);
511                     }
512                 }
513                 else {
514                     if (orderByComparator.isAscending() ^ previous) {
515                         query.append(WHERE_GREATER_THAN);
516                     }
517                     else {
518                         query.append(WHERE_LESSER_THAN);
519                     }
520                 }
521             }
522 
523             query.append(ORDER_BY_CLAUSE);
524 
525             for (int i = 0; i < orderByFields.length; i++) {
526                 query.append(_ORDER_BY_ENTITY_ALIAS);
527                 query.append(orderByFields[i]);
528 
529                 if ((i + 1) < orderByFields.length) {
530                     if (orderByComparator.isAscending() ^ previous) {
531                         query.append(ORDER_BY_ASC_HAS_NEXT);
532                     }
533                     else {
534                         query.append(ORDER_BY_DESC_HAS_NEXT);
535                     }
536                 }
537                 else {
538                     if (orderByComparator.isAscending() ^ previous) {
539                         query.append(ORDER_BY_ASC);
540                     }
541                     else {
542                         query.append(ORDER_BY_DESC);
543                     }
544                 }
545             }
546         }
547 
548         String sql = query.toString();
549 
550         Query q = session.createQuery(sql);
551 
552         q.setFirstResult(0);
553         q.setMaxResults(2);
554 
555         QueryPos qPos = QueryPos.getInstance(q);
556 
557         qPos.add(companyId);
558 
559         if (orderByComparator != null) {
560             Object[] values = orderByComparator.getOrderByValues(contact);
561 
562             for (Object value : values) {
563                 qPos.add(value);
564             }
565         }
566 
567         List<Contact> list = q.list();
568 
569         if (list.size() == 2) {
570             return list.get(1);
571         }
572         else {
573             return null;
574         }
575     }
576 
577     public List<Contact> findAll() throws SystemException {
578         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
579     }
580 
581     public List<Contact> findAll(int start, int end) throws SystemException {
582         return findAll(start, end, null);
583     }
584 
585     public List<Contact> findAll(int start, int end,
586         OrderByComparator orderByComparator) throws SystemException {
587         Object[] finderArgs = new Object[] {
588                 String.valueOf(start), String.valueOf(end),
589                 String.valueOf(orderByComparator)
590             };
591 
592         List<Contact> list = (List<Contact>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
593                 finderArgs, this);
594 
595         if (list == null) {
596             StringBundler query = null;
597             String sql = null;
598 
599             if (orderByComparator != null) {
600                 query = new StringBundler(2 +
601                         (orderByComparator.getOrderByFields().length * 3));
602 
603                 query.append(_SQL_SELECT_CONTACT);
604 
605                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
606                     orderByComparator);
607 
608                 sql = query.toString();
609             }
610             else {
611                 sql = _SQL_SELECT_CONTACT;
612             }
613 
614             Session session = null;
615 
616             try {
617                 session = openSession();
618 
619                 Query q = session.createQuery(sql);
620 
621                 if (orderByComparator == null) {
622                     list = (List<Contact>)QueryUtil.list(q, getDialect(),
623                             start, end, false);
624 
625                     Collections.sort(list);
626                 }
627                 else {
628                     list = (List<Contact>)QueryUtil.list(q, getDialect(),
629                             start, end);
630                 }
631             }
632             catch (Exception e) {
633                 throw processException(e);
634             }
635             finally {
636                 if (list == null) {
637                     list = new ArrayList<Contact>();
638                 }
639 
640                 cacheResult(list);
641 
642                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
643 
644                 closeSession(session);
645             }
646         }
647 
648         return list;
649     }
650 
651     public void removeByCompanyId(long companyId) throws SystemException {
652         for (Contact contact : findByCompanyId(companyId)) {
653             remove(contact);
654         }
655     }
656 
657     public void removeAll() throws SystemException {
658         for (Contact contact : findAll()) {
659             remove(contact);
660         }
661     }
662 
663     public int countByCompanyId(long companyId) throws SystemException {
664         Object[] finderArgs = new Object[] { companyId };
665 
666         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
667                 finderArgs, this);
668 
669         if (count == null) {
670             StringBundler query = new StringBundler(2);
671 
672             query.append(_SQL_COUNT_CONTACT_WHERE);
673 
674             query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
675 
676             String sql = query.toString();
677 
678             Session session = null;
679 
680             try {
681                 session = openSession();
682 
683                 Query q = session.createQuery(sql);
684 
685                 QueryPos qPos = QueryPos.getInstance(q);
686 
687                 qPos.add(companyId);
688 
689                 count = (Long)q.uniqueResult();
690             }
691             catch (Exception e) {
692                 throw processException(e);
693             }
694             finally {
695                 if (count == null) {
696                     count = Long.valueOf(0);
697                 }
698 
699                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
700                     finderArgs, count);
701 
702                 closeSession(session);
703             }
704         }
705 
706         return count.intValue();
707     }
708 
709     public int countAll() throws SystemException {
710         Object[] finderArgs = new Object[0];
711 
712         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
713                 finderArgs, this);
714 
715         if (count == null) {
716             Session session = null;
717 
718             try {
719                 session = openSession();
720 
721                 Query q = session.createQuery(_SQL_COUNT_CONTACT);
722 
723                 count = (Long)q.uniqueResult();
724             }
725             catch (Exception e) {
726                 throw processException(e);
727             }
728             finally {
729                 if (count == null) {
730                     count = Long.valueOf(0);
731                 }
732 
733                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
734                     count);
735 
736                 closeSession(session);
737             }
738         }
739 
740         return count.intValue();
741     }
742 
743     public void afterPropertiesSet() {
744         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
745                     com.liferay.portal.util.PropsUtil.get(
746                         "value.object.listener.com.liferay.portal.model.Contact")));
747 
748         if (listenerClassNames.length > 0) {
749             try {
750                 List<ModelListener<Contact>> listenersList = new ArrayList<ModelListener<Contact>>();
751 
752                 for (String listenerClassName : listenerClassNames) {
753                     listenersList.add((ModelListener<Contact>)InstanceFactory.newInstance(
754                             listenerClassName));
755                 }
756 
757                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
758             }
759             catch (Exception e) {
760                 _log.error(e);
761             }
762         }
763     }
764 
765     public void destroy() {
766         EntityCacheUtil.removeCache(ContactImpl.class.getName());
767         FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
768         FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
769     }
770 
771     @BeanReference(type = AccountPersistence.class)
772     protected AccountPersistence accountPersistence;
773     @BeanReference(type = AddressPersistence.class)
774     protected AddressPersistence addressPersistence;
775     @BeanReference(type = BrowserTrackerPersistence.class)
776     protected BrowserTrackerPersistence browserTrackerPersistence;
777     @BeanReference(type = ClassNamePersistence.class)
778     protected ClassNamePersistence classNamePersistence;
779     @BeanReference(type = CompanyPersistence.class)
780     protected CompanyPersistence companyPersistence;
781     @BeanReference(type = ContactPersistence.class)
782     protected ContactPersistence contactPersistence;
783     @BeanReference(type = CountryPersistence.class)
784     protected CountryPersistence countryPersistence;
785     @BeanReference(type = EmailAddressPersistence.class)
786     protected EmailAddressPersistence emailAddressPersistence;
787     @BeanReference(type = GroupPersistence.class)
788     protected GroupPersistence groupPersistence;
789     @BeanReference(type = ImagePersistence.class)
790     protected ImagePersistence imagePersistence;
791     @BeanReference(type = LayoutPersistence.class)
792     protected LayoutPersistence layoutPersistence;
793     @BeanReference(type = LayoutSetPersistence.class)
794     protected LayoutSetPersistence layoutSetPersistence;
795     @BeanReference(type = ListTypePersistence.class)
796     protected ListTypePersistence listTypePersistence;
797     @BeanReference(type = LockPersistence.class)
798     protected LockPersistence lockPersistence;
799     @BeanReference(type = MembershipRequestPersistence.class)
800     protected MembershipRequestPersistence membershipRequestPersistence;
801     @BeanReference(type = OrganizationPersistence.class)
802     protected OrganizationPersistence organizationPersistence;
803     @BeanReference(type = OrgGroupPermissionPersistence.class)
804     protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
805     @BeanReference(type = OrgGroupRolePersistence.class)
806     protected OrgGroupRolePersistence orgGroupRolePersistence;
807     @BeanReference(type = OrgLaborPersistence.class)
808     protected OrgLaborPersistence orgLaborPersistence;
809     @BeanReference(type = PasswordPolicyPersistence.class)
810     protected PasswordPolicyPersistence passwordPolicyPersistence;
811     @BeanReference(type = PasswordPolicyRelPersistence.class)
812     protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
813     @BeanReference(type = PasswordTrackerPersistence.class)
814     protected PasswordTrackerPersistence passwordTrackerPersistence;
815     @BeanReference(type = PermissionPersistence.class)
816     protected PermissionPersistence permissionPersistence;
817     @BeanReference(type = PhonePersistence.class)
818     protected PhonePersistence phonePersistence;
819     @BeanReference(type = PluginSettingPersistence.class)
820     protected PluginSettingPersistence pluginSettingPersistence;
821     @BeanReference(type = PortletPersistence.class)
822     protected PortletPersistence portletPersistence;
823     @BeanReference(type = PortletItemPersistence.class)
824     protected PortletItemPersistence portletItemPersistence;
825     @BeanReference(type = PortletPreferencesPersistence.class)
826     protected PortletPreferencesPersistence portletPreferencesPersistence;
827     @BeanReference(type = RegionPersistence.class)
828     protected RegionPersistence regionPersistence;
829     @BeanReference(type = ReleasePersistence.class)
830     protected ReleasePersistence releasePersistence;
831     @BeanReference(type = ResourcePersistence.class)
832     protected ResourcePersistence resourcePersistence;
833     @BeanReference(type = ResourceActionPersistence.class)
834     protected ResourceActionPersistence resourceActionPersistence;
835     @BeanReference(type = ResourceCodePersistence.class)
836     protected ResourceCodePersistence resourceCodePersistence;
837     @BeanReference(type = ResourcePermissionPersistence.class)
838     protected ResourcePermissionPersistence resourcePermissionPersistence;
839     @BeanReference(type = RolePersistence.class)
840     protected RolePersistence rolePersistence;
841     @BeanReference(type = ServiceComponentPersistence.class)
842     protected ServiceComponentPersistence serviceComponentPersistence;
843     @BeanReference(type = ShardPersistence.class)
844     protected ShardPersistence shardPersistence;
845     @BeanReference(type = SubscriptionPersistence.class)
846     protected SubscriptionPersistence subscriptionPersistence;
847     @BeanReference(type = UserPersistence.class)
848     protected UserPersistence userPersistence;
849     @BeanReference(type = UserGroupPersistence.class)
850     protected UserGroupPersistence userGroupPersistence;
851     @BeanReference(type = UserGroupGroupRolePersistence.class)
852     protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
853     @BeanReference(type = UserGroupRolePersistence.class)
854     protected UserGroupRolePersistence userGroupRolePersistence;
855     @BeanReference(type = UserIdMapperPersistence.class)
856     protected UserIdMapperPersistence userIdMapperPersistence;
857     @BeanReference(type = UserTrackerPersistence.class)
858     protected UserTrackerPersistence userTrackerPersistence;
859     @BeanReference(type = UserTrackerPathPersistence.class)
860     protected UserTrackerPathPersistence userTrackerPathPersistence;
861     @BeanReference(type = WebDAVPropsPersistence.class)
862     protected WebDAVPropsPersistence webDAVPropsPersistence;
863     @BeanReference(type = WebsitePersistence.class)
864     protected WebsitePersistence websitePersistence;
865     private static final String _SQL_SELECT_CONTACT = "SELECT contact FROM Contact contact";
866     private static final String _SQL_SELECT_CONTACT_WHERE = "SELECT contact FROM Contact contact WHERE ";
867     private static final String _SQL_COUNT_CONTACT = "SELECT COUNT(contact) FROM Contact contact";
868     private static final String _SQL_COUNT_CONTACT_WHERE = "SELECT COUNT(contact) FROM Contact contact WHERE ";
869     private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "contact.companyId = ?";
870     private static final String _ORDER_BY_ENTITY_ALIAS = "contact.";
871     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Contact exists with the primary key ";
872     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Contact exists with the key {";
873     private static Log _log = LogFactoryUtil.getLog(ContactPersistenceImpl.class);
874 }