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