001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.NoSuchWebsiteException;
020    import com.liferay.portal.kernel.bean.BeanReference;
021    import com.liferay.portal.kernel.dao.orm.EntityCache;
022    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderCache;
024    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
025    import com.liferay.portal.kernel.dao.orm.FinderPath;
026    import com.liferay.portal.kernel.dao.orm.Query;
027    import com.liferay.portal.kernel.dao.orm.QueryPos;
028    import com.liferay.portal.kernel.dao.orm.QueryUtil;
029    import com.liferay.portal.kernel.dao.orm.Session;
030    import com.liferay.portal.kernel.log.Log;
031    import com.liferay.portal.kernel.log.LogFactoryUtil;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.SetUtil;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.MVCCModel;
040    import com.liferay.portal.model.Website;
041    import com.liferay.portal.model.impl.WebsiteImpl;
042    import com.liferay.portal.model.impl.WebsiteModelImpl;
043    import com.liferay.portal.service.ServiceContext;
044    import com.liferay.portal.service.ServiceContextThreadLocal;
045    import com.liferay.portal.service.persistence.CompanyProvider;
046    import com.liferay.portal.service.persistence.WebsitePersistence;
047    
048    import java.io.Serializable;
049    
050    import java.util.Collections;
051    import java.util.Date;
052    import java.util.HashMap;
053    import java.util.HashSet;
054    import java.util.Iterator;
055    import java.util.List;
056    import java.util.Map;
057    import java.util.Set;
058    
059    /**
060     * The persistence implementation for the website service.
061     *
062     * <p>
063     * Caching information and settings can be found in <code>portal.properties</code>
064     * </p>
065     *
066     * @author Brian Wing Shun Chan
067     * @see WebsitePersistence
068     * @see com.liferay.portal.service.persistence.WebsiteUtil
069     * @generated
070     */
071    @ProviderType
072    public class WebsitePersistenceImpl extends BasePersistenceImpl<Website>
073            implements WebsitePersistence {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * 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.
078             */
079            public static final String FINDER_CLASS_NAME_ENTITY = WebsiteImpl.class.getName();
080            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List1";
082            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List2";
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
085                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
086                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
088                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
090            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
091                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
093            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
094                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
095                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
096                            new String[] {
097                                    String.class.getName(),
098                                    
099                            Integer.class.getName(), Integer.class.getName(),
100                                    OrderByComparator.class.getName()
101                            });
102            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
103                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
104                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
105                            new String[] { String.class.getName() },
106                            WebsiteModelImpl.UUID_COLUMN_BITMASK |
107                            WebsiteModelImpl.CREATEDATE_COLUMN_BITMASK);
108            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
109                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
111                            new String[] { String.class.getName() });
112    
113            /**
114             * Returns all the websites where uuid = &#63;.
115             *
116             * @param uuid the uuid
117             * @return the matching websites
118             */
119            @Override
120            public List<Website> findByUuid(String uuid) {
121                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
122            }
123    
124            /**
125             * Returns a range of all the websites where uuid = &#63;.
126             *
127             * <p>
128             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
129             * </p>
130             *
131             * @param uuid the uuid
132             * @param start the lower bound of the range of websites
133             * @param end the upper bound of the range of websites (not inclusive)
134             * @return the range of matching websites
135             */
136            @Override
137            public List<Website> findByUuid(String uuid, int start, int end) {
138                    return findByUuid(uuid, start, end, null);
139            }
140    
141            /**
142             * Returns an ordered range of all the websites where uuid = &#63;.
143             *
144             * <p>
145             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
146             * </p>
147             *
148             * @param uuid the uuid
149             * @param start the lower bound of the range of websites
150             * @param end the upper bound of the range of websites (not inclusive)
151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
152             * @return the ordered range of matching websites
153             */
154            @Override
155            public List<Website> findByUuid(String uuid, int start, int end,
156                    OrderByComparator<Website> orderByComparator) {
157                    return findByUuid(uuid, start, end, orderByComparator, true);
158            }
159    
160            /**
161             * Returns an ordered range of all the websites where uuid = &#63;.
162             *
163             * <p>
164             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
165             * </p>
166             *
167             * @param uuid the uuid
168             * @param start the lower bound of the range of websites
169             * @param end the upper bound of the range of websites (not inclusive)
170             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
171             * @param retrieveFromCache whether to retrieve from the finder cache
172             * @return the ordered range of matching websites
173             */
174            @Override
175            public List<Website> findByUuid(String uuid, int start, int end,
176                    OrderByComparator<Website> orderByComparator, boolean retrieveFromCache) {
177                    boolean pagination = true;
178                    FinderPath finderPath = null;
179                    Object[] finderArgs = null;
180    
181                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
182                                    (orderByComparator == null)) {
183                            pagination = false;
184                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
185                            finderArgs = new Object[] { uuid };
186                    }
187                    else {
188                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
189                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
190                    }
191    
192                    List<Website> list = null;
193    
194                    if (retrieveFromCache) {
195                            list = (List<Website>)finderCache.getResult(finderPath, finderArgs,
196                                            this);
197    
198                            if ((list != null) && !list.isEmpty()) {
199                                    for (Website website : list) {
200                                            if (!Validator.equals(uuid, website.getUuid())) {
201                                                    list = null;
202    
203                                                    break;
204                                            }
205                                    }
206                            }
207                    }
208    
209                    if (list == null) {
210                            StringBundler query = null;
211    
212                            if (orderByComparator != null) {
213                                    query = new StringBundler(3 +
214                                                    (orderByComparator.getOrderByFields().length * 3));
215                            }
216                            else {
217                                    query = new StringBundler(3);
218                            }
219    
220                            query.append(_SQL_SELECT_WEBSITE_WHERE);
221    
222                            boolean bindUuid = false;
223    
224                            if (uuid == null) {
225                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
226                            }
227                            else if (uuid.equals(StringPool.BLANK)) {
228                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
229                            }
230                            else {
231                                    bindUuid = true;
232    
233                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
234                            }
235    
236                            if (orderByComparator != null) {
237                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
238                                            orderByComparator);
239                            }
240                            else
241                             if (pagination) {
242                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
243                            }
244    
245                            String sql = query.toString();
246    
247                            Session session = null;
248    
249                            try {
250                                    session = openSession();
251    
252                                    Query q = session.createQuery(sql);
253    
254                                    QueryPos qPos = QueryPos.getInstance(q);
255    
256                                    if (bindUuid) {
257                                            qPos.add(uuid);
258                                    }
259    
260                                    if (!pagination) {
261                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
262                                                            start, end, false);
263    
264                                            Collections.sort(list);
265    
266                                            list = Collections.unmodifiableList(list);
267                                    }
268                                    else {
269                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
270                                                            start, end);
271                                    }
272    
273                                    cacheResult(list);
274    
275                                    finderCache.putResult(finderPath, finderArgs, list);
276                            }
277                            catch (Exception e) {
278                                    finderCache.removeResult(finderPath, finderArgs);
279    
280                                    throw processException(e);
281                            }
282                            finally {
283                                    closeSession(session);
284                            }
285                    }
286    
287                    return list;
288            }
289    
290            /**
291             * Returns the first website in the ordered set where uuid = &#63;.
292             *
293             * @param uuid the uuid
294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
295             * @return the first matching website
296             * @throws NoSuchWebsiteException if a matching website could not be found
297             */
298            @Override
299            public Website findByUuid_First(String uuid,
300                    OrderByComparator<Website> orderByComparator)
301                    throws NoSuchWebsiteException {
302                    Website website = fetchByUuid_First(uuid, orderByComparator);
303    
304                    if (website != null) {
305                            return website;
306                    }
307    
308                    StringBundler msg = new StringBundler(4);
309    
310                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
311    
312                    msg.append("uuid=");
313                    msg.append(uuid);
314    
315                    msg.append(StringPool.CLOSE_CURLY_BRACE);
316    
317                    throw new NoSuchWebsiteException(msg.toString());
318            }
319    
320            /**
321             * Returns the first website in the ordered set where uuid = &#63;.
322             *
323             * @param uuid the uuid
324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
325             * @return the first matching website, or <code>null</code> if a matching website could not be found
326             */
327            @Override
328            public Website fetchByUuid_First(String uuid,
329                    OrderByComparator<Website> orderByComparator) {
330                    List<Website> list = findByUuid(uuid, 0, 1, orderByComparator);
331    
332                    if (!list.isEmpty()) {
333                            return list.get(0);
334                    }
335    
336                    return null;
337            }
338    
339            /**
340             * Returns the last website in the ordered set where uuid = &#63;.
341             *
342             * @param uuid the uuid
343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
344             * @return the last matching website
345             * @throws NoSuchWebsiteException if a matching website could not be found
346             */
347            @Override
348            public Website findByUuid_Last(String uuid,
349                    OrderByComparator<Website> orderByComparator)
350                    throws NoSuchWebsiteException {
351                    Website website = fetchByUuid_Last(uuid, orderByComparator);
352    
353                    if (website != null) {
354                            return website;
355                    }
356    
357                    StringBundler msg = new StringBundler(4);
358    
359                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
360    
361                    msg.append("uuid=");
362                    msg.append(uuid);
363    
364                    msg.append(StringPool.CLOSE_CURLY_BRACE);
365    
366                    throw new NoSuchWebsiteException(msg.toString());
367            }
368    
369            /**
370             * Returns the last website in the ordered set where uuid = &#63;.
371             *
372             * @param uuid the uuid
373             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
374             * @return the last matching website, or <code>null</code> if a matching website could not be found
375             */
376            @Override
377            public Website fetchByUuid_Last(String uuid,
378                    OrderByComparator<Website> orderByComparator) {
379                    int count = countByUuid(uuid);
380    
381                    if (count == 0) {
382                            return null;
383                    }
384    
385                    List<Website> list = findByUuid(uuid, count - 1, count,
386                                    orderByComparator);
387    
388                    if (!list.isEmpty()) {
389                            return list.get(0);
390                    }
391    
392                    return null;
393            }
394    
395            /**
396             * Returns the websites before and after the current website in the ordered set where uuid = &#63;.
397             *
398             * @param websiteId the primary key of the current website
399             * @param uuid the uuid
400             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
401             * @return the previous, current, and next website
402             * @throws NoSuchWebsiteException if a website with the primary key could not be found
403             */
404            @Override
405            public Website[] findByUuid_PrevAndNext(long websiteId, String uuid,
406                    OrderByComparator<Website> orderByComparator)
407                    throws NoSuchWebsiteException {
408                    Website website = findByPrimaryKey(websiteId);
409    
410                    Session session = null;
411    
412                    try {
413                            session = openSession();
414    
415                            Website[] array = new WebsiteImpl[3];
416    
417                            array[0] = getByUuid_PrevAndNext(session, website, uuid,
418                                            orderByComparator, true);
419    
420                            array[1] = website;
421    
422                            array[2] = getByUuid_PrevAndNext(session, website, uuid,
423                                            orderByComparator, false);
424    
425                            return array;
426                    }
427                    catch (Exception e) {
428                            throw processException(e);
429                    }
430                    finally {
431                            closeSession(session);
432                    }
433            }
434    
435            protected Website getByUuid_PrevAndNext(Session session, Website website,
436                    String uuid, OrderByComparator<Website> orderByComparator,
437                    boolean previous) {
438                    StringBundler query = null;
439    
440                    if (orderByComparator != null) {
441                            query = new StringBundler(6 +
442                                            (orderByComparator.getOrderByFields().length * 6));
443                    }
444                    else {
445                            query = new StringBundler(3);
446                    }
447    
448                    query.append(_SQL_SELECT_WEBSITE_WHERE);
449    
450                    boolean bindUuid = false;
451    
452                    if (uuid == null) {
453                            query.append(_FINDER_COLUMN_UUID_UUID_1);
454                    }
455                    else if (uuid.equals(StringPool.BLANK)) {
456                            query.append(_FINDER_COLUMN_UUID_UUID_3);
457                    }
458                    else {
459                            bindUuid = true;
460    
461                            query.append(_FINDER_COLUMN_UUID_UUID_2);
462                    }
463    
464                    if (orderByComparator != null) {
465                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
466    
467                            if (orderByConditionFields.length > 0) {
468                                    query.append(WHERE_AND);
469                            }
470    
471                            for (int i = 0; i < orderByConditionFields.length; i++) {
472                                    query.append(_ORDER_BY_ENTITY_ALIAS);
473                                    query.append(orderByConditionFields[i]);
474    
475                                    if ((i + 1) < orderByConditionFields.length) {
476                                            if (orderByComparator.isAscending() ^ previous) {
477                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
478                                            }
479                                            else {
480                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
481                                            }
482                                    }
483                                    else {
484                                            if (orderByComparator.isAscending() ^ previous) {
485                                                    query.append(WHERE_GREATER_THAN);
486                                            }
487                                            else {
488                                                    query.append(WHERE_LESSER_THAN);
489                                            }
490                                    }
491                            }
492    
493                            query.append(ORDER_BY_CLAUSE);
494    
495                            String[] orderByFields = orderByComparator.getOrderByFields();
496    
497                            for (int i = 0; i < orderByFields.length; i++) {
498                                    query.append(_ORDER_BY_ENTITY_ALIAS);
499                                    query.append(orderByFields[i]);
500    
501                                    if ((i + 1) < orderByFields.length) {
502                                            if (orderByComparator.isAscending() ^ previous) {
503                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
504                                            }
505                                            else {
506                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
507                                            }
508                                    }
509                                    else {
510                                            if (orderByComparator.isAscending() ^ previous) {
511                                                    query.append(ORDER_BY_ASC);
512                                            }
513                                            else {
514                                                    query.append(ORDER_BY_DESC);
515                                            }
516                                    }
517                            }
518                    }
519                    else {
520                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
521                    }
522    
523                    String sql = query.toString();
524    
525                    Query q = session.createQuery(sql);
526    
527                    q.setFirstResult(0);
528                    q.setMaxResults(2);
529    
530                    QueryPos qPos = QueryPos.getInstance(q);
531    
532                    if (bindUuid) {
533                            qPos.add(uuid);
534                    }
535    
536                    if (orderByComparator != null) {
537                            Object[] values = orderByComparator.getOrderByConditionValues(website);
538    
539                            for (Object value : values) {
540                                    qPos.add(value);
541                            }
542                    }
543    
544                    List<Website> list = q.list();
545    
546                    if (list.size() == 2) {
547                            return list.get(1);
548                    }
549                    else {
550                            return null;
551                    }
552            }
553    
554            /**
555             * Removes all the websites where uuid = &#63; from the database.
556             *
557             * @param uuid the uuid
558             */
559            @Override
560            public void removeByUuid(String uuid) {
561                    for (Website website : findByUuid(uuid, QueryUtil.ALL_POS,
562                                    QueryUtil.ALL_POS, null)) {
563                            remove(website);
564                    }
565            }
566    
567            /**
568             * Returns the number of websites where uuid = &#63;.
569             *
570             * @param uuid the uuid
571             * @return the number of matching websites
572             */
573            @Override
574            public int countByUuid(String uuid) {
575                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
576    
577                    Object[] finderArgs = new Object[] { uuid };
578    
579                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
580    
581                    if (count == null) {
582                            StringBundler query = new StringBundler(2);
583    
584                            query.append(_SQL_COUNT_WEBSITE_WHERE);
585    
586                            boolean bindUuid = false;
587    
588                            if (uuid == null) {
589                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
590                            }
591                            else if (uuid.equals(StringPool.BLANK)) {
592                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
593                            }
594                            else {
595                                    bindUuid = true;
596    
597                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
598                            }
599    
600                            String sql = query.toString();
601    
602                            Session session = null;
603    
604                            try {
605                                    session = openSession();
606    
607                                    Query q = session.createQuery(sql);
608    
609                                    QueryPos qPos = QueryPos.getInstance(q);
610    
611                                    if (bindUuid) {
612                                            qPos.add(uuid);
613                                    }
614    
615                                    count = (Long)q.uniqueResult();
616    
617                                    finderCache.putResult(finderPath, finderArgs, count);
618                            }
619                            catch (Exception e) {
620                                    finderCache.removeResult(finderPath, finderArgs);
621    
622                                    throw processException(e);
623                            }
624                            finally {
625                                    closeSession(session);
626                            }
627                    }
628    
629                    return count.intValue();
630            }
631    
632            private static final String _FINDER_COLUMN_UUID_UUID_1 = "website.uuid IS NULL";
633            private static final String _FINDER_COLUMN_UUID_UUID_2 = "website.uuid = ?";
634            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(website.uuid IS NULL OR website.uuid = '')";
635            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
636                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
637                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
638                            new String[] {
639                                    String.class.getName(), Long.class.getName(),
640                                    
641                            Integer.class.getName(), Integer.class.getName(),
642                                    OrderByComparator.class.getName()
643                            });
644            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
645                    new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
646                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
647                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
648                            new String[] { String.class.getName(), Long.class.getName() },
649                            WebsiteModelImpl.UUID_COLUMN_BITMASK |
650                            WebsiteModelImpl.COMPANYID_COLUMN_BITMASK |
651                            WebsiteModelImpl.CREATEDATE_COLUMN_BITMASK);
652            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
653                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
654                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
655                            new String[] { String.class.getName(), Long.class.getName() });
656    
657            /**
658             * Returns all the websites where uuid = &#63; and companyId = &#63;.
659             *
660             * @param uuid the uuid
661             * @param companyId the company ID
662             * @return the matching websites
663             */
664            @Override
665            public List<Website> findByUuid_C(String uuid, long companyId) {
666                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
667                            QueryUtil.ALL_POS, null);
668            }
669    
670            /**
671             * Returns a range of all the websites where uuid = &#63; and companyId = &#63;.
672             *
673             * <p>
674             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
675             * </p>
676             *
677             * @param uuid the uuid
678             * @param companyId the company ID
679             * @param start the lower bound of the range of websites
680             * @param end the upper bound of the range of websites (not inclusive)
681             * @return the range of matching websites
682             */
683            @Override
684            public List<Website> findByUuid_C(String uuid, long companyId, int start,
685                    int end) {
686                    return findByUuid_C(uuid, companyId, start, end, null);
687            }
688    
689            /**
690             * Returns an ordered range of all the websites where uuid = &#63; and companyId = &#63;.
691             *
692             * <p>
693             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
694             * </p>
695             *
696             * @param uuid the uuid
697             * @param companyId the company ID
698             * @param start the lower bound of the range of websites
699             * @param end the upper bound of the range of websites (not inclusive)
700             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
701             * @return the ordered range of matching websites
702             */
703            @Override
704            public List<Website> findByUuid_C(String uuid, long companyId, int start,
705                    int end, OrderByComparator<Website> orderByComparator) {
706                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
707            }
708    
709            /**
710             * Returns an ordered range of all the websites where uuid = &#63; and companyId = &#63;.
711             *
712             * <p>
713             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
714             * </p>
715             *
716             * @param uuid the uuid
717             * @param companyId the company ID
718             * @param start the lower bound of the range of websites
719             * @param end the upper bound of the range of websites (not inclusive)
720             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
721             * @param retrieveFromCache whether to retrieve from the finder cache
722             * @return the ordered range of matching websites
723             */
724            @Override
725            public List<Website> findByUuid_C(String uuid, long companyId, int start,
726                    int end, OrderByComparator<Website> orderByComparator,
727                    boolean retrieveFromCache) {
728                    boolean pagination = true;
729                    FinderPath finderPath = null;
730                    Object[] finderArgs = null;
731    
732                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
733                                    (orderByComparator == null)) {
734                            pagination = false;
735                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
736                            finderArgs = new Object[] { uuid, companyId };
737                    }
738                    else {
739                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
740                            finderArgs = new Object[] {
741                                            uuid, companyId,
742                                            
743                                            start, end, orderByComparator
744                                    };
745                    }
746    
747                    List<Website> list = null;
748    
749                    if (retrieveFromCache) {
750                            list = (List<Website>)finderCache.getResult(finderPath, finderArgs,
751                                            this);
752    
753                            if ((list != null) && !list.isEmpty()) {
754                                    for (Website website : list) {
755                                            if (!Validator.equals(uuid, website.getUuid()) ||
756                                                            (companyId != website.getCompanyId())) {
757                                                    list = null;
758    
759                                                    break;
760                                            }
761                                    }
762                            }
763                    }
764    
765                    if (list == null) {
766                            StringBundler query = null;
767    
768                            if (orderByComparator != null) {
769                                    query = new StringBundler(4 +
770                                                    (orderByComparator.getOrderByFields().length * 3));
771                            }
772                            else {
773                                    query = new StringBundler(4);
774                            }
775    
776                            query.append(_SQL_SELECT_WEBSITE_WHERE);
777    
778                            boolean bindUuid = false;
779    
780                            if (uuid == null) {
781                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
782                            }
783                            else if (uuid.equals(StringPool.BLANK)) {
784                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
785                            }
786                            else {
787                                    bindUuid = true;
788    
789                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
790                            }
791    
792                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
793    
794                            if (orderByComparator != null) {
795                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
796                                            orderByComparator);
797                            }
798                            else
799                             if (pagination) {
800                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
801                            }
802    
803                            String sql = query.toString();
804    
805                            Session session = null;
806    
807                            try {
808                                    session = openSession();
809    
810                                    Query q = session.createQuery(sql);
811    
812                                    QueryPos qPos = QueryPos.getInstance(q);
813    
814                                    if (bindUuid) {
815                                            qPos.add(uuid);
816                                    }
817    
818                                    qPos.add(companyId);
819    
820                                    if (!pagination) {
821                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
822                                                            start, end, false);
823    
824                                            Collections.sort(list);
825    
826                                            list = Collections.unmodifiableList(list);
827                                    }
828                                    else {
829                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
830                                                            start, end);
831                                    }
832    
833                                    cacheResult(list);
834    
835                                    finderCache.putResult(finderPath, finderArgs, list);
836                            }
837                            catch (Exception e) {
838                                    finderCache.removeResult(finderPath, finderArgs);
839    
840                                    throw processException(e);
841                            }
842                            finally {
843                                    closeSession(session);
844                            }
845                    }
846    
847                    return list;
848            }
849    
850            /**
851             * Returns the first website in the ordered set where uuid = &#63; and companyId = &#63;.
852             *
853             * @param uuid the uuid
854             * @param companyId the company ID
855             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
856             * @return the first matching website
857             * @throws NoSuchWebsiteException if a matching website could not be found
858             */
859            @Override
860            public Website findByUuid_C_First(String uuid, long companyId,
861                    OrderByComparator<Website> orderByComparator)
862                    throws NoSuchWebsiteException {
863                    Website website = fetchByUuid_C_First(uuid, companyId, orderByComparator);
864    
865                    if (website != null) {
866                            return website;
867                    }
868    
869                    StringBundler msg = new StringBundler(6);
870    
871                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
872    
873                    msg.append("uuid=");
874                    msg.append(uuid);
875    
876                    msg.append(", companyId=");
877                    msg.append(companyId);
878    
879                    msg.append(StringPool.CLOSE_CURLY_BRACE);
880    
881                    throw new NoSuchWebsiteException(msg.toString());
882            }
883    
884            /**
885             * Returns the first website in the ordered set where uuid = &#63; and companyId = &#63;.
886             *
887             * @param uuid the uuid
888             * @param companyId the company ID
889             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
890             * @return the first matching website, or <code>null</code> if a matching website could not be found
891             */
892            @Override
893            public Website fetchByUuid_C_First(String uuid, long companyId,
894                    OrderByComparator<Website> orderByComparator) {
895                    List<Website> list = findByUuid_C(uuid, companyId, 0, 1,
896                                    orderByComparator);
897    
898                    if (!list.isEmpty()) {
899                            return list.get(0);
900                    }
901    
902                    return null;
903            }
904    
905            /**
906             * Returns the last website in the ordered set where uuid = &#63; and companyId = &#63;.
907             *
908             * @param uuid the uuid
909             * @param companyId the company ID
910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
911             * @return the last matching website
912             * @throws NoSuchWebsiteException if a matching website could not be found
913             */
914            @Override
915            public Website findByUuid_C_Last(String uuid, long companyId,
916                    OrderByComparator<Website> orderByComparator)
917                    throws NoSuchWebsiteException {
918                    Website website = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
919    
920                    if (website != null) {
921                            return website;
922                    }
923    
924                    StringBundler msg = new StringBundler(6);
925    
926                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
927    
928                    msg.append("uuid=");
929                    msg.append(uuid);
930    
931                    msg.append(", companyId=");
932                    msg.append(companyId);
933    
934                    msg.append(StringPool.CLOSE_CURLY_BRACE);
935    
936                    throw new NoSuchWebsiteException(msg.toString());
937            }
938    
939            /**
940             * Returns the last website in the ordered set where uuid = &#63; and companyId = &#63;.
941             *
942             * @param uuid the uuid
943             * @param companyId the company ID
944             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
945             * @return the last matching website, or <code>null</code> if a matching website could not be found
946             */
947            @Override
948            public Website fetchByUuid_C_Last(String uuid, long companyId,
949                    OrderByComparator<Website> orderByComparator) {
950                    int count = countByUuid_C(uuid, companyId);
951    
952                    if (count == 0) {
953                            return null;
954                    }
955    
956                    List<Website> list = findByUuid_C(uuid, companyId, count - 1, count,
957                                    orderByComparator);
958    
959                    if (!list.isEmpty()) {
960                            return list.get(0);
961                    }
962    
963                    return null;
964            }
965    
966            /**
967             * Returns the websites before and after the current website in the ordered set where uuid = &#63; and companyId = &#63;.
968             *
969             * @param websiteId the primary key of the current website
970             * @param uuid the uuid
971             * @param companyId the company ID
972             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
973             * @return the previous, current, and next website
974             * @throws NoSuchWebsiteException if a website with the primary key could not be found
975             */
976            @Override
977            public Website[] findByUuid_C_PrevAndNext(long websiteId, String uuid,
978                    long companyId, OrderByComparator<Website> orderByComparator)
979                    throws NoSuchWebsiteException {
980                    Website website = findByPrimaryKey(websiteId);
981    
982                    Session session = null;
983    
984                    try {
985                            session = openSession();
986    
987                            Website[] array = new WebsiteImpl[3];
988    
989                            array[0] = getByUuid_C_PrevAndNext(session, website, uuid,
990                                            companyId, orderByComparator, true);
991    
992                            array[1] = website;
993    
994                            array[2] = getByUuid_C_PrevAndNext(session, website, uuid,
995                                            companyId, orderByComparator, false);
996    
997                            return array;
998                    }
999                    catch (Exception e) {
1000                            throw processException(e);
1001                    }
1002                    finally {
1003                            closeSession(session);
1004                    }
1005            }
1006    
1007            protected Website getByUuid_C_PrevAndNext(Session session, Website website,
1008                    String uuid, long companyId,
1009                    OrderByComparator<Website> orderByComparator, boolean previous) {
1010                    StringBundler query = null;
1011    
1012                    if (orderByComparator != null) {
1013                            query = new StringBundler(6 +
1014                                            (orderByComparator.getOrderByFields().length * 6));
1015                    }
1016                    else {
1017                            query = new StringBundler(3);
1018                    }
1019    
1020                    query.append(_SQL_SELECT_WEBSITE_WHERE);
1021    
1022                    boolean bindUuid = false;
1023    
1024                    if (uuid == null) {
1025                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1026                    }
1027                    else if (uuid.equals(StringPool.BLANK)) {
1028                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1029                    }
1030                    else {
1031                            bindUuid = true;
1032    
1033                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1034                    }
1035    
1036                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1037    
1038                    if (orderByComparator != null) {
1039                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1040    
1041                            if (orderByConditionFields.length > 0) {
1042                                    query.append(WHERE_AND);
1043                            }
1044    
1045                            for (int i = 0; i < orderByConditionFields.length; i++) {
1046                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1047                                    query.append(orderByConditionFields[i]);
1048    
1049                                    if ((i + 1) < orderByConditionFields.length) {
1050                                            if (orderByComparator.isAscending() ^ previous) {
1051                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1052                                            }
1053                                            else {
1054                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1055                                            }
1056                                    }
1057                                    else {
1058                                            if (orderByComparator.isAscending() ^ previous) {
1059                                                    query.append(WHERE_GREATER_THAN);
1060                                            }
1061                                            else {
1062                                                    query.append(WHERE_LESSER_THAN);
1063                                            }
1064                                    }
1065                            }
1066    
1067                            query.append(ORDER_BY_CLAUSE);
1068    
1069                            String[] orderByFields = orderByComparator.getOrderByFields();
1070    
1071                            for (int i = 0; i < orderByFields.length; i++) {
1072                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1073                                    query.append(orderByFields[i]);
1074    
1075                                    if ((i + 1) < orderByFields.length) {
1076                                            if (orderByComparator.isAscending() ^ previous) {
1077                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1078                                            }
1079                                            else {
1080                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1081                                            }
1082                                    }
1083                                    else {
1084                                            if (orderByComparator.isAscending() ^ previous) {
1085                                                    query.append(ORDER_BY_ASC);
1086                                            }
1087                                            else {
1088                                                    query.append(ORDER_BY_DESC);
1089                                            }
1090                                    }
1091                            }
1092                    }
1093                    else {
1094                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1095                    }
1096    
1097                    String sql = query.toString();
1098    
1099                    Query q = session.createQuery(sql);
1100    
1101                    q.setFirstResult(0);
1102                    q.setMaxResults(2);
1103    
1104                    QueryPos qPos = QueryPos.getInstance(q);
1105    
1106                    if (bindUuid) {
1107                            qPos.add(uuid);
1108                    }
1109    
1110                    qPos.add(companyId);
1111    
1112                    if (orderByComparator != null) {
1113                            Object[] values = orderByComparator.getOrderByConditionValues(website);
1114    
1115                            for (Object value : values) {
1116                                    qPos.add(value);
1117                            }
1118                    }
1119    
1120                    List<Website> list = q.list();
1121    
1122                    if (list.size() == 2) {
1123                            return list.get(1);
1124                    }
1125                    else {
1126                            return null;
1127                    }
1128            }
1129    
1130            /**
1131             * Removes all the websites where uuid = &#63; and companyId = &#63; from the database.
1132             *
1133             * @param uuid the uuid
1134             * @param companyId the company ID
1135             */
1136            @Override
1137            public void removeByUuid_C(String uuid, long companyId) {
1138                    for (Website website : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1139                                    QueryUtil.ALL_POS, null)) {
1140                            remove(website);
1141                    }
1142            }
1143    
1144            /**
1145             * Returns the number of websites where uuid = &#63; and companyId = &#63;.
1146             *
1147             * @param uuid the uuid
1148             * @param companyId the company ID
1149             * @return the number of matching websites
1150             */
1151            @Override
1152            public int countByUuid_C(String uuid, long companyId) {
1153                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1154    
1155                    Object[] finderArgs = new Object[] { uuid, companyId };
1156    
1157                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1158    
1159                    if (count == null) {
1160                            StringBundler query = new StringBundler(3);
1161    
1162                            query.append(_SQL_COUNT_WEBSITE_WHERE);
1163    
1164                            boolean bindUuid = false;
1165    
1166                            if (uuid == null) {
1167                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1168                            }
1169                            else if (uuid.equals(StringPool.BLANK)) {
1170                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1171                            }
1172                            else {
1173                                    bindUuid = true;
1174    
1175                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1176                            }
1177    
1178                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1179    
1180                            String sql = query.toString();
1181    
1182                            Session session = null;
1183    
1184                            try {
1185                                    session = openSession();
1186    
1187                                    Query q = session.createQuery(sql);
1188    
1189                                    QueryPos qPos = QueryPos.getInstance(q);
1190    
1191                                    if (bindUuid) {
1192                                            qPos.add(uuid);
1193                                    }
1194    
1195                                    qPos.add(companyId);
1196    
1197                                    count = (Long)q.uniqueResult();
1198    
1199                                    finderCache.putResult(finderPath, finderArgs, count);
1200                            }
1201                            catch (Exception e) {
1202                                    finderCache.removeResult(finderPath, finderArgs);
1203    
1204                                    throw processException(e);
1205                            }
1206                            finally {
1207                                    closeSession(session);
1208                            }
1209                    }
1210    
1211                    return count.intValue();
1212            }
1213    
1214            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "website.uuid IS NULL AND ";
1215            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "website.uuid = ? AND ";
1216            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(website.uuid IS NULL OR website.uuid = '') AND ";
1217            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "website.companyId = ?";
1218            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
1219                    new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
1220                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
1221                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
1222                            new String[] {
1223                                    Long.class.getName(),
1224                                    
1225                            Integer.class.getName(), Integer.class.getName(),
1226                                    OrderByComparator.class.getName()
1227                            });
1228            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
1229                    new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
1230                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
1231                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
1232                            new String[] { Long.class.getName() },
1233                            WebsiteModelImpl.COMPANYID_COLUMN_BITMASK |
1234                            WebsiteModelImpl.CREATEDATE_COLUMN_BITMASK);
1235            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
1236                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
1237                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
1238                            new String[] { Long.class.getName() });
1239    
1240            /**
1241             * Returns all the websites where companyId = &#63;.
1242             *
1243             * @param companyId the company ID
1244             * @return the matching websites
1245             */
1246            @Override
1247            public List<Website> findByCompanyId(long companyId) {
1248                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1249                            null);
1250            }
1251    
1252            /**
1253             * Returns a range of all the websites where companyId = &#63;.
1254             *
1255             * <p>
1256             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1257             * </p>
1258             *
1259             * @param companyId the company ID
1260             * @param start the lower bound of the range of websites
1261             * @param end the upper bound of the range of websites (not inclusive)
1262             * @return the range of matching websites
1263             */
1264            @Override
1265            public List<Website> findByCompanyId(long companyId, int start, int end) {
1266                    return findByCompanyId(companyId, start, end, null);
1267            }
1268    
1269            /**
1270             * Returns an ordered range of all the websites where companyId = &#63;.
1271             *
1272             * <p>
1273             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1274             * </p>
1275             *
1276             * @param companyId the company ID
1277             * @param start the lower bound of the range of websites
1278             * @param end the upper bound of the range of websites (not inclusive)
1279             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1280             * @return the ordered range of matching websites
1281             */
1282            @Override
1283            public List<Website> findByCompanyId(long companyId, int start, int end,
1284                    OrderByComparator<Website> orderByComparator) {
1285                    return findByCompanyId(companyId, start, end, orderByComparator, true);
1286            }
1287    
1288            /**
1289             * Returns an ordered range of all the websites where companyId = &#63;.
1290             *
1291             * <p>
1292             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1293             * </p>
1294             *
1295             * @param companyId the company ID
1296             * @param start the lower bound of the range of websites
1297             * @param end the upper bound of the range of websites (not inclusive)
1298             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1299             * @param retrieveFromCache whether to retrieve from the finder cache
1300             * @return the ordered range of matching websites
1301             */
1302            @Override
1303            public List<Website> findByCompanyId(long companyId, int start, int end,
1304                    OrderByComparator<Website> orderByComparator, boolean retrieveFromCache) {
1305                    boolean pagination = true;
1306                    FinderPath finderPath = null;
1307                    Object[] finderArgs = null;
1308    
1309                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1310                                    (orderByComparator == null)) {
1311                            pagination = false;
1312                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1313                            finderArgs = new Object[] { companyId };
1314                    }
1315                    else {
1316                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1317                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1318                    }
1319    
1320                    List<Website> list = null;
1321    
1322                    if (retrieveFromCache) {
1323                            list = (List<Website>)finderCache.getResult(finderPath, finderArgs,
1324                                            this);
1325    
1326                            if ((list != null) && !list.isEmpty()) {
1327                                    for (Website website : list) {
1328                                            if ((companyId != website.getCompanyId())) {
1329                                                    list = null;
1330    
1331                                                    break;
1332                                            }
1333                                    }
1334                            }
1335                    }
1336    
1337                    if (list == null) {
1338                            StringBundler query = null;
1339    
1340                            if (orderByComparator != null) {
1341                                    query = new StringBundler(3 +
1342                                                    (orderByComparator.getOrderByFields().length * 3));
1343                            }
1344                            else {
1345                                    query = new StringBundler(3);
1346                            }
1347    
1348                            query.append(_SQL_SELECT_WEBSITE_WHERE);
1349    
1350                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1351    
1352                            if (orderByComparator != null) {
1353                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1354                                            orderByComparator);
1355                            }
1356                            else
1357                             if (pagination) {
1358                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1359                            }
1360    
1361                            String sql = query.toString();
1362    
1363                            Session session = null;
1364    
1365                            try {
1366                                    session = openSession();
1367    
1368                                    Query q = session.createQuery(sql);
1369    
1370                                    QueryPos qPos = QueryPos.getInstance(q);
1371    
1372                                    qPos.add(companyId);
1373    
1374                                    if (!pagination) {
1375                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
1376                                                            start, end, false);
1377    
1378                                            Collections.sort(list);
1379    
1380                                            list = Collections.unmodifiableList(list);
1381                                    }
1382                                    else {
1383                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
1384                                                            start, end);
1385                                    }
1386    
1387                                    cacheResult(list);
1388    
1389                                    finderCache.putResult(finderPath, finderArgs, list);
1390                            }
1391                            catch (Exception e) {
1392                                    finderCache.removeResult(finderPath, finderArgs);
1393    
1394                                    throw processException(e);
1395                            }
1396                            finally {
1397                                    closeSession(session);
1398                            }
1399                    }
1400    
1401                    return list;
1402            }
1403    
1404            /**
1405             * Returns the first website in the ordered set where companyId = &#63;.
1406             *
1407             * @param companyId the company ID
1408             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1409             * @return the first matching website
1410             * @throws NoSuchWebsiteException if a matching website could not be found
1411             */
1412            @Override
1413            public Website findByCompanyId_First(long companyId,
1414                    OrderByComparator<Website> orderByComparator)
1415                    throws NoSuchWebsiteException {
1416                    Website website = fetchByCompanyId_First(companyId, orderByComparator);
1417    
1418                    if (website != null) {
1419                            return website;
1420                    }
1421    
1422                    StringBundler msg = new StringBundler(4);
1423    
1424                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1425    
1426                    msg.append("companyId=");
1427                    msg.append(companyId);
1428    
1429                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1430    
1431                    throw new NoSuchWebsiteException(msg.toString());
1432            }
1433    
1434            /**
1435             * Returns the first website in the ordered set where companyId = &#63;.
1436             *
1437             * @param companyId the company ID
1438             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1439             * @return the first matching website, or <code>null</code> if a matching website could not be found
1440             */
1441            @Override
1442            public Website fetchByCompanyId_First(long companyId,
1443                    OrderByComparator<Website> orderByComparator) {
1444                    List<Website> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1445    
1446                    if (!list.isEmpty()) {
1447                            return list.get(0);
1448                    }
1449    
1450                    return null;
1451            }
1452    
1453            /**
1454             * Returns the last website in the ordered set where companyId = &#63;.
1455             *
1456             * @param companyId the company ID
1457             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1458             * @return the last matching website
1459             * @throws NoSuchWebsiteException if a matching website could not be found
1460             */
1461            @Override
1462            public Website findByCompanyId_Last(long companyId,
1463                    OrderByComparator<Website> orderByComparator)
1464                    throws NoSuchWebsiteException {
1465                    Website website = fetchByCompanyId_Last(companyId, orderByComparator);
1466    
1467                    if (website != null) {
1468                            return website;
1469                    }
1470    
1471                    StringBundler msg = new StringBundler(4);
1472    
1473                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1474    
1475                    msg.append("companyId=");
1476                    msg.append(companyId);
1477    
1478                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1479    
1480                    throw new NoSuchWebsiteException(msg.toString());
1481            }
1482    
1483            /**
1484             * Returns the last website in the ordered set where companyId = &#63;.
1485             *
1486             * @param companyId the company ID
1487             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1488             * @return the last matching website, or <code>null</code> if a matching website could not be found
1489             */
1490            @Override
1491            public Website fetchByCompanyId_Last(long companyId,
1492                    OrderByComparator<Website> orderByComparator) {
1493                    int count = countByCompanyId(companyId);
1494    
1495                    if (count == 0) {
1496                            return null;
1497                    }
1498    
1499                    List<Website> list = findByCompanyId(companyId, count - 1, count,
1500                                    orderByComparator);
1501    
1502                    if (!list.isEmpty()) {
1503                            return list.get(0);
1504                    }
1505    
1506                    return null;
1507            }
1508    
1509            /**
1510             * Returns the websites before and after the current website in the ordered set where companyId = &#63;.
1511             *
1512             * @param websiteId the primary key of the current website
1513             * @param companyId the company ID
1514             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1515             * @return the previous, current, and next website
1516             * @throws NoSuchWebsiteException if a website with the primary key could not be found
1517             */
1518            @Override
1519            public Website[] findByCompanyId_PrevAndNext(long websiteId,
1520                    long companyId, OrderByComparator<Website> orderByComparator)
1521                    throws NoSuchWebsiteException {
1522                    Website website = findByPrimaryKey(websiteId);
1523    
1524                    Session session = null;
1525    
1526                    try {
1527                            session = openSession();
1528    
1529                            Website[] array = new WebsiteImpl[3];
1530    
1531                            array[0] = getByCompanyId_PrevAndNext(session, website, companyId,
1532                                            orderByComparator, true);
1533    
1534                            array[1] = website;
1535    
1536                            array[2] = getByCompanyId_PrevAndNext(session, website, companyId,
1537                                            orderByComparator, false);
1538    
1539                            return array;
1540                    }
1541                    catch (Exception e) {
1542                            throw processException(e);
1543                    }
1544                    finally {
1545                            closeSession(session);
1546                    }
1547            }
1548    
1549            protected Website getByCompanyId_PrevAndNext(Session session,
1550                    Website website, long companyId,
1551                    OrderByComparator<Website> orderByComparator, boolean previous) {
1552                    StringBundler query = null;
1553    
1554                    if (orderByComparator != null) {
1555                            query = new StringBundler(6 +
1556                                            (orderByComparator.getOrderByFields().length * 6));
1557                    }
1558                    else {
1559                            query = new StringBundler(3);
1560                    }
1561    
1562                    query.append(_SQL_SELECT_WEBSITE_WHERE);
1563    
1564                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1565    
1566                    if (orderByComparator != null) {
1567                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1568    
1569                            if (orderByConditionFields.length > 0) {
1570                                    query.append(WHERE_AND);
1571                            }
1572    
1573                            for (int i = 0; i < orderByConditionFields.length; i++) {
1574                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1575                                    query.append(orderByConditionFields[i]);
1576    
1577                                    if ((i + 1) < orderByConditionFields.length) {
1578                                            if (orderByComparator.isAscending() ^ previous) {
1579                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1580                                            }
1581                                            else {
1582                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1583                                            }
1584                                    }
1585                                    else {
1586                                            if (orderByComparator.isAscending() ^ previous) {
1587                                                    query.append(WHERE_GREATER_THAN);
1588                                            }
1589                                            else {
1590                                                    query.append(WHERE_LESSER_THAN);
1591                                            }
1592                                    }
1593                            }
1594    
1595                            query.append(ORDER_BY_CLAUSE);
1596    
1597                            String[] orderByFields = orderByComparator.getOrderByFields();
1598    
1599                            for (int i = 0; i < orderByFields.length; i++) {
1600                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1601                                    query.append(orderByFields[i]);
1602    
1603                                    if ((i + 1) < orderByFields.length) {
1604                                            if (orderByComparator.isAscending() ^ previous) {
1605                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1606                                            }
1607                                            else {
1608                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1609                                            }
1610                                    }
1611                                    else {
1612                                            if (orderByComparator.isAscending() ^ previous) {
1613                                                    query.append(ORDER_BY_ASC);
1614                                            }
1615                                            else {
1616                                                    query.append(ORDER_BY_DESC);
1617                                            }
1618                                    }
1619                            }
1620                    }
1621                    else {
1622                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1623                    }
1624    
1625                    String sql = query.toString();
1626    
1627                    Query q = session.createQuery(sql);
1628    
1629                    q.setFirstResult(0);
1630                    q.setMaxResults(2);
1631    
1632                    QueryPos qPos = QueryPos.getInstance(q);
1633    
1634                    qPos.add(companyId);
1635    
1636                    if (orderByComparator != null) {
1637                            Object[] values = orderByComparator.getOrderByConditionValues(website);
1638    
1639                            for (Object value : values) {
1640                                    qPos.add(value);
1641                            }
1642                    }
1643    
1644                    List<Website> list = q.list();
1645    
1646                    if (list.size() == 2) {
1647                            return list.get(1);
1648                    }
1649                    else {
1650                            return null;
1651                    }
1652            }
1653    
1654            /**
1655             * Removes all the websites where companyId = &#63; from the database.
1656             *
1657             * @param companyId the company ID
1658             */
1659            @Override
1660            public void removeByCompanyId(long companyId) {
1661                    for (Website website : findByCompanyId(companyId, QueryUtil.ALL_POS,
1662                                    QueryUtil.ALL_POS, null)) {
1663                            remove(website);
1664                    }
1665            }
1666    
1667            /**
1668             * Returns the number of websites where companyId = &#63;.
1669             *
1670             * @param companyId the company ID
1671             * @return the number of matching websites
1672             */
1673            @Override
1674            public int countByCompanyId(long companyId) {
1675                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1676    
1677                    Object[] finderArgs = new Object[] { companyId };
1678    
1679                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1680    
1681                    if (count == null) {
1682                            StringBundler query = new StringBundler(2);
1683    
1684                            query.append(_SQL_COUNT_WEBSITE_WHERE);
1685    
1686                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1687    
1688                            String sql = query.toString();
1689    
1690                            Session session = null;
1691    
1692                            try {
1693                                    session = openSession();
1694    
1695                                    Query q = session.createQuery(sql);
1696    
1697                                    QueryPos qPos = QueryPos.getInstance(q);
1698    
1699                                    qPos.add(companyId);
1700    
1701                                    count = (Long)q.uniqueResult();
1702    
1703                                    finderCache.putResult(finderPath, finderArgs, count);
1704                            }
1705                            catch (Exception e) {
1706                                    finderCache.removeResult(finderPath, finderArgs);
1707    
1708                                    throw processException(e);
1709                            }
1710                            finally {
1711                                    closeSession(session);
1712                            }
1713                    }
1714    
1715                    return count.intValue();
1716            }
1717    
1718            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "website.companyId = ?";
1719            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
1720                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
1721                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
1722                            new String[] {
1723                                    Long.class.getName(),
1724                                    
1725                            Integer.class.getName(), Integer.class.getName(),
1726                                    OrderByComparator.class.getName()
1727                            });
1728            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
1729                    new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
1730                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
1731                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
1732                            new String[] { Long.class.getName() },
1733                            WebsiteModelImpl.USERID_COLUMN_BITMASK |
1734                            WebsiteModelImpl.CREATEDATE_COLUMN_BITMASK);
1735            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
1736                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
1737                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
1738                            new String[] { Long.class.getName() });
1739    
1740            /**
1741             * Returns all the websites where userId = &#63;.
1742             *
1743             * @param userId the user ID
1744             * @return the matching websites
1745             */
1746            @Override
1747            public List<Website> findByUserId(long userId) {
1748                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1749            }
1750    
1751            /**
1752             * Returns a range of all the websites where userId = &#63;.
1753             *
1754             * <p>
1755             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1756             * </p>
1757             *
1758             * @param userId the user ID
1759             * @param start the lower bound of the range of websites
1760             * @param end the upper bound of the range of websites (not inclusive)
1761             * @return the range of matching websites
1762             */
1763            @Override
1764            public List<Website> findByUserId(long userId, int start, int end) {
1765                    return findByUserId(userId, start, end, null);
1766            }
1767    
1768            /**
1769             * Returns an ordered range of all the websites where userId = &#63;.
1770             *
1771             * <p>
1772             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1773             * </p>
1774             *
1775             * @param userId the user ID
1776             * @param start the lower bound of the range of websites
1777             * @param end the upper bound of the range of websites (not inclusive)
1778             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1779             * @return the ordered range of matching websites
1780             */
1781            @Override
1782            public List<Website> findByUserId(long userId, int start, int end,
1783                    OrderByComparator<Website> orderByComparator) {
1784                    return findByUserId(userId, start, end, orderByComparator, true);
1785            }
1786    
1787            /**
1788             * Returns an ordered range of all the websites where userId = &#63;.
1789             *
1790             * <p>
1791             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1792             * </p>
1793             *
1794             * @param userId the user ID
1795             * @param start the lower bound of the range of websites
1796             * @param end the upper bound of the range of websites (not inclusive)
1797             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1798             * @param retrieveFromCache whether to retrieve from the finder cache
1799             * @return the ordered range of matching websites
1800             */
1801            @Override
1802            public List<Website> findByUserId(long userId, int start, int end,
1803                    OrderByComparator<Website> orderByComparator, boolean retrieveFromCache) {
1804                    boolean pagination = true;
1805                    FinderPath finderPath = null;
1806                    Object[] finderArgs = null;
1807    
1808                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1809                                    (orderByComparator == null)) {
1810                            pagination = false;
1811                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1812                            finderArgs = new Object[] { userId };
1813                    }
1814                    else {
1815                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1816                            finderArgs = new Object[] { userId, start, end, orderByComparator };
1817                    }
1818    
1819                    List<Website> list = null;
1820    
1821                    if (retrieveFromCache) {
1822                            list = (List<Website>)finderCache.getResult(finderPath, finderArgs,
1823                                            this);
1824    
1825                            if ((list != null) && !list.isEmpty()) {
1826                                    for (Website website : list) {
1827                                            if ((userId != website.getUserId())) {
1828                                                    list = null;
1829    
1830                                                    break;
1831                                            }
1832                                    }
1833                            }
1834                    }
1835    
1836                    if (list == null) {
1837                            StringBundler query = null;
1838    
1839                            if (orderByComparator != null) {
1840                                    query = new StringBundler(3 +
1841                                                    (orderByComparator.getOrderByFields().length * 3));
1842                            }
1843                            else {
1844                                    query = new StringBundler(3);
1845                            }
1846    
1847                            query.append(_SQL_SELECT_WEBSITE_WHERE);
1848    
1849                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1850    
1851                            if (orderByComparator != null) {
1852                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1853                                            orderByComparator);
1854                            }
1855                            else
1856                             if (pagination) {
1857                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1858                            }
1859    
1860                            String sql = query.toString();
1861    
1862                            Session session = null;
1863    
1864                            try {
1865                                    session = openSession();
1866    
1867                                    Query q = session.createQuery(sql);
1868    
1869                                    QueryPos qPos = QueryPos.getInstance(q);
1870    
1871                                    qPos.add(userId);
1872    
1873                                    if (!pagination) {
1874                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
1875                                                            start, end, false);
1876    
1877                                            Collections.sort(list);
1878    
1879                                            list = Collections.unmodifiableList(list);
1880                                    }
1881                                    else {
1882                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
1883                                                            start, end);
1884                                    }
1885    
1886                                    cacheResult(list);
1887    
1888                                    finderCache.putResult(finderPath, finderArgs, list);
1889                            }
1890                            catch (Exception e) {
1891                                    finderCache.removeResult(finderPath, finderArgs);
1892    
1893                                    throw processException(e);
1894                            }
1895                            finally {
1896                                    closeSession(session);
1897                            }
1898                    }
1899    
1900                    return list;
1901            }
1902    
1903            /**
1904             * Returns the first website in the ordered set where userId = &#63;.
1905             *
1906             * @param userId the user ID
1907             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1908             * @return the first matching website
1909             * @throws NoSuchWebsiteException if a matching website could not be found
1910             */
1911            @Override
1912            public Website findByUserId_First(long userId,
1913                    OrderByComparator<Website> orderByComparator)
1914                    throws NoSuchWebsiteException {
1915                    Website website = fetchByUserId_First(userId, orderByComparator);
1916    
1917                    if (website != null) {
1918                            return website;
1919                    }
1920    
1921                    StringBundler msg = new StringBundler(4);
1922    
1923                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1924    
1925                    msg.append("userId=");
1926                    msg.append(userId);
1927    
1928                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1929    
1930                    throw new NoSuchWebsiteException(msg.toString());
1931            }
1932    
1933            /**
1934             * Returns the first website in the ordered set where userId = &#63;.
1935             *
1936             * @param userId the user ID
1937             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1938             * @return the first matching website, or <code>null</code> if a matching website could not be found
1939             */
1940            @Override
1941            public Website fetchByUserId_First(long userId,
1942                    OrderByComparator<Website> orderByComparator) {
1943                    List<Website> list = findByUserId(userId, 0, 1, orderByComparator);
1944    
1945                    if (!list.isEmpty()) {
1946                            return list.get(0);
1947                    }
1948    
1949                    return null;
1950            }
1951    
1952            /**
1953             * Returns the last website in the ordered set where userId = &#63;.
1954             *
1955             * @param userId the user ID
1956             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1957             * @return the last matching website
1958             * @throws NoSuchWebsiteException if a matching website could not be found
1959             */
1960            @Override
1961            public Website findByUserId_Last(long userId,
1962                    OrderByComparator<Website> orderByComparator)
1963                    throws NoSuchWebsiteException {
1964                    Website website = fetchByUserId_Last(userId, orderByComparator);
1965    
1966                    if (website != null) {
1967                            return website;
1968                    }
1969    
1970                    StringBundler msg = new StringBundler(4);
1971    
1972                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1973    
1974                    msg.append("userId=");
1975                    msg.append(userId);
1976    
1977                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1978    
1979                    throw new NoSuchWebsiteException(msg.toString());
1980            }
1981    
1982            /**
1983             * Returns the last website in the ordered set where userId = &#63;.
1984             *
1985             * @param userId the user ID
1986             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1987             * @return the last matching website, or <code>null</code> if a matching website could not be found
1988             */
1989            @Override
1990            public Website fetchByUserId_Last(long userId,
1991                    OrderByComparator<Website> orderByComparator) {
1992                    int count = countByUserId(userId);
1993    
1994                    if (count == 0) {
1995                            return null;
1996                    }
1997    
1998                    List<Website> list = findByUserId(userId, count - 1, count,
1999                                    orderByComparator);
2000    
2001                    if (!list.isEmpty()) {
2002                            return list.get(0);
2003                    }
2004    
2005                    return null;
2006            }
2007    
2008            /**
2009             * Returns the websites before and after the current website in the ordered set where userId = &#63;.
2010             *
2011             * @param websiteId the primary key of the current website
2012             * @param userId the user ID
2013             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2014             * @return the previous, current, and next website
2015             * @throws NoSuchWebsiteException if a website with the primary key could not be found
2016             */
2017            @Override
2018            public Website[] findByUserId_PrevAndNext(long websiteId, long userId,
2019                    OrderByComparator<Website> orderByComparator)
2020                    throws NoSuchWebsiteException {
2021                    Website website = findByPrimaryKey(websiteId);
2022    
2023                    Session session = null;
2024    
2025                    try {
2026                            session = openSession();
2027    
2028                            Website[] array = new WebsiteImpl[3];
2029    
2030                            array[0] = getByUserId_PrevAndNext(session, website, userId,
2031                                            orderByComparator, true);
2032    
2033                            array[1] = website;
2034    
2035                            array[2] = getByUserId_PrevAndNext(session, website, userId,
2036                                            orderByComparator, false);
2037    
2038                            return array;
2039                    }
2040                    catch (Exception e) {
2041                            throw processException(e);
2042                    }
2043                    finally {
2044                            closeSession(session);
2045                    }
2046            }
2047    
2048            protected Website getByUserId_PrevAndNext(Session session, Website website,
2049                    long userId, OrderByComparator<Website> orderByComparator,
2050                    boolean previous) {
2051                    StringBundler query = null;
2052    
2053                    if (orderByComparator != null) {
2054                            query = new StringBundler(6 +
2055                                            (orderByComparator.getOrderByFields().length * 6));
2056                    }
2057                    else {
2058                            query = new StringBundler(3);
2059                    }
2060    
2061                    query.append(_SQL_SELECT_WEBSITE_WHERE);
2062    
2063                    query.append(_FINDER_COLUMN_USERID_USERID_2);
2064    
2065                    if (orderByComparator != null) {
2066                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2067    
2068                            if (orderByConditionFields.length > 0) {
2069                                    query.append(WHERE_AND);
2070                            }
2071    
2072                            for (int i = 0; i < orderByConditionFields.length; i++) {
2073                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2074                                    query.append(orderByConditionFields[i]);
2075    
2076                                    if ((i + 1) < orderByConditionFields.length) {
2077                                            if (orderByComparator.isAscending() ^ previous) {
2078                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2079                                            }
2080                                            else {
2081                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2082                                            }
2083                                    }
2084                                    else {
2085                                            if (orderByComparator.isAscending() ^ previous) {
2086                                                    query.append(WHERE_GREATER_THAN);
2087                                            }
2088                                            else {
2089                                                    query.append(WHERE_LESSER_THAN);
2090                                            }
2091                                    }
2092                            }
2093    
2094                            query.append(ORDER_BY_CLAUSE);
2095    
2096                            String[] orderByFields = orderByComparator.getOrderByFields();
2097    
2098                            for (int i = 0; i < orderByFields.length; i++) {
2099                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2100                                    query.append(orderByFields[i]);
2101    
2102                                    if ((i + 1) < orderByFields.length) {
2103                                            if (orderByComparator.isAscending() ^ previous) {
2104                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2105                                            }
2106                                            else {
2107                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2108                                            }
2109                                    }
2110                                    else {
2111                                            if (orderByComparator.isAscending() ^ previous) {
2112                                                    query.append(ORDER_BY_ASC);
2113                                            }
2114                                            else {
2115                                                    query.append(ORDER_BY_DESC);
2116                                            }
2117                                    }
2118                            }
2119                    }
2120                    else {
2121                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
2122                    }
2123    
2124                    String sql = query.toString();
2125    
2126                    Query q = session.createQuery(sql);
2127    
2128                    q.setFirstResult(0);
2129                    q.setMaxResults(2);
2130    
2131                    QueryPos qPos = QueryPos.getInstance(q);
2132    
2133                    qPos.add(userId);
2134    
2135                    if (orderByComparator != null) {
2136                            Object[] values = orderByComparator.getOrderByConditionValues(website);
2137    
2138                            for (Object value : values) {
2139                                    qPos.add(value);
2140                            }
2141                    }
2142    
2143                    List<Website> list = q.list();
2144    
2145                    if (list.size() == 2) {
2146                            return list.get(1);
2147                    }
2148                    else {
2149                            return null;
2150                    }
2151            }
2152    
2153            /**
2154             * Removes all the websites where userId = &#63; from the database.
2155             *
2156             * @param userId the user ID
2157             */
2158            @Override
2159            public void removeByUserId(long userId) {
2160                    for (Website website : findByUserId(userId, QueryUtil.ALL_POS,
2161                                    QueryUtil.ALL_POS, null)) {
2162                            remove(website);
2163                    }
2164            }
2165    
2166            /**
2167             * Returns the number of websites where userId = &#63;.
2168             *
2169             * @param userId the user ID
2170             * @return the number of matching websites
2171             */
2172            @Override
2173            public int countByUserId(long userId) {
2174                    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
2175    
2176                    Object[] finderArgs = new Object[] { userId };
2177    
2178                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2179    
2180                    if (count == null) {
2181                            StringBundler query = new StringBundler(2);
2182    
2183                            query.append(_SQL_COUNT_WEBSITE_WHERE);
2184    
2185                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2186    
2187                            String sql = query.toString();
2188    
2189                            Session session = null;
2190    
2191                            try {
2192                                    session = openSession();
2193    
2194                                    Query q = session.createQuery(sql);
2195    
2196                                    QueryPos qPos = QueryPos.getInstance(q);
2197    
2198                                    qPos.add(userId);
2199    
2200                                    count = (Long)q.uniqueResult();
2201    
2202                                    finderCache.putResult(finderPath, finderArgs, count);
2203                            }
2204                            catch (Exception e) {
2205                                    finderCache.removeResult(finderPath, finderArgs);
2206    
2207                                    throw processException(e);
2208                            }
2209                            finally {
2210                                    closeSession(session);
2211                            }
2212                    }
2213    
2214                    return count.intValue();
2215            }
2216    
2217            private static final String _FINDER_COLUMN_USERID_USERID_2 = "website.userId = ?";
2218            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
2219                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
2220                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
2221                            new String[] {
2222                                    Long.class.getName(), Long.class.getName(),
2223                                    
2224                            Integer.class.getName(), Integer.class.getName(),
2225                                    OrderByComparator.class.getName()
2226                            });
2227            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
2228                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
2229                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
2230                            new String[] { Long.class.getName(), Long.class.getName() },
2231                            WebsiteModelImpl.COMPANYID_COLUMN_BITMASK |
2232                            WebsiteModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2233                            WebsiteModelImpl.CREATEDATE_COLUMN_BITMASK);
2234            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
2235                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
2236                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
2237                            new String[] { Long.class.getName(), Long.class.getName() });
2238    
2239            /**
2240             * Returns all the websites where companyId = &#63; and classNameId = &#63;.
2241             *
2242             * @param companyId the company ID
2243             * @param classNameId the class name ID
2244             * @return the matching websites
2245             */
2246            @Override
2247            public List<Website> findByC_C(long companyId, long classNameId) {
2248                    return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
2249                            QueryUtil.ALL_POS, null);
2250            }
2251    
2252            /**
2253             * Returns a range of all the websites where companyId = &#63; and classNameId = &#63;.
2254             *
2255             * <p>
2256             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2257             * </p>
2258             *
2259             * @param companyId the company ID
2260             * @param classNameId the class name ID
2261             * @param start the lower bound of the range of websites
2262             * @param end the upper bound of the range of websites (not inclusive)
2263             * @return the range of matching websites
2264             */
2265            @Override
2266            public List<Website> findByC_C(long companyId, long classNameId, int start,
2267                    int end) {
2268                    return findByC_C(companyId, classNameId, start, end, null);
2269            }
2270    
2271            /**
2272             * Returns an ordered range of all the websites where companyId = &#63; and classNameId = &#63;.
2273             *
2274             * <p>
2275             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2276             * </p>
2277             *
2278             * @param companyId the company ID
2279             * @param classNameId the class name ID
2280             * @param start the lower bound of the range of websites
2281             * @param end the upper bound of the range of websites (not inclusive)
2282             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2283             * @return the ordered range of matching websites
2284             */
2285            @Override
2286            public List<Website> findByC_C(long companyId, long classNameId, int start,
2287                    int end, OrderByComparator<Website> orderByComparator) {
2288                    return findByC_C(companyId, classNameId, start, end, orderByComparator,
2289                            true);
2290            }
2291    
2292            /**
2293             * Returns an ordered range of all the websites where companyId = &#63; and classNameId = &#63;.
2294             *
2295             * <p>
2296             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2297             * </p>
2298             *
2299             * @param companyId the company ID
2300             * @param classNameId the class name ID
2301             * @param start the lower bound of the range of websites
2302             * @param end the upper bound of the range of websites (not inclusive)
2303             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2304             * @param retrieveFromCache whether to retrieve from the finder cache
2305             * @return the ordered range of matching websites
2306             */
2307            @Override
2308            public List<Website> findByC_C(long companyId, long classNameId, int start,
2309                    int end, OrderByComparator<Website> orderByComparator,
2310                    boolean retrieveFromCache) {
2311                    boolean pagination = true;
2312                    FinderPath finderPath = null;
2313                    Object[] finderArgs = null;
2314    
2315                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2316                                    (orderByComparator == null)) {
2317                            pagination = false;
2318                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2319                            finderArgs = new Object[] { companyId, classNameId };
2320                    }
2321                    else {
2322                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2323                            finderArgs = new Object[] {
2324                                            companyId, classNameId,
2325                                            
2326                                            start, end, orderByComparator
2327                                    };
2328                    }
2329    
2330                    List<Website> list = null;
2331    
2332                    if (retrieveFromCache) {
2333                            list = (List<Website>)finderCache.getResult(finderPath, finderArgs,
2334                                            this);
2335    
2336                            if ((list != null) && !list.isEmpty()) {
2337                                    for (Website website : list) {
2338                                            if ((companyId != website.getCompanyId()) ||
2339                                                            (classNameId != website.getClassNameId())) {
2340                                                    list = null;
2341    
2342                                                    break;
2343                                            }
2344                                    }
2345                            }
2346                    }
2347    
2348                    if (list == null) {
2349                            StringBundler query = null;
2350    
2351                            if (orderByComparator != null) {
2352                                    query = new StringBundler(4 +
2353                                                    (orderByComparator.getOrderByFields().length * 3));
2354                            }
2355                            else {
2356                                    query = new StringBundler(4);
2357                            }
2358    
2359                            query.append(_SQL_SELECT_WEBSITE_WHERE);
2360    
2361                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2362    
2363                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2364    
2365                            if (orderByComparator != null) {
2366                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2367                                            orderByComparator);
2368                            }
2369                            else
2370                             if (pagination) {
2371                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
2372                            }
2373    
2374                            String sql = query.toString();
2375    
2376                            Session session = null;
2377    
2378                            try {
2379                                    session = openSession();
2380    
2381                                    Query q = session.createQuery(sql);
2382    
2383                                    QueryPos qPos = QueryPos.getInstance(q);
2384    
2385                                    qPos.add(companyId);
2386    
2387                                    qPos.add(classNameId);
2388    
2389                                    if (!pagination) {
2390                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
2391                                                            start, end, false);
2392    
2393                                            Collections.sort(list);
2394    
2395                                            list = Collections.unmodifiableList(list);
2396                                    }
2397                                    else {
2398                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
2399                                                            start, end);
2400                                    }
2401    
2402                                    cacheResult(list);
2403    
2404                                    finderCache.putResult(finderPath, finderArgs, list);
2405                            }
2406                            catch (Exception e) {
2407                                    finderCache.removeResult(finderPath, finderArgs);
2408    
2409                                    throw processException(e);
2410                            }
2411                            finally {
2412                                    closeSession(session);
2413                            }
2414                    }
2415    
2416                    return list;
2417            }
2418    
2419            /**
2420             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63;.
2421             *
2422             * @param companyId the company ID
2423             * @param classNameId the class name ID
2424             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2425             * @return the first matching website
2426             * @throws NoSuchWebsiteException if a matching website could not be found
2427             */
2428            @Override
2429            public Website findByC_C_First(long companyId, long classNameId,
2430                    OrderByComparator<Website> orderByComparator)
2431                    throws NoSuchWebsiteException {
2432                    Website website = fetchByC_C_First(companyId, classNameId,
2433                                    orderByComparator);
2434    
2435                    if (website != null) {
2436                            return website;
2437                    }
2438    
2439                    StringBundler msg = new StringBundler(6);
2440    
2441                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2442    
2443                    msg.append("companyId=");
2444                    msg.append(companyId);
2445    
2446                    msg.append(", classNameId=");
2447                    msg.append(classNameId);
2448    
2449                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2450    
2451                    throw new NoSuchWebsiteException(msg.toString());
2452            }
2453    
2454            /**
2455             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63;.
2456             *
2457             * @param companyId the company ID
2458             * @param classNameId the class name ID
2459             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2460             * @return the first matching website, or <code>null</code> if a matching website could not be found
2461             */
2462            @Override
2463            public Website fetchByC_C_First(long companyId, long classNameId,
2464                    OrderByComparator<Website> orderByComparator) {
2465                    List<Website> list = findByC_C(companyId, classNameId, 0, 1,
2466                                    orderByComparator);
2467    
2468                    if (!list.isEmpty()) {
2469                            return list.get(0);
2470                    }
2471    
2472                    return null;
2473            }
2474    
2475            /**
2476             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63;.
2477             *
2478             * @param companyId the company ID
2479             * @param classNameId the class name ID
2480             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2481             * @return the last matching website
2482             * @throws NoSuchWebsiteException if a matching website could not be found
2483             */
2484            @Override
2485            public Website findByC_C_Last(long companyId, long classNameId,
2486                    OrderByComparator<Website> orderByComparator)
2487                    throws NoSuchWebsiteException {
2488                    Website website = fetchByC_C_Last(companyId, classNameId,
2489                                    orderByComparator);
2490    
2491                    if (website != null) {
2492                            return website;
2493                    }
2494    
2495                    StringBundler msg = new StringBundler(6);
2496    
2497                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2498    
2499                    msg.append("companyId=");
2500                    msg.append(companyId);
2501    
2502                    msg.append(", classNameId=");
2503                    msg.append(classNameId);
2504    
2505                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2506    
2507                    throw new NoSuchWebsiteException(msg.toString());
2508            }
2509    
2510            /**
2511             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63;.
2512             *
2513             * @param companyId the company ID
2514             * @param classNameId the class name ID
2515             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2516             * @return the last matching website, or <code>null</code> if a matching website could not be found
2517             */
2518            @Override
2519            public Website fetchByC_C_Last(long companyId, long classNameId,
2520                    OrderByComparator<Website> orderByComparator) {
2521                    int count = countByC_C(companyId, classNameId);
2522    
2523                    if (count == 0) {
2524                            return null;
2525                    }
2526    
2527                    List<Website> list = findByC_C(companyId, classNameId, count - 1,
2528                                    count, orderByComparator);
2529    
2530                    if (!list.isEmpty()) {
2531                            return list.get(0);
2532                    }
2533    
2534                    return null;
2535            }
2536    
2537            /**
2538             * Returns the websites before and after the current website in the ordered set where companyId = &#63; and classNameId = &#63;.
2539             *
2540             * @param websiteId the primary key of the current website
2541             * @param companyId the company ID
2542             * @param classNameId the class name ID
2543             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2544             * @return the previous, current, and next website
2545             * @throws NoSuchWebsiteException if a website with the primary key could not be found
2546             */
2547            @Override
2548            public Website[] findByC_C_PrevAndNext(long websiteId, long companyId,
2549                    long classNameId, OrderByComparator<Website> orderByComparator)
2550                    throws NoSuchWebsiteException {
2551                    Website website = findByPrimaryKey(websiteId);
2552    
2553                    Session session = null;
2554    
2555                    try {
2556                            session = openSession();
2557    
2558                            Website[] array = new WebsiteImpl[3];
2559    
2560                            array[0] = getByC_C_PrevAndNext(session, website, companyId,
2561                                            classNameId, orderByComparator, true);
2562    
2563                            array[1] = website;
2564    
2565                            array[2] = getByC_C_PrevAndNext(session, website, companyId,
2566                                            classNameId, orderByComparator, false);
2567    
2568                            return array;
2569                    }
2570                    catch (Exception e) {
2571                            throw processException(e);
2572                    }
2573                    finally {
2574                            closeSession(session);
2575                    }
2576            }
2577    
2578            protected Website getByC_C_PrevAndNext(Session session, Website website,
2579                    long companyId, long classNameId,
2580                    OrderByComparator<Website> orderByComparator, boolean previous) {
2581                    StringBundler query = null;
2582    
2583                    if (orderByComparator != null) {
2584                            query = new StringBundler(6 +
2585                                            (orderByComparator.getOrderByFields().length * 6));
2586                    }
2587                    else {
2588                            query = new StringBundler(3);
2589                    }
2590    
2591                    query.append(_SQL_SELECT_WEBSITE_WHERE);
2592    
2593                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2594    
2595                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2596    
2597                    if (orderByComparator != null) {
2598                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2599    
2600                            if (orderByConditionFields.length > 0) {
2601                                    query.append(WHERE_AND);
2602                            }
2603    
2604                            for (int i = 0; i < orderByConditionFields.length; i++) {
2605                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2606                                    query.append(orderByConditionFields[i]);
2607    
2608                                    if ((i + 1) < orderByConditionFields.length) {
2609                                            if (orderByComparator.isAscending() ^ previous) {
2610                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2611                                            }
2612                                            else {
2613                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2614                                            }
2615                                    }
2616                                    else {
2617                                            if (orderByComparator.isAscending() ^ previous) {
2618                                                    query.append(WHERE_GREATER_THAN);
2619                                            }
2620                                            else {
2621                                                    query.append(WHERE_LESSER_THAN);
2622                                            }
2623                                    }
2624                            }
2625    
2626                            query.append(ORDER_BY_CLAUSE);
2627    
2628                            String[] orderByFields = orderByComparator.getOrderByFields();
2629    
2630                            for (int i = 0; i < orderByFields.length; i++) {
2631                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2632                                    query.append(orderByFields[i]);
2633    
2634                                    if ((i + 1) < orderByFields.length) {
2635                                            if (orderByComparator.isAscending() ^ previous) {
2636                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2637                                            }
2638                                            else {
2639                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2640                                            }
2641                                    }
2642                                    else {
2643                                            if (orderByComparator.isAscending() ^ previous) {
2644                                                    query.append(ORDER_BY_ASC);
2645                                            }
2646                                            else {
2647                                                    query.append(ORDER_BY_DESC);
2648                                            }
2649                                    }
2650                            }
2651                    }
2652                    else {
2653                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
2654                    }
2655    
2656                    String sql = query.toString();
2657    
2658                    Query q = session.createQuery(sql);
2659    
2660                    q.setFirstResult(0);
2661                    q.setMaxResults(2);
2662    
2663                    QueryPos qPos = QueryPos.getInstance(q);
2664    
2665                    qPos.add(companyId);
2666    
2667                    qPos.add(classNameId);
2668    
2669                    if (orderByComparator != null) {
2670                            Object[] values = orderByComparator.getOrderByConditionValues(website);
2671    
2672                            for (Object value : values) {
2673                                    qPos.add(value);
2674                            }
2675                    }
2676    
2677                    List<Website> list = q.list();
2678    
2679                    if (list.size() == 2) {
2680                            return list.get(1);
2681                    }
2682                    else {
2683                            return null;
2684                    }
2685            }
2686    
2687            /**
2688             * Removes all the websites where companyId = &#63; and classNameId = &#63; from the database.
2689             *
2690             * @param companyId the company ID
2691             * @param classNameId the class name ID
2692             */
2693            @Override
2694            public void removeByC_C(long companyId, long classNameId) {
2695                    for (Website website : findByC_C(companyId, classNameId,
2696                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2697                            remove(website);
2698                    }
2699            }
2700    
2701            /**
2702             * Returns the number of websites where companyId = &#63; and classNameId = &#63;.
2703             *
2704             * @param companyId the company ID
2705             * @param classNameId the class name ID
2706             * @return the number of matching websites
2707             */
2708            @Override
2709            public int countByC_C(long companyId, long classNameId) {
2710                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
2711    
2712                    Object[] finderArgs = new Object[] { companyId, classNameId };
2713    
2714                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2715    
2716                    if (count == null) {
2717                            StringBundler query = new StringBundler(3);
2718    
2719                            query.append(_SQL_COUNT_WEBSITE_WHERE);
2720    
2721                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2722    
2723                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2724    
2725                            String sql = query.toString();
2726    
2727                            Session session = null;
2728    
2729                            try {
2730                                    session = openSession();
2731    
2732                                    Query q = session.createQuery(sql);
2733    
2734                                    QueryPos qPos = QueryPos.getInstance(q);
2735    
2736                                    qPos.add(companyId);
2737    
2738                                    qPos.add(classNameId);
2739    
2740                                    count = (Long)q.uniqueResult();
2741    
2742                                    finderCache.putResult(finderPath, finderArgs, count);
2743                            }
2744                            catch (Exception e) {
2745                                    finderCache.removeResult(finderPath, finderArgs);
2746    
2747                                    throw processException(e);
2748                            }
2749                            finally {
2750                                    closeSession(session);
2751                            }
2752                    }
2753    
2754                    return count.intValue();
2755            }
2756    
2757            private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "website.companyId = ? AND ";
2758            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "website.classNameId = ?";
2759            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
2760                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
2761                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_C",
2762                            new String[] {
2763                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
2764                                    
2765                            Integer.class.getName(), Integer.class.getName(),
2766                                    OrderByComparator.class.getName()
2767                            });
2768            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
2769                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
2770                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_C",
2771                            new String[] {
2772                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
2773                            },
2774                            WebsiteModelImpl.COMPANYID_COLUMN_BITMASK |
2775                            WebsiteModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2776                            WebsiteModelImpl.CLASSPK_COLUMN_BITMASK |
2777                            WebsiteModelImpl.CREATEDATE_COLUMN_BITMASK);
2778            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
2779                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
2780                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
2781                            new String[] {
2782                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
2783                            });
2784    
2785            /**
2786             * Returns all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
2787             *
2788             * @param companyId the company ID
2789             * @param classNameId the class name ID
2790             * @param classPK the class p k
2791             * @return the matching websites
2792             */
2793            @Override
2794            public List<Website> findByC_C_C(long companyId, long classNameId,
2795                    long classPK) {
2796                    return findByC_C_C(companyId, classNameId, classPK, QueryUtil.ALL_POS,
2797                            QueryUtil.ALL_POS, null);
2798            }
2799    
2800            /**
2801             * Returns a range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
2802             *
2803             * <p>
2804             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2805             * </p>
2806             *
2807             * @param companyId the company ID
2808             * @param classNameId the class name ID
2809             * @param classPK the class p k
2810             * @param start the lower bound of the range of websites
2811             * @param end the upper bound of the range of websites (not inclusive)
2812             * @return the range of matching websites
2813             */
2814            @Override
2815            public List<Website> findByC_C_C(long companyId, long classNameId,
2816                    long classPK, int start, int end) {
2817                    return findByC_C_C(companyId, classNameId, classPK, start, end, null);
2818            }
2819    
2820            /**
2821             * Returns an ordered range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
2822             *
2823             * <p>
2824             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2825             * </p>
2826             *
2827             * @param companyId the company ID
2828             * @param classNameId the class name ID
2829             * @param classPK the class p k
2830             * @param start the lower bound of the range of websites
2831             * @param end the upper bound of the range of websites (not inclusive)
2832             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2833             * @return the ordered range of matching websites
2834             */
2835            @Override
2836            public List<Website> findByC_C_C(long companyId, long classNameId,
2837                    long classPK, int start, int end,
2838                    OrderByComparator<Website> orderByComparator) {
2839                    return findByC_C_C(companyId, classNameId, classPK, start, end,
2840                            orderByComparator, true);
2841            }
2842    
2843            /**
2844             * Returns an ordered range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
2845             *
2846             * <p>
2847             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2848             * </p>
2849             *
2850             * @param companyId the company ID
2851             * @param classNameId the class name ID
2852             * @param classPK the class p k
2853             * @param start the lower bound of the range of websites
2854             * @param end the upper bound of the range of websites (not inclusive)
2855             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2856             * @param retrieveFromCache whether to retrieve from the finder cache
2857             * @return the ordered range of matching websites
2858             */
2859            @Override
2860            public List<Website> findByC_C_C(long companyId, long classNameId,
2861                    long classPK, int start, int end,
2862                    OrderByComparator<Website> orderByComparator, boolean retrieveFromCache) {
2863                    boolean pagination = true;
2864                    FinderPath finderPath = null;
2865                    Object[] finderArgs = null;
2866    
2867                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2868                                    (orderByComparator == null)) {
2869                            pagination = false;
2870                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C;
2871                            finderArgs = new Object[] { companyId, classNameId, classPK };
2872                    }
2873                    else {
2874                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C;
2875                            finderArgs = new Object[] {
2876                                            companyId, classNameId, classPK,
2877                                            
2878                                            start, end, orderByComparator
2879                                    };
2880                    }
2881    
2882                    List<Website> list = null;
2883    
2884                    if (retrieveFromCache) {
2885                            list = (List<Website>)finderCache.getResult(finderPath, finderArgs,
2886                                            this);
2887    
2888                            if ((list != null) && !list.isEmpty()) {
2889                                    for (Website website : list) {
2890                                            if ((companyId != website.getCompanyId()) ||
2891                                                            (classNameId != website.getClassNameId()) ||
2892                                                            (classPK != website.getClassPK())) {
2893                                                    list = null;
2894    
2895                                                    break;
2896                                            }
2897                                    }
2898                            }
2899                    }
2900    
2901                    if (list == null) {
2902                            StringBundler query = null;
2903    
2904                            if (orderByComparator != null) {
2905                                    query = new StringBundler(5 +
2906                                                    (orderByComparator.getOrderByFields().length * 3));
2907                            }
2908                            else {
2909                                    query = new StringBundler(5);
2910                            }
2911    
2912                            query.append(_SQL_SELECT_WEBSITE_WHERE);
2913    
2914                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2915    
2916                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2917    
2918                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2919    
2920                            if (orderByComparator != null) {
2921                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2922                                            orderByComparator);
2923                            }
2924                            else
2925                             if (pagination) {
2926                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
2927                            }
2928    
2929                            String sql = query.toString();
2930    
2931                            Session session = null;
2932    
2933                            try {
2934                                    session = openSession();
2935    
2936                                    Query q = session.createQuery(sql);
2937    
2938                                    QueryPos qPos = QueryPos.getInstance(q);
2939    
2940                                    qPos.add(companyId);
2941    
2942                                    qPos.add(classNameId);
2943    
2944                                    qPos.add(classPK);
2945    
2946                                    if (!pagination) {
2947                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
2948                                                            start, end, false);
2949    
2950                                            Collections.sort(list);
2951    
2952                                            list = Collections.unmodifiableList(list);
2953                                    }
2954                                    else {
2955                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
2956                                                            start, end);
2957                                    }
2958    
2959                                    cacheResult(list);
2960    
2961                                    finderCache.putResult(finderPath, finderArgs, list);
2962                            }
2963                            catch (Exception e) {
2964                                    finderCache.removeResult(finderPath, finderArgs);
2965    
2966                                    throw processException(e);
2967                            }
2968                            finally {
2969                                    closeSession(session);
2970                            }
2971                    }
2972    
2973                    return list;
2974            }
2975    
2976            /**
2977             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
2978             *
2979             * @param companyId the company ID
2980             * @param classNameId the class name ID
2981             * @param classPK the class p k
2982             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2983             * @return the first matching website
2984             * @throws NoSuchWebsiteException if a matching website could not be found
2985             */
2986            @Override
2987            public Website findByC_C_C_First(long companyId, long classNameId,
2988                    long classPK, OrderByComparator<Website> orderByComparator)
2989                    throws NoSuchWebsiteException {
2990                    Website website = fetchByC_C_C_First(companyId, classNameId, classPK,
2991                                    orderByComparator);
2992    
2993                    if (website != null) {
2994                            return website;
2995                    }
2996    
2997                    StringBundler msg = new StringBundler(8);
2998    
2999                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3000    
3001                    msg.append("companyId=");
3002                    msg.append(companyId);
3003    
3004                    msg.append(", classNameId=");
3005                    msg.append(classNameId);
3006    
3007                    msg.append(", classPK=");
3008                    msg.append(classPK);
3009    
3010                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3011    
3012                    throw new NoSuchWebsiteException(msg.toString());
3013            }
3014    
3015            /**
3016             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
3017             *
3018             * @param companyId the company ID
3019             * @param classNameId the class name ID
3020             * @param classPK the class p k
3021             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3022             * @return the first matching website, or <code>null</code> if a matching website could not be found
3023             */
3024            @Override
3025            public Website fetchByC_C_C_First(long companyId, long classNameId,
3026                    long classPK, OrderByComparator<Website> orderByComparator) {
3027                    List<Website> list = findByC_C_C(companyId, classNameId, classPK, 0, 1,
3028                                    orderByComparator);
3029    
3030                    if (!list.isEmpty()) {
3031                            return list.get(0);
3032                    }
3033    
3034                    return null;
3035            }
3036    
3037            /**
3038             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
3039             *
3040             * @param companyId the company ID
3041             * @param classNameId the class name ID
3042             * @param classPK the class p k
3043             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3044             * @return the last matching website
3045             * @throws NoSuchWebsiteException if a matching website could not be found
3046             */
3047            @Override
3048            public Website findByC_C_C_Last(long companyId, long classNameId,
3049                    long classPK, OrderByComparator<Website> orderByComparator)
3050                    throws NoSuchWebsiteException {
3051                    Website website = fetchByC_C_C_Last(companyId, classNameId, classPK,
3052                                    orderByComparator);
3053    
3054                    if (website != null) {
3055                            return website;
3056                    }
3057    
3058                    StringBundler msg = new StringBundler(8);
3059    
3060                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3061    
3062                    msg.append("companyId=");
3063                    msg.append(companyId);
3064    
3065                    msg.append(", classNameId=");
3066                    msg.append(classNameId);
3067    
3068                    msg.append(", classPK=");
3069                    msg.append(classPK);
3070    
3071                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3072    
3073                    throw new NoSuchWebsiteException(msg.toString());
3074            }
3075    
3076            /**
3077             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
3078             *
3079             * @param companyId the company ID
3080             * @param classNameId the class name ID
3081             * @param classPK the class p k
3082             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3083             * @return the last matching website, or <code>null</code> if a matching website could not be found
3084             */
3085            @Override
3086            public Website fetchByC_C_C_Last(long companyId, long classNameId,
3087                    long classPK, OrderByComparator<Website> orderByComparator) {
3088                    int count = countByC_C_C(companyId, classNameId, classPK);
3089    
3090                    if (count == 0) {
3091                            return null;
3092                    }
3093    
3094                    List<Website> list = findByC_C_C(companyId, classNameId, classPK,
3095                                    count - 1, count, orderByComparator);
3096    
3097                    if (!list.isEmpty()) {
3098                            return list.get(0);
3099                    }
3100    
3101                    return null;
3102            }
3103    
3104            /**
3105             * Returns the websites before and after the current website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
3106             *
3107             * @param websiteId the primary key of the current website
3108             * @param companyId the company ID
3109             * @param classNameId the class name ID
3110             * @param classPK the class p k
3111             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3112             * @return the previous, current, and next website
3113             * @throws NoSuchWebsiteException if a website with the primary key could not be found
3114             */
3115            @Override
3116            public Website[] findByC_C_C_PrevAndNext(long websiteId, long companyId,
3117                    long classNameId, long classPK,
3118                    OrderByComparator<Website> orderByComparator)
3119                    throws NoSuchWebsiteException {
3120                    Website website = findByPrimaryKey(websiteId);
3121    
3122                    Session session = null;
3123    
3124                    try {
3125                            session = openSession();
3126    
3127                            Website[] array = new WebsiteImpl[3];
3128    
3129                            array[0] = getByC_C_C_PrevAndNext(session, website, companyId,
3130                                            classNameId, classPK, orderByComparator, true);
3131    
3132                            array[1] = website;
3133    
3134                            array[2] = getByC_C_C_PrevAndNext(session, website, companyId,
3135                                            classNameId, classPK, orderByComparator, false);
3136    
3137                            return array;
3138                    }
3139                    catch (Exception e) {
3140                            throw processException(e);
3141                    }
3142                    finally {
3143                            closeSession(session);
3144                    }
3145            }
3146    
3147            protected Website getByC_C_C_PrevAndNext(Session session, Website website,
3148                    long companyId, long classNameId, long classPK,
3149                    OrderByComparator<Website> orderByComparator, boolean previous) {
3150                    StringBundler query = null;
3151    
3152                    if (orderByComparator != null) {
3153                            query = new StringBundler(6 +
3154                                            (orderByComparator.getOrderByFields().length * 6));
3155                    }
3156                    else {
3157                            query = new StringBundler(3);
3158                    }
3159    
3160                    query.append(_SQL_SELECT_WEBSITE_WHERE);
3161    
3162                    query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3163    
3164                    query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3165    
3166                    query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3167    
3168                    if (orderByComparator != null) {
3169                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3170    
3171                            if (orderByConditionFields.length > 0) {
3172                                    query.append(WHERE_AND);
3173                            }
3174    
3175                            for (int i = 0; i < orderByConditionFields.length; i++) {
3176                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3177                                    query.append(orderByConditionFields[i]);
3178    
3179                                    if ((i + 1) < orderByConditionFields.length) {
3180                                            if (orderByComparator.isAscending() ^ previous) {
3181                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3182                                            }
3183                                            else {
3184                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3185                                            }
3186                                    }
3187                                    else {
3188                                            if (orderByComparator.isAscending() ^ previous) {
3189                                                    query.append(WHERE_GREATER_THAN);
3190                                            }
3191                                            else {
3192                                                    query.append(WHERE_LESSER_THAN);
3193                                            }
3194                                    }
3195                            }
3196    
3197                            query.append(ORDER_BY_CLAUSE);
3198    
3199                            String[] orderByFields = orderByComparator.getOrderByFields();
3200    
3201                            for (int i = 0; i < orderByFields.length; i++) {
3202                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3203                                    query.append(orderByFields[i]);
3204    
3205                                    if ((i + 1) < orderByFields.length) {
3206                                            if (orderByComparator.isAscending() ^ previous) {
3207                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3208                                            }
3209                                            else {
3210                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3211                                            }
3212                                    }
3213                                    else {
3214                                            if (orderByComparator.isAscending() ^ previous) {
3215                                                    query.append(ORDER_BY_ASC);
3216                                            }
3217                                            else {
3218                                                    query.append(ORDER_BY_DESC);
3219                                            }
3220                                    }
3221                            }
3222                    }
3223                    else {
3224                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
3225                    }
3226    
3227                    String sql = query.toString();
3228    
3229                    Query q = session.createQuery(sql);
3230    
3231                    q.setFirstResult(0);
3232                    q.setMaxResults(2);
3233    
3234                    QueryPos qPos = QueryPos.getInstance(q);
3235    
3236                    qPos.add(companyId);
3237    
3238                    qPos.add(classNameId);
3239    
3240                    qPos.add(classPK);
3241    
3242                    if (orderByComparator != null) {
3243                            Object[] values = orderByComparator.getOrderByConditionValues(website);
3244    
3245                            for (Object value : values) {
3246                                    qPos.add(value);
3247                            }
3248                    }
3249    
3250                    List<Website> list = q.list();
3251    
3252                    if (list.size() == 2) {
3253                            return list.get(1);
3254                    }
3255                    else {
3256                            return null;
3257                    }
3258            }
3259    
3260            /**
3261             * Removes all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
3262             *
3263             * @param companyId the company ID
3264             * @param classNameId the class name ID
3265             * @param classPK the class p k
3266             */
3267            @Override
3268            public void removeByC_C_C(long companyId, long classNameId, long classPK) {
3269                    for (Website website : findByC_C_C(companyId, classNameId, classPK,
3270                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3271                            remove(website);
3272                    }
3273            }
3274    
3275            /**
3276             * Returns the number of websites where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
3277             *
3278             * @param companyId the company ID
3279             * @param classNameId the class name ID
3280             * @param classPK the class p k
3281             * @return the number of matching websites
3282             */
3283            @Override
3284            public int countByC_C_C(long companyId, long classNameId, long classPK) {
3285                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_C;
3286    
3287                    Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3288    
3289                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3290    
3291                    if (count == null) {
3292                            StringBundler query = new StringBundler(4);
3293    
3294                            query.append(_SQL_COUNT_WEBSITE_WHERE);
3295    
3296                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3297    
3298                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3299    
3300                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3301    
3302                            String sql = query.toString();
3303    
3304                            Session session = null;
3305    
3306                            try {
3307                                    session = openSession();
3308    
3309                                    Query q = session.createQuery(sql);
3310    
3311                                    QueryPos qPos = QueryPos.getInstance(q);
3312    
3313                                    qPos.add(companyId);
3314    
3315                                    qPos.add(classNameId);
3316    
3317                                    qPos.add(classPK);
3318    
3319                                    count = (Long)q.uniqueResult();
3320    
3321                                    finderCache.putResult(finderPath, finderArgs, count);
3322                            }
3323                            catch (Exception e) {
3324                                    finderCache.removeResult(finderPath, finderArgs);
3325    
3326                                    throw processException(e);
3327                            }
3328                            finally {
3329                                    closeSession(session);
3330                            }
3331                    }
3332    
3333                    return count.intValue();
3334            }
3335    
3336            private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "website.companyId = ? AND ";
3337            private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "website.classNameId = ? AND ";
3338            private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "website.classPK = ?";
3339            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C_P = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
3340                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
3341                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_C_P",
3342                            new String[] {
3343                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
3344                                    Boolean.class.getName(),
3345                                    
3346                            Integer.class.getName(), Integer.class.getName(),
3347                                    OrderByComparator.class.getName()
3348                            });
3349            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P =
3350                    new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
3351                            WebsiteModelImpl.FINDER_CACHE_ENABLED, WebsiteImpl.class,
3352                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_C_P",
3353                            new String[] {
3354                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
3355                                    Boolean.class.getName()
3356                            },
3357                            WebsiteModelImpl.COMPANYID_COLUMN_BITMASK |
3358                            WebsiteModelImpl.CLASSNAMEID_COLUMN_BITMASK |
3359                            WebsiteModelImpl.CLASSPK_COLUMN_BITMASK |
3360                            WebsiteModelImpl.PRIMARY_COLUMN_BITMASK |
3361                            WebsiteModelImpl.CREATEDATE_COLUMN_BITMASK);
3362            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C_P = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
3363                            WebsiteModelImpl.FINDER_CACHE_ENABLED, Long.class,
3364                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C_P",
3365                            new String[] {
3366                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
3367                                    Boolean.class.getName()
3368                            });
3369    
3370            /**
3371             * Returns all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3372             *
3373             * @param companyId the company ID
3374             * @param classNameId the class name ID
3375             * @param classPK the class p k
3376             * @param primary the primary
3377             * @return the matching websites
3378             */
3379            @Override
3380            public List<Website> findByC_C_C_P(long companyId, long classNameId,
3381                    long classPK, boolean primary) {
3382                    return findByC_C_C_P(companyId, classNameId, classPK, primary,
3383                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3384            }
3385    
3386            /**
3387             * Returns a range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3388             *
3389             * <p>
3390             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3391             * </p>
3392             *
3393             * @param companyId the company ID
3394             * @param classNameId the class name ID
3395             * @param classPK the class p k
3396             * @param primary the primary
3397             * @param start the lower bound of the range of websites
3398             * @param end the upper bound of the range of websites (not inclusive)
3399             * @return the range of matching websites
3400             */
3401            @Override
3402            public List<Website> findByC_C_C_P(long companyId, long classNameId,
3403                    long classPK, boolean primary, int start, int end) {
3404                    return findByC_C_C_P(companyId, classNameId, classPK, primary, start,
3405                            end, null);
3406            }
3407    
3408            /**
3409             * Returns an ordered range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3410             *
3411             * <p>
3412             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3413             * </p>
3414             *
3415             * @param companyId the company ID
3416             * @param classNameId the class name ID
3417             * @param classPK the class p k
3418             * @param primary the primary
3419             * @param start the lower bound of the range of websites
3420             * @param end the upper bound of the range of websites (not inclusive)
3421             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3422             * @return the ordered range of matching websites
3423             */
3424            @Override
3425            public List<Website> findByC_C_C_P(long companyId, long classNameId,
3426                    long classPK, boolean primary, int start, int end,
3427                    OrderByComparator<Website> orderByComparator) {
3428                    return findByC_C_C_P(companyId, classNameId, classPK, primary, start,
3429                            end, orderByComparator, true);
3430            }
3431    
3432            /**
3433             * Returns an ordered range of all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3434             *
3435             * <p>
3436             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3437             * </p>
3438             *
3439             * @param companyId the company ID
3440             * @param classNameId the class name ID
3441             * @param classPK the class p k
3442             * @param primary the primary
3443             * @param start the lower bound of the range of websites
3444             * @param end the upper bound of the range of websites (not inclusive)
3445             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3446             * @param retrieveFromCache whether to retrieve from the finder cache
3447             * @return the ordered range of matching websites
3448             */
3449            @Override
3450            public List<Website> findByC_C_C_P(long companyId, long classNameId,
3451                    long classPK, boolean primary, int start, int end,
3452                    OrderByComparator<Website> orderByComparator, boolean retrieveFromCache) {
3453                    boolean pagination = true;
3454                    FinderPath finderPath = null;
3455                    Object[] finderArgs = null;
3456    
3457                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3458                                    (orderByComparator == null)) {
3459                            pagination = false;
3460                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P;
3461                            finderArgs = new Object[] { companyId, classNameId, classPK, primary };
3462                    }
3463                    else {
3464                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C_P;
3465                            finderArgs = new Object[] {
3466                                            companyId, classNameId, classPK, primary,
3467                                            
3468                                            start, end, orderByComparator
3469                                    };
3470                    }
3471    
3472                    List<Website> list = null;
3473    
3474                    if (retrieveFromCache) {
3475                            list = (List<Website>)finderCache.getResult(finderPath, finderArgs,
3476                                            this);
3477    
3478                            if ((list != null) && !list.isEmpty()) {
3479                                    for (Website website : list) {
3480                                            if ((companyId != website.getCompanyId()) ||
3481                                                            (classNameId != website.getClassNameId()) ||
3482                                                            (classPK != website.getClassPK()) ||
3483                                                            (primary != website.getPrimary())) {
3484                                                    list = null;
3485    
3486                                                    break;
3487                                            }
3488                                    }
3489                            }
3490                    }
3491    
3492                    if (list == null) {
3493                            StringBundler query = null;
3494    
3495                            if (orderByComparator != null) {
3496                                    query = new StringBundler(6 +
3497                                                    (orderByComparator.getOrderByFields().length * 3));
3498                            }
3499                            else {
3500                                    query = new StringBundler(6);
3501                            }
3502    
3503                            query.append(_SQL_SELECT_WEBSITE_WHERE);
3504    
3505                            query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
3506    
3507                            query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
3508    
3509                            query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
3510    
3511                            query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
3512    
3513                            if (orderByComparator != null) {
3514                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3515                                            orderByComparator);
3516                            }
3517                            else
3518                             if (pagination) {
3519                                    query.append(WebsiteModelImpl.ORDER_BY_JPQL);
3520                            }
3521    
3522                            String sql = query.toString();
3523    
3524                            Session session = null;
3525    
3526                            try {
3527                                    session = openSession();
3528    
3529                                    Query q = session.createQuery(sql);
3530    
3531                                    QueryPos qPos = QueryPos.getInstance(q);
3532    
3533                                    qPos.add(companyId);
3534    
3535                                    qPos.add(classNameId);
3536    
3537                                    qPos.add(classPK);
3538    
3539                                    qPos.add(primary);
3540    
3541                                    if (!pagination) {
3542                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
3543                                                            start, end, false);
3544    
3545                                            Collections.sort(list);
3546    
3547                                            list = Collections.unmodifiableList(list);
3548                                    }
3549                                    else {
3550                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
3551                                                            start, end);
3552                                    }
3553    
3554                                    cacheResult(list);
3555    
3556                                    finderCache.putResult(finderPath, finderArgs, list);
3557                            }
3558                            catch (Exception e) {
3559                                    finderCache.removeResult(finderPath, finderArgs);
3560    
3561                                    throw processException(e);
3562                            }
3563                            finally {
3564                                    closeSession(session);
3565                            }
3566                    }
3567    
3568                    return list;
3569            }
3570    
3571            /**
3572             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3573             *
3574             * @param companyId the company ID
3575             * @param classNameId the class name ID
3576             * @param classPK the class p k
3577             * @param primary the primary
3578             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3579             * @return the first matching website
3580             * @throws NoSuchWebsiteException if a matching website could not be found
3581             */
3582            @Override
3583            public Website findByC_C_C_P_First(long companyId, long classNameId,
3584                    long classPK, boolean primary,
3585                    OrderByComparator<Website> orderByComparator)
3586                    throws NoSuchWebsiteException {
3587                    Website website = fetchByC_C_C_P_First(companyId, classNameId, classPK,
3588                                    primary, orderByComparator);
3589    
3590                    if (website != null) {
3591                            return website;
3592                    }
3593    
3594                    StringBundler msg = new StringBundler(10);
3595    
3596                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3597    
3598                    msg.append("companyId=");
3599                    msg.append(companyId);
3600    
3601                    msg.append(", classNameId=");
3602                    msg.append(classNameId);
3603    
3604                    msg.append(", classPK=");
3605                    msg.append(classPK);
3606    
3607                    msg.append(", primary=");
3608                    msg.append(primary);
3609    
3610                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3611    
3612                    throw new NoSuchWebsiteException(msg.toString());
3613            }
3614    
3615            /**
3616             * Returns the first website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3617             *
3618             * @param companyId the company ID
3619             * @param classNameId the class name ID
3620             * @param classPK the class p k
3621             * @param primary the primary
3622             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3623             * @return the first matching website, or <code>null</code> if a matching website could not be found
3624             */
3625            @Override
3626            public Website fetchByC_C_C_P_First(long companyId, long classNameId,
3627                    long classPK, boolean primary,
3628                    OrderByComparator<Website> orderByComparator) {
3629                    List<Website> list = findByC_C_C_P(companyId, classNameId, classPK,
3630                                    primary, 0, 1, orderByComparator);
3631    
3632                    if (!list.isEmpty()) {
3633                            return list.get(0);
3634                    }
3635    
3636                    return null;
3637            }
3638    
3639            /**
3640             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3641             *
3642             * @param companyId the company ID
3643             * @param classNameId the class name ID
3644             * @param classPK the class p k
3645             * @param primary the primary
3646             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3647             * @return the last matching website
3648             * @throws NoSuchWebsiteException if a matching website could not be found
3649             */
3650            @Override
3651            public Website findByC_C_C_P_Last(long companyId, long classNameId,
3652                    long classPK, boolean primary,
3653                    OrderByComparator<Website> orderByComparator)
3654                    throws NoSuchWebsiteException {
3655                    Website website = fetchByC_C_C_P_Last(companyId, classNameId, classPK,
3656                                    primary, orderByComparator);
3657    
3658                    if (website != null) {
3659                            return website;
3660                    }
3661    
3662                    StringBundler msg = new StringBundler(10);
3663    
3664                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3665    
3666                    msg.append("companyId=");
3667                    msg.append(companyId);
3668    
3669                    msg.append(", classNameId=");
3670                    msg.append(classNameId);
3671    
3672                    msg.append(", classPK=");
3673                    msg.append(classPK);
3674    
3675                    msg.append(", primary=");
3676                    msg.append(primary);
3677    
3678                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3679    
3680                    throw new NoSuchWebsiteException(msg.toString());
3681            }
3682    
3683            /**
3684             * Returns the last website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3685             *
3686             * @param companyId the company ID
3687             * @param classNameId the class name ID
3688             * @param classPK the class p k
3689             * @param primary the primary
3690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3691             * @return the last matching website, or <code>null</code> if a matching website could not be found
3692             */
3693            @Override
3694            public Website fetchByC_C_C_P_Last(long companyId, long classNameId,
3695                    long classPK, boolean primary,
3696                    OrderByComparator<Website> orderByComparator) {
3697                    int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
3698    
3699                    if (count == 0) {
3700                            return null;
3701                    }
3702    
3703                    List<Website> list = findByC_C_C_P(companyId, classNameId, classPK,
3704                                    primary, count - 1, count, orderByComparator);
3705    
3706                    if (!list.isEmpty()) {
3707                            return list.get(0);
3708                    }
3709    
3710                    return null;
3711            }
3712    
3713            /**
3714             * Returns the websites before and after the current website in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3715             *
3716             * @param websiteId the primary key of the current website
3717             * @param companyId the company ID
3718             * @param classNameId the class name ID
3719             * @param classPK the class p k
3720             * @param primary the primary
3721             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3722             * @return the previous, current, and next website
3723             * @throws NoSuchWebsiteException if a website with the primary key could not be found
3724             */
3725            @Override
3726            public Website[] findByC_C_C_P_PrevAndNext(long websiteId, long companyId,
3727                    long classNameId, long classPK, boolean primary,
3728                    OrderByComparator<Website> orderByComparator)
3729                    throws NoSuchWebsiteException {
3730                    Website website = findByPrimaryKey(websiteId);
3731    
3732                    Session session = null;
3733    
3734                    try {
3735                            session = openSession();
3736    
3737                            Website[] array = new WebsiteImpl[3];
3738    
3739                            array[0] = getByC_C_C_P_PrevAndNext(session, website, companyId,
3740                                            classNameId, classPK, primary, orderByComparator, true);
3741    
3742                            array[1] = website;
3743    
3744                            array[2] = getByC_C_C_P_PrevAndNext(session, website, companyId,
3745                                            classNameId, classPK, primary, orderByComparator, false);
3746    
3747                            return array;
3748                    }
3749                    catch (Exception e) {
3750                            throw processException(e);
3751                    }
3752                    finally {
3753                            closeSession(session);
3754                    }
3755            }
3756    
3757            protected Website getByC_C_C_P_PrevAndNext(Session session,
3758                    Website website, long companyId, long classNameId, long classPK,
3759                    boolean primary, OrderByComparator<Website> orderByComparator,
3760                    boolean previous) {
3761                    StringBundler query = null;
3762    
3763                    if (orderByComparator != null) {
3764                            query = new StringBundler(6 +
3765                                            (orderByComparator.getOrderByFields().length * 6));
3766                    }
3767                    else {
3768                            query = new StringBundler(3);
3769                    }
3770    
3771                    query.append(_SQL_SELECT_WEBSITE_WHERE);
3772    
3773                    query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
3774    
3775                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
3776    
3777                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
3778    
3779                    query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
3780    
3781                    if (orderByComparator != null) {
3782                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3783    
3784                            if (orderByConditionFields.length > 0) {
3785                                    query.append(WHERE_AND);
3786                            }
3787    
3788                            for (int i = 0; i < orderByConditionFields.length; i++) {
3789                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3790                                    query.append(orderByConditionFields[i]);
3791    
3792                                    if ((i + 1) < orderByConditionFields.length) {
3793                                            if (orderByComparator.isAscending() ^ previous) {
3794                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3795                                            }
3796                                            else {
3797                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3798                                            }
3799                                    }
3800                                    else {
3801                                            if (orderByComparator.isAscending() ^ previous) {
3802                                                    query.append(WHERE_GREATER_THAN);
3803                                            }
3804                                            else {
3805                                                    query.append(WHERE_LESSER_THAN);
3806                                            }
3807                                    }
3808                            }
3809    
3810                            query.append(ORDER_BY_CLAUSE);
3811    
3812                            String[] orderByFields = orderByComparator.getOrderByFields();
3813    
3814                            for (int i = 0; i < orderByFields.length; i++) {
3815                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3816                                    query.append(orderByFields[i]);
3817    
3818                                    if ((i + 1) < orderByFields.length) {
3819                                            if (orderByComparator.isAscending() ^ previous) {
3820                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3821                                            }
3822                                            else {
3823                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3824                                            }
3825                                    }
3826                                    else {
3827                                            if (orderByComparator.isAscending() ^ previous) {
3828                                                    query.append(ORDER_BY_ASC);
3829                                            }
3830                                            else {
3831                                                    query.append(ORDER_BY_DESC);
3832                                            }
3833                                    }
3834                            }
3835                    }
3836                    else {
3837                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
3838                    }
3839    
3840                    String sql = query.toString();
3841    
3842                    Query q = session.createQuery(sql);
3843    
3844                    q.setFirstResult(0);
3845                    q.setMaxResults(2);
3846    
3847                    QueryPos qPos = QueryPos.getInstance(q);
3848    
3849                    qPos.add(companyId);
3850    
3851                    qPos.add(classNameId);
3852    
3853                    qPos.add(classPK);
3854    
3855                    qPos.add(primary);
3856    
3857                    if (orderByComparator != null) {
3858                            Object[] values = orderByComparator.getOrderByConditionValues(website);
3859    
3860                            for (Object value : values) {
3861                                    qPos.add(value);
3862                            }
3863                    }
3864    
3865                    List<Website> list = q.list();
3866    
3867                    if (list.size() == 2) {
3868                            return list.get(1);
3869                    }
3870                    else {
3871                            return null;
3872                    }
3873            }
3874    
3875            /**
3876             * Removes all the websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63; from the database.
3877             *
3878             * @param companyId the company ID
3879             * @param classNameId the class name ID
3880             * @param classPK the class p k
3881             * @param primary the primary
3882             */
3883            @Override
3884            public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
3885                    boolean primary) {
3886                    for (Website website : findByC_C_C_P(companyId, classNameId, classPK,
3887                                    primary, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3888                            remove(website);
3889                    }
3890            }
3891    
3892            /**
3893             * Returns the number of websites where companyId = &#63; and classNameId = &#63; and classPK = &#63; and primary = &#63;.
3894             *
3895             * @param companyId the company ID
3896             * @param classNameId the class name ID
3897             * @param classPK the class p k
3898             * @param primary the primary
3899             * @return the number of matching websites
3900             */
3901            @Override
3902            public int countByC_C_C_P(long companyId, long classNameId, long classPK,
3903                    boolean primary) {
3904                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_C_P;
3905    
3906                    Object[] finderArgs = new Object[] {
3907                                    companyId, classNameId, classPK, primary
3908                            };
3909    
3910                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3911    
3912                    if (count == null) {
3913                            StringBundler query = new StringBundler(5);
3914    
3915                            query.append(_SQL_COUNT_WEBSITE_WHERE);
3916    
3917                            query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
3918    
3919                            query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
3920    
3921                            query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
3922    
3923                            query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
3924    
3925                            String sql = query.toString();
3926    
3927                            Session session = null;
3928    
3929                            try {
3930                                    session = openSession();
3931    
3932                                    Query q = session.createQuery(sql);
3933    
3934                                    QueryPos qPos = QueryPos.getInstance(q);
3935    
3936                                    qPos.add(companyId);
3937    
3938                                    qPos.add(classNameId);
3939    
3940                                    qPos.add(classPK);
3941    
3942                                    qPos.add(primary);
3943    
3944                                    count = (Long)q.uniqueResult();
3945    
3946                                    finderCache.putResult(finderPath, finderArgs, count);
3947                            }
3948                            catch (Exception e) {
3949                                    finderCache.removeResult(finderPath, finderArgs);
3950    
3951                                    throw processException(e);
3952                            }
3953                            finally {
3954                                    closeSession(session);
3955                            }
3956                    }
3957    
3958                    return count.intValue();
3959            }
3960    
3961            private static final String _FINDER_COLUMN_C_C_C_P_COMPANYID_2 = "website.companyId = ? AND ";
3962            private static final String _FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2 = "website.classNameId = ? AND ";
3963            private static final String _FINDER_COLUMN_C_C_C_P_CLASSPK_2 = "website.classPK = ? AND ";
3964            private static final String _FINDER_COLUMN_C_C_C_P_PRIMARY_2 = "website.primary = ?";
3965    
3966            public WebsitePersistenceImpl() {
3967                    setModelClass(Website.class);
3968            }
3969    
3970            /**
3971             * Caches the website in the entity cache if it is enabled.
3972             *
3973             * @param website the website
3974             */
3975            @Override
3976            public void cacheResult(Website website) {
3977                    entityCache.putResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
3978                            WebsiteImpl.class, website.getPrimaryKey(), website);
3979    
3980                    website.resetOriginalValues();
3981            }
3982    
3983            /**
3984             * Caches the websites in the entity cache if it is enabled.
3985             *
3986             * @param websites the websites
3987             */
3988            @Override
3989            public void cacheResult(List<Website> websites) {
3990                    for (Website website : websites) {
3991                            if (entityCache.getResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
3992                                                    WebsiteImpl.class, website.getPrimaryKey()) == null) {
3993                                    cacheResult(website);
3994                            }
3995                            else {
3996                                    website.resetOriginalValues();
3997                            }
3998                    }
3999            }
4000    
4001            /**
4002             * Clears the cache for all websites.
4003             *
4004             * <p>
4005             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
4006             * </p>
4007             */
4008            @Override
4009            public void clearCache() {
4010                    entityCache.clearCache(WebsiteImpl.class);
4011    
4012                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
4013                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4014                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4015            }
4016    
4017            /**
4018             * Clears the cache for the website.
4019             *
4020             * <p>
4021             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
4022             * </p>
4023             */
4024            @Override
4025            public void clearCache(Website website) {
4026                    entityCache.removeResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
4027                            WebsiteImpl.class, website.getPrimaryKey());
4028    
4029                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4030                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4031            }
4032    
4033            @Override
4034            public void clearCache(List<Website> websites) {
4035                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4036                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4037    
4038                    for (Website website : websites) {
4039                            entityCache.removeResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
4040                                    WebsiteImpl.class, website.getPrimaryKey());
4041                    }
4042            }
4043    
4044            /**
4045             * Creates a new website with the primary key. Does not add the website to the database.
4046             *
4047             * @param websiteId the primary key for the new website
4048             * @return the new website
4049             */
4050            @Override
4051            public Website create(long websiteId) {
4052                    Website website = new WebsiteImpl();
4053    
4054                    website.setNew(true);
4055                    website.setPrimaryKey(websiteId);
4056    
4057                    String uuid = PortalUUIDUtil.generate();
4058    
4059                    website.setUuid(uuid);
4060    
4061                    return website;
4062            }
4063    
4064            /**
4065             * Removes the website with the primary key from the database. Also notifies the appropriate model listeners.
4066             *
4067             * @param websiteId the primary key of the website
4068             * @return the website that was removed
4069             * @throws NoSuchWebsiteException if a website with the primary key could not be found
4070             */
4071            @Override
4072            public Website remove(long websiteId) throws NoSuchWebsiteException {
4073                    return remove((Serializable)websiteId);
4074            }
4075    
4076            /**
4077             * Removes the website with the primary key from the database. Also notifies the appropriate model listeners.
4078             *
4079             * @param primaryKey the primary key of the website
4080             * @return the website that was removed
4081             * @throws NoSuchWebsiteException if a website with the primary key could not be found
4082             */
4083            @Override
4084            public Website remove(Serializable primaryKey)
4085                    throws NoSuchWebsiteException {
4086                    Session session = null;
4087    
4088                    try {
4089                            session = openSession();
4090    
4091                            Website website = (Website)session.get(WebsiteImpl.class, primaryKey);
4092    
4093                            if (website == null) {
4094                                    if (_log.isWarnEnabled()) {
4095                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4096                                    }
4097    
4098                                    throw new NoSuchWebsiteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4099                                            primaryKey);
4100                            }
4101    
4102                            return remove(website);
4103                    }
4104                    catch (NoSuchWebsiteException nsee) {
4105                            throw nsee;
4106                    }
4107                    catch (Exception e) {
4108                            throw processException(e);
4109                    }
4110                    finally {
4111                            closeSession(session);
4112                    }
4113            }
4114    
4115            @Override
4116            protected Website removeImpl(Website website) {
4117                    website = toUnwrappedModel(website);
4118    
4119                    Session session = null;
4120    
4121                    try {
4122                            session = openSession();
4123    
4124                            if (!session.contains(website)) {
4125                                    website = (Website)session.get(WebsiteImpl.class,
4126                                                    website.getPrimaryKeyObj());
4127                            }
4128    
4129                            if (website != null) {
4130                                    session.delete(website);
4131                            }
4132                    }
4133                    catch (Exception e) {
4134                            throw processException(e);
4135                    }
4136                    finally {
4137                            closeSession(session);
4138                    }
4139    
4140                    if (website != null) {
4141                            clearCache(website);
4142                    }
4143    
4144                    return website;
4145            }
4146    
4147            @Override
4148            public Website updateImpl(Website website) {
4149                    website = toUnwrappedModel(website);
4150    
4151                    boolean isNew = website.isNew();
4152    
4153                    WebsiteModelImpl websiteModelImpl = (WebsiteModelImpl)website;
4154    
4155                    if (Validator.isNull(website.getUuid())) {
4156                            String uuid = PortalUUIDUtil.generate();
4157    
4158                            website.setUuid(uuid);
4159                    }
4160    
4161                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
4162    
4163                    Date now = new Date();
4164    
4165                    if (isNew && (website.getCreateDate() == null)) {
4166                            if (serviceContext == null) {
4167                                    website.setCreateDate(now);
4168                            }
4169                            else {
4170                                    website.setCreateDate(serviceContext.getCreateDate(now));
4171                            }
4172                    }
4173    
4174                    if (!websiteModelImpl.hasSetModifiedDate()) {
4175                            if (serviceContext == null) {
4176                                    website.setModifiedDate(now);
4177                            }
4178                            else {
4179                                    website.setModifiedDate(serviceContext.getModifiedDate(now));
4180                            }
4181                    }
4182    
4183                    Session session = null;
4184    
4185                    try {
4186                            session = openSession();
4187    
4188                            if (website.isNew()) {
4189                                    session.save(website);
4190    
4191                                    website.setNew(false);
4192                            }
4193                            else {
4194                                    website = (Website)session.merge(website);
4195                            }
4196                    }
4197                    catch (Exception e) {
4198                            throw processException(e);
4199                    }
4200                    finally {
4201                            closeSession(session);
4202                    }
4203    
4204                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4205    
4206                    if (isNew || !WebsiteModelImpl.COLUMN_BITMASK_ENABLED) {
4207                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4208                    }
4209    
4210                    else {
4211                            if ((websiteModelImpl.getColumnBitmask() &
4212                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
4213                                    Object[] args = new Object[] { websiteModelImpl.getOriginalUuid() };
4214    
4215                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4216                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4217                                            args);
4218    
4219                                    args = new Object[] { websiteModelImpl.getUuid() };
4220    
4221                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4222                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4223                                            args);
4224                            }
4225    
4226                            if ((websiteModelImpl.getColumnBitmask() &
4227                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
4228                                    Object[] args = new Object[] {
4229                                                    websiteModelImpl.getOriginalUuid(),
4230                                                    websiteModelImpl.getOriginalCompanyId()
4231                                            };
4232    
4233                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4234                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4235                                            args);
4236    
4237                                    args = new Object[] {
4238                                                    websiteModelImpl.getUuid(),
4239                                                    websiteModelImpl.getCompanyId()
4240                                            };
4241    
4242                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4243                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4244                                            args);
4245                            }
4246    
4247                            if ((websiteModelImpl.getColumnBitmask() &
4248                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
4249                                    Object[] args = new Object[] {
4250                                                    websiteModelImpl.getOriginalCompanyId()
4251                                            };
4252    
4253                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
4254                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4255                                            args);
4256    
4257                                    args = new Object[] { websiteModelImpl.getCompanyId() };
4258    
4259                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
4260                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4261                                            args);
4262                            }
4263    
4264                            if ((websiteModelImpl.getColumnBitmask() &
4265                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
4266                                    Object[] args = new Object[] {
4267                                                    websiteModelImpl.getOriginalUserId()
4268                                            };
4269    
4270                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
4271                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
4272                                            args);
4273    
4274                                    args = new Object[] { websiteModelImpl.getUserId() };
4275    
4276                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
4277                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
4278                                            args);
4279                            }
4280    
4281                            if ((websiteModelImpl.getColumnBitmask() &
4282                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
4283                                    Object[] args = new Object[] {
4284                                                    websiteModelImpl.getOriginalCompanyId(),
4285                                                    websiteModelImpl.getOriginalClassNameId()
4286                                            };
4287    
4288                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
4289                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
4290                                            args);
4291    
4292                                    args = new Object[] {
4293                                                    websiteModelImpl.getCompanyId(),
4294                                                    websiteModelImpl.getClassNameId()
4295                                            };
4296    
4297                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
4298                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
4299                                            args);
4300                            }
4301    
4302                            if ((websiteModelImpl.getColumnBitmask() &
4303                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C.getColumnBitmask()) != 0) {
4304                                    Object[] args = new Object[] {
4305                                                    websiteModelImpl.getOriginalCompanyId(),
4306                                                    websiteModelImpl.getOriginalClassNameId(),
4307                                                    websiteModelImpl.getOriginalClassPK()
4308                                            };
4309    
4310                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
4311                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
4312                                            args);
4313    
4314                                    args = new Object[] {
4315                                                    websiteModelImpl.getCompanyId(),
4316                                                    websiteModelImpl.getClassNameId(),
4317                                                    websiteModelImpl.getClassPK()
4318                                            };
4319    
4320                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
4321                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
4322                                            args);
4323                            }
4324    
4325                            if ((websiteModelImpl.getColumnBitmask() &
4326                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P.getColumnBitmask()) != 0) {
4327                                    Object[] args = new Object[] {
4328                                                    websiteModelImpl.getOriginalCompanyId(),
4329                                                    websiteModelImpl.getOriginalClassNameId(),
4330                                                    websiteModelImpl.getOriginalClassPK(),
4331                                                    websiteModelImpl.getOriginalPrimary()
4332                                            };
4333    
4334                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
4335                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
4336                                            args);
4337    
4338                                    args = new Object[] {
4339                                                    websiteModelImpl.getCompanyId(),
4340                                                    websiteModelImpl.getClassNameId(),
4341                                                    websiteModelImpl.getClassPK(),
4342                                                    websiteModelImpl.getPrimary()
4343                                            };
4344    
4345                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_C_P, args);
4346                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C_P,
4347                                            args);
4348                            }
4349                    }
4350    
4351                    entityCache.putResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
4352                            WebsiteImpl.class, website.getPrimaryKey(), website, false);
4353    
4354                    website.resetOriginalValues();
4355    
4356                    return website;
4357            }
4358    
4359            protected Website toUnwrappedModel(Website website) {
4360                    if (website instanceof WebsiteImpl) {
4361                            return website;
4362                    }
4363    
4364                    WebsiteImpl websiteImpl = new WebsiteImpl();
4365    
4366                    websiteImpl.setNew(website.isNew());
4367                    websiteImpl.setPrimaryKey(website.getPrimaryKey());
4368    
4369                    websiteImpl.setMvccVersion(website.getMvccVersion());
4370                    websiteImpl.setUuid(website.getUuid());
4371                    websiteImpl.setWebsiteId(website.getWebsiteId());
4372                    websiteImpl.setCompanyId(website.getCompanyId());
4373                    websiteImpl.setUserId(website.getUserId());
4374                    websiteImpl.setUserName(website.getUserName());
4375                    websiteImpl.setCreateDate(website.getCreateDate());
4376                    websiteImpl.setModifiedDate(website.getModifiedDate());
4377                    websiteImpl.setClassNameId(website.getClassNameId());
4378                    websiteImpl.setClassPK(website.getClassPK());
4379                    websiteImpl.setUrl(website.getUrl());
4380                    websiteImpl.setTypeId(website.getTypeId());
4381                    websiteImpl.setPrimary(website.isPrimary());
4382                    websiteImpl.setLastPublishDate(website.getLastPublishDate());
4383    
4384                    return websiteImpl;
4385            }
4386    
4387            /**
4388             * Returns the website with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
4389             *
4390             * @param primaryKey the primary key of the website
4391             * @return the website
4392             * @throws NoSuchWebsiteException if a website with the primary key could not be found
4393             */
4394            @Override
4395            public Website findByPrimaryKey(Serializable primaryKey)
4396                    throws NoSuchWebsiteException {
4397                    Website website = fetchByPrimaryKey(primaryKey);
4398    
4399                    if (website == null) {
4400                            if (_log.isWarnEnabled()) {
4401                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4402                            }
4403    
4404                            throw new NoSuchWebsiteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4405                                    primaryKey);
4406                    }
4407    
4408                    return website;
4409            }
4410    
4411            /**
4412             * Returns the website with the primary key or throws a {@link NoSuchWebsiteException} if it could not be found.
4413             *
4414             * @param websiteId the primary key of the website
4415             * @return the website
4416             * @throws NoSuchWebsiteException if a website with the primary key could not be found
4417             */
4418            @Override
4419            public Website findByPrimaryKey(long websiteId)
4420                    throws NoSuchWebsiteException {
4421                    return findByPrimaryKey((Serializable)websiteId);
4422            }
4423    
4424            /**
4425             * Returns the website with the primary key or returns <code>null</code> if it could not be found.
4426             *
4427             * @param primaryKey the primary key of the website
4428             * @return the website, or <code>null</code> if a website with the primary key could not be found
4429             */
4430            @Override
4431            public Website fetchByPrimaryKey(Serializable primaryKey) {
4432                    Website website = (Website)entityCache.getResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
4433                                    WebsiteImpl.class, primaryKey);
4434    
4435                    if (website == _nullWebsite) {
4436                            return null;
4437                    }
4438    
4439                    if (website == null) {
4440                            Session session = null;
4441    
4442                            try {
4443                                    session = openSession();
4444    
4445                                    website = (Website)session.get(WebsiteImpl.class, primaryKey);
4446    
4447                                    if (website != null) {
4448                                            cacheResult(website);
4449                                    }
4450                                    else {
4451                                            entityCache.putResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
4452                                                    WebsiteImpl.class, primaryKey, _nullWebsite);
4453                                    }
4454                            }
4455                            catch (Exception e) {
4456                                    entityCache.removeResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
4457                                            WebsiteImpl.class, primaryKey);
4458    
4459                                    throw processException(e);
4460                            }
4461                            finally {
4462                                    closeSession(session);
4463                            }
4464                    }
4465    
4466                    return website;
4467            }
4468    
4469            /**
4470             * Returns the website with the primary key or returns <code>null</code> if it could not be found.
4471             *
4472             * @param websiteId the primary key of the website
4473             * @return the website, or <code>null</code> if a website with the primary key could not be found
4474             */
4475            @Override
4476            public Website fetchByPrimaryKey(long websiteId) {
4477                    return fetchByPrimaryKey((Serializable)websiteId);
4478            }
4479    
4480            @Override
4481            public Map<Serializable, Website> fetchByPrimaryKeys(
4482                    Set<Serializable> primaryKeys) {
4483                    if (primaryKeys.isEmpty()) {
4484                            return Collections.emptyMap();
4485                    }
4486    
4487                    Map<Serializable, Website> map = new HashMap<Serializable, Website>();
4488    
4489                    if (primaryKeys.size() == 1) {
4490                            Iterator<Serializable> iterator = primaryKeys.iterator();
4491    
4492                            Serializable primaryKey = iterator.next();
4493    
4494                            Website website = fetchByPrimaryKey(primaryKey);
4495    
4496                            if (website != null) {
4497                                    map.put(primaryKey, website);
4498                            }
4499    
4500                            return map;
4501                    }
4502    
4503                    Set<Serializable> uncachedPrimaryKeys = null;
4504    
4505                    for (Serializable primaryKey : primaryKeys) {
4506                            Website website = (Website)entityCache.getResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
4507                                            WebsiteImpl.class, primaryKey);
4508    
4509                            if (website == null) {
4510                                    if (uncachedPrimaryKeys == null) {
4511                                            uncachedPrimaryKeys = new HashSet<Serializable>();
4512                                    }
4513    
4514                                    uncachedPrimaryKeys.add(primaryKey);
4515                            }
4516                            else {
4517                                    map.put(primaryKey, website);
4518                            }
4519                    }
4520    
4521                    if (uncachedPrimaryKeys == null) {
4522                            return map;
4523                    }
4524    
4525                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
4526                                    1);
4527    
4528                    query.append(_SQL_SELECT_WEBSITE_WHERE_PKS_IN);
4529    
4530                    for (Serializable primaryKey : uncachedPrimaryKeys) {
4531                            query.append(String.valueOf(primaryKey));
4532    
4533                            query.append(StringPool.COMMA);
4534                    }
4535    
4536                    query.setIndex(query.index() - 1);
4537    
4538                    query.append(StringPool.CLOSE_PARENTHESIS);
4539    
4540                    String sql = query.toString();
4541    
4542                    Session session = null;
4543    
4544                    try {
4545                            session = openSession();
4546    
4547                            Query q = session.createQuery(sql);
4548    
4549                            for (Website website : (List<Website>)q.list()) {
4550                                    map.put(website.getPrimaryKeyObj(), website);
4551    
4552                                    cacheResult(website);
4553    
4554                                    uncachedPrimaryKeys.remove(website.getPrimaryKeyObj());
4555                            }
4556    
4557                            for (Serializable primaryKey : uncachedPrimaryKeys) {
4558                                    entityCache.putResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
4559                                            WebsiteImpl.class, primaryKey, _nullWebsite);
4560                            }
4561                    }
4562                    catch (Exception e) {
4563                            throw processException(e);
4564                    }
4565                    finally {
4566                            closeSession(session);
4567                    }
4568    
4569                    return map;
4570            }
4571    
4572            /**
4573             * Returns all the websites.
4574             *
4575             * @return the websites
4576             */
4577            @Override
4578            public List<Website> findAll() {
4579                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4580            }
4581    
4582            /**
4583             * Returns a range of all the websites.
4584             *
4585             * <p>
4586             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4587             * </p>
4588             *
4589             * @param start the lower bound of the range of websites
4590             * @param end the upper bound of the range of websites (not inclusive)
4591             * @return the range of websites
4592             */
4593            @Override
4594            public List<Website> findAll(int start, int end) {
4595                    return findAll(start, end, null);
4596            }
4597    
4598            /**
4599             * Returns an ordered range of all the websites.
4600             *
4601             * <p>
4602             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4603             * </p>
4604             *
4605             * @param start the lower bound of the range of websites
4606             * @param end the upper bound of the range of websites (not inclusive)
4607             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4608             * @return the ordered range of websites
4609             */
4610            @Override
4611            public List<Website> findAll(int start, int end,
4612                    OrderByComparator<Website> orderByComparator) {
4613                    return findAll(start, end, orderByComparator, true);
4614            }
4615    
4616            /**
4617             * Returns an ordered range of all the websites.
4618             *
4619             * <p>
4620             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link WebsiteModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4621             * </p>
4622             *
4623             * @param start the lower bound of the range of websites
4624             * @param end the upper bound of the range of websites (not inclusive)
4625             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4626             * @param retrieveFromCache whether to retrieve from the finder cache
4627             * @return the ordered range of websites
4628             */
4629            @Override
4630            public List<Website> findAll(int start, int end,
4631                    OrderByComparator<Website> orderByComparator, boolean retrieveFromCache) {
4632                    boolean pagination = true;
4633                    FinderPath finderPath = null;
4634                    Object[] finderArgs = null;
4635    
4636                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4637                                    (orderByComparator == null)) {
4638                            pagination = false;
4639                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4640                            finderArgs = FINDER_ARGS_EMPTY;
4641                    }
4642                    else {
4643                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4644                            finderArgs = new Object[] { start, end, orderByComparator };
4645                    }
4646    
4647                    List<Website> list = null;
4648    
4649                    if (retrieveFromCache) {
4650                            list = (List<Website>)finderCache.getResult(finderPath, finderArgs,
4651                                            this);
4652                    }
4653    
4654                    if (list == null) {
4655                            StringBundler query = null;
4656                            String sql = null;
4657    
4658                            if (orderByComparator != null) {
4659                                    query = new StringBundler(2 +
4660                                                    (orderByComparator.getOrderByFields().length * 3));
4661    
4662                                    query.append(_SQL_SELECT_WEBSITE);
4663    
4664                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4665                                            orderByComparator);
4666    
4667                                    sql = query.toString();
4668                            }
4669                            else {
4670                                    sql = _SQL_SELECT_WEBSITE;
4671    
4672                                    if (pagination) {
4673                                            sql = sql.concat(WebsiteModelImpl.ORDER_BY_JPQL);
4674                                    }
4675                            }
4676    
4677                            Session session = null;
4678    
4679                            try {
4680                                    session = openSession();
4681    
4682                                    Query q = session.createQuery(sql);
4683    
4684                                    if (!pagination) {
4685                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
4686                                                            start, end, false);
4687    
4688                                            Collections.sort(list);
4689    
4690                                            list = Collections.unmodifiableList(list);
4691                                    }
4692                                    else {
4693                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
4694                                                            start, end);
4695                                    }
4696    
4697                                    cacheResult(list);
4698    
4699                                    finderCache.putResult(finderPath, finderArgs, list);
4700                            }
4701                            catch (Exception e) {
4702                                    finderCache.removeResult(finderPath, finderArgs);
4703    
4704                                    throw processException(e);
4705                            }
4706                            finally {
4707                                    closeSession(session);
4708                            }
4709                    }
4710    
4711                    return list;
4712            }
4713    
4714            /**
4715             * Removes all the websites from the database.
4716             *
4717             */
4718            @Override
4719            public void removeAll() {
4720                    for (Website website : findAll()) {
4721                            remove(website);
4722                    }
4723            }
4724    
4725            /**
4726             * Returns the number of websites.
4727             *
4728             * @return the number of websites
4729             */
4730            @Override
4731            public int countAll() {
4732                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
4733                                    FINDER_ARGS_EMPTY, this);
4734    
4735                    if (count == null) {
4736                            Session session = null;
4737    
4738                            try {
4739                                    session = openSession();
4740    
4741                                    Query q = session.createQuery(_SQL_COUNT_WEBSITE);
4742    
4743                                    count = (Long)q.uniqueResult();
4744    
4745                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
4746                                            count);
4747                            }
4748                            catch (Exception e) {
4749                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
4750                                            FINDER_ARGS_EMPTY);
4751    
4752                                    throw processException(e);
4753                            }
4754                            finally {
4755                                    closeSession(session);
4756                            }
4757                    }
4758    
4759                    return count.intValue();
4760            }
4761    
4762            @Override
4763            public Set<String> getBadColumnNames() {
4764                    return _badColumnNames;
4765            }
4766    
4767            @Override
4768            protected Map<String, Integer> getTableColumnsMap() {
4769                    return WebsiteModelImpl.TABLE_COLUMNS_MAP;
4770            }
4771    
4772            /**
4773             * Initializes the website persistence.
4774             */
4775            public void afterPropertiesSet() {
4776            }
4777    
4778            public void destroy() {
4779                    entityCache.removeCache(WebsiteImpl.class.getName());
4780                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
4781                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4782                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4783            }
4784    
4785            @BeanReference(type = CompanyProvider.class)
4786            protected CompanyProvider companyProvider;
4787            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
4788            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
4789            private static final String _SQL_SELECT_WEBSITE = "SELECT website FROM Website website";
4790            private static final String _SQL_SELECT_WEBSITE_WHERE_PKS_IN = "SELECT website FROM Website website WHERE websiteId IN (";
4791            private static final String _SQL_SELECT_WEBSITE_WHERE = "SELECT website FROM Website website WHERE ";
4792            private static final String _SQL_COUNT_WEBSITE = "SELECT COUNT(website) FROM Website website";
4793            private static final String _SQL_COUNT_WEBSITE_WHERE = "SELECT COUNT(website) FROM Website website WHERE ";
4794            private static final String _ORDER_BY_ENTITY_ALIAS = "website.";
4795            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Website exists with the primary key ";
4796            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Website exists with the key {";
4797            private static final Log _log = LogFactoryUtil.getLog(WebsitePersistenceImpl.class);
4798            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
4799                                    "uuid", "primary"
4800                            });
4801            private static final Website _nullWebsite = new WebsiteImpl() {
4802                            @Override
4803                            public Object clone() {
4804                                    return this;
4805                            }
4806    
4807                            @Override
4808                            public CacheModel<Website> toCacheModel() {
4809                                    return _nullWebsiteCacheModel;
4810                            }
4811                    };
4812    
4813            private static final CacheModel<Website> _nullWebsiteCacheModel = new NullCacheModel();
4814    
4815            private static class NullCacheModel implements CacheModel<Website>,
4816                    MVCCModel {
4817                    @Override
4818                    public long getMvccVersion() {
4819                            return -1;
4820                    }
4821    
4822                    @Override
4823                    public void setMvccVersion(long mvccVersion) {
4824                    }
4825    
4826                    @Override
4827                    public Website toEntityModel() {
4828                            return _nullWebsite;
4829                    }
4830            }
4831    }