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