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