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