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