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