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