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