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