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.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.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.GetterUtil;
32  import com.liferay.portal.kernel.util.OrderByComparator;
33  import com.liferay.portal.kernel.util.StringBundler;
34  import com.liferay.portal.kernel.util.StringPool;
35  import com.liferay.portal.kernel.util.StringUtil;
36  import com.liferay.portal.kernel.util.Validator;
37  import com.liferay.portal.model.Company;
38  import com.liferay.portal.model.ModelListener;
39  import com.liferay.portal.model.impl.CompanyImpl;
40  import com.liferay.portal.model.impl.CompanyModelImpl;
41  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42  
43  import java.io.Serializable;
44  
45  import java.util.ArrayList;
46  import java.util.Collections;
47  import java.util.List;
48  
49  /**
50   * <a href="CompanyPersistenceImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       CompanyPersistence
59   * @see       CompanyUtil
60   * @generated
61   */
62  public class CompanyPersistenceImpl extends BasePersistenceImpl<Company>
63      implements CompanyPersistence {
64      public static final String FINDER_CLASS_NAME_ENTITY = CompanyImpl.class.getName();
65      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66          ".List";
67      public static final FinderPath FINDER_PATH_FETCH_BY_WEBID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
68              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
69              "fetchByWebId", new String[] { String.class.getName() });
70      public static final FinderPath FINDER_PATH_COUNT_BY_WEBID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
71              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
72              "countByWebId", new String[] { String.class.getName() });
73      public static final FinderPath FINDER_PATH_FETCH_BY_VIRTUALHOST = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
74              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
75              "fetchByVirtualHost", new String[] { String.class.getName() });
76      public static final FinderPath FINDER_PATH_COUNT_BY_VIRTUALHOST = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
77              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
78              "countByVirtualHost", new String[] { String.class.getName() });
79      public static final FinderPath FINDER_PATH_FETCH_BY_MX = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
80              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
81              "fetchByMx", new String[] { String.class.getName() });
82      public static final FinderPath FINDER_PATH_COUNT_BY_MX = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
83              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84              "countByMx", new String[] { String.class.getName() });
85      public static final FinderPath FINDER_PATH_FETCH_BY_LOGOID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
86              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
87              "fetchByLogoId", new String[] { Long.class.getName() });
88      public static final FinderPath FINDER_PATH_COUNT_BY_LOGOID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
89              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
90              "countByLogoId", new String[] { Long.class.getName() });
91      public static final FinderPath FINDER_PATH_FIND_BY_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
92              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
93              "findBySystem", new String[] { Boolean.class.getName() });
94      public static final FinderPath FINDER_PATH_FIND_BY_OBC_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
95              CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96              "findBySystem",
97              new String[] {
98                  Boolean.class.getName(),
99                  
100             "java.lang.Integer", "java.lang.Integer",
101                 "com.liferay.portal.kernel.util.OrderByComparator"
102             });
103     public static final FinderPath FINDER_PATH_COUNT_BY_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
104             CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105             "countBySystem", new String[] { Boolean.class.getName() });
106     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
107             CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108             "findAll", new String[0]);
109     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
110             CompanyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111             "countAll", new String[0]);
112 
113     public void cacheResult(Company company) {
114         EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
115             CompanyImpl.class, company.getPrimaryKey(), company);
116 
117         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
118             new Object[] { company.getWebId() }, company);
119 
120         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
121             new Object[] { company.getVirtualHost() }, company);
122 
123         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
124             new Object[] { company.getMx() }, company);
125 
126         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
127             new Object[] { new Long(company.getLogoId()) }, company);
128     }
129 
130     public void cacheResult(List<Company> companies) {
131         for (Company company : companies) {
132             if (EntityCacheUtil.getResult(
133                         CompanyModelImpl.ENTITY_CACHE_ENABLED,
134                         CompanyImpl.class, company.getPrimaryKey(), this) == null) {
135                 cacheResult(company);
136             }
137         }
138     }
139 
140     public void clearCache() {
141         CacheRegistry.clear(CompanyImpl.class.getName());
142         EntityCacheUtil.clearCache(CompanyImpl.class.getName());
143         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
144         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
145     }
146 
147     public Company create(long companyId) {
148         Company company = new CompanyImpl();
149 
150         company.setNew(true);
151         company.setPrimaryKey(companyId);
152 
153         return company;
154     }
155 
156     public Company remove(Serializable primaryKey)
157         throws NoSuchModelException, SystemException {
158         return remove(((Long)primaryKey).longValue());
159     }
160 
161     public Company remove(long companyId)
162         throws NoSuchCompanyException, SystemException {
163         Session session = null;
164 
165         try {
166             session = openSession();
167 
168             Company company = (Company)session.get(CompanyImpl.class,
169                     new Long(companyId));
170 
171             if (company == null) {
172                 if (_log.isWarnEnabled()) {
173                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + companyId);
174                 }
175 
176                 throw new NoSuchCompanyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
177                     companyId);
178             }
179 
180             return remove(company);
181         }
182         catch (NoSuchCompanyException nsee) {
183             throw nsee;
184         }
185         catch (Exception e) {
186             throw processException(e);
187         }
188         finally {
189             closeSession(session);
190         }
191     }
192 
193     public Company remove(Company company) throws SystemException {
194         for (ModelListener<Company> listener : listeners) {
195             listener.onBeforeRemove(company);
196         }
197 
198         company = removeImpl(company);
199 
200         for (ModelListener<Company> listener : listeners) {
201             listener.onAfterRemove(company);
202         }
203 
204         return company;
205     }
206 
207     protected Company removeImpl(Company company) throws SystemException {
208         company = toUnwrappedModel(company);
209 
210         Session session = null;
211 
212         try {
213             session = openSession();
214 
215             if (company.isCachedModel() || BatchSessionUtil.isEnabled()) {
216                 Object staleObject = session.get(CompanyImpl.class,
217                         company.getPrimaryKeyObj());
218 
219                 if (staleObject != null) {
220                     session.evict(staleObject);
221                 }
222             }
223 
224             session.delete(company);
225 
226             session.flush();
227         }
228         catch (Exception e) {
229             throw processException(e);
230         }
231         finally {
232             closeSession(session);
233         }
234 
235         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
236 
237         CompanyModelImpl companyModelImpl = (CompanyModelImpl)company;
238 
239         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID,
240             new Object[] { companyModelImpl.getOriginalWebId() });
241 
242         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
243             new Object[] { companyModelImpl.getOriginalVirtualHost() });
244 
245         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX,
246             new Object[] { companyModelImpl.getOriginalMx() });
247 
248         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID,
249             new Object[] { new Long(companyModelImpl.getOriginalLogoId()) });
250 
251         EntityCacheUtil.removeResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
252             CompanyImpl.class, company.getPrimaryKey());
253 
254         return company;
255     }
256 
257     /**
258      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
259      */
260     public Company update(Company company) throws SystemException {
261         if (_log.isWarnEnabled()) {
262             _log.warn(
263                 "Using the deprecated update(Company company) method. Use update(Company company, boolean merge) instead.");
264         }
265 
266         return update(company, false);
267     }
268 
269     public Company updateImpl(com.liferay.portal.model.Company company,
270         boolean merge) throws SystemException {
271         company = toUnwrappedModel(company);
272 
273         boolean isNew = company.isNew();
274 
275         CompanyModelImpl companyModelImpl = (CompanyModelImpl)company;
276 
277         Session session = null;
278 
279         try {
280             session = openSession();
281 
282             BatchSessionUtil.update(session, company, merge);
283 
284             company.setNew(false);
285         }
286         catch (Exception e) {
287             throw processException(e);
288         }
289         finally {
290             closeSession(session);
291         }
292 
293         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
294 
295         EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
296             CompanyImpl.class, company.getPrimaryKey(), company);
297 
298         if (!isNew &&
299                 (!Validator.equals(company.getWebId(),
300                     companyModelImpl.getOriginalWebId()))) {
301             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID,
302                 new Object[] { companyModelImpl.getOriginalWebId() });
303         }
304 
305         if (isNew ||
306                 (!Validator.equals(company.getWebId(),
307                     companyModelImpl.getOriginalWebId()))) {
308             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
309                 new Object[] { company.getWebId() }, company);
310         }
311 
312         if (!isNew &&
313                 (!Validator.equals(company.getVirtualHost(),
314                     companyModelImpl.getOriginalVirtualHost()))) {
315             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
316                 new Object[] { companyModelImpl.getOriginalVirtualHost() });
317         }
318 
319         if (isNew ||
320                 (!Validator.equals(company.getVirtualHost(),
321                     companyModelImpl.getOriginalVirtualHost()))) {
322             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_VIRTUALHOST,
323                 new Object[] { company.getVirtualHost() }, company);
324         }
325 
326         if (!isNew &&
327                 (!Validator.equals(company.getMx(),
328                     companyModelImpl.getOriginalMx()))) {
329             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX,
330                 new Object[] { companyModelImpl.getOriginalMx() });
331         }
332 
333         if (isNew ||
334                 (!Validator.equals(company.getMx(),
335                     companyModelImpl.getOriginalMx()))) {
336             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
337                 new Object[] { company.getMx() }, company);
338         }
339 
340         if (!isNew &&
341                 (company.getLogoId() != companyModelImpl.getOriginalLogoId())) {
342             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID,
343                 new Object[] { new Long(companyModelImpl.getOriginalLogoId()) });
344         }
345 
346         if (isNew ||
347                 (company.getLogoId() != companyModelImpl.getOriginalLogoId())) {
348             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
349                 new Object[] { new Long(company.getLogoId()) }, company);
350         }
351 
352         return company;
353     }
354 
355     protected Company toUnwrappedModel(Company company) {
356         if (company instanceof CompanyImpl) {
357             return company;
358         }
359 
360         CompanyImpl companyImpl = new CompanyImpl();
361 
362         companyImpl.setNew(company.isNew());
363         companyImpl.setPrimaryKey(company.getPrimaryKey());
364 
365         companyImpl.setCompanyId(company.getCompanyId());
366         companyImpl.setAccountId(company.getAccountId());
367         companyImpl.setWebId(company.getWebId());
368         companyImpl.setKey(company.getKey());
369         companyImpl.setVirtualHost(company.getVirtualHost());
370         companyImpl.setMx(company.getMx());
371         companyImpl.setHomeURL(company.getHomeURL());
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 orderByComparator) throws SystemException {
943         Object[] finderArgs = new Object[] {
944                 Boolean.valueOf(system),
945                 
946                 String.valueOf(start), String.valueOf(end),
947                 String.valueOf(orderByComparator)
948             };
949 
950         List<Company> list = (List<Company>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_SYSTEM,
951                 finderArgs, this);
952 
953         if (list == null) {
954             Session session = null;
955 
956             try {
957                 session = openSession();
958 
959                 StringBundler query = null;
960 
961                 if (orderByComparator != null) {
962                     query = new StringBundler(3 +
963                             (orderByComparator.getOrderByFields().length * 3));
964                 }
965                 else {
966                     query = new StringBundler(2);
967                 }
968 
969                 query.append(_SQL_SELECT_COMPANY_WHERE);
970 
971                 query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
972 
973                 if (orderByComparator != null) {
974                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
975                         orderByComparator);
976                 }
977 
978                 String sql = query.toString();
979 
980                 Query q = session.createQuery(sql);
981 
982                 QueryPos qPos = QueryPos.getInstance(q);
983 
984                 qPos.add(system);
985 
986                 list = (List<Company>)QueryUtil.list(q, getDialect(), start, end);
987             }
988             catch (Exception e) {
989                 throw processException(e);
990             }
991             finally {
992                 if (list == null) {
993                     list = new ArrayList<Company>();
994                 }
995 
996                 cacheResult(list);
997 
998                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_SYSTEM,
999                     finderArgs, list);
1000
1001                closeSession(session);
1002            }
1003        }
1004
1005        return list;
1006    }
1007
1008    public Company findBySystem_First(boolean system,
1009        OrderByComparator orderByComparator)
1010        throws NoSuchCompanyException, SystemException {
1011        List<Company> list = findBySystem(system, 0, 1, orderByComparator);
1012
1013        if (list.isEmpty()) {
1014            StringBundler msg = new StringBundler(4);
1015
1016            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1017
1018            msg.append("system=");
1019            msg.append(system);
1020
1021            msg.append(StringPool.CLOSE_CURLY_BRACE);
1022
1023            throw new NoSuchCompanyException(msg.toString());
1024        }
1025        else {
1026            return list.get(0);
1027        }
1028    }
1029
1030    public Company findBySystem_Last(boolean system,
1031        OrderByComparator orderByComparator)
1032        throws NoSuchCompanyException, SystemException {
1033        int count = countBySystem(system);
1034
1035        List<Company> list = findBySystem(system, count - 1, count,
1036                orderByComparator);
1037
1038        if (list.isEmpty()) {
1039            StringBundler msg = new StringBundler(4);
1040
1041            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1042
1043            msg.append("system=");
1044            msg.append(system);
1045
1046            msg.append(StringPool.CLOSE_CURLY_BRACE);
1047
1048            throw new NoSuchCompanyException(msg.toString());
1049        }
1050        else {
1051            return list.get(0);
1052        }
1053    }
1054
1055    public Company[] findBySystem_PrevAndNext(long companyId, boolean system,
1056        OrderByComparator orderByComparator)
1057        throws NoSuchCompanyException, SystemException {
1058        Company company = findByPrimaryKey(companyId);
1059
1060        int count = countBySystem(system);
1061
1062        Session session = null;
1063
1064        try {
1065            session = openSession();
1066
1067            StringBundler query = null;
1068
1069            if (orderByComparator != null) {
1070                query = new StringBundler(3 +
1071                        (orderByComparator.getOrderByFields().length * 3));
1072            }
1073            else {
1074                query = new StringBundler(2);
1075            }
1076
1077            query.append(_SQL_SELECT_COMPANY_WHERE);
1078
1079            query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1080
1081            if (orderByComparator != null) {
1082                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1083                    orderByComparator);
1084            }
1085
1086            String sql = query.toString();
1087
1088            Query q = session.createQuery(sql);
1089
1090            QueryPos qPos = QueryPos.getInstance(q);
1091
1092            qPos.add(system);
1093
1094            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1095                    orderByComparator, company);
1096
1097            Company[] array = new CompanyImpl[3];
1098
1099            array[0] = (Company)objArray[0];
1100            array[1] = (Company)objArray[1];
1101            array[2] = (Company)objArray[2];
1102
1103            return array;
1104        }
1105        catch (Exception e) {
1106            throw processException(e);
1107        }
1108        finally {
1109            closeSession(session);
1110        }
1111    }
1112
1113    public List<Company> findAll() throws SystemException {
1114        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1115    }
1116
1117    public List<Company> findAll(int start, int end) throws SystemException {
1118        return findAll(start, end, null);
1119    }
1120
1121    public List<Company> findAll(int start, int end,
1122        OrderByComparator orderByComparator) throws SystemException {
1123        Object[] finderArgs = new Object[] {
1124                String.valueOf(start), String.valueOf(end),
1125                String.valueOf(orderByComparator)
1126            };
1127
1128        List<Company> list = (List<Company>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1129                finderArgs, this);
1130
1131        if (list == null) {
1132            Session session = null;
1133
1134            try {
1135                session = openSession();
1136
1137                StringBundler query = null;
1138                String sql = null;
1139
1140                if (orderByComparator != null) {
1141                    query = new StringBundler(2 +
1142                            (orderByComparator.getOrderByFields().length * 3));
1143
1144                    query.append(_SQL_SELECT_COMPANY);
1145
1146                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1147                        orderByComparator);
1148
1149                    sql = query.toString();
1150                }
1151
1152                sql = _SQL_SELECT_COMPANY;
1153
1154                Query q = session.createQuery(sql);
1155
1156                if (orderByComparator == null) {
1157                    list = (List<Company>)QueryUtil.list(q, getDialect(),
1158                            start, end, false);
1159
1160                    Collections.sort(list);
1161                }
1162                else {
1163                    list = (List<Company>)QueryUtil.list(q, getDialect(),
1164                            start, end);
1165                }
1166            }
1167            catch (Exception e) {
1168                throw processException(e);
1169            }
1170            finally {
1171                if (list == null) {
1172                    list = new ArrayList<Company>();
1173                }
1174
1175                cacheResult(list);
1176
1177                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1178
1179                closeSession(session);
1180            }
1181        }
1182
1183        return list;
1184    }
1185
1186    public void removeByWebId(String webId)
1187        throws NoSuchCompanyException, SystemException {
1188        Company company = findByWebId(webId);
1189
1190        remove(company);
1191    }
1192
1193    public void removeByVirtualHost(String virtualHost)
1194        throws NoSuchCompanyException, SystemException {
1195        Company company = findByVirtualHost(virtualHost);
1196
1197        remove(company);
1198    }
1199
1200    public void removeByMx(String mx)
1201        throws NoSuchCompanyException, SystemException {
1202        Company company = findByMx(mx);
1203
1204        remove(company);
1205    }
1206
1207    public void removeByLogoId(long logoId)
1208        throws NoSuchCompanyException, SystemException {
1209        Company company = findByLogoId(logoId);
1210
1211        remove(company);
1212    }
1213
1214    public void removeBySystem(boolean system) throws SystemException {
1215        for (Company company : findBySystem(system)) {
1216            remove(company);
1217        }
1218    }
1219
1220    public void removeAll() throws SystemException {
1221        for (Company company : findAll()) {
1222            remove(company);
1223        }
1224    }
1225
1226    public int countByWebId(String webId) throws SystemException {
1227        Object[] finderArgs = new Object[] { webId };
1228
1229        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_WEBID,
1230                finderArgs, this);
1231
1232        if (count == null) {
1233            Session session = null;
1234
1235            try {
1236                session = openSession();
1237
1238                StringBundler query = new StringBundler(2);
1239
1240                query.append(_SQL_COUNT_COMPANY_WHERE);
1241
1242                if (webId == null) {
1243                    query.append(_FINDER_COLUMN_WEBID_WEBID_1);
1244                }
1245                else {
1246                    if (webId.equals(StringPool.BLANK)) {
1247                        query.append(_FINDER_COLUMN_WEBID_WEBID_3);
1248                    }
1249                    else {
1250                        query.append(_FINDER_COLUMN_WEBID_WEBID_2);
1251                    }
1252                }
1253
1254                String sql = query.toString();
1255
1256                Query q = session.createQuery(sql);
1257
1258                QueryPos qPos = QueryPos.getInstance(q);
1259
1260                if (webId != null) {
1261                    qPos.add(webId);
1262                }
1263
1264                count = (Long)q.uniqueResult();
1265            }
1266            catch (Exception e) {
1267                throw processException(e);
1268            }
1269            finally {
1270                if (count == null) {
1271                    count = Long.valueOf(0);
1272                }
1273
1274                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_WEBID,
1275                    finderArgs, count);
1276
1277                closeSession(session);
1278            }
1279        }
1280
1281        return count.intValue();
1282    }
1283
1284    public int countByVirtualHost(String virtualHost) throws SystemException {
1285        Object[] finderArgs = new Object[] { virtualHost };
1286
1287        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VIRTUALHOST,
1288                finderArgs, this);
1289
1290        if (count == null) {
1291            Session session = null;
1292
1293            try {
1294                session = openSession();
1295
1296                StringBundler query = new StringBundler(2);
1297
1298                query.append(_SQL_COUNT_COMPANY_WHERE);
1299
1300                if (virtualHost == null) {
1301                    query.append(_FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_1);
1302                }
1303                else {
1304                    if (virtualHost.equals(StringPool.BLANK)) {
1305                        query.append(_FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_3);
1306                    }
1307                    else {
1308                        query.append(_FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_2);
1309                    }
1310                }
1311
1312                String sql = query.toString();
1313
1314                Query q = session.createQuery(sql);
1315
1316                QueryPos qPos = QueryPos.getInstance(q);
1317
1318                if (virtualHost != null) {
1319                    qPos.add(virtualHost);
1320                }
1321
1322                count = (Long)q.uniqueResult();
1323            }
1324            catch (Exception e) {
1325                throw processException(e);
1326            }
1327            finally {
1328                if (count == null) {
1329                    count = Long.valueOf(0);
1330                }
1331
1332                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VIRTUALHOST,
1333                    finderArgs, count);
1334
1335                closeSession(session);
1336            }
1337        }
1338
1339        return count.intValue();
1340    }
1341
1342    public int countByMx(String mx) throws SystemException {
1343        Object[] finderArgs = new Object[] { mx };
1344
1345        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MX,
1346                finderArgs, this);
1347
1348        if (count == null) {
1349            Session session = null;
1350
1351            try {
1352                session = openSession();
1353
1354                StringBundler query = new StringBundler(2);
1355
1356                query.append(_SQL_COUNT_COMPANY_WHERE);
1357
1358                if (mx == null) {
1359                    query.append(_FINDER_COLUMN_MX_MX_1);
1360                }
1361                else {
1362                    if (mx.equals(StringPool.BLANK)) {
1363                        query.append(_FINDER_COLUMN_MX_MX_3);
1364                    }
1365                    else {
1366                        query.append(_FINDER_COLUMN_MX_MX_2);
1367                    }
1368                }
1369
1370                String sql = query.toString();
1371
1372                Query q = session.createQuery(sql);
1373
1374                QueryPos qPos = QueryPos.getInstance(q);
1375
1376                if (mx != null) {
1377                    qPos.add(mx);
1378                }
1379
1380                count = (Long)q.uniqueResult();
1381            }
1382            catch (Exception e) {
1383                throw processException(e);
1384            }
1385            finally {
1386                if (count == null) {
1387                    count = Long.valueOf(0);
1388                }
1389
1390                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MX, finderArgs,
1391                    count);
1392
1393                closeSession(session);
1394            }
1395        }
1396
1397        return count.intValue();
1398    }
1399
1400    public int countByLogoId(long logoId) throws SystemException {
1401        Object[] finderArgs = new Object[] { new Long(logoId) };
1402
1403        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LOGOID,
1404                finderArgs, this);
1405
1406        if (count == null) {
1407            Session session = null;
1408
1409            try {
1410                session = openSession();
1411
1412                StringBundler query = new StringBundler(2);
1413
1414                query.append(_SQL_COUNT_COMPANY_WHERE);
1415
1416                query.append(_FINDER_COLUMN_LOGOID_LOGOID_2);
1417
1418                String sql = query.toString();
1419
1420                Query q = session.createQuery(sql);
1421
1422                QueryPos qPos = QueryPos.getInstance(q);
1423
1424                qPos.add(logoId);
1425
1426                count = (Long)q.uniqueResult();
1427            }
1428            catch (Exception e) {
1429                throw processException(e);
1430            }
1431            finally {
1432                if (count == null) {
1433                    count = Long.valueOf(0);
1434                }
1435
1436                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LOGOID,
1437                    finderArgs, count);
1438
1439                closeSession(session);
1440            }
1441        }
1442
1443        return count.intValue();
1444    }
1445
1446    public int countBySystem(boolean system) throws SystemException {
1447        Object[] finderArgs = new Object[] { Boolean.valueOf(system) };
1448
1449        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SYSTEM,
1450                finderArgs, this);
1451
1452        if (count == null) {
1453            Session session = null;
1454
1455            try {
1456                session = openSession();
1457
1458                StringBundler query = new StringBundler(2);
1459
1460                query.append(_SQL_COUNT_COMPANY_WHERE);
1461
1462                query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1463
1464                String sql = query.toString();
1465
1466                Query q = session.createQuery(sql);
1467
1468                QueryPos qPos = QueryPos.getInstance(q);
1469
1470                qPos.add(system);
1471
1472                count = (Long)q.uniqueResult();
1473            }
1474            catch (Exception e) {
1475                throw processException(e);
1476            }
1477            finally {
1478                if (count == null) {
1479                    count = Long.valueOf(0);
1480                }
1481
1482                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SYSTEM,
1483                    finderArgs, count);
1484
1485                closeSession(session);
1486            }
1487        }
1488
1489        return count.intValue();
1490    }
1491
1492    public int countAll() throws SystemException {
1493        Object[] finderArgs = new Object[0];
1494
1495        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1496                finderArgs, this);
1497
1498        if (count == null) {
1499            Session session = null;
1500
1501            try {
1502                session = openSession();
1503
1504                Query q = session.createQuery(_SQL_COUNT_COMPANY);
1505
1506                count = (Long)q.uniqueResult();
1507            }
1508            catch (Exception e) {
1509                throw processException(e);
1510            }
1511            finally {
1512                if (count == null) {
1513                    count = Long.valueOf(0);
1514                }
1515
1516                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1517                    count);
1518
1519                closeSession(session);
1520            }
1521        }
1522
1523        return count.intValue();
1524    }
1525
1526    public void afterPropertiesSet() {
1527        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1528                    com.liferay.portal.util.PropsUtil.get(
1529                        "value.object.listener.com.liferay.portal.model.Company")));
1530
1531        if (listenerClassNames.length > 0) {
1532            try {
1533                List<ModelListener<Company>> listenersList = new ArrayList<ModelListener<Company>>();
1534
1535                for (String listenerClassName : listenerClassNames) {
1536                    listenersList.add((ModelListener<Company>)Class.forName(
1537                            listenerClassName).newInstance());
1538                }
1539
1540                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1541            }
1542            catch (Exception e) {
1543                _log.error(e);
1544            }
1545        }
1546    }
1547
1548    @BeanReference(type = AccountPersistence.class)
1549    protected AccountPersistence accountPersistence;
1550    @BeanReference(type = AddressPersistence.class)
1551    protected AddressPersistence addressPersistence;
1552    @BeanReference(type = BrowserTrackerPersistence.class)
1553    protected BrowserTrackerPersistence browserTrackerPersistence;
1554    @BeanReference(type = ClassNamePersistence.class)
1555    protected ClassNamePersistence classNamePersistence;
1556    @BeanReference(type = CompanyPersistence.class)
1557    protected CompanyPersistence companyPersistence;
1558    @BeanReference(type = ContactPersistence.class)
1559    protected ContactPersistence contactPersistence;
1560    @BeanReference(type = CountryPersistence.class)
1561    protected CountryPersistence countryPersistence;
1562    @BeanReference(type = EmailAddressPersistence.class)
1563    protected EmailAddressPersistence emailAddressPersistence;
1564    @BeanReference(type = GroupPersistence.class)
1565    protected GroupPersistence groupPersistence;
1566    @BeanReference(type = ImagePersistence.class)
1567    protected ImagePersistence imagePersistence;
1568    @BeanReference(type = LayoutPersistence.class)
1569    protected LayoutPersistence layoutPersistence;
1570    @BeanReference(type = LayoutSetPersistence.class)
1571    protected LayoutSetPersistence layoutSetPersistence;
1572    @BeanReference(type = ListTypePersistence.class)
1573    protected ListTypePersistence listTypePersistence;
1574    @BeanReference(type = LockPersistence.class)
1575    protected LockPersistence lockPersistence;
1576    @BeanReference(type = MembershipRequestPersistence.class)
1577    protected MembershipRequestPersistence membershipRequestPersistence;
1578    @BeanReference(type = OrganizationPersistence.class)
1579    protected OrganizationPersistence organizationPersistence;
1580    @BeanReference(type = OrgGroupPermissionPersistence.class)
1581    protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1582    @BeanReference(type = OrgGroupRolePersistence.class)
1583    protected OrgGroupRolePersistence orgGroupRolePersistence;
1584    @BeanReference(type = OrgLaborPersistence.class)
1585    protected OrgLaborPersistence orgLaborPersistence;
1586    @BeanReference(type = PasswordPolicyPersistence.class)
1587    protected PasswordPolicyPersistence passwordPolicyPersistence;
1588    @BeanReference(type = PasswordPolicyRelPersistence.class)
1589    protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1590    @BeanReference(type = PasswordTrackerPersistence.class)
1591    protected PasswordTrackerPersistence passwordTrackerPersistence;
1592    @BeanReference(type = PermissionPersistence.class)
1593    protected PermissionPersistence permissionPersistence;
1594    @BeanReference(type = PhonePersistence.class)
1595    protected PhonePersistence phonePersistence;
1596    @BeanReference(type = PluginSettingPersistence.class)
1597    protected PluginSettingPersistence pluginSettingPersistence;
1598    @BeanReference(type = PortletPersistence.class)
1599    protected PortletPersistence portletPersistence;
1600    @BeanReference(type = PortletItemPersistence.class)
1601    protected PortletItemPersistence portletItemPersistence;
1602    @BeanReference(type = PortletPreferencesPersistence.class)
1603    protected PortletPreferencesPersistence portletPreferencesPersistence;
1604    @BeanReference(type = RegionPersistence.class)
1605    protected RegionPersistence regionPersistence;
1606    @BeanReference(type = ReleasePersistence.class)
1607    protected ReleasePersistence releasePersistence;
1608    @BeanReference(type = ResourcePersistence.class)
1609    protected ResourcePersistence resourcePersistence;
1610    @BeanReference(type = ResourceActionPersistence.class)
1611    protected ResourceActionPersistence resourceActionPersistence;
1612    @BeanReference(type = ResourceCodePersistence.class)
1613    protected ResourceCodePersistence resourceCodePersistence;
1614    @BeanReference(type = ResourcePermissionPersistence.class)
1615    protected ResourcePermissionPersistence resourcePermissionPersistence;
1616    @BeanReference(type = RolePersistence.class)
1617    protected RolePersistence rolePersistence;
1618    @BeanReference(type = ServiceComponentPersistence.class)
1619    protected ServiceComponentPersistence serviceComponentPersistence;
1620    @BeanReference(type = ShardPersistence.class)
1621    protected ShardPersistence shardPersistence;
1622    @BeanReference(type = SubscriptionPersistence.class)
1623    protected SubscriptionPersistence subscriptionPersistence;
1624    @BeanReference(type = UserPersistence.class)
1625    protected UserPersistence userPersistence;
1626    @BeanReference(type = UserGroupPersistence.class)
1627    protected UserGroupPersistence userGroupPersistence;
1628    @BeanReference(type = UserGroupGroupRolePersistence.class)
1629    protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1630    @BeanReference(type = UserGroupRolePersistence.class)
1631    protected UserGroupRolePersistence userGroupRolePersistence;
1632    @BeanReference(type = UserIdMapperPersistence.class)
1633    protected UserIdMapperPersistence userIdMapperPersistence;
1634    @BeanReference(type = UserTrackerPersistence.class)
1635    protected UserTrackerPersistence userTrackerPersistence;
1636    @BeanReference(type = UserTrackerPathPersistence.class)
1637    protected UserTrackerPathPersistence userTrackerPathPersistence;
1638    @BeanReference(type = WebDAVPropsPersistence.class)
1639    protected WebDAVPropsPersistence webDAVPropsPersistence;
1640    @BeanReference(type = WebsitePersistence.class)
1641    protected WebsitePersistence websitePersistence;
1642    private static final String _SQL_SELECT_COMPANY = "SELECT company FROM Company company";
1643    private static final String _SQL_SELECT_COMPANY_WHERE = "SELECT company FROM Company company WHERE ";
1644    private static final String _SQL_COUNT_COMPANY = "SELECT COUNT(company) FROM Company company";
1645    private static final String _SQL_COUNT_COMPANY_WHERE = "SELECT COUNT(company) FROM Company company WHERE ";
1646    private static final String _FINDER_COLUMN_WEBID_WEBID_1 = "company.webId IS NULL";
1647    private static final String _FINDER_COLUMN_WEBID_WEBID_2 = "company.webId = ?";
1648    private static final String _FINDER_COLUMN_WEBID_WEBID_3 = "(company.webId IS NULL OR company.webId = ?)";
1649    private static final String _FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_1 = "company.virtualHost IS NULL";
1650    private static final String _FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_2 = "company.virtualHost = ?";
1651    private static final String _FINDER_COLUMN_VIRTUALHOST_VIRTUALHOST_3 = "(company.virtualHost IS NULL OR company.virtualHost = ?)";
1652    private static final String _FINDER_COLUMN_MX_MX_1 = "company.mx IS NULL";
1653    private static final String _FINDER_COLUMN_MX_MX_2 = "company.mx = ?";
1654    private static final String _FINDER_COLUMN_MX_MX_3 = "(company.mx IS NULL OR company.mx = ?)";
1655    private static final String _FINDER_COLUMN_LOGOID_LOGOID_2 = "company.logoId = ?";
1656    private static final String _FINDER_COLUMN_SYSTEM_SYSTEM_2 = "company.system = ?";
1657    private static final String _ORDER_BY_ENTITY_ALIAS = "company.";
1658    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Company exists with the primary key ";
1659    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Company exists with the key {";
1660    private static Log _log = LogFactoryUtil.getLog(CompanyPersistenceImpl.class);
1661}