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.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.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     public Contact remove(Contact contact) throws SystemException {
160         for (ModelListener<Contact> listener : listeners) {
161             listener.onBeforeRemove(contact);
162         }
163 
164         contact = removeImpl(contact);
165 
166         for (ModelListener<Contact> listener : listeners) {
167             listener.onAfterRemove(contact);
168         }
169 
170         return contact;
171     }
172 
173     protected Contact removeImpl(Contact contact) throws SystemException {
174         contact = toUnwrappedModel(contact);
175 
176         Session session = null;
177 
178         try {
179             session = openSession();
180 
181             if (contact.isCachedModel() || BatchSessionUtil.isEnabled()) {
182                 Object staleObject = session.get(ContactImpl.class,
183                         contact.getPrimaryKeyObj());
184 
185                 if (staleObject != null) {
186                     session.evict(staleObject);
187                 }
188             }
189 
190             session.delete(contact);
191 
192             session.flush();
193         }
194         catch (Exception e) {
195             throw processException(e);
196         }
197         finally {
198             closeSession(session);
199         }
200 
201         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
202 
203         EntityCacheUtil.removeResult(ContactModelImpl.ENTITY_CACHE_ENABLED,
204             ContactImpl.class, contact.getPrimaryKey());
205 
206         return contact;
207     }
208 
209     public Contact updateImpl(com.liferay.portal.model.Contact contact,
210         boolean merge) throws SystemException {
211         contact = toUnwrappedModel(contact);
212 
213         Session session = null;
214 
215         try {
216             session = openSession();
217 
218             BatchSessionUtil.update(session, contact, merge);
219 
220             contact.setNew(false);
221         }
222         catch (Exception e) {
223             throw processException(e);
224         }
225         finally {
226             closeSession(session);
227         }
228 
229         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
230 
231         EntityCacheUtil.putResult(ContactModelImpl.ENTITY_CACHE_ENABLED,
232             ContactImpl.class, contact.getPrimaryKey(), contact);
233 
234         return contact;
235     }
236 
237     protected Contact toUnwrappedModel(Contact contact) {
238         if (contact instanceof ContactImpl) {
239             return contact;
240         }
241 
242         ContactImpl contactImpl = new ContactImpl();
243 
244         contactImpl.setNew(contact.isNew());
245         contactImpl.setPrimaryKey(contact.getPrimaryKey());
246 
247         contactImpl.setContactId(contact.getContactId());
248         contactImpl.setCompanyId(contact.getCompanyId());
249         contactImpl.setUserId(contact.getUserId());
250         contactImpl.setUserName(contact.getUserName());
251         contactImpl.setCreateDate(contact.getCreateDate());
252         contactImpl.setModifiedDate(contact.getModifiedDate());
253         contactImpl.setAccountId(contact.getAccountId());
254         contactImpl.setParentContactId(contact.getParentContactId());
255         contactImpl.setFirstName(contact.getFirstName());
256         contactImpl.setMiddleName(contact.getMiddleName());
257         contactImpl.setLastName(contact.getLastName());
258         contactImpl.setPrefixId(contact.getPrefixId());
259         contactImpl.setSuffixId(contact.getSuffixId());
260         contactImpl.setMale(contact.isMale());
261         contactImpl.setBirthday(contact.getBirthday());
262         contactImpl.setSmsSn(contact.getSmsSn());
263         contactImpl.setAimSn(contact.getAimSn());
264         contactImpl.setFacebookSn(contact.getFacebookSn());
265         contactImpl.setIcqSn(contact.getIcqSn());
266         contactImpl.setJabberSn(contact.getJabberSn());
267         contactImpl.setMsnSn(contact.getMsnSn());
268         contactImpl.setMySpaceSn(contact.getMySpaceSn());
269         contactImpl.setSkypeSn(contact.getSkypeSn());
270         contactImpl.setTwitterSn(contact.getTwitterSn());
271         contactImpl.setYmSn(contact.getYmSn());
272         contactImpl.setEmployeeStatusId(contact.getEmployeeStatusId());
273         contactImpl.setEmployeeNumber(contact.getEmployeeNumber());
274         contactImpl.setJobTitle(contact.getJobTitle());
275         contactImpl.setJobClass(contact.getJobClass());
276         contactImpl.setHoursOfOperation(contact.getHoursOfOperation());
277 
278         return contactImpl;
279     }
280 
281     public Contact findByPrimaryKey(Serializable primaryKey)
282         throws NoSuchModelException, SystemException {
283         return findByPrimaryKey(((Long)primaryKey).longValue());
284     }
285 
286     public Contact findByPrimaryKey(long contactId)
287         throws NoSuchContactException, SystemException {
288         Contact contact = fetchByPrimaryKey(contactId);
289 
290         if (contact == null) {
291             if (_log.isWarnEnabled()) {
292                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contactId);
293             }
294 
295             throw new NoSuchContactException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
296                 contactId);
297         }
298 
299         return contact;
300     }
301 
302     public Contact fetchByPrimaryKey(Serializable primaryKey)
303         throws SystemException {
304         return fetchByPrimaryKey(((Long)primaryKey).longValue());
305     }
306 
307     public Contact fetchByPrimaryKey(long contactId) throws SystemException {
308         Contact contact = (Contact)EntityCacheUtil.getResult(ContactModelImpl.ENTITY_CACHE_ENABLED,
309                 ContactImpl.class, contactId, this);
310 
311         if (contact == null) {
312             Session session = null;
313 
314             try {
315                 session = openSession();
316 
317                 contact = (Contact)session.get(ContactImpl.class,
318                         new Long(contactId));
319             }
320             catch (Exception e) {
321                 throw processException(e);
322             }
323             finally {
324                 if (contact != null) {
325                     cacheResult(contact);
326                 }
327 
328                 closeSession(session);
329             }
330         }
331 
332         return contact;
333     }
334 
335     public List<Contact> findByCompanyId(long companyId)
336         throws SystemException {
337         return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
338             null);
339     }
340 
341     public List<Contact> findByCompanyId(long companyId, int start, int end)
342         throws SystemException {
343         return findByCompanyId(companyId, start, end, null);
344     }
345 
346     public List<Contact> findByCompanyId(long companyId, int start, int end,
347         OrderByComparator orderByComparator) throws SystemException {
348         Object[] finderArgs = new Object[] {
349                 new Long(companyId),
350                 
351                 String.valueOf(start), String.valueOf(end),
352                 String.valueOf(orderByComparator)
353             };
354 
355         List<Contact> list = (List<Contact>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
356                 finderArgs, this);
357 
358         if (list == null) {
359             Session session = null;
360 
361             try {
362                 session = openSession();
363 
364                 StringBundler query = null;
365 
366                 if (orderByComparator != null) {
367                     query = new StringBundler(3 +
368                             (orderByComparator.getOrderByFields().length * 3));
369                 }
370                 else {
371                     query = new StringBundler(2);
372                 }
373 
374                 query.append(_SQL_SELECT_CONTACT_WHERE);
375 
376                 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
377 
378                 if (orderByComparator != null) {
379                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
380                         orderByComparator);
381                 }
382 
383                 String sql = query.toString();
384 
385                 Query q = session.createQuery(sql);
386 
387                 QueryPos qPos = QueryPos.getInstance(q);
388 
389                 qPos.add(companyId);
390 
391                 list = (List<Contact>)QueryUtil.list(q, getDialect(), start, end);
392             }
393             catch (Exception e) {
394                 throw processException(e);
395             }
396             finally {
397                 if (list == null) {
398                     list = new ArrayList<Contact>();
399                 }
400 
401                 cacheResult(list);
402 
403                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
404                     finderArgs, list);
405 
406                 closeSession(session);
407             }
408         }
409 
410         return list;
411     }
412 
413     public Contact findByCompanyId_First(long companyId,
414         OrderByComparator orderByComparator)
415         throws NoSuchContactException, SystemException {
416         List<Contact> list = findByCompanyId(companyId, 0, 1, orderByComparator);
417 
418         if (list.isEmpty()) {
419             StringBundler msg = new StringBundler(4);
420 
421             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
422 
423             msg.append("companyId=");
424             msg.append(companyId);
425 
426             msg.append(StringPool.CLOSE_CURLY_BRACE);
427 
428             throw new NoSuchContactException(msg.toString());
429         }
430         else {
431             return list.get(0);
432         }
433     }
434 
435     public Contact findByCompanyId_Last(long companyId,
436         OrderByComparator orderByComparator)
437         throws NoSuchContactException, SystemException {
438         int count = countByCompanyId(companyId);
439 
440         List<Contact> list = findByCompanyId(companyId, count - 1, count,
441                 orderByComparator);
442 
443         if (list.isEmpty()) {
444             StringBundler msg = new StringBundler(4);
445 
446             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
447 
448             msg.append("companyId=");
449             msg.append(companyId);
450 
451             msg.append(StringPool.CLOSE_CURLY_BRACE);
452 
453             throw new NoSuchContactException(msg.toString());
454         }
455         else {
456             return list.get(0);
457         }
458     }
459 
460     public Contact[] findByCompanyId_PrevAndNext(long contactId,
461         long companyId, OrderByComparator orderByComparator)
462         throws NoSuchContactException, SystemException {
463         Contact contact = findByPrimaryKey(contactId);
464 
465         Session session = null;
466 
467         try {
468             session = openSession();
469 
470             Contact[] array = new ContactImpl[3];
471 
472             array[0] = getByCompanyId_PrevAndNext(session, contact, companyId,
473                     orderByComparator, true);
474 
475             array[1] = contact;
476 
477             array[2] = getByCompanyId_PrevAndNext(session, contact, companyId,
478                     orderByComparator, false);
479 
480             return array;
481         }
482         catch (Exception e) {
483             throw processException(e);
484         }
485         finally {
486             closeSession(session);
487         }
488     }
489 
490     protected Contact getByCompanyId_PrevAndNext(Session session,
491         Contact contact, long companyId, OrderByComparator orderByComparator,
492         boolean previous) {
493         StringBundler query = null;
494 
495         if (orderByComparator != null) {
496             query = new StringBundler(6 +
497                     (orderByComparator.getOrderByFields().length * 6));
498         }
499         else {
500             query = new StringBundler(3);
501         }
502 
503         query.append(_SQL_SELECT_CONTACT_WHERE);
504 
505         query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
506 
507         if (orderByComparator != null) {
508             String[] orderByFields = orderByComparator.getOrderByFields();
509 
510             if (orderByFields.length > 0) {
511                 query.append(WHERE_AND);
512             }
513 
514             for (int i = 0; i < orderByFields.length; i++) {
515                 query.append(_ORDER_BY_ENTITY_ALIAS);
516                 query.append(orderByFields[i]);
517 
518                 if ((i + 1) < orderByFields.length) {
519                     if (orderByComparator.isAscending() ^ previous) {
520                         query.append(WHERE_GREATER_THAN_HAS_NEXT);
521                     }
522                     else {
523                         query.append(WHERE_LESSER_THAN_HAS_NEXT);
524                     }
525                 }
526                 else {
527                     if (orderByComparator.isAscending() ^ previous) {
528                         query.append(WHERE_GREATER_THAN);
529                     }
530                     else {
531                         query.append(WHERE_LESSER_THAN);
532                     }
533                 }
534             }
535 
536             query.append(ORDER_BY_CLAUSE);
537 
538             for (int i = 0; i < orderByFields.length; i++) {
539                 query.append(_ORDER_BY_ENTITY_ALIAS);
540                 query.append(orderByFields[i]);
541 
542                 if ((i + 1) < orderByFields.length) {
543                     if (orderByComparator.isAscending() ^ previous) {
544                         query.append(ORDER_BY_ASC_HAS_NEXT);
545                     }
546                     else {
547                         query.append(ORDER_BY_DESC_HAS_NEXT);
548                     }
549                 }
550                 else {
551                     if (orderByComparator.isAscending() ^ previous) {
552                         query.append(ORDER_BY_ASC);
553                     }
554                     else {
555                         query.append(ORDER_BY_DESC);
556                     }
557                 }
558             }
559         }
560 
561         String sql = query.toString();
562 
563         Query q = session.createQuery(sql);
564 
565         q.setFirstResult(0);
566         q.setMaxResults(2);
567 
568         QueryPos qPos = QueryPos.getInstance(q);
569 
570         qPos.add(companyId);
571 
572         if (orderByComparator != null) {
573             Object[] values = orderByComparator.getOrderByValues(contact);
574 
575             for (Object value : values) {
576                 qPos.add(value);
577             }
578         }
579 
580         List<Contact> list = q.list();
581 
582         if (list.size() == 2) {
583             return list.get(1);
584         }
585         else {
586             return null;
587         }
588     }
589 
590     public List<Contact> findAll() throws SystemException {
591         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
592     }
593 
594     public List<Contact> findAll(int start, int end) throws SystemException {
595         return findAll(start, end, null);
596     }
597 
598     public List<Contact> findAll(int start, int end,
599         OrderByComparator orderByComparator) throws SystemException {
600         Object[] finderArgs = new Object[] {
601                 String.valueOf(start), String.valueOf(end),
602                 String.valueOf(orderByComparator)
603             };
604 
605         List<Contact> list = (List<Contact>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
606                 finderArgs, this);
607 
608         if (list == null) {
609             Session session = null;
610 
611             try {
612                 session = openSession();
613 
614                 StringBundler query = null;
615                 String sql = null;
616 
617                 if (orderByComparator != null) {
618                     query = new StringBundler(2 +
619                             (orderByComparator.getOrderByFields().length * 3));
620 
621                     query.append(_SQL_SELECT_CONTACT);
622 
623                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
624                         orderByComparator);
625 
626                     sql = query.toString();
627                 }
628 
629                 sql = _SQL_SELECT_CONTACT;
630 
631                 Query q = session.createQuery(sql);
632 
633                 if (orderByComparator == 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>)InstanceFactory.newInstance(
766                             listenerClassName));
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(type = AccountPersistence.class)
778     protected AccountPersistence accountPersistence;
779     @BeanReference(type = AddressPersistence.class)
780     protected AddressPersistence addressPersistence;
781     @BeanReference(type = BrowserTrackerPersistence.class)
782     protected BrowserTrackerPersistence browserTrackerPersistence;
783     @BeanReference(type = ClassNamePersistence.class)
784     protected ClassNamePersistence classNamePersistence;
785     @BeanReference(type = CompanyPersistence.class)
786     protected CompanyPersistence companyPersistence;
787     @BeanReference(type = ContactPersistence.class)
788     protected ContactPersistence contactPersistence;
789     @BeanReference(type = CountryPersistence.class)
790     protected CountryPersistence countryPersistence;
791     @BeanReference(type = EmailAddressPersistence.class)
792     protected EmailAddressPersistence emailAddressPersistence;
793     @BeanReference(type = GroupPersistence.class)
794     protected GroupPersistence groupPersistence;
795     @BeanReference(type = ImagePersistence.class)
796     protected ImagePersistence imagePersistence;
797     @BeanReference(type = LayoutPersistence.class)
798     protected LayoutPersistence layoutPersistence;
799     @BeanReference(type = LayoutPrototypePersistence.class)
800     protected LayoutPrototypePersistence layoutPrototypePersistence;
801     @BeanReference(type = LayoutSetPersistence.class)
802     protected LayoutSetPersistence layoutSetPersistence;
803     @BeanReference(type = LayoutSetPrototypePersistence.class)
804     protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
805     @BeanReference(type = ListTypePersistence.class)
806     protected ListTypePersistence listTypePersistence;
807     @BeanReference(type = LockPersistence.class)
808     protected LockPersistence lockPersistence;
809     @BeanReference(type = MembershipRequestPersistence.class)
810     protected MembershipRequestPersistence membershipRequestPersistence;
811     @BeanReference(type = OrganizationPersistence.class)
812     protected OrganizationPersistence organizationPersistence;
813     @BeanReference(type = OrgGroupPermissionPersistence.class)
814     protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
815     @BeanReference(type = OrgGroupRolePersistence.class)
816     protected OrgGroupRolePersistence orgGroupRolePersistence;
817     @BeanReference(type = OrgLaborPersistence.class)
818     protected OrgLaborPersistence orgLaborPersistence;
819     @BeanReference(type = PasswordPolicyPersistence.class)
820     protected PasswordPolicyPersistence passwordPolicyPersistence;
821     @BeanReference(type = PasswordPolicyRelPersistence.class)
822     protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
823     @BeanReference(type = PasswordTrackerPersistence.class)
824     protected PasswordTrackerPersistence passwordTrackerPersistence;
825     @BeanReference(type = PermissionPersistence.class)
826     protected PermissionPersistence permissionPersistence;
827     @BeanReference(type = PhonePersistence.class)
828     protected PhonePersistence phonePersistence;
829     @BeanReference(type = PluginSettingPersistence.class)
830     protected PluginSettingPersistence pluginSettingPersistence;
831     @BeanReference(type = PortletPersistence.class)
832     protected PortletPersistence portletPersistence;
833     @BeanReference(type = PortletItemPersistence.class)
834     protected PortletItemPersistence portletItemPersistence;
835     @BeanReference(type = PortletPreferencesPersistence.class)
836     protected PortletPreferencesPersistence portletPreferencesPersistence;
837     @BeanReference(type = RegionPersistence.class)
838     protected RegionPersistence regionPersistence;
839     @BeanReference(type = ReleasePersistence.class)
840     protected ReleasePersistence releasePersistence;
841     @BeanReference(type = ResourcePersistence.class)
842     protected ResourcePersistence resourcePersistence;
843     @BeanReference(type = ResourceActionPersistence.class)
844     protected ResourceActionPersistence resourceActionPersistence;
845     @BeanReference(type = ResourceCodePersistence.class)
846     protected ResourceCodePersistence resourceCodePersistence;
847     @BeanReference(type = ResourcePermissionPersistence.class)
848     protected ResourcePermissionPersistence resourcePermissionPersistence;
849     @BeanReference(type = RolePersistence.class)
850     protected RolePersistence rolePersistence;
851     @BeanReference(type = ServiceComponentPersistence.class)
852     protected ServiceComponentPersistence serviceComponentPersistence;
853     @BeanReference(type = ShardPersistence.class)
854     protected ShardPersistence shardPersistence;
855     @BeanReference(type = SubscriptionPersistence.class)
856     protected SubscriptionPersistence subscriptionPersistence;
857     @BeanReference(type = TicketPersistence.class)
858     protected TicketPersistence ticketPersistence;
859     @BeanReference(type = TeamPersistence.class)
860     protected TeamPersistence teamPersistence;
861     @BeanReference(type = UserPersistence.class)
862     protected UserPersistence userPersistence;
863     @BeanReference(type = UserGroupPersistence.class)
864     protected UserGroupPersistence userGroupPersistence;
865     @BeanReference(type = UserGroupGroupRolePersistence.class)
866     protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
867     @BeanReference(type = UserGroupRolePersistence.class)
868     protected UserGroupRolePersistence userGroupRolePersistence;
869     @BeanReference(type = UserIdMapperPersistence.class)
870     protected UserIdMapperPersistence userIdMapperPersistence;
871     @BeanReference(type = UserTrackerPersistence.class)
872     protected UserTrackerPersistence userTrackerPersistence;
873     @BeanReference(type = UserTrackerPathPersistence.class)
874     protected UserTrackerPathPersistence userTrackerPathPersistence;
875     @BeanReference(type = WebDAVPropsPersistence.class)
876     protected WebDAVPropsPersistence webDAVPropsPersistence;
877     @BeanReference(type = WebsitePersistence.class)
878     protected WebsitePersistence websitePersistence;
879     @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
880     protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
881     @BeanReference(type = WorkflowInstanceLinkPersistence.class)
882     protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
883     private static final String _SQL_SELECT_CONTACT = "SELECT contact FROM Contact contact";
884     private static final String _SQL_SELECT_CONTACT_WHERE = "SELECT contact FROM Contact contact WHERE ";
885     private static final String _SQL_COUNT_CONTACT = "SELECT COUNT(contact) FROM Contact contact";
886     private static final String _SQL_COUNT_CONTACT_WHERE = "SELECT COUNT(contact) FROM Contact contact WHERE ";
887     private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "contact.companyId = ?";
888     private static final String _ORDER_BY_ENTITY_ALIAS = "contact.";
889     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Contact exists with the primary key ";
890     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Contact exists with the key {";
891     private static Log _log = LogFactoryUtil.getLog(ContactPersistenceImpl.class);
892 }