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