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