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