001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchWebsiteException;
019    import com.liferay.portal.kernel.bean.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.model.CacheModel;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.model.Website;
040    import com.liferay.portal.model.impl.WebsiteImpl;
041    import com.liferay.portal.model.impl.WebsiteModelImpl;
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 implementation for the website service.
052     *
053     * <p>
054     * Caching information and settings can be found in <code>portal.properties</code>
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see WebsitePersistence
059     * @see WebsiteUtil
060     * @generated
061     */
062    public class WebsitePersistenceImpl extends BasePersistenceImpl<Website>
063            implements WebsitePersistence {
064            /*
065             * NOTE FOR DEVELOPERS:
066             *
067             * Never modify or reference this class directly. Always use {@link WebsiteUtil} to access the website persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
068             */
069            public static final String FINDER_CLASS_NAME_ENTITY = WebsiteImpl.class.getName();
070            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071                    ".List1";
072            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073                    ".List2";
074            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
075                    new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
076                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
077                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
078                            new String[] {
079                                    Long.class.getName(),
080                                    
081                            "java.lang.Integer", "java.lang.Integer",
082                                    "com.liferay.portal.kernel.util.OrderByComparator"
083                            });
084            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
085                    new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
086                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
088                            new String[] { Long.class.getName() },
089                            WebsiteModelImpl.COMPANYID_COLUMN_BITMASK);
090            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
091                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
093                            new String[] { Long.class.getName() });
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
095                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
097                            new String[] {
098                                    Long.class.getName(),
099                                    
100                            "java.lang.Integer", "java.lang.Integer",
101                                    "com.liferay.portal.kernel.util.OrderByComparator"
102                            });
103            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
104                    new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
105                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
107                            new String[] { Long.class.getName() },
108                            WebsiteModelImpl.USERID_COLUMN_BITMASK);
109            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
110                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
112                            new String[] { Long.class.getName() });
113            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
114                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
115                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
116                            new String[] {
117                                    Long.class.getName(), Long.class.getName(),
118                                    
119                            "java.lang.Integer", "java.lang.Integer",
120                                    "com.liferay.portal.kernel.util.OrderByComparator"
121                            });
122            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
123                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
125                            new String[] { Long.class.getName(), Long.class.getName() },
126                            WebsiteModelImpl.COMPANYID_COLUMN_BITMASK |
127                            WebsiteModelImpl.CLASSNAMEID_COLUMN_BITMASK);
128            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
129                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
130                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
131                            new String[] { Long.class.getName(), Long.class.getName() });
132            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
133                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
134                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_C",
135                            new String[] {
136                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
137                                    
138                            "java.lang.Integer", "java.lang.Integer",
139                                    "com.liferay.portal.kernel.util.OrderByComparator"
140                            });
141            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
142                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
143                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_C",
144                            new String[] {
145                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
146                            },
147                            WebsiteModelImpl.COMPANYID_COLUMN_BITMASK |
148                            WebsiteModelImpl.CLASSNAMEID_COLUMN_BITMASK |
149                            WebsiteModelImpl.CLASSPK_COLUMN_BITMASK);
150            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
151                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
152                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
153                            new String[] {
154                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
155                            });
156            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C_P = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
157                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
158                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_C_P",
159                            new String[] {
160                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
161                                    Boolean.class.getName(),
162                                    
163                            "java.lang.Integer", "java.lang.Integer",
164                                    "com.liferay.portal.kernel.util.OrderByComparator"
165                            });
166            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P =
167                    new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
168                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
169                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_C_P",
170                            new String[] {
171                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
172                                    Boolean.class.getName()
173                            },
174                            WebsiteModelImpl.COMPANYID_COLUMN_BITMASK |
175                            WebsiteModelImpl.CLASSNAMEID_COLUMN_BITMASK |
176                            WebsiteModelImpl.CLASSPK_COLUMN_BITMASK |
177                            WebsiteModelImpl.PRIMARY_COLUMN_BITMASK);
178            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C_P = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
179                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
180                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C_P",
181                            new String[] {
182                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
183                                    Boolean.class.getName()
184                            });
185            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
186                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
187                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
188            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
189                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
190                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
191            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
192                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
193                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
194    
195            /**
196             * Caches the website in the entity cache if it is enabled.
197             *
198             * @param website the website
199             */
200            public void cacheResult(Website website) {
201                    EntityCacheUtil.putResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
202                            WebsiteImpl.class, website.getPrimaryKey(), website);
203    
204                    website.resetOriginalValues();
205            }
206    
207            /**
208             * Caches the websites in the entity cache if it is enabled.
209             *
210             * @param websites the websites
211             */
212            public void cacheResult(List<Website> websites) {
213                    for (Website website : websites) {
214                            if (EntityCacheUtil.getResult(
215                                                    WebsiteModelImpl.ENTITY_CACHE_ENABLED,
216                                                    WebsiteImpl.class, website.getPrimaryKey()) == null) {
217                                    cacheResult(website);
218                            }
219                            else {
220                                    website.resetOriginalValues();
221                            }
222                    }
223            }
224    
225            /**
226             * Clears the cache for all websites.
227             *
228             * <p>
229             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
230             * </p>
231             */
232            @Override
233            public void clearCache() {
234                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
235                            CacheRegistryUtil.clear(WebsiteImpl.class.getName());
236                    }
237    
238                    EntityCacheUtil.clearCache(WebsiteImpl.class.getName());
239    
240                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
241                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
242                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
243            }
244    
245            /**
246             * Clears the cache for the website.
247             *
248             * <p>
249             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
250             * </p>
251             */
252            @Override
253            public void clearCache(Website website) {
254                    EntityCacheUtil.removeResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
255                            WebsiteImpl.class, website.getPrimaryKey());
256    
257                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
258                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
259            }
260    
261            @Override
262            public void clearCache(List<Website> websites) {
263                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
264                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
265    
266                    for (Website website : websites) {
267                            EntityCacheUtil.removeResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
268                                    WebsiteImpl.class, website.getPrimaryKey());
269                    }
270            }
271    
272            /**
273             * Creates a new website with the primary key. Does not add the website to the database.
274             *
275             * @param websiteId the primary key for the new website
276             * @return the new website
277             */
278            public Website create(long websiteId) {
279                    Website website = new WebsiteImpl();
280    
281                    website.setNew(true);
282                    website.setPrimaryKey(websiteId);
283    
284                    return website;
285            }
286    
287            /**
288             * Removes the website with the primary key from the database. Also notifies the appropriate model listeners.
289             *
290             * @param websiteId the primary key of the website
291             * @return the website that was removed
292             * @throws com.liferay.portal.NoSuchWebsiteException if a website with the primary key could not be found
293             * @throws SystemException if a system exception occurred
294             */
295            public Website remove(long websiteId)
296                    throws NoSuchWebsiteException, SystemException {
297                    return remove(Long.valueOf(websiteId));
298            }
299    
300            /**
301             * Removes the website with the primary key from the database. Also notifies the appropriate model listeners.
302             *
303             * @param primaryKey the primary key of the website
304             * @return the website that was removed
305             * @throws com.liferay.portal.NoSuchWebsiteException if a website with the primary key could not be found
306             * @throws SystemException if a system exception occurred
307             */
308            @Override
309            public Website remove(Serializable primaryKey)
310                    throws NoSuchWebsiteException, SystemException {
311                    Session session = null;
312    
313                    try {
314                            session = openSession();
315    
316                            Website website = (Website)session.get(WebsiteImpl.class, primaryKey);
317    
318                            if (website == null) {
319                                    if (_log.isWarnEnabled()) {
320                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
321                                    }
322    
323                                    throw new NoSuchWebsiteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
324                                            primaryKey);
325                            }
326    
327                            return remove(website);
328                    }
329                    catch (NoSuchWebsiteException nsee) {
330                            throw nsee;
331                    }
332                    catch (Exception e) {
333                            throw processException(e);
334                    }
335                    finally {
336                            closeSession(session);
337                    }
338            }
339    
340            @Override
341            protected Website removeImpl(Website website) throws SystemException {
342                    website = toUnwrappedModel(website);
343    
344                    Session session = null;
345    
346                    try {
347                            session = openSession();
348    
349                            BatchSessionUtil.delete(session, website);
350                    }
351                    catch (Exception e) {
352                            throw processException(e);
353                    }
354                    finally {
355                            closeSession(session);
356                    }
357    
358                    clearCache(website);
359    
360                    return website;
361            }
362    
363            @Override
364            public Website updateImpl(com.liferay.portal.model.Website website,
365                    boolean merge) throws SystemException {
366                    website = toUnwrappedModel(website);
367    
368                    boolean isNew = website.isNew();
369    
370                    WebsiteModelImpl websiteModelImpl = (WebsiteModelImpl)website;
371    
372                    Session session = null;
373    
374                    try {
375                            session = openSession();
376    
377                            BatchSessionUtil.update(session, website, merge);
378    
379                            website.setNew(false);
380                    }
381                    catch (Exception e) {
382                            throw processException(e);
383                    }
384                    finally {
385                            closeSession(session);
386                    }
387    
388                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
389    
390                    if (isNew || !WebsiteModelImpl.COLUMN_BITMASK_ENABLED) {
391                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
392                    }
393    
394                    else {
395                            if ((websiteModelImpl.getColumnBitmask() &
396                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
397                                    Object[] args = new Object[] {
398                                                    Long.valueOf(websiteModelImpl.getOriginalCompanyId())
399                                            };
400    
401                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
402                                            args);
403                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
404                                            args);
405    
406                                    args = new Object[] {
407                                                    Long.valueOf(websiteModelImpl.getCompanyId())
408                                            };
409    
410                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
411                                            args);
412                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
413                                            args);
414                            }
415    
416                            if ((websiteModelImpl.getColumnBitmask() &
417                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
418                                    Object[] args = new Object[] {
419                                                    Long.valueOf(websiteModelImpl.getOriginalUserId())
420                                            };
421    
422                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
423                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
424                                            args);
425    
426                                    args = new Object[] { Long.valueOf(websiteModelImpl.getUserId()) };
427    
428                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
429                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
430                                            args);
431                            }
432    
433                            if ((websiteModelImpl.getColumnBitmask() &
434                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
435                                    Object[] args = new Object[] {
436                                                    Long.valueOf(websiteModelImpl.getOriginalCompanyId()),
437                                                    Long.valueOf(websiteModelImpl.getOriginalClassNameId())
438                                            };
439    
440                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
441                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
442                                            args);
443    
444                                    args = new Object[] {
445                                                    Long.valueOf(websiteModelImpl.getCompanyId()),
446                                                    Long.valueOf(websiteModelImpl.getClassNameId())
447                                            };
448    
449                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
450                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
451                                            args);
452                            }
453    
454                            if ((websiteModelImpl.getColumnBitmask() &
455                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C.getColumnBitmask()) != 0) {
456                                    Object[] args = new Object[] {
457                                                    Long.valueOf(websiteModelImpl.getOriginalCompanyId()),
458                                                    Long.valueOf(websiteModelImpl.getOriginalClassNameId()),
459                                                    Long.valueOf(websiteModelImpl.getOriginalClassPK())
460                                            };
461    
462                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
463                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
464                                            args);
465    
466                                    args = new Object[] {
467                                                    Long.valueOf(websiteModelImpl.getCompanyId()),
468                                                    Long.valueOf(websiteModelImpl.getClassNameId()),
469                                                    Long.valueOf(websiteModelImpl.getClassPK())
470                                            };
471    
472                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
473                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
474                                            args);
475                            }
476    
477                            if ((websiteModelImpl.getColumnBitmask() &
478                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P.getColumnBitmask()) != 0) {
479                                    Object[] args = new Object[] {
480                                                    Long.valueOf(websiteModelImpl.getOriginalCompanyId()),
481                                                    Long.valueOf(websiteModelImpl.getOriginalClassNameId()),
482                                                    Long.valueOf(websiteModelImpl.getOriginalClassPK()),
483                                                    Boolean.valueOf(websiteModelImpl.getOriginalPrimary())
484                                            };
485    
486                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
487                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
488                                            args);
489    
490                                    args = new Object[] {
491                                                    Long.valueOf(websiteModelImpl.getCompanyId()),
492                                                    Long.valueOf(websiteModelImpl.getClassNameId()),
493                                                    Long.valueOf(websiteModelImpl.getClassPK()),
494                                                    Boolean.valueOf(websiteModelImpl.getPrimary())
495                                            };
496    
497                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
498                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
499                                            args);
500                            }
501                    }
502    
503                    EntityCacheUtil.putResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
504                            WebsiteImpl.class, website.getPrimaryKey(), website);
505    
506                    return website;
507            }
508    
509            protected Website toUnwrappedModel(Website website) {
510                    if (website instanceof WebsiteImpl) {
511                            return website;
512                    }
513    
514                    WebsiteImpl websiteImpl = new WebsiteImpl();
515    
516                    websiteImpl.setNew(website.isNew());
517                    websiteImpl.setPrimaryKey(website.getPrimaryKey());
518    
519                    websiteImpl.setWebsiteId(website.getWebsiteId());
520                    websiteImpl.setCompanyId(website.getCompanyId());
521                    websiteImpl.setUserId(website.getUserId());
522                    websiteImpl.setUserName(website.getUserName());
523                    websiteImpl.setCreateDate(website.getCreateDate());
524                    websiteImpl.setModifiedDate(website.getModifiedDate());
525                    websiteImpl.setClassNameId(website.getClassNameId());
526                    websiteImpl.setClassPK(website.getClassPK());
527                    websiteImpl.setUrl(website.getUrl());
528                    websiteImpl.setTypeId(website.getTypeId());
529                    websiteImpl.setPrimary(website.isPrimary());
530    
531                    return websiteImpl;
532            }
533    
534            /**
535             * Returns the website with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
536             *
537             * @param primaryKey the primary key of the website
538             * @return the website
539             * @throws com.liferay.portal.NoSuchModelException if a website with the primary key could not be found
540             * @throws SystemException if a system exception occurred
541             */
542            @Override
543            public Website findByPrimaryKey(Serializable primaryKey)
544                    throws NoSuchModelException, SystemException {
545                    return findByPrimaryKey(((Long)primaryKey).longValue());
546            }
547    
548            /**
549             * Returns the website with the primary key or throws a {@link com.liferay.portal.NoSuchWebsiteException} if it could not be found.
550             *
551             * @param websiteId the primary key of the website
552             * @return the website
553             * @throws com.liferay.portal.NoSuchWebsiteException if a website with the primary key could not be found
554             * @throws SystemException if a system exception occurred
555             */
556            public Website findByPrimaryKey(long websiteId)
557                    throws NoSuchWebsiteException, SystemException {
558                    Website website = fetchByPrimaryKey(websiteId);
559    
560                    if (website == null) {
561                            if (_log.isWarnEnabled()) {
562                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + websiteId);
563                            }
564    
565                            throw new NoSuchWebsiteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
566                                    websiteId);
567                    }
568    
569                    return website;
570            }
571    
572            /**
573             * Returns the website with the primary key or returns <code>null</code> if it could not be found.
574             *
575             * @param primaryKey the primary key of the website
576             * @return the website, or <code>null</code> if a website with the primary key could not be found
577             * @throws SystemException if a system exception occurred
578             */
579            @Override
580            public Website fetchByPrimaryKey(Serializable primaryKey)
581                    throws SystemException {
582                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
583            }
584    
585            /**
586             * Returns the website with the primary key or returns <code>null</code> if it could not be found.
587             *
588             * @param websiteId the primary key of the website
589             * @return the website, or <code>null</code> if a website with the primary key could not be found
590             * @throws SystemException if a system exception occurred
591             */
592            public Website fetchByPrimaryKey(long websiteId) throws SystemException {
593                    Website website = (Website)EntityCacheUtil.getResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
594                                    WebsiteImpl.class, websiteId);
595    
596                    if (website == _nullWebsite) {
597                            return null;
598                    }
599    
600                    if (website == null) {
601                            Session session = null;
602    
603                            boolean hasException = false;
604    
605                            try {
606                                    session = openSession();
607    
608                                    website = (Website)session.get(WebsiteImpl.class,
609                                                    Long.valueOf(websiteId));
610                            }
611                            catch (Exception e) {
612                                    hasException = true;
613    
614                                    throw processException(e);
615                            }
616                            finally {
617                                    if (website != null) {
618                                            cacheResult(website);
619                                    }
620                                    else if (!hasException) {
621                                            EntityCacheUtil.putResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
622                                                    WebsiteImpl.class, websiteId, _nullWebsite);
623                                    }
624    
625                                    closeSession(session);
626                            }
627                    }
628    
629                    return website;
630            }
631    
632            /**
633             * Returns all the websites where companyId = &#63;.
634             *
635             * @param companyId the company ID
636             * @return the matching websites
637             * @throws SystemException if a system exception occurred
638             */
639            public List<Website> findByCompanyId(long companyId)
640                    throws SystemException {
641                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
642                            null);
643            }
644    
645            /**
646             * Returns a range of all the websites where companyId = &#63;.
647             *
648             * <p>
649             * 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.
650             * </p>
651             *
652             * @param companyId the company ID
653             * @param start the lower bound of the range of websites
654             * @param end the upper bound of the range of websites (not inclusive)
655             * @return the range of matching websites
656             * @throws SystemException if a system exception occurred
657             */
658            public List<Website> findByCompanyId(long companyId, int start, int end)
659                    throws SystemException {
660                    return findByCompanyId(companyId, start, end, null);
661            }
662    
663            /**
664             * Returns an ordered range of all the websites where companyId = &#63;.
665             *
666             * <p>
667             * 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.
668             * </p>
669             *
670             * @param companyId the company ID
671             * @param start the lower bound of the range of websites
672             * @param end the upper bound of the range of websites (not inclusive)
673             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
674             * @return the ordered range of matching websites
675             * @throws SystemException if a system exception occurred
676             */
677            public List<Website> findByCompanyId(long companyId, int start, int end,
678                    OrderByComparator orderByComparator) throws SystemException {
679                    FinderPath finderPath = null;
680                    Object[] finderArgs = null;
681    
682                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
683                                    (orderByComparator == null)) {
684                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
685                            finderArgs = new Object[] { companyId };
686                    }
687                    else {
688                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
689                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
690                    }
691    
692                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(finderPath,
693                                    finderArgs, this);
694    
695                    if ((list != null) && !list.isEmpty()) {
696                            for (Website website : list) {
697                                    if ((companyId != website.getCompanyId())) {
698                                            list = null;
699    
700                                            break;
701                                    }
702                            }
703                    }
704    
705                    if (list == null) {
706                            StringBundler query = null;
707    
708                            if (orderByComparator != null) {
709                                    query = new StringBundler(3 +
710                                                    (orderByComparator.getOrderByFields().length * 3));
711                            }
712                            else {
713                                    query = new StringBundler(3);
714                            }
715    
716                            query.append(_SQL_SELECT_WEBSITE_WHERE);
717    
718                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
719    
720                            if (orderByComparator != null) {
721                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
722                                            orderByComparator);
723                            }
724    
725                            else {
726                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
727                            }
728    
729                            String sql = query.toString();
730    
731                            Session session = null;
732    
733                            try {
734                                    session = openSession();
735    
736                                    Query q = session.createQuery(sql);
737    
738                                    QueryPos qPos = QueryPos.getInstance(q);
739    
740                                    qPos.add(companyId);
741    
742                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
743                            }
744                            catch (Exception e) {
745                                    throw processException(e);
746                            }
747                            finally {
748                                    if (list == null) {
749                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
750                                    }
751                                    else {
752                                            cacheResult(list);
753    
754                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
755                                    }
756    
757                                    closeSession(session);
758                            }
759                    }
760    
761                    return list;
762            }
763    
764            /**
765             * Returns the first website in the ordered set where companyId = &#63;.
766             *
767             * @param companyId the company ID
768             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
769             * @return the first matching website
770             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
771             * @throws SystemException if a system exception occurred
772             */
773            public Website findByCompanyId_First(long companyId,
774                    OrderByComparator orderByComparator)
775                    throws NoSuchWebsiteException, SystemException {
776                    Website website = fetchByCompanyId_First(companyId, orderByComparator);
777    
778                    if (website != null) {
779                            return website;
780                    }
781    
782                    StringBundler msg = new StringBundler(4);
783    
784                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
785    
786                    msg.append("companyId=");
787                    msg.append(companyId);
788    
789                    msg.append(StringPool.CLOSE_CURLY_BRACE);
790    
791                    throw new NoSuchWebsiteException(msg.toString());
792            }
793    
794            /**
795             * Returns the first website in the ordered set where companyId = &#63;.
796             *
797             * @param companyId the company ID
798             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
799             * @return the first matching website, or <code>null</code> if a matching website could not be found
800             * @throws SystemException if a system exception occurred
801             */
802            public Website fetchByCompanyId_First(long companyId,
803                    OrderByComparator orderByComparator) throws SystemException {
804                    List<Website> list = findByCompanyId(companyId, 0, 1, orderByComparator);
805    
806                    if (!list.isEmpty()) {
807                            return list.get(0);
808                    }
809    
810                    return null;
811            }
812    
813            /**
814             * Returns the last website in the ordered set where companyId = &#63;.
815             *
816             * @param companyId the company ID
817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
818             * @return the last matching website
819             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
820             * @throws SystemException if a system exception occurred
821             */
822            public Website findByCompanyId_Last(long companyId,
823                    OrderByComparator orderByComparator)
824                    throws NoSuchWebsiteException, SystemException {
825                    Website website = fetchByCompanyId_Last(companyId, orderByComparator);
826    
827                    if (website != null) {
828                            return website;
829                    }
830    
831                    StringBundler msg = new StringBundler(4);
832    
833                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
834    
835                    msg.append("companyId=");
836                    msg.append(companyId);
837    
838                    msg.append(StringPool.CLOSE_CURLY_BRACE);
839    
840                    throw new NoSuchWebsiteException(msg.toString());
841            }
842    
843            /**
844             * Returns the last website in the ordered set where companyId = &#63;.
845             *
846             * @param companyId the company ID
847             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
848             * @return the last matching website, or <code>null</code> if a matching website could not be found
849             * @throws SystemException if a system exception occurred
850             */
851            public Website fetchByCompanyId_Last(long companyId,
852                    OrderByComparator orderByComparator) throws SystemException {
853                    int count = countByCompanyId(companyId);
854    
855                    List<Website> list = findByCompanyId(companyId, count - 1, count,
856                                    orderByComparator);
857    
858                    if (!list.isEmpty()) {
859                            return list.get(0);
860                    }
861    
862                    return null;
863            }
864    
865            /**
866             * Returns the websites before and after the current website in the ordered set where companyId = &#63;.
867             *
868             * @param websiteId the primary key of the current website
869             * @param companyId the company ID
870             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
871             * @return the previous, current, and next website
872             * @throws com.liferay.portal.NoSuchWebsiteException if a website with the primary key could not be found
873             * @throws SystemException if a system exception occurred
874             */
875            public Website[] findByCompanyId_PrevAndNext(long websiteId,
876                    long companyId, OrderByComparator orderByComparator)
877                    throws NoSuchWebsiteException, SystemException {
878                    Website website = findByPrimaryKey(websiteId);
879    
880                    Session session = null;
881    
882                    try {
883                            session = openSession();
884    
885                            Website[] array = new WebsiteImpl[3];
886    
887                            array[0] = getByCompanyId_PrevAndNext(session, website, companyId,
888                                            orderByComparator, true);
889    
890                            array[1] = website;
891    
892                            array[2] = getByCompanyId_PrevAndNext(session, website, companyId,
893                                            orderByComparator, false);
894    
895                            return array;
896                    }
897                    catch (Exception e) {
898                            throw processException(e);
899                    }
900                    finally {
901                            closeSession(session);
902                    }
903            }
904    
905            protected Website getByCompanyId_PrevAndNext(Session session,
906                    Website website, long companyId, OrderByComparator orderByComparator,
907                    boolean previous) {
908                    StringBundler query = null;
909    
910                    if (orderByComparator != null) {
911                            query = new StringBundler(6 +
912                                            (orderByComparator.getOrderByFields().length * 6));
913                    }
914                    else {
915                            query = new StringBundler(3);
916                    }
917    
918                    query.append(_SQL_SELECT_WEBSITE_WHERE);
919    
920                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
921    
922                    if (orderByComparator != null) {
923                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
924    
925                            if (orderByConditionFields.length > 0) {
926                                    query.append(WHERE_AND);
927                            }
928    
929                            for (int i = 0; i < orderByConditionFields.length; i++) {
930                                    query.append(_ORDER_BY_ENTITY_ALIAS);
931                                    query.append(orderByConditionFields[i]);
932    
933                                    if ((i + 1) < orderByConditionFields.length) {
934                                            if (orderByComparator.isAscending() ^ previous) {
935                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
936                                            }
937                                            else {
938                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
939                                            }
940                                    }
941                                    else {
942                                            if (orderByComparator.isAscending() ^ previous) {
943                                                    query.append(WHERE_GREATER_THAN);
944                                            }
945                                            else {
946                                                    query.append(WHERE_LESSER_THAN);
947                                            }
948                                    }
949                            }
950    
951                            query.append(ORDER_BY_CLAUSE);
952    
953                            String[] orderByFields = orderByComparator.getOrderByFields();
954    
955                            for (int i = 0; i < orderByFields.length; i++) {
956                                    query.append(_ORDER_BY_ENTITY_ALIAS);
957                                    query.append(orderByFields[i]);
958    
959                                    if ((i + 1) < orderByFields.length) {
960                                            if (orderByComparator.isAscending() ^ previous) {
961                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
962                                            }
963                                            else {
964                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
965                                            }
966                                    }
967                                    else {
968                                            if (orderByComparator.isAscending() ^ previous) {
969                                                    query.append(ORDER_BY_ASC);
970                                            }
971                                            else {
972                                                    query.append(ORDER_BY_DESC);
973                                            }
974                                    }
975                            }
976                    }
977    
978                    else {
979                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
980                    }
981    
982                    String sql = query.toString();
983    
984                    Query q = session.createQuery(sql);
985    
986                    q.setFirstResult(0);
987                    q.setMaxResults(2);
988    
989                    QueryPos qPos = QueryPos.getInstance(q);
990    
991                    qPos.add(companyId);
992    
993                    if (orderByComparator != null) {
994                            Object[] values = orderByComparator.getOrderByConditionValues(website);
995    
996                            for (Object value : values) {
997                                    qPos.add(value);
998                            }
999                    }
1000    
1001                    List<Website> list = q.list();
1002    
1003                    if (list.size() == 2) {
1004                            return list.get(1);
1005                    }
1006                    else {
1007                            return null;
1008                    }
1009            }
1010    
1011            /**
1012             * Returns all the websites where userId = &#63;.
1013             *
1014             * @param userId the user ID
1015             * @return the matching websites
1016             * @throws SystemException if a system exception occurred
1017             */
1018            public List<Website> findByUserId(long userId) throws SystemException {
1019                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1020            }
1021    
1022            /**
1023             * Returns a range of all the websites where userId = &#63;.
1024             *
1025             * <p>
1026             * 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.
1027             * </p>
1028             *
1029             * @param userId the user ID
1030             * @param start the lower bound of the range of websites
1031             * @param end the upper bound of the range of websites (not inclusive)
1032             * @return the range of matching websites
1033             * @throws SystemException if a system exception occurred
1034             */
1035            public List<Website> findByUserId(long userId, int start, int end)
1036                    throws SystemException {
1037                    return findByUserId(userId, start, end, null);
1038            }
1039    
1040            /**
1041             * Returns an ordered range of all the websites where userId = &#63;.
1042             *
1043             * <p>
1044             * 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.
1045             * </p>
1046             *
1047             * @param userId the user ID
1048             * @param start the lower bound of the range of websites
1049             * @param end the upper bound of the range of websites (not inclusive)
1050             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1051             * @return the ordered range of matching websites
1052             * @throws SystemException if a system exception occurred
1053             */
1054            public List<Website> findByUserId(long userId, int start, int end,
1055                    OrderByComparator orderByComparator) throws SystemException {
1056                    FinderPath finderPath = null;
1057                    Object[] finderArgs = null;
1058    
1059                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1060                                    (orderByComparator == null)) {
1061                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1062                            finderArgs = new Object[] { userId };
1063                    }
1064                    else {
1065                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1066                            finderArgs = new Object[] { userId, start, end, orderByComparator };
1067                    }
1068    
1069                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(finderPath,
1070                                    finderArgs, this);
1071    
1072                    if ((list != null) && !list.isEmpty()) {
1073                            for (Website website : list) {
1074                                    if ((userId != website.getUserId())) {
1075                                            list = null;
1076    
1077                                            break;
1078                                    }
1079                            }
1080                    }
1081    
1082                    if (list == null) {
1083                            StringBundler query = null;
1084    
1085                            if (orderByComparator != null) {
1086                                    query = new StringBundler(3 +
1087                                                    (orderByComparator.getOrderByFields().length * 3));
1088                            }
1089                            else {
1090                                    query = new StringBundler(3);
1091                            }
1092    
1093                            query.append(_SQL_SELECT_WEBSITE_WHERE);
1094    
1095                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1096    
1097                            if (orderByComparator != null) {
1098                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1099                                            orderByComparator);
1100                            }
1101    
1102                            else {
1103                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1104                            }
1105    
1106                            String sql = query.toString();
1107    
1108                            Session session = null;
1109    
1110                            try {
1111                                    session = openSession();
1112    
1113                                    Query q = session.createQuery(sql);
1114    
1115                                    QueryPos qPos = QueryPos.getInstance(q);
1116    
1117                                    qPos.add(userId);
1118    
1119                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
1120                            }
1121                            catch (Exception e) {
1122                                    throw processException(e);
1123                            }
1124                            finally {
1125                                    if (list == null) {
1126                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1127                                    }
1128                                    else {
1129                                            cacheResult(list);
1130    
1131                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1132                                    }
1133    
1134                                    closeSession(session);
1135                            }
1136                    }
1137    
1138                    return list;
1139            }
1140    
1141            /**
1142             * Returns the first website in the ordered set where userId = &#63;.
1143             *
1144             * @param userId the user ID
1145             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1146             * @return the first matching website
1147             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
1148             * @throws SystemException if a system exception occurred
1149             */
1150            public Website findByUserId_First(long userId,
1151                    OrderByComparator orderByComparator)
1152                    throws NoSuchWebsiteException, SystemException {
1153                    Website website = fetchByUserId_First(userId, orderByComparator);
1154    
1155                    if (website != null) {
1156                            return website;
1157                    }
1158    
1159                    StringBundler msg = new StringBundler(4);
1160    
1161                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1162    
1163                    msg.append("userId=");
1164                    msg.append(userId);
1165    
1166                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1167    
1168                    throw new NoSuchWebsiteException(msg.toString());
1169            }
1170    
1171            /**
1172             * Returns the first website in the ordered set where userId = &#63;.
1173             *
1174             * @param userId the user ID
1175             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1176             * @return the first matching website, or <code>null</code> if a matching website could not be found
1177             * @throws SystemException if a system exception occurred
1178             */
1179            public Website fetchByUserId_First(long userId,
1180                    OrderByComparator orderByComparator) throws SystemException {
1181                    List<Website> list = findByUserId(userId, 0, 1, orderByComparator);
1182    
1183                    if (!list.isEmpty()) {
1184                            return list.get(0);
1185                    }
1186    
1187                    return null;
1188            }
1189    
1190            /**
1191             * Returns the last website in the ordered set where userId = &#63;.
1192             *
1193             * @param userId the user ID
1194             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1195             * @return the last matching website
1196             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
1197             * @throws SystemException if a system exception occurred
1198             */
1199            public Website findByUserId_Last(long userId,
1200                    OrderByComparator orderByComparator)
1201                    throws NoSuchWebsiteException, SystemException {
1202                    Website website = fetchByUserId_Last(userId, orderByComparator);
1203    
1204                    if (website != null) {
1205                            return website;
1206                    }
1207    
1208                    StringBundler msg = new StringBundler(4);
1209    
1210                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1211    
1212                    msg.append("userId=");
1213                    msg.append(userId);
1214    
1215                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1216    
1217                    throw new NoSuchWebsiteException(msg.toString());
1218            }
1219    
1220            /**
1221             * Returns the last website in the ordered set where userId = &#63;.
1222             *
1223             * @param userId the user ID
1224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1225             * @return the last matching website, or <code>null</code> if a matching website could not be found
1226             * @throws SystemException if a system exception occurred
1227             */
1228            public Website fetchByUserId_Last(long userId,
1229                    OrderByComparator orderByComparator) throws SystemException {
1230                    int count = countByUserId(userId);
1231    
1232                    List<Website> list = findByUserId(userId, count - 1, count,
1233                                    orderByComparator);
1234    
1235                    if (!list.isEmpty()) {
1236                            return list.get(0);
1237                    }
1238    
1239                    return null;
1240            }
1241    
1242            /**
1243             * Returns the websites before and after the current website in the ordered set where userId = &#63;.
1244             *
1245             * @param websiteId the primary key of the current website
1246             * @param userId the user ID
1247             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1248             * @return the previous, current, and next website
1249             * @throws com.liferay.portal.NoSuchWebsiteException if a website with the primary key could not be found
1250             * @throws SystemException if a system exception occurred
1251             */
1252            public Website[] findByUserId_PrevAndNext(long websiteId, long userId,
1253                    OrderByComparator orderByComparator)
1254                    throws NoSuchWebsiteException, SystemException {
1255                    Website website = findByPrimaryKey(websiteId);
1256    
1257                    Session session = null;
1258    
1259                    try {
1260                            session = openSession();
1261    
1262                            Website[] array = new WebsiteImpl[3];
1263    
1264                            array[0] = getByUserId_PrevAndNext(session, website, userId,
1265                                            orderByComparator, true);
1266    
1267                            array[1] = website;
1268    
1269                            array[2] = getByUserId_PrevAndNext(session, website, userId,
1270                                            orderByComparator, false);
1271    
1272                            return array;
1273                    }
1274                    catch (Exception e) {
1275                            throw processException(e);
1276                    }
1277                    finally {
1278                            closeSession(session);
1279                    }
1280            }
1281    
1282            protected Website getByUserId_PrevAndNext(Session session, Website website,
1283                    long userId, OrderByComparator orderByComparator, boolean previous) {
1284                    StringBundler query = null;
1285    
1286                    if (orderByComparator != null) {
1287                            query = new StringBundler(6 +
1288                                            (orderByComparator.getOrderByFields().length * 6));
1289                    }
1290                    else {
1291                            query = new StringBundler(3);
1292                    }
1293    
1294                    query.append(_SQL_SELECT_WEBSITE_WHERE);
1295    
1296                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1297    
1298                    if (orderByComparator != null) {
1299                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1300    
1301                            if (orderByConditionFields.length > 0) {
1302                                    query.append(WHERE_AND);
1303                            }
1304    
1305                            for (int i = 0; i < orderByConditionFields.length; i++) {
1306                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1307                                    query.append(orderByConditionFields[i]);
1308    
1309                                    if ((i + 1) < orderByConditionFields.length) {
1310                                            if (orderByComparator.isAscending() ^ previous) {
1311                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1312                                            }
1313                                            else {
1314                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1315                                            }
1316                                    }
1317                                    else {
1318                                            if (orderByComparator.isAscending() ^ previous) {
1319                                                    query.append(WHERE_GREATER_THAN);
1320                                            }
1321                                            else {
1322                                                    query.append(WHERE_LESSER_THAN);
1323                                            }
1324                                    }
1325                            }
1326    
1327                            query.append(ORDER_BY_CLAUSE);
1328    
1329                            String[] orderByFields = orderByComparator.getOrderByFields();
1330    
1331                            for (int i = 0; i < orderByFields.length; i++) {
1332                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1333                                    query.append(orderByFields[i]);
1334    
1335                                    if ((i + 1) < orderByFields.length) {
1336                                            if (orderByComparator.isAscending() ^ previous) {
1337                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1338                                            }
1339                                            else {
1340                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1341                                            }
1342                                    }
1343                                    else {
1344                                            if (orderByComparator.isAscending() ^ previous) {
1345                                                    query.append(ORDER_BY_ASC);
1346                                            }
1347                                            else {
1348                                                    query.append(ORDER_BY_DESC);
1349                                            }
1350                                    }
1351                            }
1352                    }
1353    
1354                    else {
1355                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1356                    }
1357    
1358                    String sql = query.toString();
1359    
1360                    Query q = session.createQuery(sql);
1361    
1362                    q.setFirstResult(0);
1363                    q.setMaxResults(2);
1364    
1365                    QueryPos qPos = QueryPos.getInstance(q);
1366    
1367                    qPos.add(userId);
1368    
1369                    if (orderByComparator != null) {
1370                            Object[] values = orderByComparator.getOrderByConditionValues(website);
1371    
1372                            for (Object value : values) {
1373                                    qPos.add(value);
1374                            }
1375                    }
1376    
1377                    List<Website> list = q.list();
1378    
1379                    if (list.size() == 2) {
1380                            return list.get(1);
1381                    }
1382                    else {
1383                            return null;
1384                    }
1385            }
1386    
1387            /**
1388             * Returns all the websites where companyId = &#63; and classNameId = &#63;.
1389             *
1390             * @param companyId the company ID
1391             * @param classNameId the class name ID
1392             * @return the matching websites
1393             * @throws SystemException if a system exception occurred
1394             */
1395            public List<Website> findByC_C(long companyId, long classNameId)
1396                    throws SystemException {
1397                    return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
1398                            QueryUtil.ALL_POS, null);
1399            }
1400    
1401            /**
1402             * Returns a range of all the websites where companyId = &#63; and classNameId = &#63;.
1403             *
1404             * <p>
1405             * 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.
1406             * </p>
1407             *
1408             * @param companyId the company ID
1409             * @param classNameId the class name ID
1410             * @param start the lower bound of the range of websites
1411             * @param end the upper bound of the range of websites (not inclusive)
1412             * @return the range of matching websites
1413             * @throws SystemException if a system exception occurred
1414             */
1415            public List<Website> findByC_C(long companyId, long classNameId, int start,
1416                    int end) throws SystemException {
1417                    return findByC_C(companyId, classNameId, start, end, null);
1418            }
1419    
1420            /**
1421             * Returns an ordered range of all the websites where companyId = &#63; and classNameId = &#63;.
1422             *
1423             * <p>
1424             * 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.
1425             * </p>
1426             *
1427             * @param companyId the company ID
1428             * @param classNameId the class name ID
1429             * @param start the lower bound of the range of websites
1430             * @param end the upper bound of the range of websites (not inclusive)
1431             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1432             * @return the ordered range of matching websites
1433             * @throws SystemException if a system exception occurred
1434             */
1435            public List<Website> findByC_C(long companyId, long classNameId, int start,
1436                    int end, OrderByComparator orderByComparator) throws SystemException {
1437                    FinderPath finderPath = null;
1438                    Object[] finderArgs = null;
1439    
1440                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1441                                    (orderByComparator == null)) {
1442                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
1443                            finderArgs = new Object[] { companyId, classNameId };
1444                    }
1445                    else {
1446                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
1447                            finderArgs = new Object[] {
1448                                            companyId, classNameId,
1449                                            
1450                                            start, end, orderByComparator
1451                                    };
1452                    }
1453    
1454                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(finderPath,
1455                                    finderArgs, this);
1456    
1457                    if ((list != null) && !list.isEmpty()) {
1458                            for (Website website : list) {
1459                                    if ((companyId != website.getCompanyId()) ||
1460                                                    (classNameId != website.getClassNameId())) {
1461                                            list = null;
1462    
1463                                            break;
1464                                    }
1465                            }
1466                    }
1467    
1468                    if (list == null) {
1469                            StringBundler query = null;
1470    
1471                            if (orderByComparator != null) {
1472                                    query = new StringBundler(4 +
1473                                                    (orderByComparator.getOrderByFields().length * 3));
1474                            }
1475                            else {
1476                                    query = new StringBundler(4);
1477                            }
1478    
1479                            query.append(_SQL_SELECT_WEBSITE_WHERE);
1480    
1481                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1482    
1483                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1484    
1485                            if (orderByComparator != null) {
1486                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1487                                            orderByComparator);
1488                            }
1489    
1490                            else {
1491                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1492                            }
1493    
1494                            String sql = query.toString();
1495    
1496                            Session session = null;
1497    
1498                            try {
1499                                    session = openSession();
1500    
1501                                    Query q = session.createQuery(sql);
1502    
1503                                    QueryPos qPos = QueryPos.getInstance(q);
1504    
1505                                    qPos.add(companyId);
1506    
1507                                    qPos.add(classNameId);
1508    
1509                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
1510                            }
1511                            catch (Exception e) {
1512                                    throw processException(e);
1513                            }
1514                            finally {
1515                                    if (list == null) {
1516                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1517                                    }
1518                                    else {
1519                                            cacheResult(list);
1520    
1521                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1522                                    }
1523    
1524                                    closeSession(session);
1525                            }
1526                    }
1527    
1528                    return list;
1529            }
1530    
1531            /**
1532             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63;.
1533             *
1534             * @param companyId the company ID
1535             * @param classNameId the class name ID
1536             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1537             * @return the first matching website
1538             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
1539             * @throws SystemException if a system exception occurred
1540             */
1541            public Website findByC_C_First(long companyId, long classNameId,
1542                    OrderByComparator orderByComparator)
1543                    throws NoSuchWebsiteException, SystemException {
1544                    Website website = fetchByC_C_First(companyId, classNameId,
1545                                    orderByComparator);
1546    
1547                    if (website != null) {
1548                            return website;
1549                    }
1550    
1551                    StringBundler msg = new StringBundler(6);
1552    
1553                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1554    
1555                    msg.append("companyId=");
1556                    msg.append(companyId);
1557    
1558                    msg.append(", classNameId=");
1559                    msg.append(classNameId);
1560    
1561                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1562    
1563                    throw new NoSuchWebsiteException(msg.toString());
1564            }
1565    
1566            /**
1567             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63;.
1568             *
1569             * @param companyId the company ID
1570             * @param classNameId the class name ID
1571             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1572             * @return the first matching website, or <code>null</code> if a matching website could not be found
1573             * @throws SystemException if a system exception occurred
1574             */
1575            public Website fetchByC_C_First(long companyId, long classNameId,
1576                    OrderByComparator orderByComparator) throws SystemException {
1577                    List<Website> list = findByC_C(companyId, classNameId, 0, 1,
1578                                    orderByComparator);
1579    
1580                    if (!list.isEmpty()) {
1581                            return list.get(0);
1582                    }
1583    
1584                    return null;
1585            }
1586    
1587            /**
1588             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63;.
1589             *
1590             * @param companyId the company ID
1591             * @param classNameId the class name ID
1592             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1593             * @return the last matching website
1594             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
1595             * @throws SystemException if a system exception occurred
1596             */
1597            public Website findByC_C_Last(long companyId, long classNameId,
1598                    OrderByComparator orderByComparator)
1599                    throws NoSuchWebsiteException, SystemException {
1600                    Website website = fetchByC_C_Last(companyId, classNameId,
1601                                    orderByComparator);
1602    
1603                    if (website != null) {
1604                            return website;
1605                    }
1606    
1607                    StringBundler msg = new StringBundler(6);
1608    
1609                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1610    
1611                    msg.append("companyId=");
1612                    msg.append(companyId);
1613    
1614                    msg.append(", classNameId=");
1615                    msg.append(classNameId);
1616    
1617                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1618    
1619                    throw new NoSuchWebsiteException(msg.toString());
1620            }
1621    
1622            /**
1623             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63;.
1624             *
1625             * @param companyId the company ID
1626             * @param classNameId the class name ID
1627             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1628             * @return the last matching website, or <code>null</code> if a matching website could not be found
1629             * @throws SystemException if a system exception occurred
1630             */
1631            public Website fetchByC_C_Last(long companyId, long classNameId,
1632                    OrderByComparator orderByComparator) throws SystemException {
1633                    int count = countByC_C(companyId, classNameId);
1634    
1635                    List<Website> list = findByC_C(companyId, classNameId, count - 1,
1636                                    count, orderByComparator);
1637    
1638                    if (!list.isEmpty()) {
1639                            return list.get(0);
1640                    }
1641    
1642                    return null;
1643            }
1644    
1645            /**
1646             * Returns the websites before and after the current website in the ordered set where companyId = &#63; and classNameId = &#63;.
1647             *
1648             * @param websiteId the primary key of the current website
1649             * @param companyId the company ID
1650             * @param classNameId the class name ID
1651             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1652             * @return the previous, current, and next website
1653             * @throws com.liferay.portal.NoSuchWebsiteException if a website with the primary key could not be found
1654             * @throws SystemException if a system exception occurred
1655             */
1656            public Website[] findByC_C_PrevAndNext(long websiteId, long companyId,
1657                    long classNameId, OrderByComparator orderByComparator)
1658                    throws NoSuchWebsiteException, SystemException {
1659                    Website website = findByPrimaryKey(websiteId);
1660    
1661                    Session session = null;
1662    
1663                    try {
1664                            session = openSession();
1665    
1666                            Website[] array = new WebsiteImpl[3];
1667    
1668                            array[0] = getByC_C_PrevAndNext(session, website, companyId,
1669                                            classNameId, orderByComparator, true);
1670    
1671                            array[1] = website;
1672    
1673                            array[2] = getByC_C_PrevAndNext(session, website, companyId,
1674                                            classNameId, orderByComparator, false);
1675    
1676                            return array;
1677                    }
1678                    catch (Exception e) {
1679                            throw processException(e);
1680                    }
1681                    finally {
1682                            closeSession(session);
1683                    }
1684            }
1685    
1686            protected Website getByC_C_PrevAndNext(Session session, Website website,
1687                    long companyId, long classNameId, OrderByComparator orderByComparator,
1688                    boolean previous) {
1689                    StringBundler query = null;
1690    
1691                    if (orderByComparator != null) {
1692                            query = new StringBundler(6 +
1693                                            (orderByComparator.getOrderByFields().length * 6));
1694                    }
1695                    else {
1696                            query = new StringBundler(3);
1697                    }
1698    
1699                    query.append(_SQL_SELECT_WEBSITE_WHERE);
1700    
1701                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1702    
1703                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1704    
1705                    if (orderByComparator != null) {
1706                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1707    
1708                            if (orderByConditionFields.length > 0) {
1709                                    query.append(WHERE_AND);
1710                            }
1711    
1712                            for (int i = 0; i < orderByConditionFields.length; i++) {
1713                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1714                                    query.append(orderByConditionFields[i]);
1715    
1716                                    if ((i + 1) < orderByConditionFields.length) {
1717                                            if (orderByComparator.isAscending() ^ previous) {
1718                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1719                                            }
1720                                            else {
1721                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1722                                            }
1723                                    }
1724                                    else {
1725                                            if (orderByComparator.isAscending() ^ previous) {
1726                                                    query.append(WHERE_GREATER_THAN);
1727                                            }
1728                                            else {
1729                                                    query.append(WHERE_LESSER_THAN);
1730                                            }
1731                                    }
1732                            }
1733    
1734                            query.append(ORDER_BY_CLAUSE);
1735    
1736                            String[] orderByFields = orderByComparator.getOrderByFields();
1737    
1738                            for (int i = 0; i < orderByFields.length; i++) {
1739                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1740                                    query.append(orderByFields[i]);
1741    
1742                                    if ((i + 1) < orderByFields.length) {
1743                                            if (orderByComparator.isAscending() ^ previous) {
1744                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1745                                            }
1746                                            else {
1747                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1748                                            }
1749                                    }
1750                                    else {
1751                                            if (orderByComparator.isAscending() ^ previous) {
1752                                                    query.append(ORDER_BY_ASC);
1753                                            }
1754                                            else {
1755                                                    query.append(ORDER_BY_DESC);
1756                                            }
1757                                    }
1758                            }
1759                    }
1760    
1761                    else {
1762                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1763                    }
1764    
1765                    String sql = query.toString();
1766    
1767                    Query q = session.createQuery(sql);
1768    
1769                    q.setFirstResult(0);
1770                    q.setMaxResults(2);
1771    
1772                    QueryPos qPos = QueryPos.getInstance(q);
1773    
1774                    qPos.add(companyId);
1775    
1776                    qPos.add(classNameId);
1777    
1778                    if (orderByComparator != null) {
1779                            Object[] values = orderByComparator.getOrderByConditionValues(website);
1780    
1781                            for (Object value : values) {
1782                                    qPos.add(value);
1783                            }
1784                    }
1785    
1786                    List<Website> list = q.list();
1787    
1788                    if (list.size() == 2) {
1789                            return list.get(1);
1790                    }
1791                    else {
1792                            return null;
1793                    }
1794            }
1795    
1796            /**
1797             * Returns all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1798             *
1799             * @param companyId the company ID
1800             * @param classNameId the class name ID
1801             * @param classPK the class p k
1802             * @return the matching websites
1803             * @throws SystemException if a system exception occurred
1804             */
1805            public List<Website> findByC_C_C(long companyId, long classNameId,
1806                    long classPK) throws SystemException {
1807                    return findByC_C_C(companyId, classNameId, classPK, QueryUtil.ALL_POS,
1808                            QueryUtil.ALL_POS, null);
1809            }
1810    
1811            /**
1812             * Returns a range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1813             *
1814             * <p>
1815             * 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.
1816             * </p>
1817             *
1818             * @param companyId the company ID
1819             * @param classNameId the class name ID
1820             * @param classPK the class p k
1821             * @param start the lower bound of the range of websites
1822             * @param end the upper bound of the range of websites (not inclusive)
1823             * @return the range of matching websites
1824             * @throws SystemException if a system exception occurred
1825             */
1826            public List<Website> findByC_C_C(long companyId, long classNameId,
1827                    long classPK, int start, int end) throws SystemException {
1828                    return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1829            }
1830    
1831            /**
1832             * Returns an ordered range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1833             *
1834             * <p>
1835             * 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.
1836             * </p>
1837             *
1838             * @param companyId the company ID
1839             * @param classNameId the class name ID
1840             * @param classPK the class p k
1841             * @param start the lower bound of the range of websites
1842             * @param end the upper bound of the range of websites (not inclusive)
1843             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1844             * @return the ordered range of matching websites
1845             * @throws SystemException if a system exception occurred
1846             */
1847            public List<Website> findByC_C_C(long companyId, long classNameId,
1848                    long classPK, int start, int end, OrderByComparator orderByComparator)
1849                    throws SystemException {
1850                    FinderPath finderPath = null;
1851                    Object[] finderArgs = null;
1852    
1853                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1854                                    (orderByComparator == null)) {
1855                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C;
1856                            finderArgs = new Object[] { companyId, classNameId, classPK };
1857                    }
1858                    else {
1859                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C;
1860                            finderArgs = new Object[] {
1861                                            companyId, classNameId, classPK,
1862                                            
1863                                            start, end, orderByComparator
1864                                    };
1865                    }
1866    
1867                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(finderPath,
1868                                    finderArgs, this);
1869    
1870                    if ((list != null) && !list.isEmpty()) {
1871                            for (Website website : list) {
1872                                    if ((companyId != website.getCompanyId()) ||
1873                                                    (classNameId != website.getClassNameId()) ||
1874                                                    (classPK != website.getClassPK())) {
1875                                            list = null;
1876    
1877                                            break;
1878                                    }
1879                            }
1880                    }
1881    
1882                    if (list == null) {
1883                            StringBundler query = null;
1884    
1885                            if (orderByComparator != null) {
1886                                    query = new StringBundler(5 +
1887                                                    (orderByComparator.getOrderByFields().length * 3));
1888                            }
1889                            else {
1890                                    query = new StringBundler(5);
1891                            }
1892    
1893                            query.append(_SQL_SELECT_WEBSITE_WHERE);
1894    
1895                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1896    
1897                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1898    
1899                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1900    
1901                            if (orderByComparator != null) {
1902                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1903                                            orderByComparator);
1904                            }
1905    
1906                            else {
1907                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1908                            }
1909    
1910                            String sql = query.toString();
1911    
1912                            Session session = null;
1913    
1914                            try {
1915                                    session = openSession();
1916    
1917                                    Query q = session.createQuery(sql);
1918    
1919                                    QueryPos qPos = QueryPos.getInstance(q);
1920    
1921                                    qPos.add(companyId);
1922    
1923                                    qPos.add(classNameId);
1924    
1925                                    qPos.add(classPK);
1926    
1927                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
1928                            }
1929                            catch (Exception e) {
1930                                    throw processException(e);
1931                            }
1932                            finally {
1933                                    if (list == null) {
1934                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1935                                    }
1936                                    else {
1937                                            cacheResult(list);
1938    
1939                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1940                                    }
1941    
1942                                    closeSession(session);
1943                            }
1944                    }
1945    
1946                    return list;
1947            }
1948    
1949            /**
1950             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1951             *
1952             * @param companyId the company ID
1953             * @param classNameId the class name ID
1954             * @param classPK the class p k
1955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1956             * @return the first matching website
1957             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
1958             * @throws SystemException if a system exception occurred
1959             */
1960            public Website findByC_C_C_First(long companyId, long classNameId,
1961                    long classPK, OrderByComparator orderByComparator)
1962                    throws NoSuchWebsiteException, SystemException {
1963                    Website website = fetchByC_C_C_First(companyId, classNameId, classPK,
1964                                    orderByComparator);
1965    
1966                    if (website != null) {
1967                            return website;
1968                    }
1969    
1970                    StringBundler msg = new StringBundler(8);
1971    
1972                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1973    
1974                    msg.append("companyId=");
1975                    msg.append(companyId);
1976    
1977                    msg.append(", classNameId=");
1978                    msg.append(classNameId);
1979    
1980                    msg.append(", classPK=");
1981                    msg.append(classPK);
1982    
1983                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1984    
1985                    throw new NoSuchWebsiteException(msg.toString());
1986            }
1987    
1988            /**
1989             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1990             *
1991             * @param companyId the company ID
1992             * @param classNameId the class name ID
1993             * @param classPK the class p k
1994             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1995             * @return the first matching website, or <code>null</code> if a matching website could not be found
1996             * @throws SystemException if a system exception occurred
1997             */
1998            public Website fetchByC_C_C_First(long companyId, long classNameId,
1999                    long classPK, OrderByComparator orderByComparator)
2000                    throws SystemException {
2001                    List<Website> list = findByC_C_C(companyId, classNameId, classPK, 0, 1,
2002                                    orderByComparator);
2003    
2004                    if (!list.isEmpty()) {
2005                            return list.get(0);
2006                    }
2007    
2008                    return null;
2009            }
2010    
2011            /**
2012             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
2013             *
2014             * @param companyId the company ID
2015             * @param classNameId the class name ID
2016             * @param classPK the class p k
2017             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2018             * @return the last matching website
2019             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
2020             * @throws SystemException if a system exception occurred
2021             */
2022            public Website findByC_C_C_Last(long companyId, long classNameId,
2023                    long classPK, OrderByComparator orderByComparator)
2024                    throws NoSuchWebsiteException, SystemException {
2025                    Website website = fetchByC_C_C_Last(companyId, classNameId, classPK,
2026                                    orderByComparator);
2027    
2028                    if (website != null) {
2029                            return website;
2030                    }
2031    
2032                    StringBundler msg = new StringBundler(8);
2033    
2034                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2035    
2036                    msg.append("companyId=");
2037                    msg.append(companyId);
2038    
2039                    msg.append(", classNameId=");
2040                    msg.append(classNameId);
2041    
2042                    msg.append(", classPK=");
2043                    msg.append(classPK);
2044    
2045                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2046    
2047                    throw new NoSuchWebsiteException(msg.toString());
2048            }
2049    
2050            /**
2051             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
2052             *
2053             * @param companyId the company ID
2054             * @param classNameId the class name ID
2055             * @param classPK the class p k
2056             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2057             * @return the last matching website, or <code>null</code> if a matching website could not be found
2058             * @throws SystemException if a system exception occurred
2059             */
2060            public Website fetchByC_C_C_Last(long companyId, long classNameId,
2061                    long classPK, OrderByComparator orderByComparator)
2062                    throws SystemException {
2063                    int count = countByC_C_C(companyId, classNameId, classPK);
2064    
2065                    List<Website> list = findByC_C_C(companyId, classNameId, classPK,
2066                                    count - 1, count, orderByComparator);
2067    
2068                    if (!list.isEmpty()) {
2069                            return list.get(0);
2070                    }
2071    
2072                    return null;
2073            }
2074    
2075            /**
2076             * Returns the websites before and after the current website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
2077             *
2078             * @param websiteId the primary key of the current website
2079             * @param companyId the company ID
2080             * @param classNameId the class name ID
2081             * @param classPK the class p k
2082             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2083             * @return the previous, current, and next website
2084             * @throws com.liferay.portal.NoSuchWebsiteException if a website with the primary key could not be found
2085             * @throws SystemException if a system exception occurred
2086             */
2087            public Website[] findByC_C_C_PrevAndNext(long websiteId, long companyId,
2088                    long classNameId, long classPK, OrderByComparator orderByComparator)
2089                    throws NoSuchWebsiteException, SystemException {
2090                    Website website = findByPrimaryKey(websiteId);
2091    
2092                    Session session = null;
2093    
2094                    try {
2095                            session = openSession();
2096    
2097                            Website[] array = new WebsiteImpl[3];
2098    
2099                            array[0] = getByC_C_C_PrevAndNext(session, website, companyId,
2100                                            classNameId, classPK, orderByComparator, true);
2101    
2102                            array[1] = website;
2103    
2104                            array[2] = getByC_C_C_PrevAndNext(session, website, companyId,
2105                                            classNameId, classPK, orderByComparator, false);
2106    
2107                            return array;
2108                    }
2109                    catch (Exception e) {
2110                            throw processException(e);
2111                    }
2112                    finally {
2113                            closeSession(session);
2114                    }
2115            }
2116    
2117            protected Website getByC_C_C_PrevAndNext(Session session, Website website,
2118                    long companyId, long classNameId, long classPK,
2119                    OrderByComparator orderByComparator, boolean previous) {
2120                    StringBundler query = null;
2121    
2122                    if (orderByComparator != null) {
2123                            query = new StringBundler(6 +
2124                                            (orderByComparator.getOrderByFields().length * 6));
2125                    }
2126                    else {
2127                            query = new StringBundler(3);
2128                    }
2129    
2130                    query.append(_SQL_SELECT_WEBSITE_WHERE);
2131    
2132                    query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2133    
2134                    query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2135    
2136                    query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2137    
2138                    if (orderByComparator != null) {
2139                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2140    
2141                            if (orderByConditionFields.length > 0) {
2142                                    query.append(WHERE_AND);
2143                            }
2144    
2145                            for (int i = 0; i < orderByConditionFields.length; i++) {
2146                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2147                                    query.append(orderByConditionFields[i]);
2148    
2149                                    if ((i + 1) < orderByConditionFields.length) {
2150                                            if (orderByComparator.isAscending() ^ previous) {
2151                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2152                                            }
2153                                            else {
2154                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2155                                            }
2156                                    }
2157                                    else {
2158                                            if (orderByComparator.isAscending() ^ previous) {
2159                                                    query.append(WHERE_GREATER_THAN);
2160                                            }
2161                                            else {
2162                                                    query.append(WHERE_LESSER_THAN);
2163                                            }
2164                                    }
2165                            }
2166    
2167                            query.append(ORDER_BY_CLAUSE);
2168    
2169                            String[] orderByFields = orderByComparator.getOrderByFields();
2170    
2171                            for (int i = 0; i < orderByFields.length; i++) {
2172                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2173                                    query.append(orderByFields[i]);
2174    
2175                                    if ((i + 1) < orderByFields.length) {
2176                                            if (orderByComparator.isAscending() ^ previous) {
2177                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2178                                            }
2179                                            else {
2180                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2181                                            }
2182                                    }
2183                                    else {
2184                                            if (orderByComparator.isAscending() ^ previous) {
2185                                                    query.append(ORDER_BY_ASC);
2186                                            }
2187                                            else {
2188                                                    query.append(ORDER_BY_DESC);
2189                                            }
2190                                    }
2191                            }
2192                    }
2193    
2194                    else {
2195                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
2196                    }
2197    
2198                    String sql = query.toString();
2199    
2200                    Query q = session.createQuery(sql);
2201    
2202                    q.setFirstResult(0);
2203                    q.setMaxResults(2);
2204    
2205                    QueryPos qPos = QueryPos.getInstance(q);
2206    
2207                    qPos.add(companyId);
2208    
2209                    qPos.add(classNameId);
2210    
2211                    qPos.add(classPK);
2212    
2213                    if (orderByComparator != null) {
2214                            Object[] values = orderByComparator.getOrderByConditionValues(website);
2215    
2216                            for (Object value : values) {
2217                                    qPos.add(value);
2218                            }
2219                    }
2220    
2221                    List<Website> list = q.list();
2222    
2223                    if (list.size() == 2) {
2224                            return list.get(1);
2225                    }
2226                    else {
2227                            return null;
2228                    }
2229            }
2230    
2231            /**
2232             * Returns all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
2233             *
2234             * @param companyId the company ID
2235             * @param classNameId the class name ID
2236             * @param classPK the class p k
2237             * @param primary the primary
2238             * @return the matching websites
2239             * @throws SystemException if a system exception occurred
2240             */
2241            public List<Website> findByC_C_C_P(long companyId, long classNameId,
2242                    long classPK, boolean primary) throws SystemException {
2243                    return findByC_C_C_P(companyId, classNameId, classPK, primary,
2244                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2245            }
2246    
2247            /**
2248             * Returns a range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
2249             *
2250             * <p>
2251             * 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.
2252             * </p>
2253             *
2254             * @param companyId the company ID
2255             * @param classNameId the class name ID
2256             * @param classPK the class p k
2257             * @param primary the primary
2258             * @param start the lower bound of the range of websites
2259             * @param end the upper bound of the range of websites (not inclusive)
2260             * @return the range of matching websites
2261             * @throws SystemException if a system exception occurred
2262             */
2263            public List<Website> findByC_C_C_P(long companyId, long classNameId,
2264                    long classPK, boolean primary, int start, int end)
2265                    throws SystemException {
2266                    return findByC_C_C_P(companyId, classNameId, classPK, primary, start,
2267                            end, null);
2268            }
2269    
2270            /**
2271             * Returns an ordered range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
2272             *
2273             * <p>
2274             * 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.
2275             * </p>
2276             *
2277             * @param companyId the company ID
2278             * @param classNameId the class name ID
2279             * @param classPK the class p k
2280             * @param primary the primary
2281             * @param start the lower bound of the range of websites
2282             * @param end the upper bound of the range of websites (not inclusive)
2283             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2284             * @return the ordered range of matching websites
2285             * @throws SystemException if a system exception occurred
2286             */
2287            public List<Website> findByC_C_C_P(long companyId, long classNameId,
2288                    long classPK, boolean primary, int start, int end,
2289                    OrderByComparator orderByComparator) throws SystemException {
2290                    FinderPath finderPath = null;
2291                    Object[] finderArgs = null;
2292    
2293                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2294                                    (orderByComparator == null)) {
2295                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P;
2296                            finderArgs = new Object[] { companyId, classNameId, classPK, primary };
2297                    }
2298                    else {
2299                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C_P;
2300                            finderArgs = new Object[] {
2301                                            companyId, classNameId, classPK, primary,
2302                                            
2303                                            start, end, orderByComparator
2304                                    };
2305                    }
2306    
2307                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(finderPath,
2308                                    finderArgs, this);
2309    
2310                    if ((list != null) && !list.isEmpty()) {
2311                            for (Website website : list) {
2312                                    if ((companyId != website.getCompanyId()) ||
2313                                                    (classNameId != website.getClassNameId()) ||
2314                                                    (classPK != website.getClassPK()) ||
2315                                                    (primary != website.getPrimary())) {
2316                                            list = null;
2317    
2318                                            break;
2319                                    }
2320                            }
2321                    }
2322    
2323                    if (list == null) {
2324                            StringBundler query = null;
2325    
2326                            if (orderByComparator != null) {
2327                                    query = new StringBundler(6 +
2328                                                    (orderByComparator.getOrderByFields().length * 3));
2329                            }
2330                            else {
2331                                    query = new StringBundler(6);
2332                            }
2333    
2334                            query.append(_SQL_SELECT_WEBSITE_WHERE);
2335    
2336                            query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2337    
2338                            query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2339    
2340                            query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2341    
2342                            query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2343    
2344                            if (orderByComparator != null) {
2345                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2346                                            orderByComparator);
2347                            }
2348    
2349                            else {
2350                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
2351                            }
2352    
2353                            String sql = query.toString();
2354    
2355                            Session session = null;
2356    
2357                            try {
2358                                    session = openSession();
2359    
2360                                    Query q = session.createQuery(sql);
2361    
2362                                    QueryPos qPos = QueryPos.getInstance(q);
2363    
2364                                    qPos.add(companyId);
2365    
2366                                    qPos.add(classNameId);
2367    
2368                                    qPos.add(classPK);
2369    
2370                                    qPos.add(primary);
2371    
2372                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
2373                            }
2374                            catch (Exception e) {
2375                                    throw processException(e);
2376                            }
2377                            finally {
2378                                    if (list == null) {
2379                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2380                                    }
2381                                    else {
2382                                            cacheResult(list);
2383    
2384                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2385                                    }
2386    
2387                                    closeSession(session);
2388                            }
2389                    }
2390    
2391                    return list;
2392            }
2393    
2394            /**
2395             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
2396             *
2397             * @param companyId the company ID
2398             * @param classNameId the class name ID
2399             * @param classPK the class p k
2400             * @param primary the primary
2401             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2402             * @return the first matching website
2403             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
2404             * @throws SystemException if a system exception occurred
2405             */
2406            public Website findByC_C_C_P_First(long companyId, long classNameId,
2407                    long classPK, boolean primary, OrderByComparator orderByComparator)
2408                    throws NoSuchWebsiteException, SystemException {
2409                    Website website = fetchByC_C_C_P_First(companyId, classNameId, classPK,
2410                                    primary, orderByComparator);
2411    
2412                    if (website != null) {
2413                            return website;
2414                    }
2415    
2416                    StringBundler msg = new StringBundler(10);
2417    
2418                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2419    
2420                    msg.append("companyId=");
2421                    msg.append(companyId);
2422    
2423                    msg.append(", classNameId=");
2424                    msg.append(classNameId);
2425    
2426                    msg.append(", classPK=");
2427                    msg.append(classPK);
2428    
2429                    msg.append(", primary=");
2430                    msg.append(primary);
2431    
2432                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2433    
2434                    throw new NoSuchWebsiteException(msg.toString());
2435            }
2436    
2437            /**
2438             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
2439             *
2440             * @param companyId the company ID
2441             * @param classNameId the class name ID
2442             * @param classPK the class p k
2443             * @param primary the primary
2444             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2445             * @return the first matching website, or <code>null</code> if a matching website could not be found
2446             * @throws SystemException if a system exception occurred
2447             */
2448            public Website fetchByC_C_C_P_First(long companyId, long classNameId,
2449                    long classPK, boolean primary, OrderByComparator orderByComparator)
2450                    throws SystemException {
2451                    List<Website> list = findByC_C_C_P(companyId, classNameId, classPK,
2452                                    primary, 0, 1, orderByComparator);
2453    
2454                    if (!list.isEmpty()) {
2455                            return list.get(0);
2456                    }
2457    
2458                    return null;
2459            }
2460    
2461            /**
2462             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
2463             *
2464             * @param companyId the company ID
2465             * @param classNameId the class name ID
2466             * @param classPK the class p k
2467             * @param primary the primary
2468             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2469             * @return the last matching website
2470             * @throws com.liferay.portal.NoSuchWebsiteException if a matching website could not be found
2471             * @throws SystemException if a system exception occurred
2472             */
2473            public Website findByC_C_C_P_Last(long companyId, long classNameId,
2474                    long classPK, boolean primary, OrderByComparator orderByComparator)
2475                    throws NoSuchWebsiteException, SystemException {
2476                    Website website = fetchByC_C_C_P_Last(companyId, classNameId, classPK,
2477                                    primary, orderByComparator);
2478    
2479                    if (website != null) {
2480                            return website;
2481                    }
2482    
2483                    StringBundler msg = new StringBundler(10);
2484    
2485                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2486    
2487                    msg.append("companyId=");
2488                    msg.append(companyId);
2489    
2490                    msg.append(", classNameId=");
2491                    msg.append(classNameId);
2492    
2493                    msg.append(", classPK=");
2494                    msg.append(classPK);
2495    
2496                    msg.append(", primary=");
2497                    msg.append(primary);
2498    
2499                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2500    
2501                    throw new NoSuchWebsiteException(msg.toString());
2502            }
2503    
2504            /**
2505             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
2506             *
2507             * @param companyId the company ID
2508             * @param classNameId the class name ID
2509             * @param classPK the class p k
2510             * @param primary the primary
2511             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2512             * @return the last matching website, or <code>null</code> if a matching website could not be found
2513             * @throws SystemException if a system exception occurred
2514             */
2515            public Website fetchByC_C_C_P_Last(long companyId, long classNameId,
2516                    long classPK, boolean primary, OrderByComparator orderByComparator)
2517                    throws SystemException {
2518                    int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
2519    
2520                    List<Website> list = findByC_C_C_P(companyId, classNameId, classPK,
2521                                    primary, count - 1, count, orderByComparator);
2522    
2523                    if (!list.isEmpty()) {
2524                            return list.get(0);
2525                    }
2526    
2527                    return null;
2528            }
2529    
2530            /**
2531             * Returns the websites before and after the current website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
2532             *
2533             * @param websiteId the primary key of the current website
2534             * @param companyId the company ID
2535             * @param classNameId the class name ID
2536             * @param classPK the class p k
2537             * @param primary the primary
2538             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2539             * @return the previous, current, and next website
2540             * @throws com.liferay.portal.NoSuchWebsiteException if a website with the primary key could not be found
2541             * @throws SystemException if a system exception occurred
2542             */
2543            public Website[] findByC_C_C_P_PrevAndNext(long websiteId, long companyId,
2544                    long classNameId, long classPK, boolean primary,
2545                    OrderByComparator orderByComparator)
2546                    throws NoSuchWebsiteException, SystemException {
2547                    Website website = findByPrimaryKey(websiteId);
2548    
2549                    Session session = null;
2550    
2551                    try {
2552                            session = openSession();
2553    
2554                            Website[] array = new WebsiteImpl[3];
2555    
2556                            array[0] = getByC_C_C_P_PrevAndNext(session, website, companyId,
2557                                            classNameId, classPK, primary, orderByComparator, true);
2558    
2559                            array[1] = website;
2560    
2561                            array[2] = getByC_C_C_P_PrevAndNext(session, website, companyId,
2562                                            classNameId, classPK, primary, orderByComparator, false);
2563    
2564                            return array;
2565                    }
2566                    catch (Exception e) {
2567                            throw processException(e);
2568                    }
2569                    finally {
2570                            closeSession(session);
2571                    }
2572            }
2573    
2574            protected Website getByC_C_C_P_PrevAndNext(Session session,
2575                    Website website, long companyId, long classNameId, long classPK,
2576                    boolean primary, OrderByComparator orderByComparator, boolean previous) {
2577                    StringBundler query = null;
2578    
2579                    if (orderByComparator != null) {
2580                            query = new StringBundler(6 +
2581                                            (orderByComparator.getOrderByFields().length * 6));
2582                    }
2583                    else {
2584                            query = new StringBundler(3);
2585                    }
2586    
2587                    query.append(_SQL_SELECT_WEBSITE_WHERE);
2588    
2589                    query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2590    
2591                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2592    
2593                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2594    
2595                    query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2596    
2597                    if (orderByComparator != null) {
2598                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2599    
2600                            if (orderByConditionFields.length > 0) {
2601                                    query.append(WHERE_AND);
2602                            }
2603    
2604                            for (int i = 0; i < orderByConditionFields.length; i++) {
2605                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2606                                    query.append(orderByConditionFields[i]);
2607    
2608                                    if ((i + 1) < orderByConditionFields.length) {
2609                                            if (orderByComparator.isAscending() ^ previous) {
2610                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2611                                            }
2612                                            else {
2613                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2614                                            }
2615                                    }
2616                                    else {
2617                                            if (orderByComparator.isAscending() ^ previous) {
2618                                                    query.append(WHERE_GREATER_THAN);
2619                                            }
2620                                            else {
2621                                                    query.append(WHERE_LESSER_THAN);
2622                                            }
2623                                    }
2624                            }
2625    
2626                            query.append(ORDER_BY_CLAUSE);
2627    
2628                            String[] orderByFields = orderByComparator.getOrderByFields();
2629    
2630                            for (int i = 0; i < orderByFields.length; i++) {
2631                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2632                                    query.append(orderByFields[i]);
2633    
2634                                    if ((i + 1) < orderByFields.length) {
2635                                            if (orderByComparator.isAscending() ^ previous) {
2636                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2637                                            }
2638                                            else {
2639                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2640                                            }
2641                                    }
2642                                    else {
2643                                            if (orderByComparator.isAscending() ^ previous) {
2644                                                    query.append(ORDER_BY_ASC);
2645                                            }
2646                                            else {
2647                                                    query.append(ORDER_BY_DESC);
2648                                            }
2649                                    }
2650                            }
2651                    }
2652    
2653                    else {
2654                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
2655                    }
2656    
2657                    String sql = query.toString();
2658    
2659                    Query q = session.createQuery(sql);
2660    
2661                    q.setFirstResult(0);
2662                    q.setMaxResults(2);
2663    
2664                    QueryPos qPos = QueryPos.getInstance(q);
2665    
2666                    qPos.add(companyId);
2667    
2668                    qPos.add(classNameId);
2669    
2670                    qPos.add(classPK);
2671    
2672                    qPos.add(primary);
2673    
2674                    if (orderByComparator != null) {
2675                            Object[] values = orderByComparator.getOrderByConditionValues(website);
2676    
2677                            for (Object value : values) {
2678                                    qPos.add(value);
2679                            }
2680                    }
2681    
2682                    List<Website> list = q.list();
2683    
2684                    if (list.size() == 2) {
2685                            return list.get(1);
2686                    }
2687                    else {
2688                            return null;
2689                    }
2690            }
2691    
2692            /**
2693             * Returns all the websites.
2694             *
2695             * @return the websites
2696             * @throws SystemException if a system exception occurred
2697             */
2698            public List<Website> findAll() throws SystemException {
2699                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2700            }
2701    
2702            /**
2703             * Returns a range of all the websites.
2704             *
2705             * <p>
2706             * 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.
2707             * </p>
2708             *
2709             * @param start the lower bound of the range of websites
2710             * @param end the upper bound of the range of websites (not inclusive)
2711             * @return the range of websites
2712             * @throws SystemException if a system exception occurred
2713             */
2714            public List<Website> findAll(int start, int end) throws SystemException {
2715                    return findAll(start, end, null);
2716            }
2717    
2718            /**
2719             * Returns an ordered range of all the websites.
2720             *
2721             * <p>
2722             * 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.
2723             * </p>
2724             *
2725             * @param start the lower bound of the range of websites
2726             * @param end the upper bound of the range of websites (not inclusive)
2727             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2728             * @return the ordered range of websites
2729             * @throws SystemException if a system exception occurred
2730             */
2731            public List<Website> findAll(int start, int end,
2732                    OrderByComparator orderByComparator) throws SystemException {
2733                    FinderPath finderPath = null;
2734                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2735    
2736                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2737                                    (orderByComparator == null)) {
2738                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2739                            finderArgs = FINDER_ARGS_EMPTY;
2740                    }
2741                    else {
2742                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2743                            finderArgs = new Object[] { start, end, orderByComparator };
2744                    }
2745    
2746                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(finderPath,
2747                                    finderArgs, this);
2748    
2749                    if (list == null) {
2750                            StringBundler query = null;
2751                            String sql = null;
2752    
2753                            if (orderByComparator != null) {
2754                                    query = new StringBundler(2 +
2755                                                    (orderByComparator.getOrderByFields().length * 3));
2756    
2757                                    query.append(_SQL_SELECT_WEBSITE);
2758    
2759                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2760                                            orderByComparator);
2761    
2762                                    sql = query.toString();
2763                            }
2764                            else {
2765                                    sql = _SQL_SELECT_WEBSITE.concat(WebsiteModelImpl.ORDER_BY_JPQL);
2766                            }
2767    
2768                            Session session = null;
2769    
2770                            try {
2771                                    session = openSession();
2772    
2773                                    Query q = session.createQuery(sql);
2774    
2775                                    if (orderByComparator == null) {
2776                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
2777                                                            start, end, false);
2778    
2779                                            Collections.sort(list);
2780                                    }
2781                                    else {
2782                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
2783                                                            start, end);
2784                                    }
2785                            }
2786                            catch (Exception e) {
2787                                    throw processException(e);
2788                            }
2789                            finally {
2790                                    if (list == null) {
2791                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2792                                    }
2793                                    else {
2794                                            cacheResult(list);
2795    
2796                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2797                                    }
2798    
2799                                    closeSession(session);
2800                            }
2801                    }
2802    
2803                    return list;
2804            }
2805    
2806            /**
2807             * Removes all the websites where companyId = &#63; from the database.
2808             *
2809             * @param companyId the company ID
2810             * @throws SystemException if a system exception occurred
2811             */
2812            public void removeByCompanyId(long companyId) throws SystemException {
2813                    for (Website website : findByCompanyId(companyId)) {
2814                            remove(website);
2815                    }
2816            }
2817    
2818            /**
2819             * Removes all the websites where userId = &#63; from the database.
2820             *
2821             * @param userId the user ID
2822             * @throws SystemException if a system exception occurred
2823             */
2824            public void removeByUserId(long userId) throws SystemException {
2825                    for (Website website : findByUserId(userId)) {
2826                            remove(website);
2827                    }
2828            }
2829    
2830            /**
2831             * Removes all the websites where companyId = &#63; and classNameId = &#63; from the database.
2832             *
2833             * @param companyId the company ID
2834             * @param classNameId the class name ID
2835             * @throws SystemException if a system exception occurred
2836             */
2837            public void removeByC_C(long companyId, long classNameId)
2838                    throws SystemException {
2839                    for (Website website : findByC_C(companyId, classNameId)) {
2840                            remove(website);
2841                    }
2842            }
2843    
2844            /**
2845             * Removes all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
2846             *
2847             * @param companyId the company ID
2848             * @param classNameId the class name ID
2849             * @param classPK the class p k
2850             * @throws SystemException if a system exception occurred
2851             */
2852            public void removeByC_C_C(long companyId, long classNameId, long classPK)
2853                    throws SystemException {
2854                    for (Website website : findByC_C_C(companyId, classNameId, classPK)) {
2855                            remove(website);
2856                    }
2857            }
2858    
2859            /**
2860             * Removes all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63; from the database.
2861             *
2862             * @param companyId the company ID
2863             * @param classNameId the class name ID
2864             * @param classPK the class p k
2865             * @param primary the primary
2866             * @throws SystemException if a system exception occurred
2867             */
2868            public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
2869                    boolean primary) throws SystemException {
2870                    for (Website website : findByC_C_C_P(companyId, classNameId, classPK,
2871                                    primary)) {
2872                            remove(website);
2873                    }
2874            }
2875    
2876            /**
2877             * Removes all the websites from the database.
2878             *
2879             * @throws SystemException if a system exception occurred
2880             */
2881            public void removeAll() throws SystemException {
2882                    for (Website website : findAll()) {
2883                            remove(website);
2884                    }
2885            }
2886    
2887            /**
2888             * Returns the number of websites where companyId = &#63;.
2889             *
2890             * @param companyId the company ID
2891             * @return the number of matching websites
2892             * @throws SystemException if a system exception occurred
2893             */
2894            public int countByCompanyId(long companyId) throws SystemException {
2895                    Object[] finderArgs = new Object[] { companyId };
2896    
2897                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2898                                    finderArgs, this);
2899    
2900                    if (count == null) {
2901                            StringBundler query = new StringBundler(2);
2902    
2903                            query.append(_SQL_COUNT_WEBSITE_WHERE);
2904    
2905                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2906    
2907                            String sql = query.toString();
2908    
2909                            Session session = null;
2910    
2911                            try {
2912                                    session = openSession();
2913    
2914                                    Query q = session.createQuery(sql);
2915    
2916                                    QueryPos qPos = QueryPos.getInstance(q);
2917    
2918                                    qPos.add(companyId);
2919    
2920                                    count = (Long)q.uniqueResult();
2921                            }
2922                            catch (Exception e) {
2923                                    throw processException(e);
2924                            }
2925                            finally {
2926                                    if (count == null) {
2927                                            count = Long.valueOf(0);
2928                                    }
2929    
2930                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2931                                            finderArgs, count);
2932    
2933                                    closeSession(session);
2934                            }
2935                    }
2936    
2937                    return count.intValue();
2938            }
2939    
2940            /**
2941             * Returns the number of websites where userId = &#63;.
2942             *
2943             * @param userId the user ID
2944             * @return the number of matching websites
2945             * @throws SystemException if a system exception occurred
2946             */
2947            public int countByUserId(long userId) throws SystemException {
2948                    Object[] finderArgs = new Object[] { userId };
2949    
2950                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2951                                    finderArgs, this);
2952    
2953                    if (count == null) {
2954                            StringBundler query = new StringBundler(2);
2955    
2956                            query.append(_SQL_COUNT_WEBSITE_WHERE);
2957    
2958                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2959    
2960                            String sql = query.toString();
2961    
2962                            Session session = null;
2963    
2964                            try {
2965                                    session = openSession();
2966    
2967                                    Query q = session.createQuery(sql);
2968    
2969                                    QueryPos qPos = QueryPos.getInstance(q);
2970    
2971                                    qPos.add(userId);
2972    
2973                                    count = (Long)q.uniqueResult();
2974                            }
2975                            catch (Exception e) {
2976                                    throw processException(e);
2977                            }
2978                            finally {
2979                                    if (count == null) {
2980                                            count = Long.valueOf(0);
2981                                    }
2982    
2983                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2984                                            finderArgs, count);
2985    
2986                                    closeSession(session);
2987                            }
2988                    }
2989    
2990                    return count.intValue();
2991            }
2992    
2993            /**
2994             * Returns the number of websites where companyId = &#63; and classNameId = &#63;.
2995             *
2996             * @param companyId the company ID
2997             * @param classNameId the class name ID
2998             * @return the number of matching websites
2999             * @throws SystemException if a system exception occurred
3000             */
3001            public int countByC_C(long companyId, long classNameId)
3002                    throws SystemException {
3003                    Object[] finderArgs = new Object[] { companyId, classNameId };
3004    
3005                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
3006                                    finderArgs, this);
3007    
3008                    if (count == null) {
3009                            StringBundler query = new StringBundler(3);
3010    
3011                            query.append(_SQL_COUNT_WEBSITE_WHERE);
3012    
3013                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
3014    
3015                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3016    
3017                            String sql = query.toString();
3018    
3019                            Session session = null;
3020    
3021                            try {
3022                                    session = openSession();
3023    
3024                                    Query q = session.createQuery(sql);
3025    
3026                                    QueryPos qPos = QueryPos.getInstance(q);
3027    
3028                                    qPos.add(companyId);
3029    
3030                                    qPos.add(classNameId);
3031    
3032                                    count = (Long)q.uniqueResult();
3033                            }
3034                            catch (Exception e) {
3035                                    throw processException(e);
3036                            }
3037                            finally {
3038                                    if (count == null) {
3039                                            count = Long.valueOf(0);
3040                                    }
3041    
3042                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
3043                                            count);
3044    
3045                                    closeSession(session);
3046                            }
3047                    }
3048    
3049                    return count.intValue();
3050            }
3051    
3052            /**
3053             * Returns the number of websites where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
3054             *
3055             * @param companyId the company ID
3056             * @param classNameId the class name ID
3057             * @param classPK the class p k
3058             * @return the number of matching websites
3059             * @throws SystemException if a system exception occurred
3060             */
3061            public int countByC_C_C(long companyId, long classNameId, long classPK)
3062                    throws SystemException {
3063                    Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3064    
3065                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
3066                                    finderArgs, this);
3067    
3068                    if (count == null) {
3069                            StringBundler query = new StringBundler(4);
3070    
3071                            query.append(_SQL_COUNT_WEBSITE_WHERE);
3072    
3073                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3074    
3075                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3076    
3077                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3078    
3079                            String sql = query.toString();
3080    
3081                            Session session = null;
3082    
3083                            try {
3084                                    session = openSession();
3085    
3086                                    Query q = session.createQuery(sql);
3087    
3088                                    QueryPos qPos = QueryPos.getInstance(q);
3089    
3090                                    qPos.add(companyId);
3091    
3092                                    qPos.add(classNameId);
3093    
3094                                    qPos.add(classPK);
3095    
3096                                    count = (Long)q.uniqueResult();
3097                            }
3098                            catch (Exception e) {
3099                                    throw processException(e);
3100                            }
3101                            finally {
3102                                    if (count == null) {
3103                                            count = Long.valueOf(0);
3104                                    }
3105    
3106                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
3107                                            finderArgs, count);
3108    
3109                                    closeSession(session);
3110                            }
3111                    }
3112    
3113                    return count.intValue();
3114            }
3115    
3116            /**
3117             * Returns the number of websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3118             *
3119             * @param companyId the company ID
3120             * @param classNameId the class name ID
3121             * @param classPK the class p k
3122             * @param primary the primary
3123             * @return the number of matching websites
3124             * @throws SystemException if a system exception occurred
3125             */
3126            public int countByC_C_C_P(long companyId, long classNameId, long classPK,
3127                    boolean primary) throws SystemException {
3128                    Object[] finderArgs = new Object[] {
3129                                    companyId, classNameId, classPK, primary
3130                            };
3131    
3132                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C_P,
3133                                    finderArgs, this);
3134    
3135                    if (count == null) {
3136                            StringBundler query = new StringBundler(5);
3137    
3138                            query.append(_SQL_COUNT_WEBSITE_WHERE);
3139    
3140                            query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
3141    
3142                            query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
3143    
3144                            query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
3145    
3146                            query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
3147    
3148                            String sql = query.toString();
3149    
3150                            Session session = null;
3151    
3152                            try {
3153                                    session = openSession();
3154    
3155                                    Query q = session.createQuery(sql);
3156    
3157                                    QueryPos qPos = QueryPos.getInstance(q);
3158    
3159                                    qPos.add(companyId);
3160    
3161                                    qPos.add(classNameId);
3162    
3163                                    qPos.add(classPK);
3164    
3165                                    qPos.add(primary);
3166    
3167                                    count = (Long)q.uniqueResult();
3168                            }
3169                            catch (Exception e) {
3170                                    throw processException(e);
3171                            }
3172                            finally {
3173                                    if (count == null) {
3174                                            count = Long.valueOf(0);
3175                                    }
3176    
3177                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C_P,
3178                                            finderArgs, count);
3179    
3180                                    closeSession(session);
3181                            }
3182                    }
3183    
3184                    return count.intValue();
3185            }
3186    
3187            /**
3188             * Returns the number of websites.
3189             *
3190             * @return the number of websites
3191             * @throws SystemException if a system exception occurred
3192             */
3193            public int countAll() throws SystemException {
3194                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3195                                    FINDER_ARGS_EMPTY, this);
3196    
3197                    if (count == null) {
3198                            Session session = null;
3199    
3200                            try {
3201                                    session = openSession();
3202    
3203                                    Query q = session.createQuery(_SQL_COUNT_WEBSITE);
3204    
3205                                    count = (Long)q.uniqueResult();
3206                            }
3207                            catch (Exception e) {
3208                                    throw processException(e);
3209                            }
3210                            finally {
3211                                    if (count == null) {
3212                                            count = Long.valueOf(0);
3213                                    }
3214    
3215                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3216                                            FINDER_ARGS_EMPTY, count);
3217    
3218                                    closeSession(session);
3219                            }
3220                    }
3221    
3222                    return count.intValue();
3223            }
3224    
3225            /**
3226             * Initializes the website persistence.
3227             */
3228            public void afterPropertiesSet() {
3229                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3230                                            com.liferay.portal.util.PropsUtil.get(
3231                                                    "value.object.listener.com.liferay.portal.model.Website")));
3232    
3233                    if (listenerClassNames.length > 0) {
3234                            try {
3235                                    List<ModelListener<Website>> listenersList = new ArrayList<ModelListener<Website>>();
3236    
3237                                    for (String listenerClassName : listenerClassNames) {
3238                                            Class<?> clazz = getClass();
3239    
3240                                            listenersList.add((ModelListener<Website>)InstanceFactory.newInstance(
3241                                                            clazz.getClassLoader(), listenerClassName));
3242                                    }
3243    
3244                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3245                            }
3246                            catch (Exception e) {
3247                                    _log.error(e);
3248                            }
3249                    }
3250            }
3251    
3252            public void destroy() {
3253                    EntityCacheUtil.removeCache(WebsiteImpl.class.getName());
3254                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3255                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3256            }
3257    
3258            @BeanReference(type = AccountPersistence.class)
3259            protected AccountPersistence accountPersistence;
3260            @BeanReference(type = AddressPersistence.class)
3261            protected AddressPersistence addressPersistence;
3262            @BeanReference(type = BrowserTrackerPersistence.class)
3263            protected BrowserTrackerPersistence browserTrackerPersistence;
3264            @BeanReference(type = ClassNamePersistence.class)
3265            protected ClassNamePersistence classNamePersistence;
3266            @BeanReference(type = ClusterGroupPersistence.class)
3267            protected ClusterGroupPersistence clusterGroupPersistence;
3268            @BeanReference(type = CompanyPersistence.class)
3269            protected CompanyPersistence companyPersistence;
3270            @BeanReference(type = ContactPersistence.class)
3271            protected ContactPersistence contactPersistence;
3272            @BeanReference(type = CountryPersistence.class)
3273            protected CountryPersistence countryPersistence;
3274            @BeanReference(type = EmailAddressPersistence.class)
3275            protected EmailAddressPersistence emailAddressPersistence;
3276            @BeanReference(type = GroupPersistence.class)
3277            protected GroupPersistence groupPersistence;
3278            @BeanReference(type = ImagePersistence.class)
3279            protected ImagePersistence imagePersistence;
3280            @BeanReference(type = LayoutPersistence.class)
3281            protected LayoutPersistence layoutPersistence;
3282            @BeanReference(type = LayoutBranchPersistence.class)
3283            protected LayoutBranchPersistence layoutBranchPersistence;
3284            @BeanReference(type = LayoutPrototypePersistence.class)
3285            protected LayoutPrototypePersistence layoutPrototypePersistence;
3286            @BeanReference(type = LayoutRevisionPersistence.class)
3287            protected LayoutRevisionPersistence layoutRevisionPersistence;
3288            @BeanReference(type = LayoutSetPersistence.class)
3289            protected LayoutSetPersistence layoutSetPersistence;
3290            @BeanReference(type = LayoutSetBranchPersistence.class)
3291            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
3292            @BeanReference(type = LayoutSetPrototypePersistence.class)
3293            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
3294            @BeanReference(type = ListTypePersistence.class)
3295            protected ListTypePersistence listTypePersistence;
3296            @BeanReference(type = LockPersistence.class)
3297            protected LockPersistence lockPersistence;
3298            @BeanReference(type = MembershipRequestPersistence.class)
3299            protected MembershipRequestPersistence membershipRequestPersistence;
3300            @BeanReference(type = OrganizationPersistence.class)
3301            protected OrganizationPersistence organizationPersistence;
3302            @BeanReference(type = OrgGroupPermissionPersistence.class)
3303            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
3304            @BeanReference(type = OrgGroupRolePersistence.class)
3305            protected OrgGroupRolePersistence orgGroupRolePersistence;
3306            @BeanReference(type = OrgLaborPersistence.class)
3307            protected OrgLaborPersistence orgLaborPersistence;
3308            @BeanReference(type = PasswordPolicyPersistence.class)
3309            protected PasswordPolicyPersistence passwordPolicyPersistence;
3310            @BeanReference(type = PasswordPolicyRelPersistence.class)
3311            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
3312            @BeanReference(type = PasswordTrackerPersistence.class)
3313            protected PasswordTrackerPersistence passwordTrackerPersistence;
3314            @BeanReference(type = PermissionPersistence.class)
3315            protected PermissionPersistence permissionPersistence;
3316            @BeanReference(type = PhonePersistence.class)
3317            protected PhonePersistence phonePersistence;
3318            @BeanReference(type = PluginSettingPersistence.class)
3319            protected PluginSettingPersistence pluginSettingPersistence;
3320            @BeanReference(type = PortalPreferencesPersistence.class)
3321            protected PortalPreferencesPersistence portalPreferencesPersistence;
3322            @BeanReference(type = PortletPersistence.class)
3323            protected PortletPersistence portletPersistence;
3324            @BeanReference(type = PortletItemPersistence.class)
3325            protected PortletItemPersistence portletItemPersistence;
3326            @BeanReference(type = PortletPreferencesPersistence.class)
3327            protected PortletPreferencesPersistence portletPreferencesPersistence;
3328            @BeanReference(type = RegionPersistence.class)
3329            protected RegionPersistence regionPersistence;
3330            @BeanReference(type = ReleasePersistence.class)
3331            protected ReleasePersistence releasePersistence;
3332            @BeanReference(type = RepositoryPersistence.class)
3333            protected RepositoryPersistence repositoryPersistence;
3334            @BeanReference(type = RepositoryEntryPersistence.class)
3335            protected RepositoryEntryPersistence repositoryEntryPersistence;
3336            @BeanReference(type = ResourcePersistence.class)
3337            protected ResourcePersistence resourcePersistence;
3338            @BeanReference(type = ResourceActionPersistence.class)
3339            protected ResourceActionPersistence resourceActionPersistence;
3340            @BeanReference(type = ResourceBlockPersistence.class)
3341            protected ResourceBlockPersistence resourceBlockPersistence;
3342            @BeanReference(type = ResourceBlockPermissionPersistence.class)
3343            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
3344            @BeanReference(type = ResourceCodePersistence.class)
3345            protected ResourceCodePersistence resourceCodePersistence;
3346            @BeanReference(type = ResourcePermissionPersistence.class)
3347            protected ResourcePermissionPersistence resourcePermissionPersistence;
3348            @BeanReference(type = ResourceTypePermissionPersistence.class)
3349            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
3350            @BeanReference(type = RolePersistence.class)
3351            protected RolePersistence rolePersistence;
3352            @BeanReference(type = ServiceComponentPersistence.class)
3353            protected ServiceComponentPersistence serviceComponentPersistence;
3354            @BeanReference(type = ShardPersistence.class)
3355            protected ShardPersistence shardPersistence;
3356            @BeanReference(type = SubscriptionPersistence.class)
3357            protected SubscriptionPersistence subscriptionPersistence;
3358            @BeanReference(type = TeamPersistence.class)
3359            protected TeamPersistence teamPersistence;
3360            @BeanReference(type = TicketPersistence.class)
3361            protected TicketPersistence ticketPersistence;
3362            @BeanReference(type = UserPersistence.class)
3363            protected UserPersistence userPersistence;
3364            @BeanReference(type = UserGroupPersistence.class)
3365            protected UserGroupPersistence userGroupPersistence;
3366            @BeanReference(type = UserGroupGroupRolePersistence.class)
3367            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3368            @BeanReference(type = UserGroupRolePersistence.class)
3369            protected UserGroupRolePersistence userGroupRolePersistence;
3370            @BeanReference(type = UserIdMapperPersistence.class)
3371            protected UserIdMapperPersistence userIdMapperPersistence;
3372            @BeanReference(type = UserNotificationEventPersistence.class)
3373            protected UserNotificationEventPersistence userNotificationEventPersistence;
3374            @BeanReference(type = UserTrackerPersistence.class)
3375            protected UserTrackerPersistence userTrackerPersistence;
3376            @BeanReference(type = UserTrackerPathPersistence.class)
3377            protected UserTrackerPathPersistence userTrackerPathPersistence;
3378            @BeanReference(type = VirtualHostPersistence.class)
3379            protected VirtualHostPersistence virtualHostPersistence;
3380            @BeanReference(type = WebDAVPropsPersistence.class)
3381            protected WebDAVPropsPersistence webDAVPropsPersistence;
3382            @BeanReference(type = WebsitePersistence.class)
3383            protected WebsitePersistence websitePersistence;
3384            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3385            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3386            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3387            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3388            private static final String _SQL_SELECT_WEBSITE = "SELECT website FROM Website website";
3389            private static final String _SQL_SELECT_WEBSITE_WHERE = "SELECT website FROM Website website WHERE ";
3390            private static final String _SQL_COUNT_WEBSITE = "SELECT COUNT(website) FROM Website website";
3391            private static final String _SQL_COUNT_WEBSITE_WHERE = "SELECT COUNT(website) FROM Website website WHERE ";
3392            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "website.companyId = ?";
3393            private static final String _FINDER_COLUMN_USERID_USERID_2 = "website.userId = ?";
3394            private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "website.companyId = ? AND ";
3395            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "website.classNameId = ?";
3396            private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "website.companyId = ? AND ";
3397            private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "website.classNameId = ? AND ";
3398            private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "website.classPK = ?";
3399            private static final String _FINDER_COLUMN_C_C_C_P_COMPANYID_2 = "website.companyId = ? AND ";
3400            private static final String _FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2 = "website.classNameId = ? AND ";
3401            private static final String _FINDER_COLUMN_C_C_C_P_CLASSPK_2 = "website.classPK = ? AND ";
3402            private static final String _FINDER_COLUMN_C_C_C_P_PRIMARY_2 = "website.primary = ?";
3403            private static final String _ORDER_BY_ENTITY_ALIAS = "website.";
3404            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Website exists with the primary key ";
3405            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Website exists with the key {";
3406            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3407            private static Log _log = LogFactoryUtil.getLog(WebsitePersistenceImpl.class);
3408            private static Website _nullWebsite = new WebsiteImpl() {
3409                            @Override
3410                            public Object clone() {
3411                                    return this;
3412                            }
3413    
3414                            @Override
3415                            public CacheModel<Website> toCacheModel() {
3416                                    return _nullWebsiteCacheModel;
3417                            }
3418                    };
3419    
3420            private static CacheModel<Website> _nullWebsiteCacheModel = new CacheModel<Website>() {
3421                            public Website toEntityModel() {
3422                                    return _nullWebsite;
3423                            }
3424                    };
3425    }