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