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