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.NoSuchCompanyException;
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.kernel.util.Validator;
38  import com.liferay.portal.model.Company;
39  import com.liferay.portal.model.ModelListener;
40  import com.liferay.portal.model.impl.CompanyImpl;
41  import com.liferay.portal.model.impl.CompanyModelImpl;
42  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
43  
44  import java.io.Serializable;
45  
46  import java.util.ArrayList;
47  import java.util.Collections;
48  import java.util.List;
49  
50  /**
51   * <a href="CompanyPersistenceImpl.java.html"><b><i>View Source</i></b></a>
52   *
53   * <p>
54   * ServiceBuilder generated this class. Modifications in this class will be
55   * overwritten the next time is generated.
56   * </p>
57   *
58   * @author    Brian Wing Shun Chan
59   * @see       CompanyPersistence
60   * @see       CompanyUtil
61   * @generated
62   */
63  public class CompanyPersistenceImpl extends BasePersistenceImpl<Company>
64      implements CompanyPersistence {
65      public static final String FINDER_CLASS_NAME_ENTITY = CompanyImpl.class.getName();
66      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
67          ".List";
68      public static final FinderPath FINDER_PATH_FETCH_BY_WEBID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
69              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
70              "fetchByWebId", new String[] { String.class.getName() });
71      public static final FinderPath FINDER_PATH_COUNT_BY_WEBID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
72              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
73              "countByWebId", new String[] { String.class.getName() });
74      public static final FinderPath FINDER_PATH_FETCH_BY_VIRTUALHOST = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
75              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
76              "fetchByVirtualHost", new String[] { String.class.getName() });
77      public static final FinderPath FINDER_PATH_COUNT_BY_VIRTUALHOST = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
78              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
79              "countByVirtualHost", new String[] { String.class.getName() });
80      public static final FinderPath FINDER_PATH_FETCH_BY_MX = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
81              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
82              "fetchByMx", new String[] { String.class.getName() });
83      public static final FinderPath FINDER_PATH_COUNT_BY_MX = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
84              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
85              "countByMx", new String[] { String.class.getName() });
86      public static final FinderPath FINDER_PATH_FETCH_BY_LOGOID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
87              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
88              "fetchByLogoId", new String[] { Long.class.getName() });
89      public static final FinderPath FINDER_PATH_COUNT_BY_LOGOID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
90              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
91              "countByLogoId", new String[] { Long.class.getName() });
92      public static final FinderPath FINDER_PATH_FIND_BY_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
93              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
94              "findBySystem", new String[] { Boolean.class.getName() });
95      public static final FinderPath FINDER_PATH_FIND_BY_OBC_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
96              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
97              "findBySystem",
98              new String[] {
99                  Boolean.class.getName(),
100                 
101             "java.lang.Integer", "java.lang.Integer",
102                 "com.liferay.portal.kernel.util.OrderByComparator"
103             });
104     public static final FinderPath FINDER_PATH_COUNT_BY_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
105             CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
106             "countBySystem", new String[] { Boolean.class.getName() });
107     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
108             CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
109             "findAll", new String[0]);
110     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
111             CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
112             "countAll", new String[0]);
113 
114     public void cacheResult(Company company) {
115         EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
116             CompanyImpl.class, company.getPrimaryKey(), company);
117 
118         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
119             new Object[] { company.getWebId() }, company);
120 
121         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
122             new Object[] { company.getVirtualHost() }, company);
123 
124         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
125             new Object[] { company.getMx() }, company);
126 
127         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
128             new Object[] { new Long(company.getLogoId()) }, company);
129     }
130 
131     public void cacheResult(List<Company> companies) {
132         for (Company company : companies) {
133             if (EntityCacheUtil.getResult(
134                         CompanyModelImpl.ENTITY_CACHE_ENABLED,
135                         CompanyImpl.class, company.getPrimaryKey(), this) == null) {
136                 cacheResult(company);
137             }
138         }
139     }
140 
141     public void clearCache() {
142         CacheRegistry.clear(CompanyImpl.class.getName());
143         EntityCacheUtil.clearCache(CompanyImpl.class.getName());
144         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
145         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
146     }
147 
148     public Company create(long companyId) {
149         Company company = new CompanyImpl();
150 
151         company.setNew(true);
152         company.setPrimaryKey(companyId);
153 
154         return company;
155     }
156 
157     public Company remove(Serializable primaryKey)
158         throws NoSuchModelException, SystemException {
159         return remove(((Long)primaryKey).longValue());
160     }
161 
162     public Company remove(long companyId)
163         throws NoSuchCompanyException, SystemException {
164         Session session = null;
165 
166         try {
167             session = openSession();
168 
169             Company company = (Company)session.get(CompanyImpl.class,
170                     new Long(companyId));
171 
172             if (company == null) {
173                 if (_log.isWarnEnabled()) {
174                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + companyId);
175                 }
176 
177                 throw new NoSuchCompanyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
178                     companyId);
179             }
180 
181             return remove(company);
182         }
183         catch (NoSuchCompanyException nsee) {
184             throw nsee;
185         }
186         catch (Exception e) {
187             throw processException(e);
188         }
189         finally {
190             closeSession(session);
191         }
192     }
193 
194     public Company remove(Company company) throws SystemException {
195         for (ModelListener<Company> listener : listeners) {
196             listener.onBeforeRemove(company);
197         }
198 
199         company = removeImpl(company);
200 
201         for (ModelListener<Company> listener : listeners) {
202             listener.onAfterRemove(company);
203         }
204 
205         return company;
206     }
207 
208     protected Company removeImpl(Company company) throws SystemException {
209         company = toUnwrappedModel(company);
210 
211         Session session = null;
212 
213         try {
214             session = openSession();
215 
216             if (company.isCachedModel() || BatchSessionUtil.isEnabled()) {
217                 Object staleObject = session.get(CompanyImpl.class,
218                         company.getPrimaryKeyObj());
219 
220                 if (staleObject != null) {
221                     session.evict(staleObject);
222                 }
223             }
224 
225             session.delete(company);
226 
227             session.flush();
228         }
229         catch (Exception e) {
230             throw processException(e);
231         }
232         finally {
233             closeSession(session);
234         }
235 
236         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
237 
238         CompanyModelImpl companyModelImpl = (CompanyModelImpl)company;
239 
240         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID,
241             new Object[] { companyModelImpl.getOriginalWebId() });
242 
243         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
244             new Object[] { companyModelImpl.getOriginalVirtualHost() });
245 
246         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX,
247             new Object[] { companyModelImpl.getOriginalMx() });
248 
249         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID,
250             new Object[] { new Long(companyModelImpl.getOriginalLogoId()) });
251 
252         EntityCacheUtil.removeResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
253             CompanyImpl.class, company.getPrimaryKey());
254 
255         return company;
256     }
257 
258     public Company updateImpl(com.liferay.portal.model.Company company,
259         boolean merge) throws SystemException {
260         company = toUnwrappedModel(company);
261 
262         boolean isNew = company.isNew();
263 
264         CompanyModelImpl companyModelImpl = (CompanyModelImpl)company;
265 
266         Session session = null;
267 
268         try {
269             session = openSession();
270 
271             BatchSessionUtil.update(session, company, merge);
272 
273             company.setNew(false);
274         }
275         catch (Exception e) {
276             throw processException(e);
277         }
278         finally {
279             closeSession(session);
280         }
281 
282         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
283 
284         EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
285             CompanyImpl.class, company.getPrimaryKey(), company);
286 
287         if (!isNew &&
288                 (!Validator.equals(company.getWebId(),
289                     companyModelImpl.getOriginalWebId()))) {
290             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID,
291                 new Object[] { companyModelImpl.getOriginalWebId() });
292         }
293 
294         if (isNew ||
295                 (!Validator.equals(company.getWebId(),
296                     companyModelImpl.getOriginalWebId()))) {
297             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
298                 new Object[] { company.getWebId() }, company);
299         }
300 
301         if (!isNew &&
302                 (!Validator.equals(company.getVirtualHost(),
303                     companyModelImpl.getOriginalVirtualHost()))) {
304             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
305                 new Object[] { companyModelImpl.getOriginalVirtualHost() });
306         }
307 
308         if (isNew ||
309                 (!Validator.equals(company.getVirtualHost(),
310                     companyModelImpl.getOriginalVirtualHost()))) {
311             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
312                 new Object[] { company.getVirtualHost() }, company);
313         }
314 
315         if (!isNew &&
316                 (!Validator.equals(company.getMx(),
317                     companyModelImpl.getOriginalMx()))) {
318             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX,
319                 new Object[] { companyModelImpl.getOriginalMx() });
320         }
321 
322         if (isNew ||
323                 (!Validator.equals(company.getMx(),
324                     companyModelImpl.getOriginalMx()))) {
325             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
326                 new Object[] { company.getMx() }, company);
327         }
328 
329         if (!isNew &&
330                 (company.getLogoId() != companyModelImpl.getOriginalLogoId())) {
331             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID,
332                 new Object[] { new Long(companyModelImpl.getOriginalLogoId()) });
333         }
334 
335         if (isNew ||
336                 (company.getLogoId() != companyModelImpl.getOriginalLogoId())) {
337             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
338                 new Object[] { new Long(company.getLogoId()) }, company);
339         }
340 
341         return company;
342     }
343 
344     protected Company toUnwrappedModel(Company company) {
345         if (company instanceof CompanyImpl) {
346             return company;
347         }
348 
349         CompanyImpl companyImpl = new CompanyImpl();
350 
351         companyImpl.setNew(company.isNew());
352         companyImpl.setPrimaryKey(company.getPrimaryKey());
353 
354         companyImpl.setCompanyId(company.getCompanyId());
355         companyImpl.setAccountId(company.getAccountId());
356         companyImpl.setWebId(company.getWebId());
357         companyImpl.setKey(company.getKey());
358         companyImpl.setVirtualHost(company.getVirtualHost());
359         companyImpl.setMx(company.getMx());
360         companyImpl.setHomeURL(company.getHomeURL());
361         companyImpl.setLogoId(company.getLogoId());
362         companyImpl.setSystem(company.isSystem());
363 
364         return companyImpl;
365     }
366 
367     public Company findByPrimaryKey(Serializable primaryKey)
368         throws NoSuchModelException, SystemException {
369         return findByPrimaryKey(((Long)primaryKey).longValue());
370     }
371 
372     public Company findByPrimaryKey(long companyId)
373         throws NoSuchCompanyException, SystemException {
374         Company company = fetchByPrimaryKey(companyId);
375 
376         if (company == null) {
377             if (_log.isWarnEnabled()) {
378                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + companyId);
379             }
380 
381             throw new NoSuchCompanyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
382                 companyId);
383         }
384 
385         return company;
386     }
387 
388     public Company fetchByPrimaryKey(Serializable primaryKey)
389         throws SystemException {
390         return fetchByPrimaryKey(((Long)primaryKey).longValue());
391     }
392 
393     public Company fetchByPrimaryKey(long companyId) throws SystemException {
394         Company company = (Company)EntityCacheUtil.getResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
395                 CompanyImpl.class, companyId, this);
396 
397         if (company == null) {
398             Session session = null;
399 
400             try {
401                 session = openSession();
402 
403                 company = (Company)session.get(CompanyImpl.class,
404                         new Long(companyId));
405             }
406             catch (Exception e) {
407                 throw processException(e);
408             }
409             finally {
410                 if (company != null) {
411                     cacheResult(company);
412                 }
413 
414                 closeSession(session);
415             }
416         }
417 
418         return company;
419     }
420 
421     public Company findByWebId(String webId)
422         throws NoSuchCompanyException, SystemException {
423         Company company = fetchByWebId(webId);
424 
425         if (company == null) {
426             StringBundler msg = new StringBundler(4);
427 
428             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
429 
430             msg.append("webId=");
431             msg.append(webId);
432 
433             msg.append(StringPool.CLOSE_CURLY_BRACE);
434 
435             if (_log.isWarnEnabled()) {
436                 _log.warn(msg.toString());
437             }
438 
439             throw new NoSuchCompanyException(msg.toString());
440         }
441 
442         return company;
443     }
444 
445     public Company fetchByWebId(String webId) throws SystemException {
446         return fetchByWebId(webId, true);
447     }
448 
449     public Company fetchByWebId(String webId, boolean retrieveFromCache)
450         throws SystemException {
451         Object[] finderArgs = new Object[] { webId };
452 
453         Object result = null;
454 
455         if (retrieveFromCache) {
456             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_WEBID,
457                     finderArgs, this);
458         }
459 
460         if (result == null) {
461             Session session = null;
462 
463             try {
464                 session = openSession();
465 
466                 StringBundler query = new StringBundler(2);
467 
468                 query.append(_SQL_SELECT_COMPANY_WHERE);
469 
470                 if (webId == null) {
471                     query.append(_FINDER_COLUMN_WEBID_WEBID_1);
472                 }
473                 else {
474                     if (webId.equals(StringPool.BLANK)) {
475                         query.append(_FINDER_COLUMN_WEBID_WEBID_3);
476                     }
477                     else {
478                         query.append(_FINDER_COLUMN_WEBID_WEBID_2);
479                     }
480                 }
481 
482                 String sql = query.toString();
483 
484                 Query q = session.createQuery(sql);
485 
486                 QueryPos qPos = QueryPos.getInstance(q);
487 
488                 if (webId != null) {
489                     qPos.add(webId);
490                 }
491 
492                 List<Company> list = q.list();
493 
494                 result = list;
495 
496                 Company company = null;
497 
498                 if (list.isEmpty()) {
499                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
500                         finderArgs, list);
501                 }
502                 else {
503                     company = list.get(0);
504 
505                     cacheResult(company);
506 
507                     if ((company.getWebId() == null) ||
508                             !company.getWebId().equals(webId)) {
509                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
510                             finderArgs, company);
511                     }
512                 }
513 
514                 return company;
515             }
516             catch (Exception e) {
517                 throw processException(e);
518             }
519             finally {
520                 if (result == null) {
521                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
522                         finderArgs, new ArrayList<Company>());
523                 }
524 
525                 closeSession(session);
526             }
527         }
528         else {
529             if (result instanceof List<?>) {
530                 return null;
531             }
532             else {
533                 return (Company)result;
534             }
535         }
536     }
537 
538     public Company findByVirtualHost(String virtualHost)
539         throws NoSuchCompanyException, SystemException {
540         Company company = fetchByVirtualHost(virtualHost);
541 
542         if (company == null) {
543             StringBundler msg = new StringBundler(4);
544 
545             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
546 
547             msg.append("virtualHost=");
548             msg.append(virtualHost);
549 
550             msg.append(StringPool.CLOSE_CURLY_BRACE);
551 
552             if (_log.isWarnEnabled()) {
553                 _log.warn(msg.toString());
554             }
555 
556             throw new NoSuchCompanyException(msg.toString());
557         }
558 
559         return company;
560     }
561 
562     public Company fetchByVirtualHost(String virtualHost)
563         throws SystemException {
564         return fetchByVirtualHost(virtualHost, true);
565     }
566 
567     public Company fetchByVirtualHost(String virtualHost,
568         boolean retrieveFromCache) throws SystemException {
569         Object[] finderArgs = new Object[] { virtualHost };
570 
571         Object result = null;
572 
573         if (retrieveFromCache) {
574             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
575                     finderArgs, this);
576         }
577 
578         if (result == null) {
579             Session session = null;
580 
581             try {
582                 session = openSession();
583 
584                 StringBundler query = new StringBundler(2);
585 
586                 query.append(_SQL_SELECT_COMPANY_WHERE);
587 
588                 if (virtualHost == null) {
589                     query.append(_FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_1);
590                 }
591                 else {
592                     if (virtualHost.equals(StringPool.BLANK)) {
593                         query.append(_FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_3);
594                     }
595                     else {
596                         query.append(_FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_2);
597                     }
598                 }
599 
600                 String sql = query.toString();
601 
602                 Query q = session.createQuery(sql);
603 
604                 QueryPos qPos = QueryPos.getInstance(q);
605 
606                 if (virtualHost != null) {
607                     qPos.add(virtualHost);
608                 }
609 
610                 List<Company> list = q.list();
611 
612                 result = list;
613 
614                 Company company = null;
615 
616                 if (list.isEmpty()) {
617                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
618                         finderArgs, list);
619                 }
620                 else {
621                     company = list.get(0);
622 
623                     cacheResult(company);
624 
625                     if ((company.getVirtualHost() == null) ||
626                             !company.getVirtualHost().equals(virtualHost)) {
627                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
628                             finderArgs, company);
629                     }
630                 }
631 
632                 return company;
633             }
634             catch (Exception e) {
635                 throw processException(e);
636             }
637             finally {
638                 if (result == null) {
639                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
640                         finderArgs, new ArrayList<Company>());
641                 }
642 
643                 closeSession(session);
644             }
645         }
646         else {
647             if (result instanceof List<?>) {
648                 return null;
649             }
650             else {
651                 return (Company)result;
652             }
653         }
654     }
655 
656     public Company findByMx(String mx)
657         throws NoSuchCompanyException, SystemException {
658         Company company = fetchByMx(mx);
659 
660         if (company == null) {
661             StringBundler msg = new StringBundler(4);
662 
663             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
664 
665             msg.append("mx=");
666             msg.append(mx);
667 
668             msg.append(StringPool.CLOSE_CURLY_BRACE);
669 
670             if (_log.isWarnEnabled()) {
671                 _log.warn(msg.toString());
672             }
673 
674             throw new NoSuchCompanyException(msg.toString());
675         }
676 
677         return company;
678     }
679 
680     public Company fetchByMx(String mx) throws SystemException {
681         return fetchByMx(mx, true);
682     }
683 
684     public Company fetchByMx(String mx, boolean retrieveFromCache)
685         throws SystemException {
686         Object[] finderArgs = new Object[] { mx };
687 
688         Object result = null;
689 
690         if (retrieveFromCache) {
691             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_MX,
692                     finderArgs, this);
693         }
694 
695         if (result == null) {
696             Session session = null;
697 
698             try {
699                 session = openSession();
700 
701                 StringBundler query = new StringBundler(2);
702 
703                 query.append(_SQL_SELECT_COMPANY_WHERE);
704 
705                 if (mx == null) {
706                     query.append(_FINDER_COLUMN_MX_MX_1);
707                 }
708                 else {
709                     if (mx.equals(StringPool.BLANK)) {
710                         query.append(_FINDER_COLUMN_MX_MX_3);
711                     }
712                     else {
713                         query.append(_FINDER_COLUMN_MX_MX_2);
714                     }
715                 }
716 
717                 String sql = query.toString();
718 
719                 Query q = session.createQuery(sql);
720 
721                 QueryPos qPos = QueryPos.getInstance(q);
722 
723                 if (mx != null) {
724                     qPos.add(mx);
725                 }
726 
727                 List<Company> list = q.list();
728 
729                 result = list;
730 
731                 Company company = null;
732 
733                 if (list.isEmpty()) {
734                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
735                         finderArgs, list);
736                 }
737                 else {
738                     company = list.get(0);
739 
740                     cacheResult(company);
741 
742                     if ((company.getMx() == null) ||
743                             !company.getMx().equals(mx)) {
744                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
745                             finderArgs, company);
746                     }
747                 }
748 
749                 return company;
750             }
751             catch (Exception e) {
752                 throw processException(e);
753             }
754             finally {
755                 if (result == null) {
756                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
757                         finderArgs, new ArrayList<Company>());
758                 }
759 
760                 closeSession(session);
761             }
762         }
763         else {
764             if (result instanceof List<?>) {
765                 return null;
766             }
767             else {
768                 return (Company)result;
769             }
770         }
771     }
772 
773     public Company findByLogoId(long logoId)
774         throws NoSuchCompanyException, SystemException {
775         Company company = fetchByLogoId(logoId);
776 
777         if (company == null) {
778             StringBundler msg = new StringBundler(4);
779 
780             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
781 
782             msg.append("logoId=");
783             msg.append(logoId);
784 
785             msg.append(StringPool.CLOSE_CURLY_BRACE);
786 
787             if (_log.isWarnEnabled()) {
788                 _log.warn(msg.toString());
789             }
790 
791             throw new NoSuchCompanyException(msg.toString());
792         }
793 
794         return company;
795     }
796 
797     public Company fetchByLogoId(long logoId) throws SystemException {
798         return fetchByLogoId(logoId, true);
799     }
800 
801     public Company fetchByLogoId(long logoId, boolean retrieveFromCache)
802         throws SystemException {
803         Object[] finderArgs = new Object[] { new Long(logoId) };
804 
805         Object result = null;
806 
807         if (retrieveFromCache) {
808             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LOGOID,
809                     finderArgs, this);
810         }
811 
812         if (result == null) {
813             Session session = null;
814 
815             try {
816                 session = openSession();
817 
818                 StringBundler query = new StringBundler(2);
819 
820                 query.append(_SQL_SELECT_COMPANY_WHERE);
821 
822                 query.append(_FINDER_COLUMN_LOGOID_LOGOID_2);
823 
824                 String sql = query.toString();
825 
826                 Query q = session.createQuery(sql);
827 
828                 QueryPos qPos = QueryPos.getInstance(q);
829 
830                 qPos.add(logoId);
831 
832                 List<Company> list = q.list();
833 
834                 result = list;
835 
836                 Company company = null;
837 
838                 if (list.isEmpty()) {
839                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
840                         finderArgs, list);
841                 }
842                 else {
843                     company = list.get(0);
844 
845                     cacheResult(company);
846 
847                     if ((company.getLogoId() != logoId)) {
848                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
849                             finderArgs, company);
850                     }
851                 }
852 
853                 return company;
854             }
855             catch (Exception e) {
856                 throw processException(e);
857             }
858             finally {
859                 if (result == null) {
860                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
861                         finderArgs, new ArrayList<Company>());
862                 }
863 
864                 closeSession(session);
865             }
866         }
867         else {
868             if (result instanceof List<?>) {
869                 return null;
870             }
871             else {
872                 return (Company)result;
873             }
874         }
875     }
876 
877     public List<Company> findBySystem(boolean system) throws SystemException {
878         Object[] finderArgs = new Object[] { Boolean.valueOf(system) };
879 
880         List<Company> list = (List<Company>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_SYSTEM,
881                 finderArgs, this);
882 
883         if (list == null) {
884             Session session = null;
885 
886             try {
887                 session = openSession();
888 
889                 StringBundler query = new StringBundler(2);
890 
891                 query.append(_SQL_SELECT_COMPANY_WHERE);
892 
893                 query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
894 
895                 String sql = query.toString();
896 
897                 Query q = session.createQuery(sql);
898 
899                 QueryPos qPos = QueryPos.getInstance(q);
900 
901                 qPos.add(system);
902 
903                 list = q.list();
904             }
905             catch (Exception e) {
906                 throw processException(e);
907             }
908             finally {
909                 if (list == null) {
910                     list = new ArrayList<Company>();
911                 }
912 
913                 cacheResult(list);
914 
915                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_SYSTEM,
916                     finderArgs, list);
917 
918                 closeSession(session);
919             }
920         }
921 
922         return list;
923     }
924 
925     public List<Company> findBySystem(boolean system, int start, int end)
926         throws SystemException {
927         return findBySystem(system, start, end, null);
928     }
929 
930     public List<Company> findBySystem(boolean system, int start, int end,
931         OrderByComparator obc) throws SystemException {
932         Object[] finderArgs = new Object[] {
933                 Boolean.valueOf(system),
934                 
935                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
936             };
937 
938         List<Company> list = (List<Company>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_SYSTEM,
939                 finderArgs, this);
940 
941         if (list == null) {
942             Session session = null;
943 
944             try {
945                 session = openSession();
946 
947                 StringBundler query = null;
948 
949                 if (obc != null) {
950                     query = new StringBundler(3 +
951                             (obc.getOrderByFields().length * 3));
952                 }
953                 else {
954                     query = new StringBundler(2);
955                 }
956 
957                 query.append(_SQL_SELECT_COMPANY_WHERE);
958 
959                 query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
960 
961                 if (obc != null) {
962                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
963                 }
964 
965                 String sql = query.toString();
966 
967                 Query q = session.createQuery(sql);
968 
969                 QueryPos qPos = QueryPos.getInstance(q);
970 
971                 qPos.add(system);
972 
973                 list = (List<Company>)QueryUtil.list(q, getDialect(), start, end);
974             }
975             catch (Exception e) {
976                 throw processException(e);
977             }
978             finally {
979                 if (list == null) {
980                     list = new ArrayList<Company>();
981                 }
982 
983                 cacheResult(list);
984 
985                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_SYSTEM,
986                     finderArgs, list);
987 
988                 closeSession(session);
989             }
990         }
991 
992         return list;
993     }
994 
995     public Company findBySystem_First(boolean system, OrderByComparator obc)
996         throws NoSuchCompanyException, SystemException {
997         List<Company> list = findBySystem(system, 0, 1, obc);
998 
999         if (list.isEmpty()) {
1000            StringBundler msg = new StringBundler(4);
1001
1002            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1003
1004            msg.append("system=");
1005            msg.append(system);
1006
1007            msg.append(StringPool.CLOSE_CURLY_BRACE);
1008
1009            throw new NoSuchCompanyException(msg.toString());
1010        }
1011        else {
1012            return list.get(0);
1013        }
1014    }
1015
1016    public Company findBySystem_Last(boolean system, OrderByComparator obc)
1017        throws NoSuchCompanyException, SystemException {
1018        int count = countBySystem(system);
1019
1020        List<Company> list = findBySystem(system, count - 1, count, obc);
1021
1022        if (list.isEmpty()) {
1023            StringBundler msg = new StringBundler(4);
1024
1025            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1026
1027            msg.append("system=");
1028            msg.append(system);
1029
1030            msg.append(StringPool.CLOSE_CURLY_BRACE);
1031
1032            throw new NoSuchCompanyException(msg.toString());
1033        }
1034        else {
1035            return list.get(0);
1036        }
1037    }
1038
1039    public Company[] findBySystem_PrevAndNext(long companyId, boolean system,
1040        OrderByComparator obc) throws NoSuchCompanyException, SystemException {
1041        Company company = findByPrimaryKey(companyId);
1042
1043        int count = countBySystem(system);
1044
1045        Session session = null;
1046
1047        try {
1048            session = openSession();
1049
1050            StringBundler query = null;
1051
1052            if (obc != null) {
1053                query = new StringBundler(3 +
1054                        (obc.getOrderByFields().length * 3));
1055            }
1056            else {
1057                query = new StringBundler(2);
1058            }
1059
1060            query.append(_SQL_SELECT_COMPANY_WHERE);
1061
1062            query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1063
1064            if (obc != null) {
1065                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1066            }
1067
1068            String sql = query.toString();
1069
1070            Query q = session.createQuery(sql);
1071
1072            QueryPos qPos = QueryPos.getInstance(q);
1073
1074            qPos.add(system);
1075
1076            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, company);
1077
1078            Company[] array = new CompanyImpl[3];
1079
1080            array[0] = (Company)objArray[0];
1081            array[1] = (Company)objArray[1];
1082            array[2] = (Company)objArray[2];
1083
1084            return array;
1085        }
1086        catch (Exception e) {
1087            throw processException(e);
1088        }
1089        finally {
1090            closeSession(session);
1091        }
1092    }
1093
1094    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1095        throws SystemException {
1096        Session session = null;
1097
1098        try {
1099            session = openSession();
1100
1101            dynamicQuery.compile(session);
1102
1103            return dynamicQuery.list();
1104        }
1105        catch (Exception e) {
1106            throw processException(e);
1107        }
1108        finally {
1109            closeSession(session);
1110        }
1111    }
1112
1113    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1114        int start, int end) throws SystemException {
1115        Session session = null;
1116
1117        try {
1118            session = openSession();
1119
1120            dynamicQuery.setLimit(start, end);
1121
1122            dynamicQuery.compile(session);
1123
1124            return dynamicQuery.list();
1125        }
1126        catch (Exception e) {
1127            throw processException(e);
1128        }
1129        finally {
1130            closeSession(session);
1131        }
1132    }
1133
1134    public List<Company> findAll() throws SystemException {
1135        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1136    }
1137
1138    public List<Company> findAll(int start, int end) throws SystemException {
1139        return findAll(start, end, null);
1140    }
1141
1142    public List<Company> findAll(int start, int end, OrderByComparator obc)
1143        throws SystemException {
1144        Object[] finderArgs = new Object[] {
1145                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1146            };
1147
1148        List<Company> list = (List<Company>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1149                finderArgs, this);
1150
1151        if (list == null) {
1152            Session session = null;
1153
1154            try {
1155                session = openSession();
1156
1157                StringBundler query = null;
1158                String sql = null;
1159
1160                if (obc != null) {
1161                    query = new StringBundler(2 +
1162                            (obc.getOrderByFields().length * 3));
1163
1164                    query.append(_SQL_SELECT_COMPANY);
1165
1166                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1167
1168                    sql = query.toString();
1169                }
1170
1171                sql = _SQL_SELECT_COMPANY;
1172
1173                Query q = session.createQuery(sql);
1174
1175                if (obc == null) {
1176                    list = (List<Company>)QueryUtil.list(q, getDialect(),
1177                            start, end, false);
1178
1179                    Collections.sort(list);
1180                }
1181                else {
1182                    list = (List<Company>)QueryUtil.list(q, getDialect(),
1183                            start, end);
1184                }
1185            }
1186            catch (Exception e) {
1187                throw processException(e);
1188            }
1189            finally {
1190                if (list == null) {
1191                    list = new ArrayList<Company>();
1192                }
1193
1194                cacheResult(list);
1195
1196                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1197
1198                closeSession(session);
1199            }
1200        }
1201
1202        return list;
1203    }
1204
1205    public void removeByWebId(String webId)
1206        throws NoSuchCompanyException, SystemException {
1207        Company company = findByWebId(webId);
1208
1209        remove(company);
1210    }
1211
1212    public void removeByVirtualHost(String virtualHost)
1213        throws NoSuchCompanyException, SystemException {
1214        Company company = findByVirtualHost(virtualHost);
1215
1216        remove(company);
1217    }
1218
1219    public void removeByMx(String mx)
1220        throws NoSuchCompanyException, SystemException {
1221        Company company = findByMx(mx);
1222
1223        remove(company);
1224    }
1225
1226    public void removeByLogoId(long logoId)
1227        throws NoSuchCompanyException, SystemException {
1228        Company company = findByLogoId(logoId);
1229
1230        remove(company);
1231    }
1232
1233    public void removeBySystem(boolean system) throws SystemException {
1234        for (Company company : findBySystem(system)) {
1235            remove(company);
1236        }
1237    }
1238
1239    public void removeAll() throws SystemException {
1240        for (Company company : findAll()) {
1241            remove(company);
1242        }
1243    }
1244
1245    public int countByWebId(String webId) throws SystemException {
1246        Object[] finderArgs = new Object[] { webId };
1247
1248        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_WEBID,
1249                finderArgs, this);
1250
1251        if (count == null) {
1252            Session session = null;
1253
1254            try {
1255                session = openSession();
1256
1257                StringBundler query = new StringBundler(2);
1258
1259                query.append(_SQL_COUNT_COMPANY_WHERE);
1260
1261                if (webId == null) {
1262                    query.append(_FINDER_COLUMN_WEBID_WEBID_1);
1263                }
1264                else {
1265                    if (webId.equals(StringPool.BLANK)) {
1266                        query.append(_FINDER_COLUMN_WEBID_WEBID_3);
1267                    }
1268                    else {
1269                        query.append(_FINDER_COLUMN_WEBID_WEBID_2);
1270                    }
1271                }
1272
1273                String sql = query.toString();
1274
1275                Query q = session.createQuery(sql);
1276
1277                QueryPos qPos = QueryPos.getInstance(q);
1278
1279                if (webId != null) {
1280                    qPos.add(webId);
1281                }
1282
1283                count = (Long)q.uniqueResult();
1284            }
1285            catch (Exception e) {
1286                throw processException(e);
1287            }
1288            finally {
1289                if (count == null) {
1290                    count = Long.valueOf(0);
1291                }
1292
1293                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_WEBID,
1294                    finderArgs, count);
1295
1296                closeSession(session);
1297            }
1298        }
1299
1300        return count.intValue();
1301    }
1302
1303    public int countByVirtualHost(String virtualHost) throws SystemException {
1304        Object[] finderArgs = new Object[] { virtualHost };
1305
1306        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VIRTUALHOST,
1307                finderArgs, this);
1308
1309        if (count == null) {
1310            Session session = null;
1311
1312            try {
1313                session = openSession();
1314
1315                StringBundler query = new StringBundler(2);
1316
1317                query.append(_SQL_COUNT_COMPANY_WHERE);
1318
1319                if (virtualHost == null) {
1320                    query.append(_FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_1);
1321                }
1322                else {
1323                    if (virtualHost.equals(StringPool.BLANK)) {
1324                        query.append(_FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_3);
1325                    }
1326                    else {
1327                        query.append(_FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_2);
1328                    }
1329                }
1330
1331                String sql = query.toString();
1332
1333                Query q = session.createQuery(sql);
1334
1335                QueryPos qPos = QueryPos.getInstance(q);
1336
1337                if (virtualHost != null) {
1338                    qPos.add(virtualHost);
1339                }
1340
1341                count = (Long)q.uniqueResult();
1342            }
1343            catch (Exception e) {
1344                throw processException(e);
1345            }
1346            finally {
1347                if (count == null) {
1348                    count = Long.valueOf(0);
1349                }
1350
1351                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VIRTUALHOST,
1352                    finderArgs, count);
1353
1354                closeSession(session);
1355            }
1356        }
1357
1358        return count.intValue();
1359    }
1360
1361    public int countByMx(String mx) throws SystemException {
1362        Object[] finderArgs = new Object[] { mx };
1363
1364        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MX,
1365                finderArgs, this);
1366
1367        if (count == null) {
1368            Session session = null;
1369
1370            try {
1371                session = openSession();
1372
1373                StringBundler query = new StringBundler(2);
1374
1375                query.append(_SQL_COUNT_COMPANY_WHERE);
1376
1377                if (mx == null) {
1378                    query.append(_FINDER_COLUMN_MX_MX_1);
1379                }
1380                else {
1381                    if (mx.equals(StringPool.BLANK)) {
1382                        query.append(_FINDER_COLUMN_MX_MX_3);
1383                    }
1384                    else {
1385                        query.append(_FINDER_COLUMN_MX_MX_2);
1386                    }
1387                }
1388
1389                String sql = query.toString();
1390
1391                Query q = session.createQuery(sql);
1392
1393                QueryPos qPos = QueryPos.getInstance(q);
1394
1395                if (mx != null) {
1396                    qPos.add(mx);
1397                }
1398
1399                count = (Long)q.uniqueResult();
1400            }
1401            catch (Exception e) {
1402                throw processException(e);
1403            }
1404            finally {
1405                if (count == null) {
1406                    count = Long.valueOf(0);
1407                }
1408
1409                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MX, finderArgs,
1410                    count);
1411
1412                closeSession(session);
1413            }
1414        }
1415
1416        return count.intValue();
1417    }
1418
1419    public int countByLogoId(long logoId) throws SystemException {
1420        Object[] finderArgs = new Object[] { new Long(logoId) };
1421
1422        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LOGOID,
1423                finderArgs, this);
1424
1425        if (count == null) {
1426            Session session = null;
1427
1428            try {
1429                session = openSession();
1430
1431                StringBundler query = new StringBundler(2);
1432
1433                query.append(_SQL_COUNT_COMPANY_WHERE);
1434
1435                query.append(_FINDER_COLUMN_LOGOID_LOGOID_2);
1436
1437                String sql = query.toString();
1438
1439                Query q = session.createQuery(sql);
1440
1441                QueryPos qPos = QueryPos.getInstance(q);
1442
1443                qPos.add(logoId);
1444
1445                count = (Long)q.uniqueResult();
1446            }
1447            catch (Exception e) {
1448                throw processException(e);
1449            }
1450            finally {
1451                if (count == null) {
1452                    count = Long.valueOf(0);
1453                }
1454
1455                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LOGOID,
1456                    finderArgs, count);
1457
1458                closeSession(session);
1459            }
1460        }
1461
1462        return count.intValue();
1463    }
1464
1465    public int countBySystem(boolean system) throws SystemException {
1466        Object[] finderArgs = new Object[] { Boolean.valueOf(system) };
1467
1468        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SYSTEM,
1469                finderArgs, this);
1470
1471        if (count == null) {
1472            Session session = null;
1473
1474            try {
1475                session = openSession();
1476
1477                StringBundler query = new StringBundler(2);
1478
1479                query.append(_SQL_COUNT_COMPANY_WHERE);
1480
1481                query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1482
1483                String sql = query.toString();
1484
1485                Query q = session.createQuery(sql);
1486
1487                QueryPos qPos = QueryPos.getInstance(q);
1488
1489                qPos.add(system);
1490
1491                count = (Long)q.uniqueResult();
1492            }
1493            catch (Exception e) {
1494                throw processException(e);
1495            }
1496            finally {
1497                if (count == null) {
1498                    count = Long.valueOf(0);
1499                }
1500
1501                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SYSTEM,
1502                    finderArgs, count);
1503
1504                closeSession(session);
1505            }
1506        }
1507
1508        return count.intValue();
1509    }
1510
1511    public int countAll() throws SystemException {
1512        Object[] finderArgs = new Object[0];
1513
1514        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1515                finderArgs, this);
1516
1517        if (count == null) {
1518            Session session = null;
1519
1520            try {
1521                session = openSession();
1522
1523                Query q = session.createQuery(_SQL_COUNT_COMPANY);
1524
1525                count = (Long)q.uniqueResult();
1526            }
1527            catch (Exception e) {
1528                throw processException(e);
1529            }
1530            finally {
1531                if (count == null) {
1532                    count = Long.valueOf(0);
1533                }
1534
1535                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1536                    count);
1537
1538                closeSession(session);
1539            }
1540        }
1541
1542        return count.intValue();
1543    }
1544
1545    public void afterPropertiesSet() {
1546        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1547                    com.liferay.portal.util.PropsUtil.get(
1548                        "value.object.listener.com.liferay.portal.model.Company")));
1549
1550        if (listenerClassNames.length > 0) {
1551            try {
1552                List<ModelListener<Company>> listenersList = new ArrayList<ModelListener<Company>>();
1553
1554                for (String listenerClassName : listenerClassNames) {
1555                    listenersList.add((ModelListener<Company>)Class.forName(
1556                            listenerClassName).newInstance());
1557                }
1558
1559                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1560            }
1561            catch (Exception e) {
1562                _log.error(e);
1563            }
1564        }
1565    }
1566
1567    @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence")
1568    protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1569    @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence")
1570    protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1571    @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence")
1572    protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1573    @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence")
1574    protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1575    @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
1576    protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1577    @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence")
1578    protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1579    @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence")
1580    protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1581    @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence")
1582    protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1583    @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
1584    protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1585    @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
1586    protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1587    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence")
1588    protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1589    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPrototypePersistence")
1590    protected com.liferay.portal.service.persistence.LayoutPrototypePersistence layoutPrototypePersistence;
1591    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence")
1592    protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1593    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPrototypePersistence")
1594    protected com.liferay.portal.service.persistence.LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1595    @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence")
1596    protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1597    @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence")
1598    protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
1599    @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence")
1600    protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1601    @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence")
1602    protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1603    @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence")
1604    protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1605    @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence")
1606    protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1607    @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence")
1608    protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1609    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence")
1610    protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1611    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence")
1612    protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1613    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence")
1614    protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1615    @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence")
1616    protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1617    @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence")
1618    protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1619    @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence")
1620    protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1621    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence")
1622    protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1623    @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence")
1624    protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1625    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
1626    protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1627    @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence")
1628    protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1629    @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence")
1630    protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1631    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1632    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1633    @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence")
1634    protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1635    @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence")
1636    protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1637    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence")
1638    protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1639    @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence")
1640    protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1641    @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence")
1642    protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1643    @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence")
1644    protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1645    @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
1646    protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1647    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1648    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1649    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence")
1650    protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1651    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence")
1652    protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1653    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence")
1654    protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1655    @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence")
1656    protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1657    @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence")
1658    protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1659    @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence")
1660    protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1661    @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
1662    protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1663    @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence")
1664    protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1665    @BeanReference(name = "com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence")
1666    protected com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1667    @BeanReference(name = "com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence")
1668    protected com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1669    private static final String _SQL_SELECT_COMPANY = "SELECT company FROM Company company";
1670    private static final String _SQL_SELECT_COMPANY_WHERE = "SELECT company FROM Company company WHERE ";
1671    private static final String _SQL_COUNT_COMPANY = "SELECT COUNT(company) FROM Company company";
1672    private static final String _SQL_COUNT_COMPANY_WHERE = "SELECT COUNT(company) FROM Company company WHERE ";
1673    private static final String _FINDER_COLUMN_WEBID_WEBID_1 = "company.webId IS NULL";
1674    private static final String _FINDER_COLUMN_WEBID_WEBID_2 = "company.webId = ?";
1675    private static final String _FINDER_COLUMN_WEBID_WEBID_3 = "(company.webId IS NULL OR company.webId = ?)";
1676    private static final String _FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_1 = "company.virtualHost IS NULL";
1677    private static final String _FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_2 = "company.virtualHost = ?";
1678    private static final String _FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_3 = "(company.virtualHost IS NULL OR company.virtualHost = ?)";
1679    private static final String _FINDER_COLUMN_MX_MX_1 = "company.mx IS NULL";
1680    private static final String _FINDER_COLUMN_MX_MX_2 = "company.mx = ?";
1681    private static final String _FINDER_COLUMN_MX_MX_3 = "(company.mx IS NULL OR company.mx = ?)";
1682    private static final String _FINDER_COLUMN_LOGOID_LOGOID_2 = "company.logoId = ?";
1683    private static final String _FINDER_COLUMN_SYSTEM_SYSTEM_2 = "company.system = ?";
1684    private static final String _ORDER_BY_ENTITY_ALIAS = "company.";
1685    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Company exists with the primary key ";
1686    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Company exists with the key {";
1687    private static Log _log = LogFactoryUtil.getLog(CompanyPersistenceImpl.class);
1688}