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