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