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