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