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