001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchCompanyException;
018    import com.liferay.portal.NoSuchModelException;
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.model.Company;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.model.impl.CompanyImpl;
041    import com.liferay.portal.model.impl.CompanyModelImpl;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import java.io.Serializable;
045    
046    import java.util.ArrayList;
047    import java.util.Collections;
048    import java.util.List;
049    
050    /**
051     * The persistence implementation for the company service.
052     *
053     * <p>
054     * Caching information and settings can be found in <code>portal.properties</code>
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see CompanyPersistence
059     * @see CompanyUtil
060     * @generated
061     */
062    public class CompanyPersistenceImpl extends BasePersistenceImpl<Company>
063            implements CompanyPersistence {
064            /*
065             * NOTE FOR DEVELOPERS:
066             *
067             * Never modify or reference this class directly. Always use {@link CompanyUtil} to access the company persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
068             */
069            public static final String FINDER_CLASS_NAME_ENTITY = CompanyImpl.class.getName();
070            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071                    ".List1";
072            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073                    ".List2";
074            public static final FinderPath FINDER_PATH_FETCH_BY_WEBID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
075                            CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
076                            FINDER_CLASS_NAME_ENTITY, "fetchByWebId",
077                            new String[] { String.class.getName() },
078                            CompanyModelImpl.WEBID_COLUMN_BITMASK);
079            public static final FinderPath FINDER_PATH_COUNT_BY_WEBID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
080                            CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
081                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByWebId",
082                            new String[] { String.class.getName() });
083            public static final FinderPath FINDER_PATH_FETCH_BY_MX = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
084                            CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
085                            FINDER_CLASS_NAME_ENTITY, "fetchByMx",
086                            new String[] { String.class.getName() },
087                            CompanyModelImpl.MX_COLUMN_BITMASK);
088            public static final FinderPath FINDER_PATH_COUNT_BY_MX = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
089                            CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByMx",
091                            new String[] { String.class.getName() });
092            public static final FinderPath FINDER_PATH_FETCH_BY_LOGOID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
093                            CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
094                            FINDER_CLASS_NAME_ENTITY, "fetchByLogoId",
095                            new String[] { Long.class.getName() },
096                            CompanyModelImpl.LOGOID_COLUMN_BITMASK);
097            public static final FinderPath FINDER_PATH_COUNT_BY_LOGOID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
098                            CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLogoId",
100                            new String[] { Long.class.getName() });
101            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
102                            CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySystem",
104                            new String[] {
105                                    Boolean.class.getName(),
106                                    
107                            "java.lang.Integer", "java.lang.Integer",
108                                    "com.liferay.portal.kernel.util.OrderByComparator"
109                            });
110            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM =
111                    new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
112                            CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
113                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySystem",
114                            new String[] { Boolean.class.getName() },
115                            CompanyModelImpl.SYSTEM_COLUMN_BITMASK);
116            public static final FinderPath FINDER_PATH_COUNT_BY_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
117                            CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
118                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySystem",
119                            new String[] { Boolean.class.getName() });
120            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
121                            CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
123            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
124                            CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
125                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
126            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
127                            CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
129    
130            /**
131             * Caches the company in the entity cache if it is enabled.
132             *
133             * @param company the company
134             */
135            public void cacheResult(Company company) {
136                    EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
137                            CompanyImpl.class, company.getPrimaryKey(), company);
138    
139                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
140                            new Object[] { company.getWebId() }, company);
141    
142                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
143                            new Object[] { company.getMx() }, company);
144    
145                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
146                            new Object[] { Long.valueOf(company.getLogoId()) }, company);
147    
148                    company.resetOriginalValues();
149            }
150    
151            /**
152             * Caches the companies in the entity cache if it is enabled.
153             *
154             * @param companies the companies
155             */
156            public void cacheResult(List<Company> companies) {
157                    for (Company company : companies) {
158                            if (EntityCacheUtil.getResult(
159                                                    CompanyModelImpl.ENTITY_CACHE_ENABLED,
160                                                    CompanyImpl.class, company.getPrimaryKey()) == null) {
161                                    cacheResult(company);
162                            }
163                            else {
164                                    company.resetOriginalValues();
165                            }
166                    }
167            }
168    
169            /**
170             * Clears the cache for all companies.
171             *
172             * <p>
173             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
174             * </p>
175             */
176            @Override
177            public void clearCache() {
178                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
179                            CacheRegistryUtil.clear(CompanyImpl.class.getName());
180                    }
181    
182                    EntityCacheUtil.clearCache(CompanyImpl.class.getName());
183    
184                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
185                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
186                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
187            }
188    
189            /**
190             * Clears the cache for the company.
191             *
192             * <p>
193             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
194             * </p>
195             */
196            @Override
197            public void clearCache(Company company) {
198                    EntityCacheUtil.removeResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
199                            CompanyImpl.class, company.getPrimaryKey());
200    
201                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
202                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
203    
204                    clearUniqueFindersCache(company);
205            }
206    
207            @Override
208            public void clearCache(List<Company> companies) {
209                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
210                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
211    
212                    for (Company company : companies) {
213                            EntityCacheUtil.removeResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
214                                    CompanyImpl.class, company.getPrimaryKey());
215    
216                            clearUniqueFindersCache(company);
217                    }
218            }
219    
220            protected void clearUniqueFindersCache(Company company) {
221                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID,
222                            new Object[] { company.getWebId() });
223    
224                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX,
225                            new Object[] { company.getMx() });
226    
227                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID,
228                            new Object[] { Long.valueOf(company.getLogoId()) });
229            }
230    
231            /**
232             * Creates a new company with the primary key. Does not add the company to the database.
233             *
234             * @param companyId the primary key for the new company
235             * @return the new company
236             */
237            public Company create(long companyId) {
238                    Company company = new CompanyImpl();
239    
240                    company.setNew(true);
241                    company.setPrimaryKey(companyId);
242    
243                    return company;
244            }
245    
246            /**
247             * Removes the company with the primary key from the database. Also notifies the appropriate model listeners.
248             *
249             * @param companyId the primary key of the company
250             * @return the company that was removed
251             * @throws com.liferay.portal.NoSuchCompanyException if a company with the primary key could not be found
252             * @throws SystemException if a system exception occurred
253             */
254            public Company remove(long companyId)
255                    throws NoSuchCompanyException, SystemException {
256                    return remove(Long.valueOf(companyId));
257            }
258    
259            /**
260             * Removes the company with the primary key from the database. Also notifies the appropriate model listeners.
261             *
262             * @param primaryKey the primary key of the company
263             * @return the company that was removed
264             * @throws com.liferay.portal.NoSuchCompanyException if a company with the primary key could not be found
265             * @throws SystemException if a system exception occurred
266             */
267            @Override
268            public Company remove(Serializable primaryKey)
269                    throws NoSuchCompanyException, SystemException {
270                    Session session = null;
271    
272                    try {
273                            session = openSession();
274    
275                            Company company = (Company)session.get(CompanyImpl.class, primaryKey);
276    
277                            if (company == null) {
278                                    if (_log.isWarnEnabled()) {
279                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
280                                    }
281    
282                                    throw new NoSuchCompanyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
283                                            primaryKey);
284                            }
285    
286                            return remove(company);
287                    }
288                    catch (NoSuchCompanyException nsee) {
289                            throw nsee;
290                    }
291                    catch (Exception e) {
292                            throw processException(e);
293                    }
294                    finally {
295                            closeSession(session);
296                    }
297            }
298    
299            @Override
300            protected Company removeImpl(Company company) throws SystemException {
301                    company = toUnwrappedModel(company);
302    
303                    Session session = null;
304    
305                    try {
306                            session = openSession();
307    
308                            BatchSessionUtil.delete(session, company);
309                    }
310                    catch (Exception e) {
311                            throw processException(e);
312                    }
313                    finally {
314                            closeSession(session);
315                    }
316    
317                    clearCache(company);
318    
319                    return company;
320            }
321    
322            @Override
323            public Company updateImpl(com.liferay.portal.model.Company company,
324                    boolean merge) throws SystemException {
325                    company = toUnwrappedModel(company);
326    
327                    boolean isNew = company.isNew();
328    
329                    CompanyModelImpl companyModelImpl = (CompanyModelImpl)company;
330    
331                    Session session = null;
332    
333                    try {
334                            session = openSession();
335    
336                            BatchSessionUtil.update(session, company, merge);
337    
338                            company.setNew(false);
339                    }
340                    catch (Exception e) {
341                            throw processException(e);
342                    }
343                    finally {
344                            closeSession(session);
345                    }
346    
347                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
348    
349                    if (isNew || !CompanyModelImpl.COLUMN_BITMASK_ENABLED) {
350                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
351                    }
352    
353                    else {
354                            if ((companyModelImpl.getColumnBitmask() &
355                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM.getColumnBitmask()) != 0) {
356                                    Object[] args = new Object[] {
357                                                    Boolean.valueOf(companyModelImpl.getOriginalSystem())
358                                            };
359    
360                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SYSTEM, args);
361                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM,
362                                            args);
363    
364                                    args = new Object[] {
365                                                    Boolean.valueOf(companyModelImpl.getSystem())
366                                            };
367    
368                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SYSTEM, args);
369                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM,
370                                            args);
371                            }
372                    }
373    
374                    EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
375                            CompanyImpl.class, company.getPrimaryKey(), company);
376    
377                    if (isNew) {
378                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
379                                    new Object[] { company.getWebId() }, company);
380    
381                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
382                                    new Object[] { company.getMx() }, company);
383    
384                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
385                                    new Object[] { Long.valueOf(company.getLogoId()) }, company);
386                    }
387                    else {
388                            if ((companyModelImpl.getColumnBitmask() &
389                                            FINDER_PATH_FETCH_BY_WEBID.getColumnBitmask()) != 0) {
390                                    Object[] args = new Object[] { companyModelImpl.getOriginalWebId() };
391    
392                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_WEBID, args);
393                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID, args);
394    
395                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
396                                            new Object[] { company.getWebId() }, company);
397                            }
398    
399                            if ((companyModelImpl.getColumnBitmask() &
400                                            FINDER_PATH_FETCH_BY_MX.getColumnBitmask()) != 0) {
401                                    Object[] args = new Object[] { companyModelImpl.getOriginalMx() };
402    
403                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MX, args);
404                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX, args);
405    
406                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
407                                            new Object[] { company.getMx() }, company);
408                            }
409    
410                            if ((companyModelImpl.getColumnBitmask() &
411                                            FINDER_PATH_FETCH_BY_LOGOID.getColumnBitmask()) != 0) {
412                                    Object[] args = new Object[] {
413                                                    Long.valueOf(companyModelImpl.getOriginalLogoId())
414                                            };
415    
416                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOGOID, args);
417                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID, args);
418    
419                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
420                                            new Object[] { Long.valueOf(company.getLogoId()) }, company);
421                            }
422                    }
423    
424                    return company;
425            }
426    
427            protected Company toUnwrappedModel(Company company) {
428                    if (company instanceof CompanyImpl) {
429                            return company;
430                    }
431    
432                    CompanyImpl companyImpl = new CompanyImpl();
433    
434                    companyImpl.setNew(company.isNew());
435                    companyImpl.setPrimaryKey(company.getPrimaryKey());
436    
437                    companyImpl.setCompanyId(company.getCompanyId());
438                    companyImpl.setAccountId(company.getAccountId());
439                    companyImpl.setWebId(company.getWebId());
440                    companyImpl.setKey(company.getKey());
441                    companyImpl.setMx(company.getMx());
442                    companyImpl.setHomeURL(company.getHomeURL());
443                    companyImpl.setLogoId(company.getLogoId());
444                    companyImpl.setSystem(company.isSystem());
445                    companyImpl.setMaxUsers(company.getMaxUsers());
446                    companyImpl.setActive(company.isActive());
447    
448                    return companyImpl;
449            }
450    
451            /**
452             * Returns the company with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
453             *
454             * @param primaryKey the primary key of the company
455             * @return the company
456             * @throws com.liferay.portal.NoSuchModelException if a company with the primary key could not be found
457             * @throws SystemException if a system exception occurred
458             */
459            @Override
460            public Company findByPrimaryKey(Serializable primaryKey)
461                    throws NoSuchModelException, SystemException {
462                    return findByPrimaryKey(((Long)primaryKey).longValue());
463            }
464    
465            /**
466             * Returns the company with the primary key or throws a {@link com.liferay.portal.NoSuchCompanyException} if it could not be found.
467             *
468             * @param companyId the primary key of the company
469             * @return the company
470             * @throws com.liferay.portal.NoSuchCompanyException if a company with the primary key could not be found
471             * @throws SystemException if a system exception occurred
472             */
473            public Company findByPrimaryKey(long companyId)
474                    throws NoSuchCompanyException, SystemException {
475                    Company company = fetchByPrimaryKey(companyId);
476    
477                    if (company == null) {
478                            if (_log.isWarnEnabled()) {
479                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + companyId);
480                            }
481    
482                            throw new NoSuchCompanyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
483                                    companyId);
484                    }
485    
486                    return company;
487            }
488    
489            /**
490             * Returns the company with the primary key or returns <code>null</code> if it could not be found.
491             *
492             * @param primaryKey the primary key of the company
493             * @return the company, or <code>null</code> if a company with the primary key could not be found
494             * @throws SystemException if a system exception occurred
495             */
496            @Override
497            public Company fetchByPrimaryKey(Serializable primaryKey)
498                    throws SystemException {
499                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
500            }
501    
502            /**
503             * Returns the company with the primary key or returns <code>null</code> if it could not be found.
504             *
505             * @param companyId the primary key of the company
506             * @return the company, or <code>null</code> if a company with the primary key could not be found
507             * @throws SystemException if a system exception occurred
508             */
509            public Company fetchByPrimaryKey(long companyId) throws SystemException {
510                    Company company = (Company)EntityCacheUtil.getResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
511                                    CompanyImpl.class, companyId);
512    
513                    if (company == _nullCompany) {
514                            return null;
515                    }
516    
517                    if (company == null) {
518                            Session session = null;
519    
520                            boolean hasException = false;
521    
522                            try {
523                                    session = openSession();
524    
525                                    company = (Company)session.get(CompanyImpl.class,
526                                                    Long.valueOf(companyId));
527                            }
528                            catch (Exception e) {
529                                    hasException = true;
530    
531                                    throw processException(e);
532                            }
533                            finally {
534                                    if (company != null) {
535                                            cacheResult(company);
536                                    }
537                                    else if (!hasException) {
538                                            EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
539                                                    CompanyImpl.class, companyId, _nullCompany);
540                                    }
541    
542                                    closeSession(session);
543                            }
544                    }
545    
546                    return company;
547            }
548    
549            /**
550             * Returns the company where webId = &#63; or throws a {@link com.liferay.portal.NoSuchCompanyException} if it could not be found.
551             *
552             * @param webId the web ID
553             * @return the matching company
554             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
555             * @throws SystemException if a system exception occurred
556             */
557            public Company findByWebId(String webId)
558                    throws NoSuchCompanyException, SystemException {
559                    Company company = fetchByWebId(webId);
560    
561                    if (company == null) {
562                            StringBundler msg = new StringBundler(4);
563    
564                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
565    
566                            msg.append("webId=");
567                            msg.append(webId);
568    
569                            msg.append(StringPool.CLOSE_CURLY_BRACE);
570    
571                            if (_log.isWarnEnabled()) {
572                                    _log.warn(msg.toString());
573                            }
574    
575                            throw new NoSuchCompanyException(msg.toString());
576                    }
577    
578                    return company;
579            }
580    
581            /**
582             * Returns the company where webId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
583             *
584             * @param webId the web ID
585             * @return the matching company, or <code>null</code> if a matching company could not be found
586             * @throws SystemException if a system exception occurred
587             */
588            public Company fetchByWebId(String webId) throws SystemException {
589                    return fetchByWebId(webId, true);
590            }
591    
592            /**
593             * Returns the company where webId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
594             *
595             * @param webId the web ID
596             * @param retrieveFromCache whether to use the finder cache
597             * @return the matching company, or <code>null</code> if a matching company could not be found
598             * @throws SystemException if a system exception occurred
599             */
600            public Company fetchByWebId(String webId, boolean retrieveFromCache)
601                    throws SystemException {
602                    Object[] finderArgs = new Object[] { webId };
603    
604                    Object result = null;
605    
606                    if (retrieveFromCache) {
607                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_WEBID,
608                                            finderArgs, this);
609                    }
610    
611                    if (result == null) {
612                            StringBundler query = new StringBundler(2);
613    
614                            query.append(_SQL_SELECT_COMPANY_WHERE);
615    
616                            if (webId == null) {
617                                    query.append(_FINDER_COLUMN_WEBID_WEBID_1);
618                            }
619                            else {
620                                    if (webId.equals(StringPool.BLANK)) {
621                                            query.append(_FINDER_COLUMN_WEBID_WEBID_3);
622                                    }
623                                    else {
624                                            query.append(_FINDER_COLUMN_WEBID_WEBID_2);
625                                    }
626                            }
627    
628                            String sql = query.toString();
629    
630                            Session session = null;
631    
632                            try {
633                                    session = openSession();
634    
635                                    Query q = session.createQuery(sql);
636    
637                                    QueryPos qPos = QueryPos.getInstance(q);
638    
639                                    if (webId != null) {
640                                            qPos.add(webId);
641                                    }
642    
643                                    List<Company> list = q.list();
644    
645                                    result = list;
646    
647                                    Company company = null;
648    
649                                    if (list.isEmpty()) {
650                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
651                                                    finderArgs, list);
652                                    }
653                                    else {
654                                            company = list.get(0);
655    
656                                            cacheResult(company);
657    
658                                            if ((company.getWebId() == null) ||
659                                                            !company.getWebId().equals(webId)) {
660                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
661                                                            finderArgs, company);
662                                            }
663                                    }
664    
665                                    return company;
666                            }
667                            catch (Exception e) {
668                                    throw processException(e);
669                            }
670                            finally {
671                                    if (result == null) {
672                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID,
673                                                    finderArgs);
674                                    }
675    
676                                    closeSession(session);
677                            }
678                    }
679                    else {
680                            if (result instanceof List<?>) {
681                                    return null;
682                            }
683                            else {
684                                    return (Company)result;
685                            }
686                    }
687            }
688    
689            /**
690             * Returns the company where mx = &#63; or throws a {@link com.liferay.portal.NoSuchCompanyException} if it could not be found.
691             *
692             * @param mx the mx
693             * @return the matching company
694             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
695             * @throws SystemException if a system exception occurred
696             */
697            public Company findByMx(String mx)
698                    throws NoSuchCompanyException, SystemException {
699                    Company company = fetchByMx(mx);
700    
701                    if (company == null) {
702                            StringBundler msg = new StringBundler(4);
703    
704                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
705    
706                            msg.append("mx=");
707                            msg.append(mx);
708    
709                            msg.append(StringPool.CLOSE_CURLY_BRACE);
710    
711                            if (_log.isWarnEnabled()) {
712                                    _log.warn(msg.toString());
713                            }
714    
715                            throw new NoSuchCompanyException(msg.toString());
716                    }
717    
718                    return company;
719            }
720    
721            /**
722             * Returns the company where mx = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
723             *
724             * @param mx the mx
725             * @return the matching company, or <code>null</code> if a matching company could not be found
726             * @throws SystemException if a system exception occurred
727             */
728            public Company fetchByMx(String mx) throws SystemException {
729                    return fetchByMx(mx, true);
730            }
731    
732            /**
733             * Returns the company where mx = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
734             *
735             * @param mx the mx
736             * @param retrieveFromCache whether to use the finder cache
737             * @return the matching company, or <code>null</code> if a matching company could not be found
738             * @throws SystemException if a system exception occurred
739             */
740            public Company fetchByMx(String mx, boolean retrieveFromCache)
741                    throws SystemException {
742                    Object[] finderArgs = new Object[] { mx };
743    
744                    Object result = null;
745    
746                    if (retrieveFromCache) {
747                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_MX,
748                                            finderArgs, this);
749                    }
750    
751                    if (result == null) {
752                            StringBundler query = new StringBundler(2);
753    
754                            query.append(_SQL_SELECT_COMPANY_WHERE);
755    
756                            if (mx == null) {
757                                    query.append(_FINDER_COLUMN_MX_MX_1);
758                            }
759                            else {
760                                    if (mx.equals(StringPool.BLANK)) {
761                                            query.append(_FINDER_COLUMN_MX_MX_3);
762                                    }
763                                    else {
764                                            query.append(_FINDER_COLUMN_MX_MX_2);
765                                    }
766                            }
767    
768                            String sql = query.toString();
769    
770                            Session session = null;
771    
772                            try {
773                                    session = openSession();
774    
775                                    Query q = session.createQuery(sql);
776    
777                                    QueryPos qPos = QueryPos.getInstance(q);
778    
779                                    if (mx != null) {
780                                            qPos.add(mx);
781                                    }
782    
783                                    List<Company> list = q.list();
784    
785                                    result = list;
786    
787                                    Company company = null;
788    
789                                    if (list.isEmpty()) {
790                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
791                                                    finderArgs, list);
792                                    }
793                                    else {
794                                            company = list.get(0);
795    
796                                            cacheResult(company);
797    
798                                            if ((company.getMx() == null) ||
799                                                            !company.getMx().equals(mx)) {
800                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
801                                                            finderArgs, company);
802                                            }
803                                    }
804    
805                                    return company;
806                            }
807                            catch (Exception e) {
808                                    throw processException(e);
809                            }
810                            finally {
811                                    if (result == null) {
812                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX,
813                                                    finderArgs);
814                                    }
815    
816                                    closeSession(session);
817                            }
818                    }
819                    else {
820                            if (result instanceof List<?>) {
821                                    return null;
822                            }
823                            else {
824                                    return (Company)result;
825                            }
826                    }
827            }
828    
829            /**
830             * Returns the company where logoId = &#63; or throws a {@link com.liferay.portal.NoSuchCompanyException} if it could not be found.
831             *
832             * @param logoId the logo ID
833             * @return the matching company
834             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
835             * @throws SystemException if a system exception occurred
836             */
837            public Company findByLogoId(long logoId)
838                    throws NoSuchCompanyException, SystemException {
839                    Company company = fetchByLogoId(logoId);
840    
841                    if (company == null) {
842                            StringBundler msg = new StringBundler(4);
843    
844                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
845    
846                            msg.append("logoId=");
847                            msg.append(logoId);
848    
849                            msg.append(StringPool.CLOSE_CURLY_BRACE);
850    
851                            if (_log.isWarnEnabled()) {
852                                    _log.warn(msg.toString());
853                            }
854    
855                            throw new NoSuchCompanyException(msg.toString());
856                    }
857    
858                    return company;
859            }
860    
861            /**
862             * Returns the company where logoId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
863             *
864             * @param logoId the logo ID
865             * @return the matching company, or <code>null</code> if a matching company could not be found
866             * @throws SystemException if a system exception occurred
867             */
868            public Company fetchByLogoId(long logoId) throws SystemException {
869                    return fetchByLogoId(logoId, true);
870            }
871    
872            /**
873             * Returns the company where logoId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
874             *
875             * @param logoId the logo ID
876             * @param retrieveFromCache whether to use the finder cache
877             * @return the matching company, or <code>null</code> if a matching company could not be found
878             * @throws SystemException if a system exception occurred
879             */
880            public Company fetchByLogoId(long logoId, boolean retrieveFromCache)
881                    throws SystemException {
882                    Object[] finderArgs = new Object[] { logoId };
883    
884                    Object result = null;
885    
886                    if (retrieveFromCache) {
887                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LOGOID,
888                                            finderArgs, this);
889                    }
890    
891                    if (result == null) {
892                            StringBundler query = new StringBundler(2);
893    
894                            query.append(_SQL_SELECT_COMPANY_WHERE);
895    
896                            query.append(_FINDER_COLUMN_LOGOID_LOGOID_2);
897    
898                            String sql = query.toString();
899    
900                            Session session = null;
901    
902                            try {
903                                    session = openSession();
904    
905                                    Query q = session.createQuery(sql);
906    
907                                    QueryPos qPos = QueryPos.getInstance(q);
908    
909                                    qPos.add(logoId);
910    
911                                    List<Company> list = q.list();
912    
913                                    result = list;
914    
915                                    Company company = null;
916    
917                                    if (list.isEmpty()) {
918                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
919                                                    finderArgs, list);
920                                    }
921                                    else {
922                                            company = list.get(0);
923    
924                                            cacheResult(company);
925    
926                                            if ((company.getLogoId() != logoId)) {
927                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
928                                                            finderArgs, company);
929                                            }
930                                    }
931    
932                                    return company;
933                            }
934                            catch (Exception e) {
935                                    throw processException(e);
936                            }
937                            finally {
938                                    if (result == null) {
939                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID,
940                                                    finderArgs);
941                                    }
942    
943                                    closeSession(session);
944                            }
945                    }
946                    else {
947                            if (result instanceof List<?>) {
948                                    return null;
949                            }
950                            else {
951                                    return (Company)result;
952                            }
953                    }
954            }
955    
956            /**
957             * Returns all the companies where system = &#63;.
958             *
959             * @param system the system
960             * @return the matching companies
961             * @throws SystemException if a system exception occurred
962             */
963            public List<Company> findBySystem(boolean system) throws SystemException {
964                    return findBySystem(system, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
965            }
966    
967            /**
968             * Returns a range of all the companies where system = &#63;.
969             *
970             * <p>
971             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
972             * </p>
973             *
974             * @param system the system
975             * @param start the lower bound of the range of companies
976             * @param end the upper bound of the range of companies (not inclusive)
977             * @return the range of matching companies
978             * @throws SystemException if a system exception occurred
979             */
980            public List<Company> findBySystem(boolean system, int start, int end)
981                    throws SystemException {
982                    return findBySystem(system, start, end, null);
983            }
984    
985            /**
986             * Returns an ordered range of all the companies where system = &#63;.
987             *
988             * <p>
989             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
990             * </p>
991             *
992             * @param system the system
993             * @param start the lower bound of the range of companies
994             * @param end the upper bound of the range of companies (not inclusive)
995             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
996             * @return the ordered range of matching companies
997             * @throws SystemException if a system exception occurred
998             */
999            public List<Company> findBySystem(boolean system, int start, int end,
1000                    OrderByComparator orderByComparator) throws SystemException {
1001                    FinderPath finderPath = null;
1002                    Object[] finderArgs = null;
1003    
1004                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1005                                    (orderByComparator == null)) {
1006                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM;
1007                            finderArgs = new Object[] { system };
1008                    }
1009                    else {
1010                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SYSTEM;
1011                            finderArgs = new Object[] { system, start, end, orderByComparator };
1012                    }
1013    
1014                    List<Company> list = (List<Company>)FinderCacheUtil.getResult(finderPath,
1015                                    finderArgs, this);
1016    
1017                    if (list == null) {
1018                            StringBundler query = null;
1019    
1020                            if (orderByComparator != null) {
1021                                    query = new StringBundler(3 +
1022                                                    (orderByComparator.getOrderByFields().length * 3));
1023                            }
1024                            else {
1025                                    query = new StringBundler(2);
1026                            }
1027    
1028                            query.append(_SQL_SELECT_COMPANY_WHERE);
1029    
1030                            query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1031    
1032                            if (orderByComparator != null) {
1033                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1034                                            orderByComparator);
1035                            }
1036    
1037                            String sql = query.toString();
1038    
1039                            Session session = null;
1040    
1041                            try {
1042                                    session = openSession();
1043    
1044                                    Query q = session.createQuery(sql);
1045    
1046                                    QueryPos qPos = QueryPos.getInstance(q);
1047    
1048                                    qPos.add(system);
1049    
1050                                    list = (List<Company>)QueryUtil.list(q, getDialect(), start, end);
1051                            }
1052                            catch (Exception e) {
1053                                    throw processException(e);
1054                            }
1055                            finally {
1056                                    if (list == null) {
1057                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1058                                    }
1059                                    else {
1060                                            cacheResult(list);
1061    
1062                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1063                                    }
1064    
1065                                    closeSession(session);
1066                            }
1067                    }
1068    
1069                    return list;
1070            }
1071    
1072            /**
1073             * Returns the first company in the ordered set where system = &#63;.
1074             *
1075             * <p>
1076             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1077             * </p>
1078             *
1079             * @param system the system
1080             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1081             * @return the first matching company
1082             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
1083             * @throws SystemException if a system exception occurred
1084             */
1085            public Company findBySystem_First(boolean system,
1086                    OrderByComparator orderByComparator)
1087                    throws NoSuchCompanyException, SystemException {
1088                    List<Company> list = findBySystem(system, 0, 1, orderByComparator);
1089    
1090                    if (list.isEmpty()) {
1091                            StringBundler msg = new StringBundler(4);
1092    
1093                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1094    
1095                            msg.append("system=");
1096                            msg.append(system);
1097    
1098                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1099    
1100                            throw new NoSuchCompanyException(msg.toString());
1101                    }
1102                    else {
1103                            return list.get(0);
1104                    }
1105            }
1106    
1107            /**
1108             * Returns the last company in the ordered set where system = &#63;.
1109             *
1110             * <p>
1111             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1112             * </p>
1113             *
1114             * @param system the system
1115             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1116             * @return the last matching company
1117             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
1118             * @throws SystemException if a system exception occurred
1119             */
1120            public Company findBySystem_Last(boolean system,
1121                    OrderByComparator orderByComparator)
1122                    throws NoSuchCompanyException, SystemException {
1123                    int count = countBySystem(system);
1124    
1125                    List<Company> list = findBySystem(system, count - 1, count,
1126                                    orderByComparator);
1127    
1128                    if (list.isEmpty()) {
1129                            StringBundler msg = new StringBundler(4);
1130    
1131                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1132    
1133                            msg.append("system=");
1134                            msg.append(system);
1135    
1136                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1137    
1138                            throw new NoSuchCompanyException(msg.toString());
1139                    }
1140                    else {
1141                            return list.get(0);
1142                    }
1143            }
1144    
1145            /**
1146             * Returns the companies before and after the current company in the ordered set where system = &#63;.
1147             *
1148             * <p>
1149             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1150             * </p>
1151             *
1152             * @param companyId the primary key of the current company
1153             * @param system the system
1154             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1155             * @return the previous, current, and next company
1156             * @throws com.liferay.portal.NoSuchCompanyException if a company with the primary key could not be found
1157             * @throws SystemException if a system exception occurred
1158             */
1159            public Company[] findBySystem_PrevAndNext(long companyId, boolean system,
1160                    OrderByComparator orderByComparator)
1161                    throws NoSuchCompanyException, SystemException {
1162                    Company company = findByPrimaryKey(companyId);
1163    
1164                    Session session = null;
1165    
1166                    try {
1167                            session = openSession();
1168    
1169                            Company[] array = new CompanyImpl[3];
1170    
1171                            array[0] = getBySystem_PrevAndNext(session, company, system,
1172                                            orderByComparator, true);
1173    
1174                            array[1] = company;
1175    
1176                            array[2] = getBySystem_PrevAndNext(session, company, system,
1177                                            orderByComparator, false);
1178    
1179                            return array;
1180                    }
1181                    catch (Exception e) {
1182                            throw processException(e);
1183                    }
1184                    finally {
1185                            closeSession(session);
1186                    }
1187            }
1188    
1189            protected Company getBySystem_PrevAndNext(Session session, Company company,
1190                    boolean system, OrderByComparator orderByComparator, boolean previous) {
1191                    StringBundler query = null;
1192    
1193                    if (orderByComparator != null) {
1194                            query = new StringBundler(6 +
1195                                            (orderByComparator.getOrderByFields().length * 6));
1196                    }
1197                    else {
1198                            query = new StringBundler(3);
1199                    }
1200    
1201                    query.append(_SQL_SELECT_COMPANY_WHERE);
1202    
1203                    query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1204    
1205                    if (orderByComparator != null) {
1206                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1207    
1208                            if (orderByConditionFields.length > 0) {
1209                                    query.append(WHERE_AND);
1210                            }
1211    
1212                            for (int i = 0; i < orderByConditionFields.length; i++) {
1213                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1214                                    query.append(orderByConditionFields[i]);
1215    
1216                                    if ((i + 1) < orderByConditionFields.length) {
1217                                            if (orderByComparator.isAscending() ^ previous) {
1218                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1219                                            }
1220                                            else {
1221                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1222                                            }
1223                                    }
1224                                    else {
1225                                            if (orderByComparator.isAscending() ^ previous) {
1226                                                    query.append(WHERE_GREATER_THAN);
1227                                            }
1228                                            else {
1229                                                    query.append(WHERE_LESSER_THAN);
1230                                            }
1231                                    }
1232                            }
1233    
1234                            query.append(ORDER_BY_CLAUSE);
1235    
1236                            String[] orderByFields = orderByComparator.getOrderByFields();
1237    
1238                            for (int i = 0; i < orderByFields.length; i++) {
1239                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1240                                    query.append(orderByFields[i]);
1241    
1242                                    if ((i + 1) < orderByFields.length) {
1243                                            if (orderByComparator.isAscending() ^ previous) {
1244                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1245                                            }
1246                                            else {
1247                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1248                                            }
1249                                    }
1250                                    else {
1251                                            if (orderByComparator.isAscending() ^ previous) {
1252                                                    query.append(ORDER_BY_ASC);
1253                                            }
1254                                            else {
1255                                                    query.append(ORDER_BY_DESC);
1256                                            }
1257                                    }
1258                            }
1259                    }
1260    
1261                    String sql = query.toString();
1262    
1263                    Query q = session.createQuery(sql);
1264    
1265                    q.setFirstResult(0);
1266                    q.setMaxResults(2);
1267    
1268                    QueryPos qPos = QueryPos.getInstance(q);
1269    
1270                    qPos.add(system);
1271    
1272                    if (orderByComparator != null) {
1273                            Object[] values = orderByComparator.getOrderByConditionValues(company);
1274    
1275                            for (Object value : values) {
1276                                    qPos.add(value);
1277                            }
1278                    }
1279    
1280                    List<Company> list = q.list();
1281    
1282                    if (list.size() == 2) {
1283                            return list.get(1);
1284                    }
1285                    else {
1286                            return null;
1287                    }
1288            }
1289    
1290            /**
1291             * Returns all the companies.
1292             *
1293             * @return the companies
1294             * @throws SystemException if a system exception occurred
1295             */
1296            public List<Company> findAll() throws SystemException {
1297                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1298            }
1299    
1300            /**
1301             * Returns a range of all the companies.
1302             *
1303             * <p>
1304             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1305             * </p>
1306             *
1307             * @param start the lower bound of the range of companies
1308             * @param end the upper bound of the range of companies (not inclusive)
1309             * @return the range of companies
1310             * @throws SystemException if a system exception occurred
1311             */
1312            public List<Company> findAll(int start, int end) throws SystemException {
1313                    return findAll(start, end, null);
1314            }
1315    
1316            /**
1317             * Returns an ordered range of all the companies.
1318             *
1319             * <p>
1320             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1321             * </p>
1322             *
1323             * @param start the lower bound of the range of companies
1324             * @param end the upper bound of the range of companies (not inclusive)
1325             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1326             * @return the ordered range of companies
1327             * @throws SystemException if a system exception occurred
1328             */
1329            public List<Company> findAll(int start, int end,
1330                    OrderByComparator orderByComparator) throws SystemException {
1331                    FinderPath finderPath = null;
1332                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1333    
1334                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1335                                    (orderByComparator == null)) {
1336                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1337                            finderArgs = FINDER_ARGS_EMPTY;
1338                    }
1339                    else {
1340                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1341                            finderArgs = new Object[] { start, end, orderByComparator };
1342                    }
1343    
1344                    List<Company> list = (List<Company>)FinderCacheUtil.getResult(finderPath,
1345                                    finderArgs, this);
1346    
1347                    if (list == null) {
1348                            StringBundler query = null;
1349                            String sql = null;
1350    
1351                            if (orderByComparator != null) {
1352                                    query = new StringBundler(2 +
1353                                                    (orderByComparator.getOrderByFields().length * 3));
1354    
1355                                    query.append(_SQL_SELECT_COMPANY);
1356    
1357                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1358                                            orderByComparator);
1359    
1360                                    sql = query.toString();
1361                            }
1362                            else {
1363                                    sql = _SQL_SELECT_COMPANY;
1364                            }
1365    
1366                            Session session = null;
1367    
1368                            try {
1369                                    session = openSession();
1370    
1371                                    Query q = session.createQuery(sql);
1372    
1373                                    if (orderByComparator == null) {
1374                                            list = (List<Company>)QueryUtil.list(q, getDialect(),
1375                                                            start, end, false);
1376    
1377                                            Collections.sort(list);
1378                                    }
1379                                    else {
1380                                            list = (List<Company>)QueryUtil.list(q, getDialect(),
1381                                                            start, end);
1382                                    }
1383                            }
1384                            catch (Exception e) {
1385                                    throw processException(e);
1386                            }
1387                            finally {
1388                                    if (list == null) {
1389                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1390                                    }
1391                                    else {
1392                                            cacheResult(list);
1393    
1394                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1395                                    }
1396    
1397                                    closeSession(session);
1398                            }
1399                    }
1400    
1401                    return list;
1402            }
1403    
1404            /**
1405             * Removes the company where webId = &#63; from the database.
1406             *
1407             * @param webId the web ID
1408             * @throws SystemException if a system exception occurred
1409             */
1410            public void removeByWebId(String webId)
1411                    throws NoSuchCompanyException, SystemException {
1412                    Company company = findByWebId(webId);
1413    
1414                    remove(company);
1415            }
1416    
1417            /**
1418             * Removes the company where mx = &#63; from the database.
1419             *
1420             * @param mx the mx
1421             * @throws SystemException if a system exception occurred
1422             */
1423            public void removeByMx(String mx)
1424                    throws NoSuchCompanyException, SystemException {
1425                    Company company = findByMx(mx);
1426    
1427                    remove(company);
1428            }
1429    
1430            /**
1431             * Removes the company where logoId = &#63; from the database.
1432             *
1433             * @param logoId the logo ID
1434             * @throws SystemException if a system exception occurred
1435             */
1436            public void removeByLogoId(long logoId)
1437                    throws NoSuchCompanyException, SystemException {
1438                    Company company = findByLogoId(logoId);
1439    
1440                    remove(company);
1441            }
1442    
1443            /**
1444             * Removes all the companies where system = &#63; from the database.
1445             *
1446             * @param system the system
1447             * @throws SystemException if a system exception occurred
1448             */
1449            public void removeBySystem(boolean system) throws SystemException {
1450                    for (Company company : findBySystem(system)) {
1451                            remove(company);
1452                    }
1453            }
1454    
1455            /**
1456             * Removes all the companies from the database.
1457             *
1458             * @throws SystemException if a system exception occurred
1459             */
1460            public void removeAll() throws SystemException {
1461                    for (Company company : findAll()) {
1462                            remove(company);
1463                    }
1464            }
1465    
1466            /**
1467             * Returns the number of companies where webId = &#63;.
1468             *
1469             * @param webId the web ID
1470             * @return the number of matching companies
1471             * @throws SystemException if a system exception occurred
1472             */
1473            public int countByWebId(String webId) throws SystemException {
1474                    Object[] finderArgs = new Object[] { webId };
1475    
1476                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_WEBID,
1477                                    finderArgs, this);
1478    
1479                    if (count == null) {
1480                            StringBundler query = new StringBundler(2);
1481    
1482                            query.append(_SQL_COUNT_COMPANY_WHERE);
1483    
1484                            if (webId == null) {
1485                                    query.append(_FINDER_COLUMN_WEBID_WEBID_1);
1486                            }
1487                            else {
1488                                    if (webId.equals(StringPool.BLANK)) {
1489                                            query.append(_FINDER_COLUMN_WEBID_WEBID_3);
1490                                    }
1491                                    else {
1492                                            query.append(_FINDER_COLUMN_WEBID_WEBID_2);
1493                                    }
1494                            }
1495    
1496                            String sql = query.toString();
1497    
1498                            Session session = null;
1499    
1500                            try {
1501                                    session = openSession();
1502    
1503                                    Query q = session.createQuery(sql);
1504    
1505                                    QueryPos qPos = QueryPos.getInstance(q);
1506    
1507                                    if (webId != null) {
1508                                            qPos.add(webId);
1509                                    }
1510    
1511                                    count = (Long)q.uniqueResult();
1512                            }
1513                            catch (Exception e) {
1514                                    throw processException(e);
1515                            }
1516                            finally {
1517                                    if (count == null) {
1518                                            count = Long.valueOf(0);
1519                                    }
1520    
1521                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_WEBID,
1522                                            finderArgs, count);
1523    
1524                                    closeSession(session);
1525                            }
1526                    }
1527    
1528                    return count.intValue();
1529            }
1530    
1531            /**
1532             * Returns the number of companies where mx = &#63;.
1533             *
1534             * @param mx the mx
1535             * @return the number of matching companies
1536             * @throws SystemException if a system exception occurred
1537             */
1538            public int countByMx(String mx) throws SystemException {
1539                    Object[] finderArgs = new Object[] { mx };
1540    
1541                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MX,
1542                                    finderArgs, this);
1543    
1544                    if (count == null) {
1545                            StringBundler query = new StringBundler(2);
1546    
1547                            query.append(_SQL_COUNT_COMPANY_WHERE);
1548    
1549                            if (mx == null) {
1550                                    query.append(_FINDER_COLUMN_MX_MX_1);
1551                            }
1552                            else {
1553                                    if (mx.equals(StringPool.BLANK)) {
1554                                            query.append(_FINDER_COLUMN_MX_MX_3);
1555                                    }
1556                                    else {
1557                                            query.append(_FINDER_COLUMN_MX_MX_2);
1558                                    }
1559                            }
1560    
1561                            String sql = query.toString();
1562    
1563                            Session session = null;
1564    
1565                            try {
1566                                    session = openSession();
1567    
1568                                    Query q = session.createQuery(sql);
1569    
1570                                    QueryPos qPos = QueryPos.getInstance(q);
1571    
1572                                    if (mx != null) {
1573                                            qPos.add(mx);
1574                                    }
1575    
1576                                    count = (Long)q.uniqueResult();
1577                            }
1578                            catch (Exception e) {
1579                                    throw processException(e);
1580                            }
1581                            finally {
1582                                    if (count == null) {
1583                                            count = Long.valueOf(0);
1584                                    }
1585    
1586                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MX, finderArgs,
1587                                            count);
1588    
1589                                    closeSession(session);
1590                            }
1591                    }
1592    
1593                    return count.intValue();
1594            }
1595    
1596            /**
1597             * Returns the number of companies where logoId = &#63;.
1598             *
1599             * @param logoId the logo ID
1600             * @return the number of matching companies
1601             * @throws SystemException if a system exception occurred
1602             */
1603            public int countByLogoId(long logoId) throws SystemException {
1604                    Object[] finderArgs = new Object[] { logoId };
1605    
1606                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LOGOID,
1607                                    finderArgs, this);
1608    
1609                    if (count == null) {
1610                            StringBundler query = new StringBundler(2);
1611    
1612                            query.append(_SQL_COUNT_COMPANY_WHERE);
1613    
1614                            query.append(_FINDER_COLUMN_LOGOID_LOGOID_2);
1615    
1616                            String sql = query.toString();
1617    
1618                            Session session = null;
1619    
1620                            try {
1621                                    session = openSession();
1622    
1623                                    Query q = session.createQuery(sql);
1624    
1625                                    QueryPos qPos = QueryPos.getInstance(q);
1626    
1627                                    qPos.add(logoId);
1628    
1629                                    count = (Long)q.uniqueResult();
1630                            }
1631                            catch (Exception e) {
1632                                    throw processException(e);
1633                            }
1634                            finally {
1635                                    if (count == null) {
1636                                            count = Long.valueOf(0);
1637                                    }
1638    
1639                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LOGOID,
1640                                            finderArgs, count);
1641    
1642                                    closeSession(session);
1643                            }
1644                    }
1645    
1646                    return count.intValue();
1647            }
1648    
1649            /**
1650             * Returns the number of companies where system = &#63;.
1651             *
1652             * @param system the system
1653             * @return the number of matching companies
1654             * @throws SystemException if a system exception occurred
1655             */
1656            public int countBySystem(boolean system) throws SystemException {
1657                    Object[] finderArgs = new Object[] { system };
1658    
1659                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SYSTEM,
1660                                    finderArgs, this);
1661    
1662                    if (count == null) {
1663                            StringBundler query = new StringBundler(2);
1664    
1665                            query.append(_SQL_COUNT_COMPANY_WHERE);
1666    
1667                            query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1668    
1669                            String sql = query.toString();
1670    
1671                            Session session = null;
1672    
1673                            try {
1674                                    session = openSession();
1675    
1676                                    Query q = session.createQuery(sql);
1677    
1678                                    QueryPos qPos = QueryPos.getInstance(q);
1679    
1680                                    qPos.add(system);
1681    
1682                                    count = (Long)q.uniqueResult();
1683                            }
1684                            catch (Exception e) {
1685                                    throw processException(e);
1686                            }
1687                            finally {
1688                                    if (count == null) {
1689                                            count = Long.valueOf(0);
1690                                    }
1691    
1692                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SYSTEM,
1693                                            finderArgs, count);
1694    
1695                                    closeSession(session);
1696                            }
1697                    }
1698    
1699                    return count.intValue();
1700            }
1701    
1702            /**
1703             * Returns the number of companies.
1704             *
1705             * @return the number of companies
1706             * @throws SystemException if a system exception occurred
1707             */
1708            public int countAll() throws SystemException {
1709                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1710                                    FINDER_ARGS_EMPTY, this);
1711    
1712                    if (count == null) {
1713                            Session session = null;
1714    
1715                            try {
1716                                    session = openSession();
1717    
1718                                    Query q = session.createQuery(_SQL_COUNT_COMPANY);
1719    
1720                                    count = (Long)q.uniqueResult();
1721                            }
1722                            catch (Exception e) {
1723                                    throw processException(e);
1724                            }
1725                            finally {
1726                                    if (count == null) {
1727                                            count = Long.valueOf(0);
1728                                    }
1729    
1730                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1731                                            FINDER_ARGS_EMPTY, count);
1732    
1733                                    closeSession(session);
1734                            }
1735                    }
1736    
1737                    return count.intValue();
1738            }
1739    
1740            /**
1741             * Initializes the company persistence.
1742             */
1743            public void afterPropertiesSet() {
1744                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1745                                            com.liferay.portal.util.PropsUtil.get(
1746                                                    "value.object.listener.com.liferay.portal.model.Company")));
1747    
1748                    if (listenerClassNames.length > 0) {
1749                            try {
1750                                    List<ModelListener<Company>> listenersList = new ArrayList<ModelListener<Company>>();
1751    
1752                                    for (String listenerClassName : listenerClassNames) {
1753                                            listenersList.add((ModelListener<Company>)InstanceFactory.newInstance(
1754                                                            listenerClassName));
1755                                    }
1756    
1757                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1758                            }
1759                            catch (Exception e) {
1760                                    _log.error(e);
1761                            }
1762                    }
1763            }
1764    
1765            public void destroy() {
1766                    EntityCacheUtil.removeCache(CompanyImpl.class.getName());
1767                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1768                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1769            }
1770    
1771            @BeanReference(type = AccountPersistence.class)
1772            protected AccountPersistence accountPersistence;
1773            @BeanReference(type = AddressPersistence.class)
1774            protected AddressPersistence addressPersistence;
1775            @BeanReference(type = BrowserTrackerPersistence.class)
1776            protected BrowserTrackerPersistence browserTrackerPersistence;
1777            @BeanReference(type = ClassNamePersistence.class)
1778            protected ClassNamePersistence classNamePersistence;
1779            @BeanReference(type = ClusterGroupPersistence.class)
1780            protected ClusterGroupPersistence clusterGroupPersistence;
1781            @BeanReference(type = CompanyPersistence.class)
1782            protected CompanyPersistence companyPersistence;
1783            @BeanReference(type = ContactPersistence.class)
1784            protected ContactPersistence contactPersistence;
1785            @BeanReference(type = CountryPersistence.class)
1786            protected CountryPersistence countryPersistence;
1787            @BeanReference(type = EmailAddressPersistence.class)
1788            protected EmailAddressPersistence emailAddressPersistence;
1789            @BeanReference(type = GroupPersistence.class)
1790            protected GroupPersistence groupPersistence;
1791            @BeanReference(type = ImagePersistence.class)
1792            protected ImagePersistence imagePersistence;
1793            @BeanReference(type = LayoutPersistence.class)
1794            protected LayoutPersistence layoutPersistence;
1795            @BeanReference(type = LayoutBranchPersistence.class)
1796            protected LayoutBranchPersistence layoutBranchPersistence;
1797            @BeanReference(type = LayoutPrototypePersistence.class)
1798            protected LayoutPrototypePersistence layoutPrototypePersistence;
1799            @BeanReference(type = LayoutRevisionPersistence.class)
1800            protected LayoutRevisionPersistence layoutRevisionPersistence;
1801            @BeanReference(type = LayoutSetPersistence.class)
1802            protected LayoutSetPersistence layoutSetPersistence;
1803            @BeanReference(type = LayoutSetBranchPersistence.class)
1804            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1805            @BeanReference(type = LayoutSetPrototypePersistence.class)
1806            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1807            @BeanReference(type = ListTypePersistence.class)
1808            protected ListTypePersistence listTypePersistence;
1809            @BeanReference(type = LockPersistence.class)
1810            protected LockPersistence lockPersistence;
1811            @BeanReference(type = MembershipRequestPersistence.class)
1812            protected MembershipRequestPersistence membershipRequestPersistence;
1813            @BeanReference(type = OrganizationPersistence.class)
1814            protected OrganizationPersistence organizationPersistence;
1815            @BeanReference(type = OrgGroupPermissionPersistence.class)
1816            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1817            @BeanReference(type = OrgGroupRolePersistence.class)
1818            protected OrgGroupRolePersistence orgGroupRolePersistence;
1819            @BeanReference(type = OrgLaborPersistence.class)
1820            protected OrgLaborPersistence orgLaborPersistence;
1821            @BeanReference(type = PasswordPolicyPersistence.class)
1822            protected PasswordPolicyPersistence passwordPolicyPersistence;
1823            @BeanReference(type = PasswordPolicyRelPersistence.class)
1824            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1825            @BeanReference(type = PasswordTrackerPersistence.class)
1826            protected PasswordTrackerPersistence passwordTrackerPersistence;
1827            @BeanReference(type = PermissionPersistence.class)
1828            protected PermissionPersistence permissionPersistence;
1829            @BeanReference(type = PhonePersistence.class)
1830            protected PhonePersistence phonePersistence;
1831            @BeanReference(type = PluginSettingPersistence.class)
1832            protected PluginSettingPersistence pluginSettingPersistence;
1833            @BeanReference(type = PortalPreferencesPersistence.class)
1834            protected PortalPreferencesPersistence portalPreferencesPersistence;
1835            @BeanReference(type = PortletPersistence.class)
1836            protected PortletPersistence portletPersistence;
1837            @BeanReference(type = PortletItemPersistence.class)
1838            protected PortletItemPersistence portletItemPersistence;
1839            @BeanReference(type = PortletPreferencesPersistence.class)
1840            protected PortletPreferencesPersistence portletPreferencesPersistence;
1841            @BeanReference(type = RegionPersistence.class)
1842            protected RegionPersistence regionPersistence;
1843            @BeanReference(type = ReleasePersistence.class)
1844            protected ReleasePersistence releasePersistence;
1845            @BeanReference(type = RepositoryPersistence.class)
1846            protected RepositoryPersistence repositoryPersistence;
1847            @BeanReference(type = RepositoryEntryPersistence.class)
1848            protected RepositoryEntryPersistence repositoryEntryPersistence;
1849            @BeanReference(type = ResourcePersistence.class)
1850            protected ResourcePersistence resourcePersistence;
1851            @BeanReference(type = ResourceActionPersistence.class)
1852            protected ResourceActionPersistence resourceActionPersistence;
1853            @BeanReference(type = ResourceBlockPersistence.class)
1854            protected ResourceBlockPersistence resourceBlockPersistence;
1855            @BeanReference(type = ResourceBlockPermissionPersistence.class)
1856            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1857            @BeanReference(type = ResourceCodePersistence.class)
1858            protected ResourceCodePersistence resourceCodePersistence;
1859            @BeanReference(type = ResourcePermissionPersistence.class)
1860            protected ResourcePermissionPersistence resourcePermissionPersistence;
1861            @BeanReference(type = ResourceTypePermissionPersistence.class)
1862            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1863            @BeanReference(type = RolePersistence.class)
1864            protected RolePersistence rolePersistence;
1865            @BeanReference(type = ServiceComponentPersistence.class)
1866            protected ServiceComponentPersistence serviceComponentPersistence;
1867            @BeanReference(type = ShardPersistence.class)
1868            protected ShardPersistence shardPersistence;
1869            @BeanReference(type = SubscriptionPersistence.class)
1870            protected SubscriptionPersistence subscriptionPersistence;
1871            @BeanReference(type = TeamPersistence.class)
1872            protected TeamPersistence teamPersistence;
1873            @BeanReference(type = TicketPersistence.class)
1874            protected TicketPersistence ticketPersistence;
1875            @BeanReference(type = UserPersistence.class)
1876            protected UserPersistence userPersistence;
1877            @BeanReference(type = UserGroupPersistence.class)
1878            protected UserGroupPersistence userGroupPersistence;
1879            @BeanReference(type = UserGroupGroupRolePersistence.class)
1880            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1881            @BeanReference(type = UserGroupRolePersistence.class)
1882            protected UserGroupRolePersistence userGroupRolePersistence;
1883            @BeanReference(type = UserIdMapperPersistence.class)
1884            protected UserIdMapperPersistence userIdMapperPersistence;
1885            @BeanReference(type = UserNotificationEventPersistence.class)
1886            protected UserNotificationEventPersistence userNotificationEventPersistence;
1887            @BeanReference(type = UserTrackerPersistence.class)
1888            protected UserTrackerPersistence userTrackerPersistence;
1889            @BeanReference(type = UserTrackerPathPersistence.class)
1890            protected UserTrackerPathPersistence userTrackerPathPersistence;
1891            @BeanReference(type = VirtualHostPersistence.class)
1892            protected VirtualHostPersistence virtualHostPersistence;
1893            @BeanReference(type = WebDAVPropsPersistence.class)
1894            protected WebDAVPropsPersistence webDAVPropsPersistence;
1895            @BeanReference(type = WebsitePersistence.class)
1896            protected WebsitePersistence websitePersistence;
1897            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1898            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1899            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1900            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1901            private static final String _SQL_SELECT_COMPANY = "SELECT company FROM Company company";
1902            private static final String _SQL_SELECT_COMPANY_WHERE = "SELECT company FROM Company company WHERE ";
1903            private static final String _SQL_COUNT_COMPANY = "SELECT COUNT(company) FROM Company company";
1904            private static final String _SQL_COUNT_COMPANY_WHERE = "SELECT COUNT(company) FROM Company company WHERE ";
1905            private static final String _FINDER_COLUMN_WEBID_WEBID_1 = "company.webId IS NULL";
1906            private static final String _FINDER_COLUMN_WEBID_WEBID_2 = "company.webId = ?";
1907            private static final String _FINDER_COLUMN_WEBID_WEBID_3 = "(company.webId IS NULL OR company.webId = ?)";
1908            private static final String _FINDER_COLUMN_MX_MX_1 = "company.mx IS NULL";
1909            private static final String _FINDER_COLUMN_MX_MX_2 = "company.mx = ?";
1910            private static final String _FINDER_COLUMN_MX_MX_3 = "(company.mx IS NULL OR company.mx = ?)";
1911            private static final String _FINDER_COLUMN_LOGOID_LOGOID_2 = "company.logoId = ?";
1912            private static final String _FINDER_COLUMN_SYSTEM_SYSTEM_2 = "company.system = ?";
1913            private static final String _ORDER_BY_ENTITY_ALIAS = "company.";
1914            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Company exists with the primary key ";
1915            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Company exists with the key {";
1916            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1917            private static Log _log = LogFactoryUtil.getLog(CompanyPersistenceImpl.class);
1918            private static Company _nullCompany = new CompanyImpl() {
1919                            @Override
1920                            public Object clone() {
1921                                    return this;
1922                            }
1923    
1924                            @Override
1925                            public CacheModel<Company> toCacheModel() {
1926                                    return _nullCompanyCacheModel;
1927                            }
1928                    };
1929    
1930            private static CacheModel<Company> _nullCompanyCacheModel = new CacheModel<Company>() {
1931                            public Company toEntityModel() {
1932                                    return _nullCompany;
1933                            }
1934                    };
1935    }