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