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                            if (company.isCachedModel()) {
310                                    company = (Company)session.get(CompanyImpl.class,
311                                                    company.getPrimaryKeyObj());
312                            }
313    
314                            session.delete(company);
315                    }
316                    catch (Exception e) {
317                            throw processException(e);
318                    }
319                    finally {
320                            closeSession(session);
321                    }
322    
323                    clearCache(company);
324    
325                    return company;
326            }
327    
328            @Override
329            public Company updateImpl(com.liferay.portal.model.Company company)
330                    throws SystemException {
331                    company = toUnwrappedModel(company);
332    
333                    boolean isNew = company.isNew();
334    
335                    CompanyModelImpl companyModelImpl = (CompanyModelImpl)company;
336    
337                    Session session = null;
338    
339                    try {
340                            session = openSession();
341    
342                            if (company.isNew()) {
343                                    session.save(company);
344    
345                                    company.setNew(false);
346                            }
347                            else {
348                                    session.merge(company);
349                            }
350                    }
351                    catch (Exception e) {
352                            throw processException(e);
353                    }
354                    finally {
355                            closeSession(session);
356                    }
357    
358                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
359    
360                    if (isNew || !CompanyModelImpl.COLUMN_BITMASK_ENABLED) {
361                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
362                    }
363    
364                    else {
365                            if ((companyModelImpl.getColumnBitmask() &
366                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM.getColumnBitmask()) != 0) {
367                                    Object[] args = new Object[] {
368                                                    Boolean.valueOf(companyModelImpl.getOriginalSystem())
369                                            };
370    
371                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SYSTEM, args);
372                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM,
373                                            args);
374    
375                                    args = new Object[] {
376                                                    Boolean.valueOf(companyModelImpl.getSystem())
377                                            };
378    
379                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SYSTEM, args);
380                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM,
381                                            args);
382                            }
383                    }
384    
385                    EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
386                            CompanyImpl.class, company.getPrimaryKey(), company);
387    
388                    if (isNew) {
389                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
390                                    new Object[] { company.getWebId() }, company);
391    
392                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
393                                    new Object[] { company.getMx() }, company);
394    
395                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
396                                    new Object[] { Long.valueOf(company.getLogoId()) }, company);
397                    }
398                    else {
399                            if ((companyModelImpl.getColumnBitmask() &
400                                            FINDER_PATH_FETCH_BY_WEBID.getColumnBitmask()) != 0) {
401                                    Object[] args = new Object[] { companyModelImpl.getOriginalWebId() };
402    
403                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_WEBID, args);
404    
405                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID, args);
406    
407                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
408                                            new Object[] { company.getWebId() }, company);
409                            }
410    
411                            if ((companyModelImpl.getColumnBitmask() &
412                                            FINDER_PATH_FETCH_BY_MX.getColumnBitmask()) != 0) {
413                                    Object[] args = new Object[] { companyModelImpl.getOriginalMx() };
414    
415                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MX, args);
416    
417                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX, args);
418    
419                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
420                                            new Object[] { company.getMx() }, company);
421                            }
422    
423                            if ((companyModelImpl.getColumnBitmask() &
424                                            FINDER_PATH_FETCH_BY_LOGOID.getColumnBitmask()) != 0) {
425                                    Object[] args = new Object[] {
426                                                    Long.valueOf(companyModelImpl.getOriginalLogoId())
427                                            };
428    
429                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOGOID, args);
430    
431                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID, args);
432    
433                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
434                                            new Object[] { Long.valueOf(company.getLogoId()) }, company);
435                            }
436                    }
437    
438                    return company;
439            }
440    
441            protected Company toUnwrappedModel(Company company) {
442                    if (company instanceof CompanyImpl) {
443                            return company;
444                    }
445    
446                    CompanyImpl companyImpl = new CompanyImpl();
447    
448                    companyImpl.setNew(company.isNew());
449                    companyImpl.setPrimaryKey(company.getPrimaryKey());
450    
451                    companyImpl.setCompanyId(company.getCompanyId());
452                    companyImpl.setAccountId(company.getAccountId());
453                    companyImpl.setWebId(company.getWebId());
454                    companyImpl.setKey(company.getKey());
455                    companyImpl.setMx(company.getMx());
456                    companyImpl.setHomeURL(company.getHomeURL());
457                    companyImpl.setLogoId(company.getLogoId());
458                    companyImpl.setSystem(company.isSystem());
459                    companyImpl.setMaxUsers(company.getMaxUsers());
460                    companyImpl.setActive(company.isActive());
461    
462                    return companyImpl;
463            }
464    
465            /**
466             * Returns the company with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
467             *
468             * @param primaryKey the primary key of the company
469             * @return the company
470             * @throws com.liferay.portal.NoSuchModelException if a company with the primary key could not be found
471             * @throws SystemException if a system exception occurred
472             */
473            @Override
474            public Company findByPrimaryKey(Serializable primaryKey)
475                    throws NoSuchModelException, SystemException {
476                    return findByPrimaryKey(((Long)primaryKey).longValue());
477            }
478    
479            /**
480             * Returns the company with the primary key or throws a {@link com.liferay.portal.NoSuchCompanyException} if it could not be found.
481             *
482             * @param companyId the primary key of the company
483             * @return the company
484             * @throws com.liferay.portal.NoSuchCompanyException if a company with the primary key could not be found
485             * @throws SystemException if a system exception occurred
486             */
487            public Company findByPrimaryKey(long companyId)
488                    throws NoSuchCompanyException, SystemException {
489                    Company company = fetchByPrimaryKey(companyId);
490    
491                    if (company == null) {
492                            if (_log.isWarnEnabled()) {
493                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + companyId);
494                            }
495    
496                            throw new NoSuchCompanyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
497                                    companyId);
498                    }
499    
500                    return company;
501            }
502    
503            /**
504             * Returns the company with the primary key or returns <code>null</code> if it could not be found.
505             *
506             * @param primaryKey the primary key of the company
507             * @return the company, or <code>null</code> if a company with the primary key could not be found
508             * @throws SystemException if a system exception occurred
509             */
510            @Override
511            public Company fetchByPrimaryKey(Serializable primaryKey)
512                    throws SystemException {
513                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
514            }
515    
516            /**
517             * Returns the company with the primary key or returns <code>null</code> if it could not be found.
518             *
519             * @param companyId the primary key of the company
520             * @return the company, or <code>null</code> if a company with the primary key could not be found
521             * @throws SystemException if a system exception occurred
522             */
523            public Company fetchByPrimaryKey(long companyId) throws SystemException {
524                    Company company = (Company)EntityCacheUtil.getResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
525                                    CompanyImpl.class, companyId);
526    
527                    if (company == _nullCompany) {
528                            return null;
529                    }
530    
531                    if (company == null) {
532                            Session session = null;
533    
534                            boolean hasException = false;
535    
536                            try {
537                                    session = openSession();
538    
539                                    company = (Company)session.get(CompanyImpl.class,
540                                                    Long.valueOf(companyId));
541                            }
542                            catch (Exception e) {
543                                    hasException = true;
544    
545                                    throw processException(e);
546                            }
547                            finally {
548                                    if (company != null) {
549                                            cacheResult(company);
550                                    }
551                                    else if (!hasException) {
552                                            EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
553                                                    CompanyImpl.class, companyId, _nullCompany);
554                                    }
555    
556                                    closeSession(session);
557                            }
558                    }
559    
560                    return company;
561            }
562    
563            /**
564             * Returns the company where webId = &#63; or throws a {@link com.liferay.portal.NoSuchCompanyException} if it could not be found.
565             *
566             * @param webId the web ID
567             * @return the matching company
568             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
569             * @throws SystemException if a system exception occurred
570             */
571            public Company findByWebId(String webId)
572                    throws NoSuchCompanyException, SystemException {
573                    Company company = fetchByWebId(webId);
574    
575                    if (company == null) {
576                            StringBundler msg = new StringBundler(4);
577    
578                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
579    
580                            msg.append("webId=");
581                            msg.append(webId);
582    
583                            msg.append(StringPool.CLOSE_CURLY_BRACE);
584    
585                            if (_log.isWarnEnabled()) {
586                                    _log.warn(msg.toString());
587                            }
588    
589                            throw new NoSuchCompanyException(msg.toString());
590                    }
591    
592                    return company;
593            }
594    
595            /**
596             * Returns the company where webId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
597             *
598             * @param webId the web ID
599             * @return the matching company, or <code>null</code> if a matching company could not be found
600             * @throws SystemException if a system exception occurred
601             */
602            public Company fetchByWebId(String webId) throws SystemException {
603                    return fetchByWebId(webId, true);
604            }
605    
606            /**
607             * Returns the company where webId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
608             *
609             * @param webId the web ID
610             * @param retrieveFromCache whether to use the finder cache
611             * @return the matching company, or <code>null</code> if a matching company could not be found
612             * @throws SystemException if a system exception occurred
613             */
614            public Company fetchByWebId(String webId, boolean retrieveFromCache)
615                    throws SystemException {
616                    Object[] finderArgs = new Object[] { webId };
617    
618                    Object result = null;
619    
620                    if (retrieveFromCache) {
621                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_WEBID,
622                                            finderArgs, this);
623                    }
624    
625                    if (result instanceof Company) {
626                            Company company = (Company)result;
627    
628                            if (!Validator.equals(webId, company.getWebId())) {
629                                    result = null;
630                            }
631                    }
632    
633                    if (result == null) {
634                            StringBundler query = new StringBundler(2);
635    
636                            query.append(_SQL_SELECT_COMPANY_WHERE);
637    
638                            if (webId == null) {
639                                    query.append(_FINDER_COLUMN_WEBID_WEBID_1);
640                            }
641                            else {
642                                    if (webId.equals(StringPool.BLANK)) {
643                                            query.append(_FINDER_COLUMN_WEBID_WEBID_3);
644                                    }
645                                    else {
646                                            query.append(_FINDER_COLUMN_WEBID_WEBID_2);
647                                    }
648                            }
649    
650                            String sql = query.toString();
651    
652                            Session session = null;
653    
654                            try {
655                                    session = openSession();
656    
657                                    Query q = session.createQuery(sql);
658    
659                                    QueryPos qPos = QueryPos.getInstance(q);
660    
661                                    if (webId != null) {
662                                            qPos.add(webId);
663                                    }
664    
665                                    List<Company> list = q.list();
666    
667                                    result = list;
668    
669                                    Company company = null;
670    
671                                    if (list.isEmpty()) {
672                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
673                                                    finderArgs, list);
674                                    }
675                                    else {
676                                            company = list.get(0);
677    
678                                            cacheResult(company);
679    
680                                            if ((company.getWebId() == null) ||
681                                                            !company.getWebId().equals(webId)) {
682                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
683                                                            finderArgs, company);
684                                            }
685                                    }
686    
687                                    return company;
688                            }
689                            catch (Exception e) {
690                                    throw processException(e);
691                            }
692                            finally {
693                                    if (result == null) {
694                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID,
695                                                    finderArgs);
696                                    }
697    
698                                    closeSession(session);
699                            }
700                    }
701                    else {
702                            if (result instanceof List<?>) {
703                                    return null;
704                            }
705                            else {
706                                    return (Company)result;
707                            }
708                    }
709            }
710    
711            /**
712             * Returns the company where mx = &#63; or throws a {@link com.liferay.portal.NoSuchCompanyException} if it could not be found.
713             *
714             * @param mx the mx
715             * @return the matching company
716             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
717             * @throws SystemException if a system exception occurred
718             */
719            public Company findByMx(String mx)
720                    throws NoSuchCompanyException, SystemException {
721                    Company company = fetchByMx(mx);
722    
723                    if (company == null) {
724                            StringBundler msg = new StringBundler(4);
725    
726                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
727    
728                            msg.append("mx=");
729                            msg.append(mx);
730    
731                            msg.append(StringPool.CLOSE_CURLY_BRACE);
732    
733                            if (_log.isWarnEnabled()) {
734                                    _log.warn(msg.toString());
735                            }
736    
737                            throw new NoSuchCompanyException(msg.toString());
738                    }
739    
740                    return company;
741            }
742    
743            /**
744             * Returns the company where mx = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
745             *
746             * @param mx the mx
747             * @return the matching company, or <code>null</code> if a matching company could not be found
748             * @throws SystemException if a system exception occurred
749             */
750            public Company fetchByMx(String mx) throws SystemException {
751                    return fetchByMx(mx, true);
752            }
753    
754            /**
755             * Returns the company where mx = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
756             *
757             * @param mx the mx
758             * @param retrieveFromCache whether to use the finder cache
759             * @return the matching company, or <code>null</code> if a matching company could not be found
760             * @throws SystemException if a system exception occurred
761             */
762            public Company fetchByMx(String mx, boolean retrieveFromCache)
763                    throws SystemException {
764                    Object[] finderArgs = new Object[] { mx };
765    
766                    Object result = null;
767    
768                    if (retrieveFromCache) {
769                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_MX,
770                                            finderArgs, this);
771                    }
772    
773                    if (result instanceof Company) {
774                            Company company = (Company)result;
775    
776                            if (!Validator.equals(mx, company.getMx())) {
777                                    result = null;
778                            }
779                    }
780    
781                    if (result == null) {
782                            StringBundler query = new StringBundler(2);
783    
784                            query.append(_SQL_SELECT_COMPANY_WHERE);
785    
786                            if (mx == null) {
787                                    query.append(_FINDER_COLUMN_MX_MX_1);
788                            }
789                            else {
790                                    if (mx.equals(StringPool.BLANK)) {
791                                            query.append(_FINDER_COLUMN_MX_MX_3);
792                                    }
793                                    else {
794                                            query.append(_FINDER_COLUMN_MX_MX_2);
795                                    }
796                            }
797    
798                            String sql = query.toString();
799    
800                            Session session = null;
801    
802                            try {
803                                    session = openSession();
804    
805                                    Query q = session.createQuery(sql);
806    
807                                    QueryPos qPos = QueryPos.getInstance(q);
808    
809                                    if (mx != null) {
810                                            qPos.add(mx);
811                                    }
812    
813                                    List<Company> list = q.list();
814    
815                                    result = list;
816    
817                                    Company company = null;
818    
819                                    if (list.isEmpty()) {
820                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
821                                                    finderArgs, list);
822                                    }
823                                    else {
824                                            company = list.get(0);
825    
826                                            cacheResult(company);
827    
828                                            if ((company.getMx() == null) ||
829                                                            !company.getMx().equals(mx)) {
830                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
831                                                            finderArgs, company);
832                                            }
833                                    }
834    
835                                    return company;
836                            }
837                            catch (Exception e) {
838                                    throw processException(e);
839                            }
840                            finally {
841                                    if (result == null) {
842                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX,
843                                                    finderArgs);
844                                    }
845    
846                                    closeSession(session);
847                            }
848                    }
849                    else {
850                            if (result instanceof List<?>) {
851                                    return null;
852                            }
853                            else {
854                                    return (Company)result;
855                            }
856                    }
857            }
858    
859            /**
860             * Returns the company where logoId = &#63; or throws a {@link com.liferay.portal.NoSuchCompanyException} if it could not be found.
861             *
862             * @param logoId the logo ID
863             * @return the matching company
864             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
865             * @throws SystemException if a system exception occurred
866             */
867            public Company findByLogoId(long logoId)
868                    throws NoSuchCompanyException, SystemException {
869                    Company company = fetchByLogoId(logoId);
870    
871                    if (company == null) {
872                            StringBundler msg = new StringBundler(4);
873    
874                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
875    
876                            msg.append("logoId=");
877                            msg.append(logoId);
878    
879                            msg.append(StringPool.CLOSE_CURLY_BRACE);
880    
881                            if (_log.isWarnEnabled()) {
882                                    _log.warn(msg.toString());
883                            }
884    
885                            throw new NoSuchCompanyException(msg.toString());
886                    }
887    
888                    return company;
889            }
890    
891            /**
892             * Returns the company where logoId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
893             *
894             * @param logoId the logo ID
895             * @return the matching company, or <code>null</code> if a matching company could not be found
896             * @throws SystemException if a system exception occurred
897             */
898            public Company fetchByLogoId(long logoId) throws SystemException {
899                    return fetchByLogoId(logoId, true);
900            }
901    
902            /**
903             * Returns the company where logoId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
904             *
905             * @param logoId the logo ID
906             * @param retrieveFromCache whether to use the finder cache
907             * @return the matching company, or <code>null</code> if a matching company could not be found
908             * @throws SystemException if a system exception occurred
909             */
910            public Company fetchByLogoId(long logoId, boolean retrieveFromCache)
911                    throws SystemException {
912                    Object[] finderArgs = new Object[] { logoId };
913    
914                    Object result = null;
915    
916                    if (retrieveFromCache) {
917                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LOGOID,
918                                            finderArgs, this);
919                    }
920    
921                    if (result instanceof Company) {
922                            Company company = (Company)result;
923    
924                            if ((logoId != company.getLogoId())) {
925                                    result = null;
926                            }
927                    }
928    
929                    if (result == null) {
930                            StringBundler query = new StringBundler(2);
931    
932                            query.append(_SQL_SELECT_COMPANY_WHERE);
933    
934                            query.append(_FINDER_COLUMN_LOGOID_LOGOID_2);
935    
936                            String sql = query.toString();
937    
938                            Session session = null;
939    
940                            try {
941                                    session = openSession();
942    
943                                    Query q = session.createQuery(sql);
944    
945                                    QueryPos qPos = QueryPos.getInstance(q);
946    
947                                    qPos.add(logoId);
948    
949                                    List<Company> list = q.list();
950    
951                                    result = list;
952    
953                                    Company company = null;
954    
955                                    if (list.isEmpty()) {
956                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
957                                                    finderArgs, list);
958                                    }
959                                    else {
960                                            company = list.get(0);
961    
962                                            cacheResult(company);
963    
964                                            if ((company.getLogoId() != logoId)) {
965                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
966                                                            finderArgs, company);
967                                            }
968                                    }
969    
970                                    return company;
971                            }
972                            catch (Exception e) {
973                                    throw processException(e);
974                            }
975                            finally {
976                                    if (result == null) {
977                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID,
978                                                    finderArgs);
979                                    }
980    
981                                    closeSession(session);
982                            }
983                    }
984                    else {
985                            if (result instanceof List<?>) {
986                                    return null;
987                            }
988                            else {
989                                    return (Company)result;
990                            }
991                    }
992            }
993    
994            /**
995             * Returns all the companies where system = &#63;.
996             *
997             * @param system the system
998             * @return the matching companies
999             * @throws SystemException if a system exception occurred
1000             */
1001            public List<Company> findBySystem(boolean system) throws SystemException {
1002                    return findBySystem(system, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1003            }
1004    
1005            /**
1006             * Returns a range of all the companies where system = &#63;.
1007             *
1008             * <p>
1009             * 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.
1010             * </p>
1011             *
1012             * @param system the system
1013             * @param start the lower bound of the range of companies
1014             * @param end the upper bound of the range of companies (not inclusive)
1015             * @return the range of matching companies
1016             * @throws SystemException if a system exception occurred
1017             */
1018            public List<Company> findBySystem(boolean system, int start, int end)
1019                    throws SystemException {
1020                    return findBySystem(system, start, end, null);
1021            }
1022    
1023            /**
1024             * Returns an ordered range of all the companies where system = &#63;.
1025             *
1026             * <p>
1027             * 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.
1028             * </p>
1029             *
1030             * @param system the system
1031             * @param start the lower bound of the range of companies
1032             * @param end the upper bound of the range of companies (not inclusive)
1033             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1034             * @return the ordered range of matching companies
1035             * @throws SystemException if a system exception occurred
1036             */
1037            public List<Company> findBySystem(boolean system, int start, int end,
1038                    OrderByComparator orderByComparator) throws SystemException {
1039                    FinderPath finderPath = null;
1040                    Object[] finderArgs = null;
1041    
1042                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1043                                    (orderByComparator == null)) {
1044                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM;
1045                            finderArgs = new Object[] { system };
1046                    }
1047                    else {
1048                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SYSTEM;
1049                            finderArgs = new Object[] { system, start, end, orderByComparator };
1050                    }
1051    
1052                    List<Company> list = (List<Company>)FinderCacheUtil.getResult(finderPath,
1053                                    finderArgs, this);
1054    
1055                    if ((list != null) && !list.isEmpty()) {
1056                            for (Company company : list) {
1057                                    if ((system != company.getSystem())) {
1058                                            list = null;
1059    
1060                                            break;
1061                                    }
1062                            }
1063                    }
1064    
1065                    if (list == null) {
1066                            StringBundler query = null;
1067    
1068                            if (orderByComparator != null) {
1069                                    query = new StringBundler(3 +
1070                                                    (orderByComparator.getOrderByFields().length * 3));
1071                            }
1072                            else {
1073                                    query = new StringBundler(2);
1074                            }
1075    
1076                            query.append(_SQL_SELECT_COMPANY_WHERE);
1077    
1078                            query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1079    
1080                            if (orderByComparator != null) {
1081                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1082                                            orderByComparator);
1083                            }
1084    
1085                            String sql = query.toString();
1086    
1087                            Session session = null;
1088    
1089                            try {
1090                                    session = openSession();
1091    
1092                                    Query q = session.createQuery(sql);
1093    
1094                                    QueryPos qPos = QueryPos.getInstance(q);
1095    
1096                                    qPos.add(system);
1097    
1098                                    list = (List<Company>)QueryUtil.list(q, getDialect(), start, end);
1099                            }
1100                            catch (Exception e) {
1101                                    throw processException(e);
1102                            }
1103                            finally {
1104                                    if (list == null) {
1105                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1106                                    }
1107                                    else {
1108                                            cacheResult(list);
1109    
1110                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1111                                    }
1112    
1113                                    closeSession(session);
1114                            }
1115                    }
1116    
1117                    return list;
1118            }
1119    
1120            /**
1121             * Returns the first company in the ordered set where system = &#63;.
1122             *
1123             * @param system the system
1124             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1125             * @return the first matching company
1126             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
1127             * @throws SystemException if a system exception occurred
1128             */
1129            public Company findBySystem_First(boolean system,
1130                    OrderByComparator orderByComparator)
1131                    throws NoSuchCompanyException, SystemException {
1132                    Company company = fetchBySystem_First(system, orderByComparator);
1133    
1134                    if (company != null) {
1135                            return company;
1136                    }
1137    
1138                    StringBundler msg = new StringBundler(4);
1139    
1140                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1141    
1142                    msg.append("system=");
1143                    msg.append(system);
1144    
1145                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1146    
1147                    throw new NoSuchCompanyException(msg.toString());
1148            }
1149    
1150            /**
1151             * Returns the first company in the ordered set where system = &#63;.
1152             *
1153             * @param system the system
1154             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1155             * @return the first matching company, or <code>null</code> if a matching company could not be found
1156             * @throws SystemException if a system exception occurred
1157             */
1158            public Company fetchBySystem_First(boolean system,
1159                    OrderByComparator orderByComparator) throws SystemException {
1160                    List<Company> list = findBySystem(system, 0, 1, orderByComparator);
1161    
1162                    if (!list.isEmpty()) {
1163                            return list.get(0);
1164                    }
1165    
1166                    return null;
1167            }
1168    
1169            /**
1170             * Returns the last company in the ordered set where system = &#63;.
1171             *
1172             * @param system the system
1173             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1174             * @return the last matching company
1175             * @throws com.liferay.portal.NoSuchCompanyException if a matching company could not be found
1176             * @throws SystemException if a system exception occurred
1177             */
1178            public Company findBySystem_Last(boolean system,
1179                    OrderByComparator orderByComparator)
1180                    throws NoSuchCompanyException, SystemException {
1181                    Company company = fetchBySystem_Last(system, orderByComparator);
1182    
1183                    if (company != null) {
1184                            return company;
1185                    }
1186    
1187                    StringBundler msg = new StringBundler(4);
1188    
1189                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1190    
1191                    msg.append("system=");
1192                    msg.append(system);
1193    
1194                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1195    
1196                    throw new NoSuchCompanyException(msg.toString());
1197            }
1198    
1199            /**
1200             * Returns the last company in the ordered set where system = &#63;.
1201             *
1202             * @param system the system
1203             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1204             * @return the last matching company, or <code>null</code> if a matching company could not be found
1205             * @throws SystemException if a system exception occurred
1206             */
1207            public Company fetchBySystem_Last(boolean system,
1208                    OrderByComparator orderByComparator) throws SystemException {
1209                    int count = countBySystem(system);
1210    
1211                    List<Company> list = findBySystem(system, count - 1, count,
1212                                    orderByComparator);
1213    
1214                    if (!list.isEmpty()) {
1215                            return list.get(0);
1216                    }
1217    
1218                    return null;
1219            }
1220    
1221            /**
1222             * Returns the companies before and after the current company in the ordered set where system = &#63;.
1223             *
1224             * @param companyId the primary key of the current company
1225             * @param system the system
1226             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1227             * @return the previous, current, and next company
1228             * @throws com.liferay.portal.NoSuchCompanyException if a company with the primary key could not be found
1229             * @throws SystemException if a system exception occurred
1230             */
1231            public Company[] findBySystem_PrevAndNext(long companyId, boolean system,
1232                    OrderByComparator orderByComparator)
1233                    throws NoSuchCompanyException, SystemException {
1234                    Company company = findByPrimaryKey(companyId);
1235    
1236                    Session session = null;
1237    
1238                    try {
1239                            session = openSession();
1240    
1241                            Company[] array = new CompanyImpl[3];
1242    
1243                            array[0] = getBySystem_PrevAndNext(session, company, system,
1244                                            orderByComparator, true);
1245    
1246                            array[1] = company;
1247    
1248                            array[2] = getBySystem_PrevAndNext(session, company, system,
1249                                            orderByComparator, false);
1250    
1251                            return array;
1252                    }
1253                    catch (Exception e) {
1254                            throw processException(e);
1255                    }
1256                    finally {
1257                            closeSession(session);
1258                    }
1259            }
1260    
1261            protected Company getBySystem_PrevAndNext(Session session, Company company,
1262                    boolean system, OrderByComparator orderByComparator, boolean previous) {
1263                    StringBundler query = null;
1264    
1265                    if (orderByComparator != null) {
1266                            query = new StringBundler(6 +
1267                                            (orderByComparator.getOrderByFields().length * 6));
1268                    }
1269                    else {
1270                            query = new StringBundler(3);
1271                    }
1272    
1273                    query.append(_SQL_SELECT_COMPANY_WHERE);
1274    
1275                    query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1276    
1277                    if (orderByComparator != null) {
1278                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1279    
1280                            if (orderByConditionFields.length > 0) {
1281                                    query.append(WHERE_AND);
1282                            }
1283    
1284                            for (int i = 0; i < orderByConditionFields.length; i++) {
1285                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1286                                    query.append(orderByConditionFields[i]);
1287    
1288                                    if ((i + 1) < orderByConditionFields.length) {
1289                                            if (orderByComparator.isAscending() ^ previous) {
1290                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1291                                            }
1292                                            else {
1293                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1294                                            }
1295                                    }
1296                                    else {
1297                                            if (orderByComparator.isAscending() ^ previous) {
1298                                                    query.append(WHERE_GREATER_THAN);
1299                                            }
1300                                            else {
1301                                                    query.append(WHERE_LESSER_THAN);
1302                                            }
1303                                    }
1304                            }
1305    
1306                            query.append(ORDER_BY_CLAUSE);
1307    
1308                            String[] orderByFields = orderByComparator.getOrderByFields();
1309    
1310                            for (int i = 0; i < orderByFields.length; i++) {
1311                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1312                                    query.append(orderByFields[i]);
1313    
1314                                    if ((i + 1) < orderByFields.length) {
1315                                            if (orderByComparator.isAscending() ^ previous) {
1316                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1317                                            }
1318                                            else {
1319                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1320                                            }
1321                                    }
1322                                    else {
1323                                            if (orderByComparator.isAscending() ^ previous) {
1324                                                    query.append(ORDER_BY_ASC);
1325                                            }
1326                                            else {
1327                                                    query.append(ORDER_BY_DESC);
1328                                            }
1329                                    }
1330                            }
1331                    }
1332    
1333                    String sql = query.toString();
1334    
1335                    Query q = session.createQuery(sql);
1336    
1337                    q.setFirstResult(0);
1338                    q.setMaxResults(2);
1339    
1340                    QueryPos qPos = QueryPos.getInstance(q);
1341    
1342                    qPos.add(system);
1343    
1344                    if (orderByComparator != null) {
1345                            Object[] values = orderByComparator.getOrderByConditionValues(company);
1346    
1347                            for (Object value : values) {
1348                                    qPos.add(value);
1349                            }
1350                    }
1351    
1352                    List<Company> list = q.list();
1353    
1354                    if (list.size() == 2) {
1355                            return list.get(1);
1356                    }
1357                    else {
1358                            return null;
1359                    }
1360            }
1361    
1362            /**
1363             * Returns all the companies.
1364             *
1365             * @return the companies
1366             * @throws SystemException if a system exception occurred
1367             */
1368            public List<Company> findAll() throws SystemException {
1369                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1370            }
1371    
1372            /**
1373             * Returns a range of all the companies.
1374             *
1375             * <p>
1376             * 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.
1377             * </p>
1378             *
1379             * @param start the lower bound of the range of companies
1380             * @param end the upper bound of the range of companies (not inclusive)
1381             * @return the range of companies
1382             * @throws SystemException if a system exception occurred
1383             */
1384            public List<Company> findAll(int start, int end) throws SystemException {
1385                    return findAll(start, end, null);
1386            }
1387    
1388            /**
1389             * Returns an ordered range of all the companies.
1390             *
1391             * <p>
1392             * 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.
1393             * </p>
1394             *
1395             * @param start the lower bound of the range of companies
1396             * @param end the upper bound of the range of companies (not inclusive)
1397             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1398             * @return the ordered range of companies
1399             * @throws SystemException if a system exception occurred
1400             */
1401            public List<Company> findAll(int start, int end,
1402                    OrderByComparator orderByComparator) throws SystemException {
1403                    FinderPath finderPath = null;
1404                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1405    
1406                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1407                                    (orderByComparator == null)) {
1408                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1409                            finderArgs = FINDER_ARGS_EMPTY;
1410                    }
1411                    else {
1412                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1413                            finderArgs = new Object[] { start, end, orderByComparator };
1414                    }
1415    
1416                    List<Company> list = (List<Company>)FinderCacheUtil.getResult(finderPath,
1417                                    finderArgs, this);
1418    
1419                    if (list == null) {
1420                            StringBundler query = null;
1421                            String sql = null;
1422    
1423                            if (orderByComparator != null) {
1424                                    query = new StringBundler(2 +
1425                                                    (orderByComparator.getOrderByFields().length * 3));
1426    
1427                                    query.append(_SQL_SELECT_COMPANY);
1428    
1429                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1430                                            orderByComparator);
1431    
1432                                    sql = query.toString();
1433                            }
1434                            else {
1435                                    sql = _SQL_SELECT_COMPANY;
1436                            }
1437    
1438                            Session session = null;
1439    
1440                            try {
1441                                    session = openSession();
1442    
1443                                    Query q = session.createQuery(sql);
1444    
1445                                    if (orderByComparator == null) {
1446                                            list = (List<Company>)QueryUtil.list(q, getDialect(),
1447                                                            start, end, false);
1448    
1449                                            Collections.sort(list);
1450                                    }
1451                                    else {
1452                                            list = (List<Company>)QueryUtil.list(q, getDialect(),
1453                                                            start, end);
1454                                    }
1455                            }
1456                            catch (Exception e) {
1457                                    throw processException(e);
1458                            }
1459                            finally {
1460                                    if (list == null) {
1461                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1462                                    }
1463                                    else {
1464                                            cacheResult(list);
1465    
1466                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1467                                    }
1468    
1469                                    closeSession(session);
1470                            }
1471                    }
1472    
1473                    return list;
1474            }
1475    
1476            /**
1477             * Removes the company where webId = &#63; from the database.
1478             *
1479             * @param webId the web ID
1480             * @return the company that was removed
1481             * @throws SystemException if a system exception occurred
1482             */
1483            public Company removeByWebId(String webId)
1484                    throws NoSuchCompanyException, SystemException {
1485                    Company company = findByWebId(webId);
1486    
1487                    return remove(company);
1488            }
1489    
1490            /**
1491             * Removes the company where mx = &#63; from the database.
1492             *
1493             * @param mx the mx
1494             * @return the company that was removed
1495             * @throws SystemException if a system exception occurred
1496             */
1497            public Company removeByMx(String mx)
1498                    throws NoSuchCompanyException, SystemException {
1499                    Company company = findByMx(mx);
1500    
1501                    return remove(company);
1502            }
1503    
1504            /**
1505             * Removes the company where logoId = &#63; from the database.
1506             *
1507             * @param logoId the logo ID
1508             * @return the company that was removed
1509             * @throws SystemException if a system exception occurred
1510             */
1511            public Company removeByLogoId(long logoId)
1512                    throws NoSuchCompanyException, SystemException {
1513                    Company company = findByLogoId(logoId);
1514    
1515                    return remove(company);
1516            }
1517    
1518            /**
1519             * Removes all the companies where system = &#63; from the database.
1520             *
1521             * @param system the system
1522             * @throws SystemException if a system exception occurred
1523             */
1524            public void removeBySystem(boolean system) throws SystemException {
1525                    for (Company company : findBySystem(system)) {
1526                            remove(company);
1527                    }
1528            }
1529    
1530            /**
1531             * Removes all the companies from the database.
1532             *
1533             * @throws SystemException if a system exception occurred
1534             */
1535            public void removeAll() throws SystemException {
1536                    for (Company company : findAll()) {
1537                            remove(company);
1538                    }
1539            }
1540    
1541            /**
1542             * Returns the number of companies where webId = &#63;.
1543             *
1544             * @param webId the web ID
1545             * @return the number of matching companies
1546             * @throws SystemException if a system exception occurred
1547             */
1548            public int countByWebId(String webId) throws SystemException {
1549                    Object[] finderArgs = new Object[] { webId };
1550    
1551                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_WEBID,
1552                                    finderArgs, this);
1553    
1554                    if (count == null) {
1555                            StringBundler query = new StringBundler(2);
1556    
1557                            query.append(_SQL_COUNT_COMPANY_WHERE);
1558    
1559                            if (webId == null) {
1560                                    query.append(_FINDER_COLUMN_WEBID_WEBID_1);
1561                            }
1562                            else {
1563                                    if (webId.equals(StringPool.BLANK)) {
1564                                            query.append(_FINDER_COLUMN_WEBID_WEBID_3);
1565                                    }
1566                                    else {
1567                                            query.append(_FINDER_COLUMN_WEBID_WEBID_2);
1568                                    }
1569                            }
1570    
1571                            String sql = query.toString();
1572    
1573                            Session session = null;
1574    
1575                            try {
1576                                    session = openSession();
1577    
1578                                    Query q = session.createQuery(sql);
1579    
1580                                    QueryPos qPos = QueryPos.getInstance(q);
1581    
1582                                    if (webId != null) {
1583                                            qPos.add(webId);
1584                                    }
1585    
1586                                    count = (Long)q.uniqueResult();
1587                            }
1588                            catch (Exception e) {
1589                                    throw processException(e);
1590                            }
1591                            finally {
1592                                    if (count == null) {
1593                                            count = Long.valueOf(0);
1594                                    }
1595    
1596                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_WEBID,
1597                                            finderArgs, count);
1598    
1599                                    closeSession(session);
1600                            }
1601                    }
1602    
1603                    return count.intValue();
1604            }
1605    
1606            /**
1607             * Returns the number of companies where mx = &#63;.
1608             *
1609             * @param mx the mx
1610             * @return the number of matching companies
1611             * @throws SystemException if a system exception occurred
1612             */
1613            public int countByMx(String mx) throws SystemException {
1614                    Object[] finderArgs = new Object[] { mx };
1615    
1616                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MX,
1617                                    finderArgs, this);
1618    
1619                    if (count == null) {
1620                            StringBundler query = new StringBundler(2);
1621    
1622                            query.append(_SQL_COUNT_COMPANY_WHERE);
1623    
1624                            if (mx == null) {
1625                                    query.append(_FINDER_COLUMN_MX_MX_1);
1626                            }
1627                            else {
1628                                    if (mx.equals(StringPool.BLANK)) {
1629                                            query.append(_FINDER_COLUMN_MX_MX_3);
1630                                    }
1631                                    else {
1632                                            query.append(_FINDER_COLUMN_MX_MX_2);
1633                                    }
1634                            }
1635    
1636                            String sql = query.toString();
1637    
1638                            Session session = null;
1639    
1640                            try {
1641                                    session = openSession();
1642    
1643                                    Query q = session.createQuery(sql);
1644    
1645                                    QueryPos qPos = QueryPos.getInstance(q);
1646    
1647                                    if (mx != null) {
1648                                            qPos.add(mx);
1649                                    }
1650    
1651                                    count = (Long)q.uniqueResult();
1652                            }
1653                            catch (Exception e) {
1654                                    throw processException(e);
1655                            }
1656                            finally {
1657                                    if (count == null) {
1658                                            count = Long.valueOf(0);
1659                                    }
1660    
1661                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MX, finderArgs,
1662                                            count);
1663    
1664                                    closeSession(session);
1665                            }
1666                    }
1667    
1668                    return count.intValue();
1669            }
1670    
1671            /**
1672             * Returns the number of companies where logoId = &#63;.
1673             *
1674             * @param logoId the logo ID
1675             * @return the number of matching companies
1676             * @throws SystemException if a system exception occurred
1677             */
1678            public int countByLogoId(long logoId) throws SystemException {
1679                    Object[] finderArgs = new Object[] { logoId };
1680    
1681                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LOGOID,
1682                                    finderArgs, this);
1683    
1684                    if (count == null) {
1685                            StringBundler query = new StringBundler(2);
1686    
1687                            query.append(_SQL_COUNT_COMPANY_WHERE);
1688    
1689                            query.append(_FINDER_COLUMN_LOGOID_LOGOID_2);
1690    
1691                            String sql = query.toString();
1692    
1693                            Session session = null;
1694    
1695                            try {
1696                                    session = openSession();
1697    
1698                                    Query q = session.createQuery(sql);
1699    
1700                                    QueryPos qPos = QueryPos.getInstance(q);
1701    
1702                                    qPos.add(logoId);
1703    
1704                                    count = (Long)q.uniqueResult();
1705                            }
1706                            catch (Exception e) {
1707                                    throw processException(e);
1708                            }
1709                            finally {
1710                                    if (count == null) {
1711                                            count = Long.valueOf(0);
1712                                    }
1713    
1714                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LOGOID,
1715                                            finderArgs, count);
1716    
1717                                    closeSession(session);
1718                            }
1719                    }
1720    
1721                    return count.intValue();
1722            }
1723    
1724            /**
1725             * Returns the number of companies where system = &#63;.
1726             *
1727             * @param system the system
1728             * @return the number of matching companies
1729             * @throws SystemException if a system exception occurred
1730             */
1731            public int countBySystem(boolean system) throws SystemException {
1732                    Object[] finderArgs = new Object[] { system };
1733    
1734                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SYSTEM,
1735                                    finderArgs, this);
1736    
1737                    if (count == null) {
1738                            StringBundler query = new StringBundler(2);
1739    
1740                            query.append(_SQL_COUNT_COMPANY_WHERE);
1741    
1742                            query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1743    
1744                            String sql = query.toString();
1745    
1746                            Session session = null;
1747    
1748                            try {
1749                                    session = openSession();
1750    
1751                                    Query q = session.createQuery(sql);
1752    
1753                                    QueryPos qPos = QueryPos.getInstance(q);
1754    
1755                                    qPos.add(system);
1756    
1757                                    count = (Long)q.uniqueResult();
1758                            }
1759                            catch (Exception e) {
1760                                    throw processException(e);
1761                            }
1762                            finally {
1763                                    if (count == null) {
1764                                            count = Long.valueOf(0);
1765                                    }
1766    
1767                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SYSTEM,
1768                                            finderArgs, count);
1769    
1770                                    closeSession(session);
1771                            }
1772                    }
1773    
1774                    return count.intValue();
1775            }
1776    
1777            /**
1778             * Returns the number of companies.
1779             *
1780             * @return the number of companies
1781             * @throws SystemException if a system exception occurred
1782             */
1783            public int countAll() throws SystemException {
1784                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1785                                    FINDER_ARGS_EMPTY, this);
1786    
1787                    if (count == null) {
1788                            Session session = null;
1789    
1790                            try {
1791                                    session = openSession();
1792    
1793                                    Query q = session.createQuery(_SQL_COUNT_COMPANY);
1794    
1795                                    count = (Long)q.uniqueResult();
1796                            }
1797                            catch (Exception e) {
1798                                    throw processException(e);
1799                            }
1800                            finally {
1801                                    if (count == null) {
1802                                            count = Long.valueOf(0);
1803                                    }
1804    
1805                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1806                                            FINDER_ARGS_EMPTY, count);
1807    
1808                                    closeSession(session);
1809                            }
1810                    }
1811    
1812                    return count.intValue();
1813            }
1814    
1815            /**
1816             * Initializes the company persistence.
1817             */
1818            public void afterPropertiesSet() {
1819                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1820                                            com.liferay.portal.util.PropsUtil.get(
1821                                                    "value.object.listener.com.liferay.portal.model.Company")));
1822    
1823                    if (listenerClassNames.length > 0) {
1824                            try {
1825                                    List<ModelListener<Company>> listenersList = new ArrayList<ModelListener<Company>>();
1826    
1827                                    for (String listenerClassName : listenerClassNames) {
1828                                            listenersList.add((ModelListener<Company>)InstanceFactory.newInstance(
1829                                                            listenerClassName));
1830                                    }
1831    
1832                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1833                            }
1834                            catch (Exception e) {
1835                                    _log.error(e);
1836                            }
1837                    }
1838            }
1839    
1840            public void destroy() {
1841                    EntityCacheUtil.removeCache(CompanyImpl.class.getName());
1842                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1843                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1844            }
1845    
1846            @BeanReference(type = AccountPersistence.class)
1847            protected AccountPersistence accountPersistence;
1848            @BeanReference(type = AddressPersistence.class)
1849            protected AddressPersistence addressPersistence;
1850            @BeanReference(type = BrowserTrackerPersistence.class)
1851            protected BrowserTrackerPersistence browserTrackerPersistence;
1852            @BeanReference(type = ClassNamePersistence.class)
1853            protected ClassNamePersistence classNamePersistence;
1854            @BeanReference(type = ClusterGroupPersistence.class)
1855            protected ClusterGroupPersistence clusterGroupPersistence;
1856            @BeanReference(type = CompanyPersistence.class)
1857            protected CompanyPersistence companyPersistence;
1858            @BeanReference(type = ContactPersistence.class)
1859            protected ContactPersistence contactPersistence;
1860            @BeanReference(type = CountryPersistence.class)
1861            protected CountryPersistence countryPersistence;
1862            @BeanReference(type = EmailAddressPersistence.class)
1863            protected EmailAddressPersistence emailAddressPersistence;
1864            @BeanReference(type = GroupPersistence.class)
1865            protected GroupPersistence groupPersistence;
1866            @BeanReference(type = ImagePersistence.class)
1867            protected ImagePersistence imagePersistence;
1868            @BeanReference(type = LayoutPersistence.class)
1869            protected LayoutPersistence layoutPersistence;
1870            @BeanReference(type = LayoutBranchPersistence.class)
1871            protected LayoutBranchPersistence layoutBranchPersistence;
1872            @BeanReference(type = LayoutPrototypePersistence.class)
1873            protected LayoutPrototypePersistence layoutPrototypePersistence;
1874            @BeanReference(type = LayoutRevisionPersistence.class)
1875            protected LayoutRevisionPersistence layoutRevisionPersistence;
1876            @BeanReference(type = LayoutSetPersistence.class)
1877            protected LayoutSetPersistence layoutSetPersistence;
1878            @BeanReference(type = LayoutSetBranchPersistence.class)
1879            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1880            @BeanReference(type = LayoutSetPrototypePersistence.class)
1881            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1882            @BeanReference(type = ListTypePersistence.class)
1883            protected ListTypePersistence listTypePersistence;
1884            @BeanReference(type = LockPersistence.class)
1885            protected LockPersistence lockPersistence;
1886            @BeanReference(type = MembershipRequestPersistence.class)
1887            protected MembershipRequestPersistence membershipRequestPersistence;
1888            @BeanReference(type = OrganizationPersistence.class)
1889            protected OrganizationPersistence organizationPersistence;
1890            @BeanReference(type = OrgGroupRolePersistence.class)
1891            protected OrgGroupRolePersistence orgGroupRolePersistence;
1892            @BeanReference(type = OrgLaborPersistence.class)
1893            protected OrgLaborPersistence orgLaborPersistence;
1894            @BeanReference(type = PasswordPolicyPersistence.class)
1895            protected PasswordPolicyPersistence passwordPolicyPersistence;
1896            @BeanReference(type = PasswordPolicyRelPersistence.class)
1897            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1898            @BeanReference(type = PasswordTrackerPersistence.class)
1899            protected PasswordTrackerPersistence passwordTrackerPersistence;
1900            @BeanReference(type = PhonePersistence.class)
1901            protected PhonePersistence phonePersistence;
1902            @BeanReference(type = PluginSettingPersistence.class)
1903            protected PluginSettingPersistence pluginSettingPersistence;
1904            @BeanReference(type = PortalPreferencesPersistence.class)
1905            protected PortalPreferencesPersistence portalPreferencesPersistence;
1906            @BeanReference(type = PortletPersistence.class)
1907            protected PortletPersistence portletPersistence;
1908            @BeanReference(type = PortletItemPersistence.class)
1909            protected PortletItemPersistence portletItemPersistence;
1910            @BeanReference(type = PortletPreferencesPersistence.class)
1911            protected PortletPreferencesPersistence portletPreferencesPersistence;
1912            @BeanReference(type = RegionPersistence.class)
1913            protected RegionPersistence regionPersistence;
1914            @BeanReference(type = ReleasePersistence.class)
1915            protected ReleasePersistence releasePersistence;
1916            @BeanReference(type = RepositoryPersistence.class)
1917            protected RepositoryPersistence repositoryPersistence;
1918            @BeanReference(type = RepositoryEntryPersistence.class)
1919            protected RepositoryEntryPersistence repositoryEntryPersistence;
1920            @BeanReference(type = ResourceActionPersistence.class)
1921            protected ResourceActionPersistence resourceActionPersistence;
1922            @BeanReference(type = ResourceBlockPersistence.class)
1923            protected ResourceBlockPersistence resourceBlockPersistence;
1924            @BeanReference(type = ResourceBlockPermissionPersistence.class)
1925            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1926            @BeanReference(type = ResourcePermissionPersistence.class)
1927            protected ResourcePermissionPersistence resourcePermissionPersistence;
1928            @BeanReference(type = ResourceTypePermissionPersistence.class)
1929            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1930            @BeanReference(type = RolePersistence.class)
1931            protected RolePersistence rolePersistence;
1932            @BeanReference(type = ServiceComponentPersistence.class)
1933            protected ServiceComponentPersistence serviceComponentPersistence;
1934            @BeanReference(type = ShardPersistence.class)
1935            protected ShardPersistence shardPersistence;
1936            @BeanReference(type = SubscriptionPersistence.class)
1937            protected SubscriptionPersistence subscriptionPersistence;
1938            @BeanReference(type = TeamPersistence.class)
1939            protected TeamPersistence teamPersistence;
1940            @BeanReference(type = TicketPersistence.class)
1941            protected TicketPersistence ticketPersistence;
1942            @BeanReference(type = UserPersistence.class)
1943            protected UserPersistence userPersistence;
1944            @BeanReference(type = UserGroupPersistence.class)
1945            protected UserGroupPersistence userGroupPersistence;
1946            @BeanReference(type = UserGroupGroupRolePersistence.class)
1947            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1948            @BeanReference(type = UserGroupRolePersistence.class)
1949            protected UserGroupRolePersistence userGroupRolePersistence;
1950            @BeanReference(type = UserIdMapperPersistence.class)
1951            protected UserIdMapperPersistence userIdMapperPersistence;
1952            @BeanReference(type = UserNotificationEventPersistence.class)
1953            protected UserNotificationEventPersistence userNotificationEventPersistence;
1954            @BeanReference(type = UserTrackerPersistence.class)
1955            protected UserTrackerPersistence userTrackerPersistence;
1956            @BeanReference(type = UserTrackerPathPersistence.class)
1957            protected UserTrackerPathPersistence userTrackerPathPersistence;
1958            @BeanReference(type = VirtualHostPersistence.class)
1959            protected VirtualHostPersistence virtualHostPersistence;
1960            @BeanReference(type = WebDAVPropsPersistence.class)
1961            protected WebDAVPropsPersistence webDAVPropsPersistence;
1962            @BeanReference(type = WebsitePersistence.class)
1963            protected WebsitePersistence websitePersistence;
1964            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1965            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1966            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1967            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1968            private static final String _SQL_SELECT_COMPANY = "SELECT company FROM Company company";
1969            private static final String _SQL_SELECT_COMPANY_WHERE = "SELECT company FROM Company company WHERE ";
1970            private static final String _SQL_COUNT_COMPANY = "SELECT COUNT(company) FROM Company company";
1971            private static final String _SQL_COUNT_COMPANY_WHERE = "SELECT COUNT(company) FROM Company company WHERE ";
1972            private static final String _FINDER_COLUMN_WEBID_WEBID_1 = "company.webId IS NULL";
1973            private static final String _FINDER_COLUMN_WEBID_WEBID_2 = "company.webId = ?";
1974            private static final String _FINDER_COLUMN_WEBID_WEBID_3 = "(company.webId IS NULL OR company.webId = ?)";
1975            private static final String _FINDER_COLUMN_MX_MX_1 = "company.mx IS NULL";
1976            private static final String _FINDER_COLUMN_MX_MX_2 = "company.mx = ?";
1977            private static final String _FINDER_COLUMN_MX_MX_3 = "(company.mx IS NULL OR company.mx = ?)";
1978            private static final String _FINDER_COLUMN_LOGOID_LOGOID_2 = "company.logoId = ?";
1979            private static final String _FINDER_COLUMN_SYSTEM_SYSTEM_2 = "company.system = ?";
1980            private static final String _ORDER_BY_ENTITY_ALIAS = "company.";
1981            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Company exists with the primary key ";
1982            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Company exists with the key {";
1983            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1984            private static Log _log = LogFactoryUtil.getLog(CompanyPersistenceImpl.class);
1985            private static Company _nullCompany = new CompanyImpl() {
1986                            @Override
1987                            public Object clone() {
1988                                    return this;
1989                            }
1990    
1991                            @Override
1992                            public CacheModel<Company> toCacheModel() {
1993                                    return _nullCompanyCacheModel;
1994                            }
1995                    };
1996    
1997            private static CacheModel<Company> _nullCompanyCacheModel = new CacheModel<Company>() {
1998                            public Company toEntityModel() {
1999                                    return _nullCompany;
2000                            }
2001                    };
2002    }