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