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