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