001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.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_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
180                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
181                            LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
182                            "findByH_P",
183                            new String[] {
184                                    Boolean.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_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
190                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
191                            LayoutRevisionImpl.class,
192                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByH_P",
193                            new String[] { Boolean.class.getName(), Long.class.getName() },
194                            LayoutRevisionModelImpl.HEAD_COLUMN_BITMASK |
195                            LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
196            public static final FinderPath FINDER_PATH_COUNT_BY_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
197                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
198                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByH_P",
199                            new String[] { Boolean.class.getName(), Long.class.getName() });
200            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_NOTS = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
201                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
202                            LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
203                            "findByP_NotS",
204                            new String[] {
205                                    Long.class.getName(), Integer.class.getName(),
206                                    
207                            "java.lang.Integer", "java.lang.Integer",
208                                    "com.liferay.portal.kernel.util.OrderByComparator"
209                            });
210            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
211                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
212                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByP_NotS",
213                            new String[] { Long.class.getName(), Integer.class.getName() });
214            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
215                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
216                            LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
217                            "findByL_L_P",
218                            new String[] {
219                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
220                                    
221                            "java.lang.Integer", "java.lang.Integer",
222                                    "com.liferay.portal.kernel.util.OrderByComparator"
223                            });
224            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
225                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
226                            LayoutRevisionImpl.class,
227                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_L_P",
228                            new String[] {
229                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
230                            },
231                            LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
232                            LayoutRevisionModelImpl.LAYOUTBRANCHID_COLUMN_BITMASK |
233                            LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
234            public static final FinderPath FINDER_PATH_COUNT_BY_L_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
235                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
236                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_L_P",
237                            new String[] {
238                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
239                            });
240            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
241                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
242                            LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
243                            "findByL_P_P",
244                            new String[] {
245                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
246                                    
247                            "java.lang.Integer", "java.lang.Integer",
248                                    "com.liferay.portal.kernel.util.OrderByComparator"
249                            });
250            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
251                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
252                            LayoutRevisionImpl.class,
253                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P_P",
254                            new String[] {
255                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
256                            },
257                            LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
258                            LayoutRevisionModelImpl.PARENTLAYOUTREVISIONID_COLUMN_BITMASK |
259                            LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
260            public static final FinderPath FINDER_PATH_COUNT_BY_L_P_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
261                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
262                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_P",
263                            new String[] {
264                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
265                            });
266            public static final FinderPath FINDER_PATH_FETCH_BY_L_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
267                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
268                            LayoutRevisionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByL_H_P",
269                            new String[] {
270                                    Long.class.getName(), Boolean.class.getName(),
271                                    Long.class.getName()
272                            },
273                            LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
274                            LayoutRevisionModelImpl.HEAD_COLUMN_BITMASK |
275                            LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
276            public static final FinderPath FINDER_PATH_COUNT_BY_L_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
277                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
278                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_H_P",
279                            new String[] {
280                                    Long.class.getName(), Boolean.class.getName(),
281                                    Long.class.getName()
282                            });
283            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
284                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
285                            LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
286                            "findByL_P_S",
287                            new String[] {
288                                    Long.class.getName(), Long.class.getName(),
289                                    Integer.class.getName(),
290                                    
291                            "java.lang.Integer", "java.lang.Integer",
292                                    "com.liferay.portal.kernel.util.OrderByComparator"
293                            });
294            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
295                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
296                            LayoutRevisionImpl.class,
297                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P_S",
298                            new String[] {
299                                    Long.class.getName(), Long.class.getName(),
300                                    Integer.class.getName()
301                            },
302                            LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
303                            LayoutRevisionModelImpl.PLID_COLUMN_BITMASK |
304                            LayoutRevisionModelImpl.STATUS_COLUMN_BITMASK);
305            public static final FinderPath FINDER_PATH_COUNT_BY_L_P_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
306                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
307                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_S",
308                            new String[] {
309                                    Long.class.getName(), Long.class.getName(),
310                                    Integer.class.getName()
311                            });
312            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
313                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
314                            LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
315                            "findAll", new String[0]);
316            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
317                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
318                            LayoutRevisionImpl.class,
319                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
320            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
321                            LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
322                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
323    
324            /**
325             * Caches the layout revision in the entity cache if it is enabled.
326             *
327             * @param layoutRevision the layout revision
328             */
329            public void cacheResult(LayoutRevision layoutRevision) {
330                    EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
331                            LayoutRevisionImpl.class, layoutRevision.getPrimaryKey(),
332                            layoutRevision);
333    
334                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
335                            new Object[] {
336                                    Long.valueOf(layoutRevision.getLayoutSetBranchId()),
337                                    Boolean.valueOf(layoutRevision.getHead()),
338                                    Long.valueOf(layoutRevision.getPlid())
339                            }, layoutRevision);
340    
341                    layoutRevision.resetOriginalValues();
342            }
343    
344            /**
345             * Caches the layout revisions in the entity cache if it is enabled.
346             *
347             * @param layoutRevisions the layout revisions
348             */
349            public void cacheResult(List<LayoutRevision> layoutRevisions) {
350                    for (LayoutRevision layoutRevision : layoutRevisions) {
351                            if (EntityCacheUtil.getResult(
352                                                    LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
353                                                    LayoutRevisionImpl.class, layoutRevision.getPrimaryKey()) == null) {
354                                    cacheResult(layoutRevision);
355                            }
356                            else {
357                                    layoutRevision.resetOriginalValues();
358                            }
359                    }
360            }
361    
362            /**
363             * Clears the cache for all layout revisions.
364             *
365             * <p>
366             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
367             * </p>
368             */
369            @Override
370            public void clearCache() {
371                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
372                            CacheRegistryUtil.clear(LayoutRevisionImpl.class.getName());
373                    }
374    
375                    EntityCacheUtil.clearCache(LayoutRevisionImpl.class.getName());
376    
377                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
378                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
379                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
380            }
381    
382            /**
383             * Clears the cache for the layout revision.
384             *
385             * <p>
386             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
387             * </p>
388             */
389            @Override
390            public void clearCache(LayoutRevision layoutRevision) {
391                    EntityCacheUtil.removeResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
392                            LayoutRevisionImpl.class, layoutRevision.getPrimaryKey());
393    
394                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
395                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
396    
397                    clearUniqueFindersCache(layoutRevision);
398            }
399    
400            @Override
401            public void clearCache(List<LayoutRevision> layoutRevisions) {
402                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
403                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
404    
405                    for (LayoutRevision layoutRevision : layoutRevisions) {
406                            EntityCacheUtil.removeResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
407                                    LayoutRevisionImpl.class, layoutRevision.getPrimaryKey());
408    
409                            clearUniqueFindersCache(layoutRevision);
410                    }
411            }
412    
413            protected void cacheUniqueFindersCache(LayoutRevision layoutRevision) {
414                    if (layoutRevision.isNew()) {
415                            Object[] args = new Object[] {
416                                            Long.valueOf(layoutRevision.getLayoutSetBranchId()),
417                                            Boolean.valueOf(layoutRevision.getHead()),
418                                            Long.valueOf(layoutRevision.getPlid())
419                                    };
420    
421                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H_P, args,
422                                    Long.valueOf(1));
423                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P, args,
424                                    layoutRevision);
425                    }
426                    else {
427                            LayoutRevisionModelImpl layoutRevisionModelImpl = (LayoutRevisionModelImpl)layoutRevision;
428    
429                            if ((layoutRevisionModelImpl.getColumnBitmask() &
430                                            FINDER_PATH_FETCH_BY_L_H_P.getColumnBitmask()) != 0) {
431                                    Object[] args = new Object[] {
432                                                    Long.valueOf(layoutRevision.getLayoutSetBranchId()),
433                                                    Boolean.valueOf(layoutRevision.getHead()),
434                                                    Long.valueOf(layoutRevision.getPlid())
435                                            };
436    
437                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H_P, args,
438                                            Long.valueOf(1));
439                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P, args,
440                                            layoutRevision);
441                            }
442                    }
443            }
444    
445            protected void clearUniqueFindersCache(LayoutRevision layoutRevision) {
446                    LayoutRevisionModelImpl layoutRevisionModelImpl = (LayoutRevisionModelImpl)layoutRevision;
447    
448                    Object[] args = new Object[] {
449                                    Long.valueOf(layoutRevision.getLayoutSetBranchId()),
450                                    Boolean.valueOf(layoutRevision.getHead()),
451                                    Long.valueOf(layoutRevision.getPlid())
452                            };
453    
454                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H_P, args);
455                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P, args);
456    
457                    if ((layoutRevisionModelImpl.getColumnBitmask() &
458                                    FINDER_PATH_FETCH_BY_L_H_P.getColumnBitmask()) != 0) {
459                            args = new Object[] {
460                                            Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
461                                            Boolean.valueOf(layoutRevisionModelImpl.getOriginalHead()),
462                                            Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
463                                    };
464    
465                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H_P, args);
466                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P, args);
467                    }
468            }
469    
470            /**
471             * Creates a new layout revision with the primary key. Does not add the layout revision to the database.
472             *
473             * @param layoutRevisionId the primary key for the new layout revision
474             * @return the new layout revision
475             */
476            public LayoutRevision create(long layoutRevisionId) {
477                    LayoutRevision layoutRevision = new LayoutRevisionImpl();
478    
479                    layoutRevision.setNew(true);
480                    layoutRevision.setPrimaryKey(layoutRevisionId);
481    
482                    return layoutRevision;
483            }
484    
485            /**
486             * Removes the layout revision with the primary key from the database. Also notifies the appropriate model listeners.
487             *
488             * @param layoutRevisionId the primary key of the layout revision
489             * @return the layout revision that was removed
490             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
491             * @throws SystemException if a system exception occurred
492             */
493            public LayoutRevision remove(long layoutRevisionId)
494                    throws NoSuchLayoutRevisionException, SystemException {
495                    return remove(Long.valueOf(layoutRevisionId));
496            }
497    
498            /**
499             * Removes the layout revision with the primary key from the database. Also notifies the appropriate model listeners.
500             *
501             * @param primaryKey the primary key of the layout revision
502             * @return the layout revision that was removed
503             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
504             * @throws SystemException if a system exception occurred
505             */
506            @Override
507            public LayoutRevision remove(Serializable primaryKey)
508                    throws NoSuchLayoutRevisionException, SystemException {
509                    Session session = null;
510    
511                    try {
512                            session = openSession();
513    
514                            LayoutRevision layoutRevision = (LayoutRevision)session.get(LayoutRevisionImpl.class,
515                                            primaryKey);
516    
517                            if (layoutRevision == null) {
518                                    if (_log.isWarnEnabled()) {
519                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
520                                    }
521    
522                                    throw new NoSuchLayoutRevisionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
523                                            primaryKey);
524                            }
525    
526                            return remove(layoutRevision);
527                    }
528                    catch (NoSuchLayoutRevisionException nsee) {
529                            throw nsee;
530                    }
531                    catch (Exception e) {
532                            throw processException(e);
533                    }
534                    finally {
535                            closeSession(session);
536                    }
537            }
538    
539            @Override
540            protected LayoutRevision removeImpl(LayoutRevision layoutRevision)
541                    throws SystemException {
542                    layoutRevision = toUnwrappedModel(layoutRevision);
543    
544                    Session session = null;
545    
546                    try {
547                            session = openSession();
548    
549                            BatchSessionUtil.delete(session, layoutRevision);
550                    }
551                    catch (Exception e) {
552                            throw processException(e);
553                    }
554                    finally {
555                            closeSession(session);
556                    }
557    
558                    clearCache(layoutRevision);
559    
560                    return layoutRevision;
561            }
562    
563            @Override
564            public LayoutRevision updateImpl(
565                    com.liferay.portal.model.LayoutRevision layoutRevision, boolean merge)
566                    throws SystemException {
567                    layoutRevision = toUnwrappedModel(layoutRevision);
568    
569                    boolean isNew = layoutRevision.isNew();
570    
571                    LayoutRevisionModelImpl layoutRevisionModelImpl = (LayoutRevisionModelImpl)layoutRevision;
572    
573                    Session session = null;
574    
575                    try {
576                            session = openSession();
577    
578                            BatchSessionUtil.update(session, layoutRevision, merge);
579    
580                            layoutRevision.setNew(false);
581                    }
582                    catch (Exception e) {
583                            throw processException(e);
584                    }
585                    finally {
586                            closeSession(session);
587                    }
588    
589                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
590    
591                    if (isNew || !LayoutRevisionModelImpl.COLUMN_BITMASK_ENABLED) {
592                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
593                    }
594    
595                    else {
596                            if ((layoutRevisionModelImpl.getColumnBitmask() &
597                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID.getColumnBitmask()) != 0) {
598                                    Object[] args = new Object[] {
599                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId())
600                                            };
601    
602                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
603                                            args);
604                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
605                                            args);
606    
607                                    args = new Object[] {
608                                                    Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId())
609                                            };
610    
611                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
612                                            args);
613                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
614                                            args);
615                            }
616    
617                            if ((layoutRevisionModelImpl.getColumnBitmask() &
618                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID.getColumnBitmask()) != 0) {
619                                    Object[] args = new Object[] {
620                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
621                                            };
622    
623                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
624                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
625                                            args);
626    
627                                    args = new Object[] {
628                                                    Long.valueOf(layoutRevisionModelImpl.getPlid())
629                                            };
630    
631                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
632                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
633                                            args);
634                            }
635    
636                            if ((layoutRevisionModelImpl.getColumnBitmask() &
637                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H.getColumnBitmask()) != 0) {
638                                    Object[] args = new Object[] {
639                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
640                                                    Boolean.valueOf(layoutRevisionModelImpl.getOriginalHead())
641                                            };
642    
643                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H, args);
644                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H,
645                                            args);
646    
647                                    args = new Object[] {
648                                                    Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
649                                                    Boolean.valueOf(layoutRevisionModelImpl.getHead())
650                                            };
651    
652                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H, args);
653                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H,
654                                            args);
655                            }
656    
657                            if ((layoutRevisionModelImpl.getColumnBitmask() &
658                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) {
659                                    Object[] args = new Object[] {
660                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
661                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
662                                            };
663    
664                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
665                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
666                                            args);
667    
668                                    args = new Object[] {
669                                                    Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
670                                                    Long.valueOf(layoutRevisionModelImpl.getPlid())
671                                            };
672    
673                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
674                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
675                                            args);
676                            }
677    
678                            if ((layoutRevisionModelImpl.getColumnBitmask() &
679                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S.getColumnBitmask()) != 0) {
680                                    Object[] args = new Object[] {
681                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
682                                                    Integer.valueOf(layoutRevisionModelImpl.getOriginalStatus())
683                                            };
684    
685                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_S, args);
686                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S,
687                                            args);
688    
689                                    args = new Object[] {
690                                                    Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
691                                                    Integer.valueOf(layoutRevisionModelImpl.getStatus())
692                                            };
693    
694                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_S, args);
695                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S,
696                                            args);
697                            }
698    
699                            if ((layoutRevisionModelImpl.getColumnBitmask() &
700                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P.getColumnBitmask()) != 0) {
701                                    Object[] args = new Object[] {
702                                                    Boolean.valueOf(layoutRevisionModelImpl.getOriginalHead()),
703                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
704                                            };
705    
706                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_H_P, args);
707                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P,
708                                            args);
709    
710                                    args = new Object[] {
711                                                    Boolean.valueOf(layoutRevisionModelImpl.getHead()),
712                                                    Long.valueOf(layoutRevisionModelImpl.getPlid())
713                                            };
714    
715                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_H_P, args);
716                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P,
717                                            args);
718                            }
719    
720                            if ((layoutRevisionModelImpl.getColumnBitmask() &
721                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P.getColumnBitmask()) != 0) {
722                                    Object[] args = new Object[] {
723                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
724                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutBranchId()),
725                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
726                                            };
727    
728                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_L_P, args);
729                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P,
730                                            args);
731    
732                                    args = new Object[] {
733                                                    Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
734                                                    Long.valueOf(layoutRevisionModelImpl.getLayoutBranchId()),
735                                                    Long.valueOf(layoutRevisionModelImpl.getPlid())
736                                            };
737    
738                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_L_P, args);
739                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P,
740                                            args);
741                            }
742    
743                            if ((layoutRevisionModelImpl.getColumnBitmask() &
744                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P.getColumnBitmask()) != 0) {
745                                    Object[] args = new Object[] {
746                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
747                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalParentLayoutRevisionId()),
748                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
749                                            };
750    
751                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_P, args);
752                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P,
753                                            args);
754    
755                                    args = new Object[] {
756                                                    Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
757                                                    Long.valueOf(layoutRevisionModelImpl.getParentLayoutRevisionId()),
758                                                    Long.valueOf(layoutRevisionModelImpl.getPlid())
759                                            };
760    
761                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_P, args);
762                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P,
763                                            args);
764                            }
765    
766                            if ((layoutRevisionModelImpl.getColumnBitmask() &
767                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S.getColumnBitmask()) != 0) {
768                                    Object[] args = new Object[] {
769                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
770                                                    Long.valueOf(layoutRevisionModelImpl.getOriginalPlid()),
771                                                    Integer.valueOf(layoutRevisionModelImpl.getOriginalStatus())
772                                            };
773    
774                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_S, args);
775                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S,
776                                            args);
777    
778                                    args = new Object[] {
779                                                    Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
780                                                    Long.valueOf(layoutRevisionModelImpl.getPlid()),
781                                                    Integer.valueOf(layoutRevisionModelImpl.getStatus())
782                                            };
783    
784                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_S, args);
785                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S,
786                                            args);
787                            }
788                    }
789    
790                    EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
791                            LayoutRevisionImpl.class, layoutRevision.getPrimaryKey(),
792                            layoutRevision);
793    
794                    clearUniqueFindersCache(layoutRevision);
795                    cacheUniqueFindersCache(layoutRevision);
796    
797                    return layoutRevision;
798            }
799    
800            protected LayoutRevision toUnwrappedModel(LayoutRevision layoutRevision) {
801                    if (layoutRevision instanceof LayoutRevisionImpl) {
802                            return layoutRevision;
803                    }
804    
805                    LayoutRevisionImpl layoutRevisionImpl = new LayoutRevisionImpl();
806    
807                    layoutRevisionImpl.setNew(layoutRevision.isNew());
808                    layoutRevisionImpl.setPrimaryKey(layoutRevision.getPrimaryKey());
809    
810                    layoutRevisionImpl.setLayoutRevisionId(layoutRevision.getLayoutRevisionId());
811                    layoutRevisionImpl.setGroupId(layoutRevision.getGroupId());
812                    layoutRevisionImpl.setCompanyId(layoutRevision.getCompanyId());
813                    layoutRevisionImpl.setUserId(layoutRevision.getUserId());
814                    layoutRevisionImpl.setUserName(layoutRevision.getUserName());
815                    layoutRevisionImpl.setCreateDate(layoutRevision.getCreateDate());
816                    layoutRevisionImpl.setModifiedDate(layoutRevision.getModifiedDate());
817                    layoutRevisionImpl.setLayoutSetBranchId(layoutRevision.getLayoutSetBranchId());
818                    layoutRevisionImpl.setLayoutBranchId(layoutRevision.getLayoutBranchId());
819                    layoutRevisionImpl.setParentLayoutRevisionId(layoutRevision.getParentLayoutRevisionId());
820                    layoutRevisionImpl.setHead(layoutRevision.isHead());
821                    layoutRevisionImpl.setMajor(layoutRevision.isMajor());
822                    layoutRevisionImpl.setPlid(layoutRevision.getPlid());
823                    layoutRevisionImpl.setPrivateLayout(layoutRevision.isPrivateLayout());
824                    layoutRevisionImpl.setName(layoutRevision.getName());
825                    layoutRevisionImpl.setTitle(layoutRevision.getTitle());
826                    layoutRevisionImpl.setDescription(layoutRevision.getDescription());
827                    layoutRevisionImpl.setKeywords(layoutRevision.getKeywords());
828                    layoutRevisionImpl.setRobots(layoutRevision.getRobots());
829                    layoutRevisionImpl.setTypeSettings(layoutRevision.getTypeSettings());
830                    layoutRevisionImpl.setIconImage(layoutRevision.isIconImage());
831                    layoutRevisionImpl.setIconImageId(layoutRevision.getIconImageId());
832                    layoutRevisionImpl.setThemeId(layoutRevision.getThemeId());
833                    layoutRevisionImpl.setColorSchemeId(layoutRevision.getColorSchemeId());
834                    layoutRevisionImpl.setWapThemeId(layoutRevision.getWapThemeId());
835                    layoutRevisionImpl.setWapColorSchemeId(layoutRevision.getWapColorSchemeId());
836                    layoutRevisionImpl.setCss(layoutRevision.getCss());
837                    layoutRevisionImpl.setStatus(layoutRevision.getStatus());
838                    layoutRevisionImpl.setStatusByUserId(layoutRevision.getStatusByUserId());
839                    layoutRevisionImpl.setStatusByUserName(layoutRevision.getStatusByUserName());
840                    layoutRevisionImpl.setStatusDate(layoutRevision.getStatusDate());
841    
842                    return layoutRevisionImpl;
843            }
844    
845            /**
846             * Returns the layout revision with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
847             *
848             * @param primaryKey the primary key of the layout revision
849             * @return the layout revision
850             * @throws com.liferay.portal.NoSuchModelException if a layout revision with the primary key could not be found
851             * @throws SystemException if a system exception occurred
852             */
853            @Override
854            public LayoutRevision findByPrimaryKey(Serializable primaryKey)
855                    throws NoSuchModelException, SystemException {
856                    return findByPrimaryKey(((Long)primaryKey).longValue());
857            }
858    
859            /**
860             * Returns the layout revision with the primary key or throws a {@link com.liferay.portal.NoSuchLayoutRevisionException} if it could not be found.
861             *
862             * @param layoutRevisionId the primary key of the layout revision
863             * @return the layout revision
864             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
865             * @throws SystemException if a system exception occurred
866             */
867            public LayoutRevision findByPrimaryKey(long layoutRevisionId)
868                    throws NoSuchLayoutRevisionException, SystemException {
869                    LayoutRevision layoutRevision = fetchByPrimaryKey(layoutRevisionId);
870    
871                    if (layoutRevision == null) {
872                            if (_log.isWarnEnabled()) {
873                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutRevisionId);
874                            }
875    
876                            throw new NoSuchLayoutRevisionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
877                                    layoutRevisionId);
878                    }
879    
880                    return layoutRevision;
881            }
882    
883            /**
884             * Returns the layout revision with the primary key or returns <code>null</code> if it could not be found.
885             *
886             * @param primaryKey the primary key of the layout revision
887             * @return the layout revision, or <code>null</code> if a layout revision with the primary key could not be found
888             * @throws SystemException if a system exception occurred
889             */
890            @Override
891            public LayoutRevision fetchByPrimaryKey(Serializable primaryKey)
892                    throws SystemException {
893                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
894            }
895    
896            /**
897             * Returns the layout revision with the primary key or returns <code>null</code> if it could not be found.
898             *
899             * @param layoutRevisionId the primary key of the layout revision
900             * @return the layout revision, or <code>null</code> if a layout revision with the primary key could not be found
901             * @throws SystemException if a system exception occurred
902             */
903            public LayoutRevision fetchByPrimaryKey(long layoutRevisionId)
904                    throws SystemException {
905                    LayoutRevision layoutRevision = (LayoutRevision)EntityCacheUtil.getResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
906                                    LayoutRevisionImpl.class, layoutRevisionId);
907    
908                    if (layoutRevision == _nullLayoutRevision) {
909                            return null;
910                    }
911    
912                    if (layoutRevision == null) {
913                            Session session = null;
914    
915                            boolean hasException = false;
916    
917                            try {
918                                    session = openSession();
919    
920                                    layoutRevision = (LayoutRevision)session.get(LayoutRevisionImpl.class,
921                                                    Long.valueOf(layoutRevisionId));
922                            }
923                            catch (Exception e) {
924                                    hasException = true;
925    
926                                    throw processException(e);
927                            }
928                            finally {
929                                    if (layoutRevision != null) {
930                                            cacheResult(layoutRevision);
931                                    }
932                                    else if (!hasException) {
933                                            EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
934                                                    LayoutRevisionImpl.class, layoutRevisionId,
935                                                    _nullLayoutRevision);
936                                    }
937    
938                                    closeSession(session);
939                            }
940                    }
941    
942                    return layoutRevision;
943            }
944    
945            /**
946             * Returns all the layout revisions where layoutSetBranchId = &#63;.
947             *
948             * @param layoutSetBranchId the layout set branch ID
949             * @return the matching layout revisions
950             * @throws SystemException if a system exception occurred
951             */
952            public List<LayoutRevision> findByLayoutSetBranchId(long layoutSetBranchId)
953                    throws SystemException {
954                    return findByLayoutSetBranchId(layoutSetBranchId, QueryUtil.ALL_POS,
955                            QueryUtil.ALL_POS, null);
956            }
957    
958            /**
959             * Returns a range of all the layout revisions where layoutSetBranchId = &#63;.
960             *
961             * <p>
962             * 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.
963             * </p>
964             *
965             * @param layoutSetBranchId the layout set branch ID
966             * @param start the lower bound of the range of layout revisions
967             * @param end the upper bound of the range of layout revisions (not inclusive)
968             * @return the range of matching layout revisions
969             * @throws SystemException if a system exception occurred
970             */
971            public List<LayoutRevision> findByLayoutSetBranchId(
972                    long layoutSetBranchId, int start, int end) throws SystemException {
973                    return findByLayoutSetBranchId(layoutSetBranchId, start, end, null);
974            }
975    
976            /**
977             * Returns an ordered range of all the layout revisions where layoutSetBranchId = &#63;.
978             *
979             * <p>
980             * 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.
981             * </p>
982             *
983             * @param layoutSetBranchId the layout set branch ID
984             * @param start the lower bound of the range of layout revisions
985             * @param end the upper bound of the range of layout revisions (not inclusive)
986             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
987             * @return the ordered range of matching layout revisions
988             * @throws SystemException if a system exception occurred
989             */
990            public List<LayoutRevision> findByLayoutSetBranchId(
991                    long layoutSetBranchId, int start, int end,
992                    OrderByComparator orderByComparator) throws SystemException {
993                    FinderPath finderPath = null;
994                    Object[] finderArgs = null;
995    
996                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
997                                    (orderByComparator == null)) {
998                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
999                            finderArgs = new Object[] { layoutSetBranchId };
1000                    }
1001                    else {
1002                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
1003                            finderArgs = new Object[] {
1004                                            layoutSetBranchId,
1005                                            
1006                                            start, end, orderByComparator
1007                                    };
1008                    }
1009    
1010                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1011                                    finderArgs, this);
1012    
1013                    if ((list != null) && !list.isEmpty()) {
1014                            for (LayoutRevision layoutRevision : list) {
1015                                    if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId())) {
1016                                            list = null;
1017    
1018                                            break;
1019                                    }
1020                            }
1021                    }
1022    
1023                    if (list == null) {
1024                            StringBundler query = null;
1025    
1026                            if (orderByComparator != null) {
1027                                    query = new StringBundler(3 +
1028                                                    (orderByComparator.getOrderByFields().length * 3));
1029                            }
1030                            else {
1031                                    query = new StringBundler(3);
1032                            }
1033    
1034                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1035    
1036                            query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
1037    
1038                            if (orderByComparator != null) {
1039                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1040                                            orderByComparator);
1041                            }
1042    
1043                            else {
1044                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1045                            }
1046    
1047                            String sql = query.toString();
1048    
1049                            Session session = null;
1050    
1051                            try {
1052                                    session = openSession();
1053    
1054                                    Query q = session.createQuery(sql);
1055    
1056                                    QueryPos qPos = QueryPos.getInstance(q);
1057    
1058                                    qPos.add(layoutSetBranchId);
1059    
1060                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
1061                                                    start, end);
1062                            }
1063                            catch (Exception e) {
1064                                    throw processException(e);
1065                            }
1066                            finally {
1067                                    if (list == null) {
1068                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1069                                    }
1070                                    else {
1071                                            cacheResult(list);
1072    
1073                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1074                                    }
1075    
1076                                    closeSession(session);
1077                            }
1078                    }
1079    
1080                    return list;
1081            }
1082    
1083            /**
1084             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63;.
1085             *
1086             * @param layoutSetBranchId the layout set branch ID
1087             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1088             * @return the first matching layout revision
1089             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
1090             * @throws SystemException if a system exception occurred
1091             */
1092            public LayoutRevision findByLayoutSetBranchId_First(
1093                    long layoutSetBranchId, OrderByComparator orderByComparator)
1094                    throws NoSuchLayoutRevisionException, SystemException {
1095                    LayoutRevision layoutRevision = fetchByLayoutSetBranchId_First(layoutSetBranchId,
1096                                    orderByComparator);
1097    
1098                    if (layoutRevision != null) {
1099                            return layoutRevision;
1100                    }
1101    
1102                    StringBundler msg = new StringBundler(4);
1103    
1104                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1105    
1106                    msg.append("layoutSetBranchId=");
1107                    msg.append(layoutSetBranchId);
1108    
1109                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1110    
1111                    throw new NoSuchLayoutRevisionException(msg.toString());
1112            }
1113    
1114            /**
1115             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63;.
1116             *
1117             * @param layoutSetBranchId the layout set branch ID
1118             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1119             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
1120             * @throws SystemException if a system exception occurred
1121             */
1122            public LayoutRevision fetchByLayoutSetBranchId_First(
1123                    long layoutSetBranchId, OrderByComparator orderByComparator)
1124                    throws SystemException {
1125                    List<LayoutRevision> list = findByLayoutSetBranchId(layoutSetBranchId,
1126                                    0, 1, orderByComparator);
1127    
1128                    if (!list.isEmpty()) {
1129                            return list.get(0);
1130                    }
1131    
1132                    return null;
1133            }
1134    
1135            /**
1136             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63;.
1137             *
1138             * @param layoutSetBranchId the layout set branch ID
1139             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1140             * @return the last matching layout revision
1141             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
1142             * @throws SystemException if a system exception occurred
1143             */
1144            public LayoutRevision findByLayoutSetBranchId_Last(long layoutSetBranchId,
1145                    OrderByComparator orderByComparator)
1146                    throws NoSuchLayoutRevisionException, SystemException {
1147                    LayoutRevision layoutRevision = fetchByLayoutSetBranchId_Last(layoutSetBranchId,
1148                                    orderByComparator);
1149    
1150                    if (layoutRevision != null) {
1151                            return layoutRevision;
1152                    }
1153    
1154                    StringBundler msg = new StringBundler(4);
1155    
1156                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1157    
1158                    msg.append("layoutSetBranchId=");
1159                    msg.append(layoutSetBranchId);
1160    
1161                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1162    
1163                    throw new NoSuchLayoutRevisionException(msg.toString());
1164            }
1165    
1166            /**
1167             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63;.
1168             *
1169             * @param layoutSetBranchId the layout set branch ID
1170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1171             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
1172             * @throws SystemException if a system exception occurred
1173             */
1174            public LayoutRevision fetchByLayoutSetBranchId_Last(
1175                    long layoutSetBranchId, OrderByComparator orderByComparator)
1176                    throws SystemException {
1177                    int count = countByLayoutSetBranchId(layoutSetBranchId);
1178    
1179                    List<LayoutRevision> list = findByLayoutSetBranchId(layoutSetBranchId,
1180                                    count - 1, count, orderByComparator);
1181    
1182                    if (!list.isEmpty()) {
1183                            return list.get(0);
1184                    }
1185    
1186                    return null;
1187            }
1188    
1189            /**
1190             * Returns the layout revisions before and after the current layout revision in the ordered set where layoutSetBranchId = &#63;.
1191             *
1192             * @param layoutRevisionId the primary key of the current layout revision
1193             * @param layoutSetBranchId the layout set branch ID
1194             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1195             * @return the previous, current, and next layout revision
1196             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
1197             * @throws SystemException if a system exception occurred
1198             */
1199            public LayoutRevision[] findByLayoutSetBranchId_PrevAndNext(
1200                    long layoutRevisionId, long layoutSetBranchId,
1201                    OrderByComparator orderByComparator)
1202                    throws NoSuchLayoutRevisionException, SystemException {
1203                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1204    
1205                    Session session = null;
1206    
1207                    try {
1208                            session = openSession();
1209    
1210                            LayoutRevision[] array = new LayoutRevisionImpl[3];
1211    
1212                            array[0] = getByLayoutSetBranchId_PrevAndNext(session,
1213                                            layoutRevision, layoutSetBranchId, orderByComparator, true);
1214    
1215                            array[1] = layoutRevision;
1216    
1217                            array[2] = getByLayoutSetBranchId_PrevAndNext(session,
1218                                            layoutRevision, layoutSetBranchId, orderByComparator, false);
1219    
1220                            return array;
1221                    }
1222                    catch (Exception e) {
1223                            throw processException(e);
1224                    }
1225                    finally {
1226                            closeSession(session);
1227                    }
1228            }
1229    
1230            protected LayoutRevision getByLayoutSetBranchId_PrevAndNext(
1231                    Session session, LayoutRevision layoutRevision, long layoutSetBranchId,
1232                    OrderByComparator orderByComparator, boolean previous) {
1233                    StringBundler query = null;
1234    
1235                    if (orderByComparator != null) {
1236                            query = new StringBundler(6 +
1237                                            (orderByComparator.getOrderByFields().length * 6));
1238                    }
1239                    else {
1240                            query = new StringBundler(3);
1241                    }
1242    
1243                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1244    
1245                    query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
1246    
1247                    if (orderByComparator != null) {
1248                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1249    
1250                            if (orderByConditionFields.length > 0) {
1251                                    query.append(WHERE_AND);
1252                            }
1253    
1254                            for (int i = 0; i < orderByConditionFields.length; i++) {
1255                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1256                                    query.append(orderByConditionFields[i]);
1257    
1258                                    if ((i + 1) < orderByConditionFields.length) {
1259                                            if (orderByComparator.isAscending() ^ previous) {
1260                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1261                                            }
1262                                            else {
1263                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1264                                            }
1265                                    }
1266                                    else {
1267                                            if (orderByComparator.isAscending() ^ previous) {
1268                                                    query.append(WHERE_GREATER_THAN);
1269                                            }
1270                                            else {
1271                                                    query.append(WHERE_LESSER_THAN);
1272                                            }
1273                                    }
1274                            }
1275    
1276                            query.append(ORDER_BY_CLAUSE);
1277    
1278                            String[] orderByFields = orderByComparator.getOrderByFields();
1279    
1280                            for (int i = 0; i < orderByFields.length; i++) {
1281                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1282                                    query.append(orderByFields[i]);
1283    
1284                                    if ((i + 1) < orderByFields.length) {
1285                                            if (orderByComparator.isAscending() ^ previous) {
1286                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1287                                            }
1288                                            else {
1289                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1290                                            }
1291                                    }
1292                                    else {
1293                                            if (orderByComparator.isAscending() ^ previous) {
1294                                                    query.append(ORDER_BY_ASC);
1295                                            }
1296                                            else {
1297                                                    query.append(ORDER_BY_DESC);
1298                                            }
1299                                    }
1300                            }
1301                    }
1302    
1303                    else {
1304                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1305                    }
1306    
1307                    String sql = query.toString();
1308    
1309                    Query q = session.createQuery(sql);
1310    
1311                    q.setFirstResult(0);
1312                    q.setMaxResults(2);
1313    
1314                    QueryPos qPos = QueryPos.getInstance(q);
1315    
1316                    qPos.add(layoutSetBranchId);
1317    
1318                    if (orderByComparator != null) {
1319                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
1320    
1321                            for (Object value : values) {
1322                                    qPos.add(value);
1323                            }
1324                    }
1325    
1326                    List<LayoutRevision> list = q.list();
1327    
1328                    if (list.size() == 2) {
1329                            return list.get(1);
1330                    }
1331                    else {
1332                            return null;
1333                    }
1334            }
1335    
1336            /**
1337             * Returns all the layout revisions where plid = &#63;.
1338             *
1339             * @param plid the plid
1340             * @return the matching layout revisions
1341             * @throws SystemException if a system exception occurred
1342             */
1343            public List<LayoutRevision> findByPlid(long plid) throws SystemException {
1344                    return findByPlid(plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1345            }
1346    
1347            /**
1348             * Returns a range of all the layout revisions where plid = &#63;.
1349             *
1350             * <p>
1351             * 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.
1352             * </p>
1353             *
1354             * @param plid the plid
1355             * @param start the lower bound of the range of layout revisions
1356             * @param end the upper bound of the range of layout revisions (not inclusive)
1357             * @return the range of matching layout revisions
1358             * @throws SystemException if a system exception occurred
1359             */
1360            public List<LayoutRevision> findByPlid(long plid, int start, int end)
1361                    throws SystemException {
1362                    return findByPlid(plid, start, end, null);
1363            }
1364    
1365            /**
1366             * Returns an ordered range of all the layout revisions where plid = &#63;.
1367             *
1368             * <p>
1369             * 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.
1370             * </p>
1371             *
1372             * @param plid the plid
1373             * @param start the lower bound of the range of layout revisions
1374             * @param end the upper bound of the range of layout revisions (not inclusive)
1375             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1376             * @return the ordered range of matching layout revisions
1377             * @throws SystemException if a system exception occurred
1378             */
1379            public List<LayoutRevision> findByPlid(long plid, int start, int end,
1380                    OrderByComparator orderByComparator) throws SystemException {
1381                    FinderPath finderPath = null;
1382                    Object[] finderArgs = null;
1383    
1384                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1385                                    (orderByComparator == null)) {
1386                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID;
1387                            finderArgs = new Object[] { plid };
1388                    }
1389                    else {
1390                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PLID;
1391                            finderArgs = new Object[] { plid, start, end, orderByComparator };
1392                    }
1393    
1394                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1395                                    finderArgs, this);
1396    
1397                    if ((list != null) && !list.isEmpty()) {
1398                            for (LayoutRevision layoutRevision : list) {
1399                                    if ((plid != layoutRevision.getPlid())) {
1400                                            list = null;
1401    
1402                                            break;
1403                                    }
1404                            }
1405                    }
1406    
1407                    if (list == null) {
1408                            StringBundler query = null;
1409    
1410                            if (orderByComparator != null) {
1411                                    query = new StringBundler(3 +
1412                                                    (orderByComparator.getOrderByFields().length * 3));
1413                            }
1414                            else {
1415                                    query = new StringBundler(3);
1416                            }
1417    
1418                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1419    
1420                            query.append(_FINDER_COLUMN_PLID_PLID_2);
1421    
1422                            if (orderByComparator != null) {
1423                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1424                                            orderByComparator);
1425                            }
1426    
1427                            else {
1428                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1429                            }
1430    
1431                            String sql = query.toString();
1432    
1433                            Session session = null;
1434    
1435                            try {
1436                                    session = openSession();
1437    
1438                                    Query q = session.createQuery(sql);
1439    
1440                                    QueryPos qPos = QueryPos.getInstance(q);
1441    
1442                                    qPos.add(plid);
1443    
1444                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
1445                                                    start, end);
1446                            }
1447                            catch (Exception e) {
1448                                    throw processException(e);
1449                            }
1450                            finally {
1451                                    if (list == null) {
1452                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1453                                    }
1454                                    else {
1455                                            cacheResult(list);
1456    
1457                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1458                                    }
1459    
1460                                    closeSession(session);
1461                            }
1462                    }
1463    
1464                    return list;
1465            }
1466    
1467            /**
1468             * Returns the first layout revision in the ordered set where plid = &#63;.
1469             *
1470             * @param plid the plid
1471             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1472             * @return the first matching layout revision
1473             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
1474             * @throws SystemException if a system exception occurred
1475             */
1476            public LayoutRevision findByPlid_First(long plid,
1477                    OrderByComparator orderByComparator)
1478                    throws NoSuchLayoutRevisionException, SystemException {
1479                    LayoutRevision layoutRevision = fetchByPlid_First(plid,
1480                                    orderByComparator);
1481    
1482                    if (layoutRevision != null) {
1483                            return layoutRevision;
1484                    }
1485    
1486                    StringBundler msg = new StringBundler(4);
1487    
1488                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1489    
1490                    msg.append("plid=");
1491                    msg.append(plid);
1492    
1493                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1494    
1495                    throw new NoSuchLayoutRevisionException(msg.toString());
1496            }
1497    
1498            /**
1499             * Returns the first layout revision in the ordered set where plid = &#63;.
1500             *
1501             * @param plid the plid
1502             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1503             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
1504             * @throws SystemException if a system exception occurred
1505             */
1506            public LayoutRevision fetchByPlid_First(long plid,
1507                    OrderByComparator orderByComparator) throws SystemException {
1508                    List<LayoutRevision> list = findByPlid(plid, 0, 1, orderByComparator);
1509    
1510                    if (!list.isEmpty()) {
1511                            return list.get(0);
1512                    }
1513    
1514                    return null;
1515            }
1516    
1517            /**
1518             * Returns the last layout revision in the ordered set where plid = &#63;.
1519             *
1520             * @param plid the plid
1521             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1522             * @return the last matching layout revision
1523             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
1524             * @throws SystemException if a system exception occurred
1525             */
1526            public LayoutRevision findByPlid_Last(long plid,
1527                    OrderByComparator orderByComparator)
1528                    throws NoSuchLayoutRevisionException, SystemException {
1529                    LayoutRevision layoutRevision = fetchByPlid_Last(plid, orderByComparator);
1530    
1531                    if (layoutRevision != null) {
1532                            return layoutRevision;
1533                    }
1534    
1535                    StringBundler msg = new StringBundler(4);
1536    
1537                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1538    
1539                    msg.append("plid=");
1540                    msg.append(plid);
1541    
1542                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1543    
1544                    throw new NoSuchLayoutRevisionException(msg.toString());
1545            }
1546    
1547            /**
1548             * Returns the last layout revision in the ordered set where plid = &#63;.
1549             *
1550             * @param plid the plid
1551             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1552             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
1553             * @throws SystemException if a system exception occurred
1554             */
1555            public LayoutRevision fetchByPlid_Last(long plid,
1556                    OrderByComparator orderByComparator) throws SystemException {
1557                    int count = countByPlid(plid);
1558    
1559                    List<LayoutRevision> list = findByPlid(plid, count - 1, count,
1560                                    orderByComparator);
1561    
1562                    if (!list.isEmpty()) {
1563                            return list.get(0);
1564                    }
1565    
1566                    return null;
1567            }
1568    
1569            /**
1570             * Returns the layout revisions before and after the current layout revision in the ordered set where plid = &#63;.
1571             *
1572             * @param layoutRevisionId the primary key of the current layout revision
1573             * @param plid the plid
1574             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1575             * @return the previous, current, and next layout revision
1576             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
1577             * @throws SystemException if a system exception occurred
1578             */
1579            public LayoutRevision[] findByPlid_PrevAndNext(long layoutRevisionId,
1580                    long plid, OrderByComparator orderByComparator)
1581                    throws NoSuchLayoutRevisionException, SystemException {
1582                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1583    
1584                    Session session = null;
1585    
1586                    try {
1587                            session = openSession();
1588    
1589                            LayoutRevision[] array = new LayoutRevisionImpl[3];
1590    
1591                            array[0] = getByPlid_PrevAndNext(session, layoutRevision, plid,
1592                                            orderByComparator, true);
1593    
1594                            array[1] = layoutRevision;
1595    
1596                            array[2] = getByPlid_PrevAndNext(session, layoutRevision, plid,
1597                                            orderByComparator, false);
1598    
1599                            return array;
1600                    }
1601                    catch (Exception e) {
1602                            throw processException(e);
1603                    }
1604                    finally {
1605                            closeSession(session);
1606                    }
1607            }
1608    
1609            protected LayoutRevision getByPlid_PrevAndNext(Session session,
1610                    LayoutRevision layoutRevision, long plid,
1611                    OrderByComparator orderByComparator, boolean previous) {
1612                    StringBundler query = null;
1613    
1614                    if (orderByComparator != null) {
1615                            query = new StringBundler(6 +
1616                                            (orderByComparator.getOrderByFields().length * 6));
1617                    }
1618                    else {
1619                            query = new StringBundler(3);
1620                    }
1621    
1622                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1623    
1624                    query.append(_FINDER_COLUMN_PLID_PLID_2);
1625    
1626                    if (orderByComparator != null) {
1627                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1628    
1629                            if (orderByConditionFields.length > 0) {
1630                                    query.append(WHERE_AND);
1631                            }
1632    
1633                            for (int i = 0; i < orderByConditionFields.length; i++) {
1634                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1635                                    query.append(orderByConditionFields[i]);
1636    
1637                                    if ((i + 1) < orderByConditionFields.length) {
1638                                            if (orderByComparator.isAscending() ^ previous) {
1639                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1640                                            }
1641                                            else {
1642                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1643                                            }
1644                                    }
1645                                    else {
1646                                            if (orderByComparator.isAscending() ^ previous) {
1647                                                    query.append(WHERE_GREATER_THAN);
1648                                            }
1649                                            else {
1650                                                    query.append(WHERE_LESSER_THAN);
1651                                            }
1652                                    }
1653                            }
1654    
1655                            query.append(ORDER_BY_CLAUSE);
1656    
1657                            String[] orderByFields = orderByComparator.getOrderByFields();
1658    
1659                            for (int i = 0; i < orderByFields.length; i++) {
1660                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1661                                    query.append(orderByFields[i]);
1662    
1663                                    if ((i + 1) < orderByFields.length) {
1664                                            if (orderByComparator.isAscending() ^ previous) {
1665                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1666                                            }
1667                                            else {
1668                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1669                                            }
1670                                    }
1671                                    else {
1672                                            if (orderByComparator.isAscending() ^ previous) {
1673                                                    query.append(ORDER_BY_ASC);
1674                                            }
1675                                            else {
1676                                                    query.append(ORDER_BY_DESC);
1677                                            }
1678                                    }
1679                            }
1680                    }
1681    
1682                    else {
1683                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1684                    }
1685    
1686                    String sql = query.toString();
1687    
1688                    Query q = session.createQuery(sql);
1689    
1690                    q.setFirstResult(0);
1691                    q.setMaxResults(2);
1692    
1693                    QueryPos qPos = QueryPos.getInstance(q);
1694    
1695                    qPos.add(plid);
1696    
1697                    if (orderByComparator != null) {
1698                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
1699    
1700                            for (Object value : values) {
1701                                    qPos.add(value);
1702                            }
1703                    }
1704    
1705                    List<LayoutRevision> list = q.list();
1706    
1707                    if (list.size() == 2) {
1708                            return list.get(1);
1709                    }
1710                    else {
1711                            return null;
1712                    }
1713            }
1714    
1715            /**
1716             * Returns all the layout revisions where layoutSetBranchId = &#63; and head = &#63;.
1717             *
1718             * @param layoutSetBranchId the layout set branch ID
1719             * @param head the head
1720             * @return the matching layout revisions
1721             * @throws SystemException if a system exception occurred
1722             */
1723            public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head)
1724                    throws SystemException {
1725                    return findByL_H(layoutSetBranchId, head, QueryUtil.ALL_POS,
1726                            QueryUtil.ALL_POS, null);
1727            }
1728    
1729            /**
1730             * Returns a range of all the layout revisions where layoutSetBranchId = &#63; and head = &#63;.
1731             *
1732             * <p>
1733             * 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.
1734             * </p>
1735             *
1736             * @param layoutSetBranchId the layout set branch ID
1737             * @param head the head
1738             * @param start the lower bound of the range of layout revisions
1739             * @param end the upper bound of the range of layout revisions (not inclusive)
1740             * @return the range of matching layout revisions
1741             * @throws SystemException if a system exception occurred
1742             */
1743            public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head,
1744                    int start, int end) throws SystemException {
1745                    return findByL_H(layoutSetBranchId, head, start, end, null);
1746            }
1747    
1748            /**
1749             * Returns an ordered range of all the layout revisions where layoutSetBranchId = &#63; and head = &#63;.
1750             *
1751             * <p>
1752             * 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.
1753             * </p>
1754             *
1755             * @param layoutSetBranchId the layout set branch ID
1756             * @param head the head
1757             * @param start the lower bound of the range of layout revisions
1758             * @param end the upper bound of the range of layout revisions (not inclusive)
1759             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1760             * @return the ordered range of matching layout revisions
1761             * @throws SystemException if a system exception occurred
1762             */
1763            public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head,
1764                    int start, int end, OrderByComparator orderByComparator)
1765                    throws SystemException {
1766                    FinderPath finderPath = null;
1767                    Object[] finderArgs = null;
1768    
1769                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1770                                    (orderByComparator == null)) {
1771                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H;
1772                            finderArgs = new Object[] { layoutSetBranchId, head };
1773                    }
1774                    else {
1775                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_H;
1776                            finderArgs = new Object[] {
1777                                            layoutSetBranchId, head,
1778                                            
1779                                            start, end, orderByComparator
1780                                    };
1781                    }
1782    
1783                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1784                                    finderArgs, this);
1785    
1786                    if ((list != null) && !list.isEmpty()) {
1787                            for (LayoutRevision layoutRevision : list) {
1788                                    if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
1789                                                    (head != layoutRevision.getHead())) {
1790                                            list = null;
1791    
1792                                            break;
1793                                    }
1794                            }
1795                    }
1796    
1797                    if (list == null) {
1798                            StringBundler query = null;
1799    
1800                            if (orderByComparator != null) {
1801                                    query = new StringBundler(4 +
1802                                                    (orderByComparator.getOrderByFields().length * 3));
1803                            }
1804                            else {
1805                                    query = new StringBundler(4);
1806                            }
1807    
1808                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1809    
1810                            query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
1811    
1812                            query.append(_FINDER_COLUMN_L_H_HEAD_2);
1813    
1814                            if (orderByComparator != null) {
1815                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1816                                            orderByComparator);
1817                            }
1818    
1819                            else {
1820                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1821                            }
1822    
1823                            String sql = query.toString();
1824    
1825                            Session session = null;
1826    
1827                            try {
1828                                    session = openSession();
1829    
1830                                    Query q = session.createQuery(sql);
1831    
1832                                    QueryPos qPos = QueryPos.getInstance(q);
1833    
1834                                    qPos.add(layoutSetBranchId);
1835    
1836                                    qPos.add(head);
1837    
1838                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
1839                                                    start, end);
1840                            }
1841                            catch (Exception e) {
1842                                    throw processException(e);
1843                            }
1844                            finally {
1845                                    if (list == null) {
1846                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1847                                    }
1848                                    else {
1849                                            cacheResult(list);
1850    
1851                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1852                                    }
1853    
1854                                    closeSession(session);
1855                            }
1856                    }
1857    
1858                    return list;
1859            }
1860    
1861            /**
1862             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and head = &#63;.
1863             *
1864             * @param layoutSetBranchId the layout set branch ID
1865             * @param head the head
1866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1867             * @return the first matching layout revision
1868             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
1869             * @throws SystemException if a system exception occurred
1870             */
1871            public LayoutRevision findByL_H_First(long layoutSetBranchId, boolean head,
1872                    OrderByComparator orderByComparator)
1873                    throws NoSuchLayoutRevisionException, SystemException {
1874                    LayoutRevision layoutRevision = fetchByL_H_First(layoutSetBranchId,
1875                                    head, orderByComparator);
1876    
1877                    if (layoutRevision != null) {
1878                            return layoutRevision;
1879                    }
1880    
1881                    StringBundler msg = new StringBundler(6);
1882    
1883                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1884    
1885                    msg.append("layoutSetBranchId=");
1886                    msg.append(layoutSetBranchId);
1887    
1888                    msg.append(", head=");
1889                    msg.append(head);
1890    
1891                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1892    
1893                    throw new NoSuchLayoutRevisionException(msg.toString());
1894            }
1895    
1896            /**
1897             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and head = &#63;.
1898             *
1899             * @param layoutSetBranchId the layout set branch ID
1900             * @param head the head
1901             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1902             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
1903             * @throws SystemException if a system exception occurred
1904             */
1905            public LayoutRevision fetchByL_H_First(long layoutSetBranchId,
1906                    boolean head, OrderByComparator orderByComparator)
1907                    throws SystemException {
1908                    List<LayoutRevision> list = findByL_H(layoutSetBranchId, head, 0, 1,
1909                                    orderByComparator);
1910    
1911                    if (!list.isEmpty()) {
1912                            return list.get(0);
1913                    }
1914    
1915                    return null;
1916            }
1917    
1918            /**
1919             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and head = &#63;.
1920             *
1921             * @param layoutSetBranchId the layout set branch ID
1922             * @param head the head
1923             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1924             * @return the last matching layout revision
1925             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
1926             * @throws SystemException if a system exception occurred
1927             */
1928            public LayoutRevision findByL_H_Last(long layoutSetBranchId, boolean head,
1929                    OrderByComparator orderByComparator)
1930                    throws NoSuchLayoutRevisionException, SystemException {
1931                    LayoutRevision layoutRevision = fetchByL_H_Last(layoutSetBranchId,
1932                                    head, orderByComparator);
1933    
1934                    if (layoutRevision != null) {
1935                            return layoutRevision;
1936                    }
1937    
1938                    StringBundler msg = new StringBundler(6);
1939    
1940                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1941    
1942                    msg.append("layoutSetBranchId=");
1943                    msg.append(layoutSetBranchId);
1944    
1945                    msg.append(", head=");
1946                    msg.append(head);
1947    
1948                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1949    
1950                    throw new NoSuchLayoutRevisionException(msg.toString());
1951            }
1952    
1953            /**
1954             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and head = &#63;.
1955             *
1956             * @param layoutSetBranchId the layout set branch ID
1957             * @param head the head
1958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1959             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
1960             * @throws SystemException if a system exception occurred
1961             */
1962            public LayoutRevision fetchByL_H_Last(long layoutSetBranchId, boolean head,
1963                    OrderByComparator orderByComparator) throws SystemException {
1964                    int count = countByL_H(layoutSetBranchId, head);
1965    
1966                    List<LayoutRevision> list = findByL_H(layoutSetBranchId, head,
1967                                    count - 1, count, orderByComparator);
1968    
1969                    if (!list.isEmpty()) {
1970                            return list.get(0);
1971                    }
1972    
1973                    return null;
1974            }
1975    
1976            /**
1977             * Returns the layout revisions before and after the current layout revision in the ordered set where layoutSetBranchId = &#63; and head = &#63;.
1978             *
1979             * @param layoutRevisionId the primary key of the current layout revision
1980             * @param layoutSetBranchId the layout set branch ID
1981             * @param head the head
1982             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1983             * @return the previous, current, and next layout revision
1984             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
1985             * @throws SystemException if a system exception occurred
1986             */
1987            public LayoutRevision[] findByL_H_PrevAndNext(long layoutRevisionId,
1988                    long layoutSetBranchId, boolean head,
1989                    OrderByComparator orderByComparator)
1990                    throws NoSuchLayoutRevisionException, SystemException {
1991                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1992    
1993                    Session session = null;
1994    
1995                    try {
1996                            session = openSession();
1997    
1998                            LayoutRevision[] array = new LayoutRevisionImpl[3];
1999    
2000                            array[0] = getByL_H_PrevAndNext(session, layoutRevision,
2001                                            layoutSetBranchId, head, orderByComparator, true);
2002    
2003                            array[1] = layoutRevision;
2004    
2005                            array[2] = getByL_H_PrevAndNext(session, layoutRevision,
2006                                            layoutSetBranchId, head, orderByComparator, false);
2007    
2008                            return array;
2009                    }
2010                    catch (Exception e) {
2011                            throw processException(e);
2012                    }
2013                    finally {
2014                            closeSession(session);
2015                    }
2016            }
2017    
2018            protected LayoutRevision getByL_H_PrevAndNext(Session session,
2019                    LayoutRevision layoutRevision, long layoutSetBranchId, boolean head,
2020                    OrderByComparator orderByComparator, boolean previous) {
2021                    StringBundler query = null;
2022    
2023                    if (orderByComparator != null) {
2024                            query = new StringBundler(6 +
2025                                            (orderByComparator.getOrderByFields().length * 6));
2026                    }
2027                    else {
2028                            query = new StringBundler(3);
2029                    }
2030    
2031                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2032    
2033                    query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
2034    
2035                    query.append(_FINDER_COLUMN_L_H_HEAD_2);
2036    
2037                    if (orderByComparator != null) {
2038                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2039    
2040                            if (orderByConditionFields.length > 0) {
2041                                    query.append(WHERE_AND);
2042                            }
2043    
2044                            for (int i = 0; i < orderByConditionFields.length; i++) {
2045                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2046                                    query.append(orderByConditionFields[i]);
2047    
2048                                    if ((i + 1) < orderByConditionFields.length) {
2049                                            if (orderByComparator.isAscending() ^ previous) {
2050                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2051                                            }
2052                                            else {
2053                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2054                                            }
2055                                    }
2056                                    else {
2057                                            if (orderByComparator.isAscending() ^ previous) {
2058                                                    query.append(WHERE_GREATER_THAN);
2059                                            }
2060                                            else {
2061                                                    query.append(WHERE_LESSER_THAN);
2062                                            }
2063                                    }
2064                            }
2065    
2066                            query.append(ORDER_BY_CLAUSE);
2067    
2068                            String[] orderByFields = orderByComparator.getOrderByFields();
2069    
2070                            for (int i = 0; i < orderByFields.length; i++) {
2071                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2072                                    query.append(orderByFields[i]);
2073    
2074                                    if ((i + 1) < orderByFields.length) {
2075                                            if (orderByComparator.isAscending() ^ previous) {
2076                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2077                                            }
2078                                            else {
2079                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2080                                            }
2081                                    }
2082                                    else {
2083                                            if (orderByComparator.isAscending() ^ previous) {
2084                                                    query.append(ORDER_BY_ASC);
2085                                            }
2086                                            else {
2087                                                    query.append(ORDER_BY_DESC);
2088                                            }
2089                                    }
2090                            }
2091                    }
2092    
2093                    else {
2094                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2095                    }
2096    
2097                    String sql = query.toString();
2098    
2099                    Query q = session.createQuery(sql);
2100    
2101                    q.setFirstResult(0);
2102                    q.setMaxResults(2);
2103    
2104                    QueryPos qPos = QueryPos.getInstance(q);
2105    
2106                    qPos.add(layoutSetBranchId);
2107    
2108                    qPos.add(head);
2109    
2110                    if (orderByComparator != null) {
2111                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2112    
2113                            for (Object value : values) {
2114                                    qPos.add(value);
2115                            }
2116                    }
2117    
2118                    List<LayoutRevision> list = q.list();
2119    
2120                    if (list.size() == 2) {
2121                            return list.get(1);
2122                    }
2123                    else {
2124                            return null;
2125                    }
2126            }
2127    
2128            /**
2129             * Returns all the layout revisions where layoutSetBranchId = &#63; and plid = &#63;.
2130             *
2131             * @param layoutSetBranchId the layout set branch ID
2132             * @param plid the plid
2133             * @return the matching layout revisions
2134             * @throws SystemException if a system exception occurred
2135             */
2136            public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid)
2137                    throws SystemException {
2138                    return findByL_P(layoutSetBranchId, plid, QueryUtil.ALL_POS,
2139                            QueryUtil.ALL_POS, null);
2140            }
2141    
2142            /**
2143             * Returns a range of all the layout revisions where layoutSetBranchId = &#63; and plid = &#63;.
2144             *
2145             * <p>
2146             * 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.
2147             * </p>
2148             *
2149             * @param layoutSetBranchId the layout set branch ID
2150             * @param plid the plid
2151             * @param start the lower bound of the range of layout revisions
2152             * @param end the upper bound of the range of layout revisions (not inclusive)
2153             * @return the range of matching layout revisions
2154             * @throws SystemException if a system exception occurred
2155             */
2156            public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid,
2157                    int start, int end) throws SystemException {
2158                    return findByL_P(layoutSetBranchId, plid, start, end, null);
2159            }
2160    
2161            /**
2162             * Returns an ordered range of all the layout revisions where layoutSetBranchId = &#63; and plid = &#63;.
2163             *
2164             * <p>
2165             * 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.
2166             * </p>
2167             *
2168             * @param layoutSetBranchId the layout set branch ID
2169             * @param plid the plid
2170             * @param start the lower bound of the range of layout revisions
2171             * @param end the upper bound of the range of layout revisions (not inclusive)
2172             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2173             * @return the ordered range of matching layout revisions
2174             * @throws SystemException if a system exception occurred
2175             */
2176            public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid,
2177                    int start, int end, OrderByComparator orderByComparator)
2178                    throws SystemException {
2179                    FinderPath finderPath = null;
2180                    Object[] finderArgs = null;
2181    
2182                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2183                                    (orderByComparator == null)) {
2184                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P;
2185                            finderArgs = new Object[] { layoutSetBranchId, plid };
2186                    }
2187                    else {
2188                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P;
2189                            finderArgs = new Object[] {
2190                                            layoutSetBranchId, plid,
2191                                            
2192                                            start, end, orderByComparator
2193                                    };
2194                    }
2195    
2196                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
2197                                    finderArgs, this);
2198    
2199                    if ((list != null) && !list.isEmpty()) {
2200                            for (LayoutRevision layoutRevision : list) {
2201                                    if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
2202                                                    (plid != layoutRevision.getPlid())) {
2203                                            list = null;
2204    
2205                                            break;
2206                                    }
2207                            }
2208                    }
2209    
2210                    if (list == null) {
2211                            StringBundler query = null;
2212    
2213                            if (orderByComparator != null) {
2214                                    query = new StringBundler(4 +
2215                                                    (orderByComparator.getOrderByFields().length * 3));
2216                            }
2217                            else {
2218                                    query = new StringBundler(4);
2219                            }
2220    
2221                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2222    
2223                            query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
2224    
2225                            query.append(_FINDER_COLUMN_L_P_PLID_2);
2226    
2227                            if (orderByComparator != null) {
2228                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2229                                            orderByComparator);
2230                            }
2231    
2232                            else {
2233                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2234                            }
2235    
2236                            String sql = query.toString();
2237    
2238                            Session session = null;
2239    
2240                            try {
2241                                    session = openSession();
2242    
2243                                    Query q = session.createQuery(sql);
2244    
2245                                    QueryPos qPos = QueryPos.getInstance(q);
2246    
2247                                    qPos.add(layoutSetBranchId);
2248    
2249                                    qPos.add(plid);
2250    
2251                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
2252                                                    start, end);
2253                            }
2254                            catch (Exception e) {
2255                                    throw processException(e);
2256                            }
2257                            finally {
2258                                    if (list == null) {
2259                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2260                                    }
2261                                    else {
2262                                            cacheResult(list);
2263    
2264                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2265                                    }
2266    
2267                                    closeSession(session);
2268                            }
2269                    }
2270    
2271                    return list;
2272            }
2273    
2274            /**
2275             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63;.
2276             *
2277             * @param layoutSetBranchId the layout set branch ID
2278             * @param plid the plid
2279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2280             * @return the first matching layout revision
2281             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
2282             * @throws SystemException if a system exception occurred
2283             */
2284            public LayoutRevision findByL_P_First(long layoutSetBranchId, long plid,
2285                    OrderByComparator orderByComparator)
2286                    throws NoSuchLayoutRevisionException, SystemException {
2287                    LayoutRevision layoutRevision = fetchByL_P_First(layoutSetBranchId,
2288                                    plid, orderByComparator);
2289    
2290                    if (layoutRevision != null) {
2291                            return layoutRevision;
2292                    }
2293    
2294                    StringBundler msg = new StringBundler(6);
2295    
2296                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2297    
2298                    msg.append("layoutSetBranchId=");
2299                    msg.append(layoutSetBranchId);
2300    
2301                    msg.append(", plid=");
2302                    msg.append(plid);
2303    
2304                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2305    
2306                    throw new NoSuchLayoutRevisionException(msg.toString());
2307            }
2308    
2309            /**
2310             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63;.
2311             *
2312             * @param layoutSetBranchId the layout set branch ID
2313             * @param plid the plid
2314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2315             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
2316             * @throws SystemException if a system exception occurred
2317             */
2318            public LayoutRevision fetchByL_P_First(long layoutSetBranchId, long plid,
2319                    OrderByComparator orderByComparator) throws SystemException {
2320                    List<LayoutRevision> list = findByL_P(layoutSetBranchId, plid, 0, 1,
2321                                    orderByComparator);
2322    
2323                    if (!list.isEmpty()) {
2324                            return list.get(0);
2325                    }
2326    
2327                    return null;
2328            }
2329    
2330            /**
2331             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63;.
2332             *
2333             * @param layoutSetBranchId the layout set branch ID
2334             * @param plid the plid
2335             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2336             * @return the last matching layout revision
2337             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
2338             * @throws SystemException if a system exception occurred
2339             */
2340            public LayoutRevision findByL_P_Last(long layoutSetBranchId, long plid,
2341                    OrderByComparator orderByComparator)
2342                    throws NoSuchLayoutRevisionException, SystemException {
2343                    LayoutRevision layoutRevision = fetchByL_P_Last(layoutSetBranchId,
2344                                    plid, orderByComparator);
2345    
2346                    if (layoutRevision != null) {
2347                            return layoutRevision;
2348                    }
2349    
2350                    StringBundler msg = new StringBundler(6);
2351    
2352                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2353    
2354                    msg.append("layoutSetBranchId=");
2355                    msg.append(layoutSetBranchId);
2356    
2357                    msg.append(", plid=");
2358                    msg.append(plid);
2359    
2360                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2361    
2362                    throw new NoSuchLayoutRevisionException(msg.toString());
2363            }
2364    
2365            /**
2366             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63;.
2367             *
2368             * @param layoutSetBranchId the layout set branch ID
2369             * @param plid the plid
2370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2371             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
2372             * @throws SystemException if a system exception occurred
2373             */
2374            public LayoutRevision fetchByL_P_Last(long layoutSetBranchId, long plid,
2375                    OrderByComparator orderByComparator) throws SystemException {
2376                    int count = countByL_P(layoutSetBranchId, plid);
2377    
2378                    List<LayoutRevision> list = findByL_P(layoutSetBranchId, plid,
2379                                    count - 1, count, orderByComparator);
2380    
2381                    if (!list.isEmpty()) {
2382                            return list.get(0);
2383                    }
2384    
2385                    return null;
2386            }
2387    
2388            /**
2389             * Returns the layout revisions before and after the current layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63;.
2390             *
2391             * @param layoutRevisionId the primary key of the current layout revision
2392             * @param layoutSetBranchId the layout set branch ID
2393             * @param plid the plid
2394             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2395             * @return the previous, current, and next layout revision
2396             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
2397             * @throws SystemException if a system exception occurred
2398             */
2399            public LayoutRevision[] findByL_P_PrevAndNext(long layoutRevisionId,
2400                    long layoutSetBranchId, long plid, OrderByComparator orderByComparator)
2401                    throws NoSuchLayoutRevisionException, SystemException {
2402                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
2403    
2404                    Session session = null;
2405    
2406                    try {
2407                            session = openSession();
2408    
2409                            LayoutRevision[] array = new LayoutRevisionImpl[3];
2410    
2411                            array[0] = getByL_P_PrevAndNext(session, layoutRevision,
2412                                            layoutSetBranchId, plid, orderByComparator, true);
2413    
2414                            array[1] = layoutRevision;
2415    
2416                            array[2] = getByL_P_PrevAndNext(session, layoutRevision,
2417                                            layoutSetBranchId, plid, orderByComparator, false);
2418    
2419                            return array;
2420                    }
2421                    catch (Exception e) {
2422                            throw processException(e);
2423                    }
2424                    finally {
2425                            closeSession(session);
2426                    }
2427            }
2428    
2429            protected LayoutRevision getByL_P_PrevAndNext(Session session,
2430                    LayoutRevision layoutRevision, long layoutSetBranchId, long plid,
2431                    OrderByComparator orderByComparator, boolean previous) {
2432                    StringBundler query = null;
2433    
2434                    if (orderByComparator != null) {
2435                            query = new StringBundler(6 +
2436                                            (orderByComparator.getOrderByFields().length * 6));
2437                    }
2438                    else {
2439                            query = new StringBundler(3);
2440                    }
2441    
2442                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2443    
2444                    query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
2445    
2446                    query.append(_FINDER_COLUMN_L_P_PLID_2);
2447    
2448                    if (orderByComparator != null) {
2449                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2450    
2451                            if (orderByConditionFields.length > 0) {
2452                                    query.append(WHERE_AND);
2453                            }
2454    
2455                            for (int i = 0; i < orderByConditionFields.length; i++) {
2456                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2457                                    query.append(orderByConditionFields[i]);
2458    
2459                                    if ((i + 1) < orderByConditionFields.length) {
2460                                            if (orderByComparator.isAscending() ^ previous) {
2461                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2462                                            }
2463                                            else {
2464                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2465                                            }
2466                                    }
2467                                    else {
2468                                            if (orderByComparator.isAscending() ^ previous) {
2469                                                    query.append(WHERE_GREATER_THAN);
2470                                            }
2471                                            else {
2472                                                    query.append(WHERE_LESSER_THAN);
2473                                            }
2474                                    }
2475                            }
2476    
2477                            query.append(ORDER_BY_CLAUSE);
2478    
2479                            String[] orderByFields = orderByComparator.getOrderByFields();
2480    
2481                            for (int i = 0; i < orderByFields.length; i++) {
2482                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2483                                    query.append(orderByFields[i]);
2484    
2485                                    if ((i + 1) < orderByFields.length) {
2486                                            if (orderByComparator.isAscending() ^ previous) {
2487                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2488                                            }
2489                                            else {
2490                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2491                                            }
2492                                    }
2493                                    else {
2494                                            if (orderByComparator.isAscending() ^ previous) {
2495                                                    query.append(ORDER_BY_ASC);
2496                                            }
2497                                            else {
2498                                                    query.append(ORDER_BY_DESC);
2499                                            }
2500                                    }
2501                            }
2502                    }
2503    
2504                    else {
2505                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2506                    }
2507    
2508                    String sql = query.toString();
2509    
2510                    Query q = session.createQuery(sql);
2511    
2512                    q.setFirstResult(0);
2513                    q.setMaxResults(2);
2514    
2515                    QueryPos qPos = QueryPos.getInstance(q);
2516    
2517                    qPos.add(layoutSetBranchId);
2518    
2519                    qPos.add(plid);
2520    
2521                    if (orderByComparator != null) {
2522                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2523    
2524                            for (Object value : values) {
2525                                    qPos.add(value);
2526                            }
2527                    }
2528    
2529                    List<LayoutRevision> list = q.list();
2530    
2531                    if (list.size() == 2) {
2532                            return list.get(1);
2533                    }
2534                    else {
2535                            return null;
2536                    }
2537            }
2538    
2539            /**
2540             * Returns all the layout revisions where layoutSetBranchId = &#63; and status = &#63;.
2541             *
2542             * @param layoutSetBranchId the layout set branch ID
2543             * @param status the status
2544             * @return the matching layout revisions
2545             * @throws SystemException if a system exception occurred
2546             */
2547            public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status)
2548                    throws SystemException {
2549                    return findByL_S(layoutSetBranchId, status, QueryUtil.ALL_POS,
2550                            QueryUtil.ALL_POS, null);
2551            }
2552    
2553            /**
2554             * Returns a range of all the layout revisions where layoutSetBranchId = &#63; and status = &#63;.
2555             *
2556             * <p>
2557             * 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.
2558             * </p>
2559             *
2560             * @param layoutSetBranchId the layout set branch ID
2561             * @param status the status
2562             * @param start the lower bound of the range of layout revisions
2563             * @param end the upper bound of the range of layout revisions (not inclusive)
2564             * @return the range of matching layout revisions
2565             * @throws SystemException if a system exception occurred
2566             */
2567            public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status,
2568                    int start, int end) throws SystemException {
2569                    return findByL_S(layoutSetBranchId, status, start, end, null);
2570            }
2571    
2572            /**
2573             * Returns an ordered range of all the layout revisions where layoutSetBranchId = &#63; and status = &#63;.
2574             *
2575             * <p>
2576             * 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.
2577             * </p>
2578             *
2579             * @param layoutSetBranchId the layout set branch ID
2580             * @param status the status
2581             * @param start the lower bound of the range of layout revisions
2582             * @param end the upper bound of the range of layout revisions (not inclusive)
2583             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2584             * @return the ordered range of matching layout revisions
2585             * @throws SystemException if a system exception occurred
2586             */
2587            public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status,
2588                    int start, int end, OrderByComparator orderByComparator)
2589                    throws SystemException {
2590                    FinderPath finderPath = null;
2591                    Object[] finderArgs = null;
2592    
2593                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2594                                    (orderByComparator == null)) {
2595                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S;
2596                            finderArgs = new Object[] { layoutSetBranchId, status };
2597                    }
2598                    else {
2599                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_S;
2600                            finderArgs = new Object[] {
2601                                            layoutSetBranchId, status,
2602                                            
2603                                            start, end, orderByComparator
2604                                    };
2605                    }
2606    
2607                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
2608                                    finderArgs, this);
2609    
2610                    if ((list != null) && !list.isEmpty()) {
2611                            for (LayoutRevision layoutRevision : list) {
2612                                    if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
2613                                                    (status != layoutRevision.getStatus())) {
2614                                            list = null;
2615    
2616                                            break;
2617                                    }
2618                            }
2619                    }
2620    
2621                    if (list == null) {
2622                            StringBundler query = null;
2623    
2624                            if (orderByComparator != null) {
2625                                    query = new StringBundler(4 +
2626                                                    (orderByComparator.getOrderByFields().length * 3));
2627                            }
2628                            else {
2629                                    query = new StringBundler(4);
2630                            }
2631    
2632                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2633    
2634                            query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
2635    
2636                            query.append(_FINDER_COLUMN_L_S_STATUS_2);
2637    
2638                            if (orderByComparator != null) {
2639                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2640                                            orderByComparator);
2641                            }
2642    
2643                            else {
2644                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2645                            }
2646    
2647                            String sql = query.toString();
2648    
2649                            Session session = null;
2650    
2651                            try {
2652                                    session = openSession();
2653    
2654                                    Query q = session.createQuery(sql);
2655    
2656                                    QueryPos qPos = QueryPos.getInstance(q);
2657    
2658                                    qPos.add(layoutSetBranchId);
2659    
2660                                    qPos.add(status);
2661    
2662                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
2663                                                    start, end);
2664                            }
2665                            catch (Exception e) {
2666                                    throw processException(e);
2667                            }
2668                            finally {
2669                                    if (list == null) {
2670                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2671                                    }
2672                                    else {
2673                                            cacheResult(list);
2674    
2675                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2676                                    }
2677    
2678                                    closeSession(session);
2679                            }
2680                    }
2681    
2682                    return list;
2683            }
2684    
2685            /**
2686             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and status = &#63;.
2687             *
2688             * @param layoutSetBranchId the layout set branch ID
2689             * @param status the status
2690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2691             * @return the first matching layout revision
2692             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
2693             * @throws SystemException if a system exception occurred
2694             */
2695            public LayoutRevision findByL_S_First(long layoutSetBranchId, int status,
2696                    OrderByComparator orderByComparator)
2697                    throws NoSuchLayoutRevisionException, SystemException {
2698                    LayoutRevision layoutRevision = fetchByL_S_First(layoutSetBranchId,
2699                                    status, orderByComparator);
2700    
2701                    if (layoutRevision != null) {
2702                            return layoutRevision;
2703                    }
2704    
2705                    StringBundler msg = new StringBundler(6);
2706    
2707                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2708    
2709                    msg.append("layoutSetBranchId=");
2710                    msg.append(layoutSetBranchId);
2711    
2712                    msg.append(", status=");
2713                    msg.append(status);
2714    
2715                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2716    
2717                    throw new NoSuchLayoutRevisionException(msg.toString());
2718            }
2719    
2720            /**
2721             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and status = &#63;.
2722             *
2723             * @param layoutSetBranchId the layout set branch ID
2724             * @param status the status
2725             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2726             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
2727             * @throws SystemException if a system exception occurred
2728             */
2729            public LayoutRevision fetchByL_S_First(long layoutSetBranchId, int status,
2730                    OrderByComparator orderByComparator) throws SystemException {
2731                    List<LayoutRevision> list = findByL_S(layoutSetBranchId, status, 0, 1,
2732                                    orderByComparator);
2733    
2734                    if (!list.isEmpty()) {
2735                            return list.get(0);
2736                    }
2737    
2738                    return null;
2739            }
2740    
2741            /**
2742             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and status = &#63;.
2743             *
2744             * @param layoutSetBranchId the layout set branch ID
2745             * @param status the status
2746             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2747             * @return the last matching layout revision
2748             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
2749             * @throws SystemException if a system exception occurred
2750             */
2751            public LayoutRevision findByL_S_Last(long layoutSetBranchId, int status,
2752                    OrderByComparator orderByComparator)
2753                    throws NoSuchLayoutRevisionException, SystemException {
2754                    LayoutRevision layoutRevision = fetchByL_S_Last(layoutSetBranchId,
2755                                    status, orderByComparator);
2756    
2757                    if (layoutRevision != null) {
2758                            return layoutRevision;
2759                    }
2760    
2761                    StringBundler msg = new StringBundler(6);
2762    
2763                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2764    
2765                    msg.append("layoutSetBranchId=");
2766                    msg.append(layoutSetBranchId);
2767    
2768                    msg.append(", status=");
2769                    msg.append(status);
2770    
2771                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2772    
2773                    throw new NoSuchLayoutRevisionException(msg.toString());
2774            }
2775    
2776            /**
2777             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and status = &#63;.
2778             *
2779             * @param layoutSetBranchId the layout set branch ID
2780             * @param status the status
2781             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2782             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
2783             * @throws SystemException if a system exception occurred
2784             */
2785            public LayoutRevision fetchByL_S_Last(long layoutSetBranchId, int status,
2786                    OrderByComparator orderByComparator) throws SystemException {
2787                    int count = countByL_S(layoutSetBranchId, status);
2788    
2789                    List<LayoutRevision> list = findByL_S(layoutSetBranchId, status,
2790                                    count - 1, count, orderByComparator);
2791    
2792                    if (!list.isEmpty()) {
2793                            return list.get(0);
2794                    }
2795    
2796                    return null;
2797            }
2798    
2799            /**
2800             * Returns the layout revisions before and after the current layout revision in the ordered set where layoutSetBranchId = &#63; and status = &#63;.
2801             *
2802             * @param layoutRevisionId the primary key of the current layout revision
2803             * @param layoutSetBranchId the layout set branch ID
2804             * @param status the status
2805             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2806             * @return the previous, current, and next layout revision
2807             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
2808             * @throws SystemException if a system exception occurred
2809             */
2810            public LayoutRevision[] findByL_S_PrevAndNext(long layoutRevisionId,
2811                    long layoutSetBranchId, int status, OrderByComparator orderByComparator)
2812                    throws NoSuchLayoutRevisionException, SystemException {
2813                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
2814    
2815                    Session session = null;
2816    
2817                    try {
2818                            session = openSession();
2819    
2820                            LayoutRevision[] array = new LayoutRevisionImpl[3];
2821    
2822                            array[0] = getByL_S_PrevAndNext(session, layoutRevision,
2823                                            layoutSetBranchId, status, orderByComparator, true);
2824    
2825                            array[1] = layoutRevision;
2826    
2827                            array[2] = getByL_S_PrevAndNext(session, layoutRevision,
2828                                            layoutSetBranchId, status, orderByComparator, false);
2829    
2830                            return array;
2831                    }
2832                    catch (Exception e) {
2833                            throw processException(e);
2834                    }
2835                    finally {
2836                            closeSession(session);
2837                    }
2838            }
2839    
2840            protected LayoutRevision getByL_S_PrevAndNext(Session session,
2841                    LayoutRevision layoutRevision, long layoutSetBranchId, int status,
2842                    OrderByComparator orderByComparator, boolean previous) {
2843                    StringBundler query = null;
2844    
2845                    if (orderByComparator != null) {
2846                            query = new StringBundler(6 +
2847                                            (orderByComparator.getOrderByFields().length * 6));
2848                    }
2849                    else {
2850                            query = new StringBundler(3);
2851                    }
2852    
2853                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2854    
2855                    query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
2856    
2857                    query.append(_FINDER_COLUMN_L_S_STATUS_2);
2858    
2859                    if (orderByComparator != null) {
2860                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2861    
2862                            if (orderByConditionFields.length > 0) {
2863                                    query.append(WHERE_AND);
2864                            }
2865    
2866                            for (int i = 0; i < orderByConditionFields.length; i++) {
2867                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2868                                    query.append(orderByConditionFields[i]);
2869    
2870                                    if ((i + 1) < orderByConditionFields.length) {
2871                                            if (orderByComparator.isAscending() ^ previous) {
2872                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2873                                            }
2874                                            else {
2875                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2876                                            }
2877                                    }
2878                                    else {
2879                                            if (orderByComparator.isAscending() ^ previous) {
2880                                                    query.append(WHERE_GREATER_THAN);
2881                                            }
2882                                            else {
2883                                                    query.append(WHERE_LESSER_THAN);
2884                                            }
2885                                    }
2886                            }
2887    
2888                            query.append(ORDER_BY_CLAUSE);
2889    
2890                            String[] orderByFields = orderByComparator.getOrderByFields();
2891    
2892                            for (int i = 0; i < orderByFields.length; i++) {
2893                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2894                                    query.append(orderByFields[i]);
2895    
2896                                    if ((i + 1) < orderByFields.length) {
2897                                            if (orderByComparator.isAscending() ^ previous) {
2898                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2899                                            }
2900                                            else {
2901                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2902                                            }
2903                                    }
2904                                    else {
2905                                            if (orderByComparator.isAscending() ^ previous) {
2906                                                    query.append(ORDER_BY_ASC);
2907                                            }
2908                                            else {
2909                                                    query.append(ORDER_BY_DESC);
2910                                            }
2911                                    }
2912                            }
2913                    }
2914    
2915                    else {
2916                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2917                    }
2918    
2919                    String sql = query.toString();
2920    
2921                    Query q = session.createQuery(sql);
2922    
2923                    q.setFirstResult(0);
2924                    q.setMaxResults(2);
2925    
2926                    QueryPos qPos = QueryPos.getInstance(q);
2927    
2928                    qPos.add(layoutSetBranchId);
2929    
2930                    qPos.add(status);
2931    
2932                    if (orderByComparator != null) {
2933                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2934    
2935                            for (Object value : values) {
2936                                    qPos.add(value);
2937                            }
2938                    }
2939    
2940                    List<LayoutRevision> list = q.list();
2941    
2942                    if (list.size() == 2) {
2943                            return list.get(1);
2944                    }
2945                    else {
2946                            return null;
2947                    }
2948            }
2949    
2950            /**
2951             * Returns all the layout revisions where head = &#63; and plid = &#63;.
2952             *
2953             * @param head the head
2954             * @param plid the plid
2955             * @return the matching layout revisions
2956             * @throws SystemException if a system exception occurred
2957             */
2958            public List<LayoutRevision> findByH_P(boolean head, long plid)
2959                    throws SystemException {
2960                    return findByH_P(head, plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2961            }
2962    
2963            /**
2964             * Returns a range of all the layout revisions where head = &#63; and plid = &#63;.
2965             *
2966             * <p>
2967             * 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.
2968             * </p>
2969             *
2970             * @param head the head
2971             * @param plid the plid
2972             * @param start the lower bound of the range of layout revisions
2973             * @param end the upper bound of the range of layout revisions (not inclusive)
2974             * @return the range of matching layout revisions
2975             * @throws SystemException if a system exception occurred
2976             */
2977            public List<LayoutRevision> findByH_P(boolean head, long plid, int start,
2978                    int end) throws SystemException {
2979                    return findByH_P(head, plid, start, end, null);
2980            }
2981    
2982            /**
2983             * Returns an ordered range of all the layout revisions where head = &#63; and plid = &#63;.
2984             *
2985             * <p>
2986             * 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.
2987             * </p>
2988             *
2989             * @param head the head
2990             * @param plid the plid
2991             * @param start the lower bound of the range of layout revisions
2992             * @param end the upper bound of the range of layout revisions (not inclusive)
2993             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2994             * @return the ordered range of matching layout revisions
2995             * @throws SystemException if a system exception occurred
2996             */
2997            public List<LayoutRevision> findByH_P(boolean head, long plid, int start,
2998                    int end, OrderByComparator orderByComparator) throws SystemException {
2999                    FinderPath finderPath = null;
3000                    Object[] finderArgs = null;
3001    
3002                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3003                                    (orderByComparator == null)) {
3004                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P;
3005                            finderArgs = new Object[] { head, plid };
3006                    }
3007                    else {
3008                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_H_P;
3009                            finderArgs = new Object[] { head, plid, start, end, orderByComparator };
3010                    }
3011    
3012                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3013                                    finderArgs, this);
3014    
3015                    if ((list != null) && !list.isEmpty()) {
3016                            for (LayoutRevision layoutRevision : list) {
3017                                    if ((head != layoutRevision.getHead()) ||
3018                                                    (plid != layoutRevision.getPlid())) {
3019                                            list = null;
3020    
3021                                            break;
3022                                    }
3023                            }
3024                    }
3025    
3026                    if (list == null) {
3027                            StringBundler query = null;
3028    
3029                            if (orderByComparator != null) {
3030                                    query = new StringBundler(4 +
3031                                                    (orderByComparator.getOrderByFields().length * 3));
3032                            }
3033                            else {
3034                                    query = new StringBundler(4);
3035                            }
3036    
3037                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3038    
3039                            query.append(_FINDER_COLUMN_H_P_HEAD_2);
3040    
3041                            query.append(_FINDER_COLUMN_H_P_PLID_2);
3042    
3043                            if (orderByComparator != null) {
3044                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3045                                            orderByComparator);
3046                            }
3047    
3048                            else {
3049                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3050                            }
3051    
3052                            String sql = query.toString();
3053    
3054                            Session session = null;
3055    
3056                            try {
3057                                    session = openSession();
3058    
3059                                    Query q = session.createQuery(sql);
3060    
3061                                    QueryPos qPos = QueryPos.getInstance(q);
3062    
3063                                    qPos.add(head);
3064    
3065                                    qPos.add(plid);
3066    
3067                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
3068                                                    start, end);
3069                            }
3070                            catch (Exception e) {
3071                                    throw processException(e);
3072                            }
3073                            finally {
3074                                    if (list == null) {
3075                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3076                                    }
3077                                    else {
3078                                            cacheResult(list);
3079    
3080                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3081                                    }
3082    
3083                                    closeSession(session);
3084                            }
3085                    }
3086    
3087                    return list;
3088            }
3089    
3090            /**
3091             * Returns the first layout revision in the ordered set where head = &#63; and plid = &#63;.
3092             *
3093             * @param head the head
3094             * @param plid the plid
3095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3096             * @return the first matching layout revision
3097             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
3098             * @throws SystemException if a system exception occurred
3099             */
3100            public LayoutRevision findByH_P_First(boolean head, long plid,
3101                    OrderByComparator orderByComparator)
3102                    throws NoSuchLayoutRevisionException, SystemException {
3103                    LayoutRevision layoutRevision = fetchByH_P_First(head, plid,
3104                                    orderByComparator);
3105    
3106                    if (layoutRevision != null) {
3107                            return layoutRevision;
3108                    }
3109    
3110                    StringBundler msg = new StringBundler(6);
3111    
3112                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3113    
3114                    msg.append("head=");
3115                    msg.append(head);
3116    
3117                    msg.append(", plid=");
3118                    msg.append(plid);
3119    
3120                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3121    
3122                    throw new NoSuchLayoutRevisionException(msg.toString());
3123            }
3124    
3125            /**
3126             * Returns the first layout revision in the ordered set where head = &#63; and plid = &#63;.
3127             *
3128             * @param head the head
3129             * @param plid the plid
3130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3131             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
3132             * @throws SystemException if a system exception occurred
3133             */
3134            public LayoutRevision fetchByH_P_First(boolean head, long plid,
3135                    OrderByComparator orderByComparator) throws SystemException {
3136                    List<LayoutRevision> list = findByH_P(head, plid, 0, 1,
3137                                    orderByComparator);
3138    
3139                    if (!list.isEmpty()) {
3140                            return list.get(0);
3141                    }
3142    
3143                    return null;
3144            }
3145    
3146            /**
3147             * Returns the last layout revision in the ordered set where head = &#63; and plid = &#63;.
3148             *
3149             * @param head the head
3150             * @param plid the plid
3151             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3152             * @return the last matching layout revision
3153             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
3154             * @throws SystemException if a system exception occurred
3155             */
3156            public LayoutRevision findByH_P_Last(boolean head, long plid,
3157                    OrderByComparator orderByComparator)
3158                    throws NoSuchLayoutRevisionException, SystemException {
3159                    LayoutRevision layoutRevision = fetchByH_P_Last(head, plid,
3160                                    orderByComparator);
3161    
3162                    if (layoutRevision != null) {
3163                            return layoutRevision;
3164                    }
3165    
3166                    StringBundler msg = new StringBundler(6);
3167    
3168                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3169    
3170                    msg.append("head=");
3171                    msg.append(head);
3172    
3173                    msg.append(", plid=");
3174                    msg.append(plid);
3175    
3176                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3177    
3178                    throw new NoSuchLayoutRevisionException(msg.toString());
3179            }
3180    
3181            /**
3182             * Returns the last layout revision in the ordered set where head = &#63; and plid = &#63;.
3183             *
3184             * @param head the head
3185             * @param plid the plid
3186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3187             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
3188             * @throws SystemException if a system exception occurred
3189             */
3190            public LayoutRevision fetchByH_P_Last(boolean head, long plid,
3191                    OrderByComparator orderByComparator) throws SystemException {
3192                    int count = countByH_P(head, plid);
3193    
3194                    List<LayoutRevision> list = findByH_P(head, plid, count - 1, count,
3195                                    orderByComparator);
3196    
3197                    if (!list.isEmpty()) {
3198                            return list.get(0);
3199                    }
3200    
3201                    return null;
3202            }
3203    
3204            /**
3205             * Returns the layout revisions before and after the current layout revision in the ordered set where head = &#63; and plid = &#63;.
3206             *
3207             * @param layoutRevisionId the primary key of the current layout revision
3208             * @param head the head
3209             * @param plid the plid
3210             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3211             * @return the previous, current, and next layout revision
3212             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
3213             * @throws SystemException if a system exception occurred
3214             */
3215            public LayoutRevision[] findByH_P_PrevAndNext(long layoutRevisionId,
3216                    boolean head, long plid, OrderByComparator orderByComparator)
3217                    throws NoSuchLayoutRevisionException, SystemException {
3218                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
3219    
3220                    Session session = null;
3221    
3222                    try {
3223                            session = openSession();
3224    
3225                            LayoutRevision[] array = new LayoutRevisionImpl[3];
3226    
3227                            array[0] = getByH_P_PrevAndNext(session, layoutRevision, head,
3228                                            plid, orderByComparator, true);
3229    
3230                            array[1] = layoutRevision;
3231    
3232                            array[2] = getByH_P_PrevAndNext(session, layoutRevision, head,
3233                                            plid, orderByComparator, false);
3234    
3235                            return array;
3236                    }
3237                    catch (Exception e) {
3238                            throw processException(e);
3239                    }
3240                    finally {
3241                            closeSession(session);
3242                    }
3243            }
3244    
3245            protected LayoutRevision getByH_P_PrevAndNext(Session session,
3246                    LayoutRevision layoutRevision, boolean head, long plid,
3247                    OrderByComparator orderByComparator, boolean previous) {
3248                    StringBundler query = null;
3249    
3250                    if (orderByComparator != null) {
3251                            query = new StringBundler(6 +
3252                                            (orderByComparator.getOrderByFields().length * 6));
3253                    }
3254                    else {
3255                            query = new StringBundler(3);
3256                    }
3257    
3258                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3259    
3260                    query.append(_FINDER_COLUMN_H_P_HEAD_2);
3261    
3262                    query.append(_FINDER_COLUMN_H_P_PLID_2);
3263    
3264                    if (orderByComparator != null) {
3265                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3266    
3267                            if (orderByConditionFields.length > 0) {
3268                                    query.append(WHERE_AND);
3269                            }
3270    
3271                            for (int i = 0; i < orderByConditionFields.length; i++) {
3272                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3273                                    query.append(orderByConditionFields[i]);
3274    
3275                                    if ((i + 1) < orderByConditionFields.length) {
3276                                            if (orderByComparator.isAscending() ^ previous) {
3277                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3278                                            }
3279                                            else {
3280                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3281                                            }
3282                                    }
3283                                    else {
3284                                            if (orderByComparator.isAscending() ^ previous) {
3285                                                    query.append(WHERE_GREATER_THAN);
3286                                            }
3287                                            else {
3288                                                    query.append(WHERE_LESSER_THAN);
3289                                            }
3290                                    }
3291                            }
3292    
3293                            query.append(ORDER_BY_CLAUSE);
3294    
3295                            String[] orderByFields = orderByComparator.getOrderByFields();
3296    
3297                            for (int i = 0; i < orderByFields.length; i++) {
3298                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3299                                    query.append(orderByFields[i]);
3300    
3301                                    if ((i + 1) < orderByFields.length) {
3302                                            if (orderByComparator.isAscending() ^ previous) {
3303                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3304                                            }
3305                                            else {
3306                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3307                                            }
3308                                    }
3309                                    else {
3310                                            if (orderByComparator.isAscending() ^ previous) {
3311                                                    query.append(ORDER_BY_ASC);
3312                                            }
3313                                            else {
3314                                                    query.append(ORDER_BY_DESC);
3315                                            }
3316                                    }
3317                            }
3318                    }
3319    
3320                    else {
3321                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3322                    }
3323    
3324                    String sql = query.toString();
3325    
3326                    Query q = session.createQuery(sql);
3327    
3328                    q.setFirstResult(0);
3329                    q.setMaxResults(2);
3330    
3331                    QueryPos qPos = QueryPos.getInstance(q);
3332    
3333                    qPos.add(head);
3334    
3335                    qPos.add(plid);
3336    
3337                    if (orderByComparator != null) {
3338                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
3339    
3340                            for (Object value : values) {
3341                                    qPos.add(value);
3342                            }
3343                    }
3344    
3345                    List<LayoutRevision> list = q.list();
3346    
3347                    if (list.size() == 2) {
3348                            return list.get(1);
3349                    }
3350                    else {
3351                            return null;
3352                    }
3353            }
3354    
3355            /**
3356             * Returns all the layout revisions where plid = &#63; and status &ne; &#63;.
3357             *
3358             * @param plid the plid
3359             * @param status the status
3360             * @return the matching layout revisions
3361             * @throws SystemException if a system exception occurred
3362             */
3363            public List<LayoutRevision> findByP_NotS(long plid, int status)
3364                    throws SystemException {
3365                    return findByP_NotS(plid, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3366                            null);
3367            }
3368    
3369            /**
3370             * Returns a range of all the layout revisions where plid = &#63; and status &ne; &#63;.
3371             *
3372             * <p>
3373             * 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.
3374             * </p>
3375             *
3376             * @param plid the plid
3377             * @param status the status
3378             * @param start the lower bound of the range of layout revisions
3379             * @param end the upper bound of the range of layout revisions (not inclusive)
3380             * @return the range of matching layout revisions
3381             * @throws SystemException if a system exception occurred
3382             */
3383            public List<LayoutRevision> findByP_NotS(long plid, int status, int start,
3384                    int end) throws SystemException {
3385                    return findByP_NotS(plid, status, start, end, null);
3386            }
3387    
3388            /**
3389             * Returns an ordered range of all the layout revisions where plid = &#63; and status &ne; &#63;.
3390             *
3391             * <p>
3392             * 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.
3393             * </p>
3394             *
3395             * @param plid the plid
3396             * @param status the status
3397             * @param start the lower bound of the range of layout revisions
3398             * @param end the upper bound of the range of layout revisions (not inclusive)
3399             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3400             * @return the ordered range of matching layout revisions
3401             * @throws SystemException if a system exception occurred
3402             */
3403            public List<LayoutRevision> findByP_NotS(long plid, int status, int start,
3404                    int end, OrderByComparator orderByComparator) throws SystemException {
3405                    FinderPath finderPath = null;
3406                    Object[] finderArgs = null;
3407    
3408                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_NOTS;
3409                    finderArgs = new Object[] { plid, status, start, end, orderByComparator };
3410    
3411                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3412                                    finderArgs, this);
3413    
3414                    if ((list != null) && !list.isEmpty()) {
3415                            for (LayoutRevision layoutRevision : list) {
3416                                    if ((plid != layoutRevision.getPlid()) ||
3417                                                    (status != layoutRevision.getStatus())) {
3418                                            list = null;
3419    
3420                                            break;
3421                                    }
3422                            }
3423                    }
3424    
3425                    if (list == null) {
3426                            StringBundler query = null;
3427    
3428                            if (orderByComparator != null) {
3429                                    query = new StringBundler(4 +
3430                                                    (orderByComparator.getOrderByFields().length * 3));
3431                            }
3432                            else {
3433                                    query = new StringBundler(4);
3434                            }
3435    
3436                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3437    
3438                            query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
3439    
3440                            query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
3441    
3442                            if (orderByComparator != null) {
3443                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3444                                            orderByComparator);
3445                            }
3446    
3447                            else {
3448                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3449                            }
3450    
3451                            String sql = query.toString();
3452    
3453                            Session session = null;
3454    
3455                            try {
3456                                    session = openSession();
3457    
3458                                    Query q = session.createQuery(sql);
3459    
3460                                    QueryPos qPos = QueryPos.getInstance(q);
3461    
3462                                    qPos.add(plid);
3463    
3464                                    qPos.add(status);
3465    
3466                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
3467                                                    start, end);
3468                            }
3469                            catch (Exception e) {
3470                                    throw processException(e);
3471                            }
3472                            finally {
3473                                    if (list == null) {
3474                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3475                                    }
3476                                    else {
3477                                            cacheResult(list);
3478    
3479                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3480                                    }
3481    
3482                                    closeSession(session);
3483                            }
3484                    }
3485    
3486                    return list;
3487            }
3488    
3489            /**
3490             * Returns the first layout revision in the ordered set where plid = &#63; and status &ne; &#63;.
3491             *
3492             * @param plid the plid
3493             * @param status the status
3494             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3495             * @return the first matching layout revision
3496             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
3497             * @throws SystemException if a system exception occurred
3498             */
3499            public LayoutRevision findByP_NotS_First(long plid, int status,
3500                    OrderByComparator orderByComparator)
3501                    throws NoSuchLayoutRevisionException, SystemException {
3502                    LayoutRevision layoutRevision = fetchByP_NotS_First(plid, status,
3503                                    orderByComparator);
3504    
3505                    if (layoutRevision != null) {
3506                            return layoutRevision;
3507                    }
3508    
3509                    StringBundler msg = new StringBundler(6);
3510    
3511                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3512    
3513                    msg.append("plid=");
3514                    msg.append(plid);
3515    
3516                    msg.append(", status=");
3517                    msg.append(status);
3518    
3519                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3520    
3521                    throw new NoSuchLayoutRevisionException(msg.toString());
3522            }
3523    
3524            /**
3525             * Returns the first layout revision in the ordered set where plid = &#63; and status &ne; &#63;.
3526             *
3527             * @param plid the plid
3528             * @param status the status
3529             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3530             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
3531             * @throws SystemException if a system exception occurred
3532             */
3533            public LayoutRevision fetchByP_NotS_First(long plid, int status,
3534                    OrderByComparator orderByComparator) throws SystemException {
3535                    List<LayoutRevision> list = findByP_NotS(plid, status, 0, 1,
3536                                    orderByComparator);
3537    
3538                    if (!list.isEmpty()) {
3539                            return list.get(0);
3540                    }
3541    
3542                    return null;
3543            }
3544    
3545            /**
3546             * Returns the last layout revision in the ordered set where plid = &#63; and status &ne; &#63;.
3547             *
3548             * @param plid the plid
3549             * @param status the status
3550             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3551             * @return the last matching layout revision
3552             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
3553             * @throws SystemException if a system exception occurred
3554             */
3555            public LayoutRevision findByP_NotS_Last(long plid, int status,
3556                    OrderByComparator orderByComparator)
3557                    throws NoSuchLayoutRevisionException, SystemException {
3558                    LayoutRevision layoutRevision = fetchByP_NotS_Last(plid, status,
3559                                    orderByComparator);
3560    
3561                    if (layoutRevision != null) {
3562                            return layoutRevision;
3563                    }
3564    
3565                    StringBundler msg = new StringBundler(6);
3566    
3567                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3568    
3569                    msg.append("plid=");
3570                    msg.append(plid);
3571    
3572                    msg.append(", status=");
3573                    msg.append(status);
3574    
3575                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3576    
3577                    throw new NoSuchLayoutRevisionException(msg.toString());
3578            }
3579    
3580            /**
3581             * Returns the last layout revision in the ordered set where plid = &#63; and status &ne; &#63;.
3582             *
3583             * @param plid the plid
3584             * @param status the status
3585             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3586             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
3587             * @throws SystemException if a system exception occurred
3588             */
3589            public LayoutRevision fetchByP_NotS_Last(long plid, int status,
3590                    OrderByComparator orderByComparator) throws SystemException {
3591                    int count = countByP_NotS(plid, status);
3592    
3593                    List<LayoutRevision> list = findByP_NotS(plid, status, count - 1,
3594                                    count, orderByComparator);
3595    
3596                    if (!list.isEmpty()) {
3597                            return list.get(0);
3598                    }
3599    
3600                    return null;
3601            }
3602    
3603            /**
3604             * Returns the layout revisions before and after the current layout revision in the ordered set where plid = &#63; and status &ne; &#63;.
3605             *
3606             * @param layoutRevisionId the primary key of the current layout revision
3607             * @param plid the plid
3608             * @param status the status
3609             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3610             * @return the previous, current, and next layout revision
3611             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
3612             * @throws SystemException if a system exception occurred
3613             */
3614            public LayoutRevision[] findByP_NotS_PrevAndNext(long layoutRevisionId,
3615                    long plid, int status, OrderByComparator orderByComparator)
3616                    throws NoSuchLayoutRevisionException, SystemException {
3617                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
3618    
3619                    Session session = null;
3620    
3621                    try {
3622                            session = openSession();
3623    
3624                            LayoutRevision[] array = new LayoutRevisionImpl[3];
3625    
3626                            array[0] = getByP_NotS_PrevAndNext(session, layoutRevision, plid,
3627                                            status, orderByComparator, true);
3628    
3629                            array[1] = layoutRevision;
3630    
3631                            array[2] = getByP_NotS_PrevAndNext(session, layoutRevision, plid,
3632                                            status, orderByComparator, false);
3633    
3634                            return array;
3635                    }
3636                    catch (Exception e) {
3637                            throw processException(e);
3638                    }
3639                    finally {
3640                            closeSession(session);
3641                    }
3642            }
3643    
3644            protected LayoutRevision getByP_NotS_PrevAndNext(Session session,
3645                    LayoutRevision layoutRevision, long plid, int status,
3646                    OrderByComparator orderByComparator, boolean previous) {
3647                    StringBundler query = null;
3648    
3649                    if (orderByComparator != null) {
3650                            query = new StringBundler(6 +
3651                                            (orderByComparator.getOrderByFields().length * 6));
3652                    }
3653                    else {
3654                            query = new StringBundler(3);
3655                    }
3656    
3657                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3658    
3659                    query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
3660    
3661                    query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
3662    
3663                    if (orderByComparator != null) {
3664                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3665    
3666                            if (orderByConditionFields.length > 0) {
3667                                    query.append(WHERE_AND);
3668                            }
3669    
3670                            for (int i = 0; i < orderByConditionFields.length; i++) {
3671                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3672                                    query.append(orderByConditionFields[i]);
3673    
3674                                    if ((i + 1) < orderByConditionFields.length) {
3675                                            if (orderByComparator.isAscending() ^ previous) {
3676                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3677                                            }
3678                                            else {
3679                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3680                                            }
3681                                    }
3682                                    else {
3683                                            if (orderByComparator.isAscending() ^ previous) {
3684                                                    query.append(WHERE_GREATER_THAN);
3685                                            }
3686                                            else {
3687                                                    query.append(WHERE_LESSER_THAN);
3688                                            }
3689                                    }
3690                            }
3691    
3692                            query.append(ORDER_BY_CLAUSE);
3693    
3694                            String[] orderByFields = orderByComparator.getOrderByFields();
3695    
3696                            for (int i = 0; i < orderByFields.length; i++) {
3697                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3698                                    query.append(orderByFields[i]);
3699    
3700                                    if ((i + 1) < orderByFields.length) {
3701                                            if (orderByComparator.isAscending() ^ previous) {
3702                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3703                                            }
3704                                            else {
3705                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3706                                            }
3707                                    }
3708                                    else {
3709                                            if (orderByComparator.isAscending() ^ previous) {
3710                                                    query.append(ORDER_BY_ASC);
3711                                            }
3712                                            else {
3713                                                    query.append(ORDER_BY_DESC);
3714                                            }
3715                                    }
3716                            }
3717                    }
3718    
3719                    else {
3720                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3721                    }
3722    
3723                    String sql = query.toString();
3724    
3725                    Query q = session.createQuery(sql);
3726    
3727                    q.setFirstResult(0);
3728                    q.setMaxResults(2);
3729    
3730                    QueryPos qPos = QueryPos.getInstance(q);
3731    
3732                    qPos.add(plid);
3733    
3734                    qPos.add(status);
3735    
3736                    if (orderByComparator != null) {
3737                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
3738    
3739                            for (Object value : values) {
3740                                    qPos.add(value);
3741                            }
3742                    }
3743    
3744                    List<LayoutRevision> list = q.list();
3745    
3746                    if (list.size() == 2) {
3747                            return list.get(1);
3748                    }
3749                    else {
3750                            return null;
3751                    }
3752            }
3753    
3754            /**
3755             * Returns all the layout revisions where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63;.
3756             *
3757             * @param layoutSetBranchId the layout set branch ID
3758             * @param layoutBranchId the layout branch ID
3759             * @param plid the plid
3760             * @return the matching layout revisions
3761             * @throws SystemException if a system exception occurred
3762             */
3763            public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3764                    long layoutBranchId, long plid) throws SystemException {
3765                    return findByL_L_P(layoutSetBranchId, layoutBranchId, plid,
3766                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3767            }
3768    
3769            /**
3770             * Returns a range of all the layout revisions where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63;.
3771             *
3772             * <p>
3773             * 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.
3774             * </p>
3775             *
3776             * @param layoutSetBranchId the layout set branch ID
3777             * @param layoutBranchId the layout branch ID
3778             * @param plid the plid
3779             * @param start the lower bound of the range of layout revisions
3780             * @param end the upper bound of the range of layout revisions (not inclusive)
3781             * @return the range of matching layout revisions
3782             * @throws SystemException if a system exception occurred
3783             */
3784            public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3785                    long layoutBranchId, long plid, int start, int end)
3786                    throws SystemException {
3787                    return findByL_L_P(layoutSetBranchId, layoutBranchId, plid, start, end,
3788                            null);
3789            }
3790    
3791            /**
3792             * Returns an ordered range of all the layout revisions where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63;.
3793             *
3794             * <p>
3795             * 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.
3796             * </p>
3797             *
3798             * @param layoutSetBranchId the layout set branch ID
3799             * @param layoutBranchId the layout branch ID
3800             * @param plid the plid
3801             * @param start the lower bound of the range of layout revisions
3802             * @param end the upper bound of the range of layout revisions (not inclusive)
3803             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3804             * @return the ordered range of matching layout revisions
3805             * @throws SystemException if a system exception occurred
3806             */
3807            public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3808                    long layoutBranchId, long plid, int start, int end,
3809                    OrderByComparator orderByComparator) throws SystemException {
3810                    FinderPath finderPath = null;
3811                    Object[] finderArgs = null;
3812    
3813                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3814                                    (orderByComparator == null)) {
3815                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P;
3816                            finderArgs = new Object[] { layoutSetBranchId, layoutBranchId, plid };
3817                    }
3818                    else {
3819                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_L_P;
3820                            finderArgs = new Object[] {
3821                                            layoutSetBranchId, layoutBranchId, plid,
3822                                            
3823                                            start, end, orderByComparator
3824                                    };
3825                    }
3826    
3827                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3828                                    finderArgs, this);
3829    
3830                    if ((list != null) && !list.isEmpty()) {
3831                            for (LayoutRevision layoutRevision : list) {
3832                                    if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
3833                                                    (layoutBranchId != layoutRevision.getLayoutBranchId()) ||
3834                                                    (plid != layoutRevision.getPlid())) {
3835                                            list = null;
3836    
3837                                            break;
3838                                    }
3839                            }
3840                    }
3841    
3842                    if (list == null) {
3843                            StringBundler query = null;
3844    
3845                            if (orderByComparator != null) {
3846                                    query = new StringBundler(5 +
3847                                                    (orderByComparator.getOrderByFields().length * 3));
3848                            }
3849                            else {
3850                                    query = new StringBundler(5);
3851                            }
3852    
3853                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3854    
3855                            query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
3856    
3857                            query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
3858    
3859                            query.append(_FINDER_COLUMN_L_L_P_PLID_2);
3860    
3861                            if (orderByComparator != null) {
3862                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3863                                            orderByComparator);
3864                            }
3865    
3866                            else {
3867                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3868                            }
3869    
3870                            String sql = query.toString();
3871    
3872                            Session session = null;
3873    
3874                            try {
3875                                    session = openSession();
3876    
3877                                    Query q = session.createQuery(sql);
3878    
3879                                    QueryPos qPos = QueryPos.getInstance(q);
3880    
3881                                    qPos.add(layoutSetBranchId);
3882    
3883                                    qPos.add(layoutBranchId);
3884    
3885                                    qPos.add(plid);
3886    
3887                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
3888                                                    start, end);
3889                            }
3890                            catch (Exception e) {
3891                                    throw processException(e);
3892                            }
3893                            finally {
3894                                    if (list == null) {
3895                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3896                                    }
3897                                    else {
3898                                            cacheResult(list);
3899    
3900                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3901                                    }
3902    
3903                                    closeSession(session);
3904                            }
3905                    }
3906    
3907                    return list;
3908            }
3909    
3910            /**
3911             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63;.
3912             *
3913             * @param layoutSetBranchId the layout set branch ID
3914             * @param layoutBranchId the layout branch ID
3915             * @param plid the plid
3916             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3917             * @return the first matching layout revision
3918             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
3919             * @throws SystemException if a system exception occurred
3920             */
3921            public LayoutRevision findByL_L_P_First(long layoutSetBranchId,
3922                    long layoutBranchId, long plid, OrderByComparator orderByComparator)
3923                    throws NoSuchLayoutRevisionException, SystemException {
3924                    LayoutRevision layoutRevision = fetchByL_L_P_First(layoutSetBranchId,
3925                                    layoutBranchId, plid, orderByComparator);
3926    
3927                    if (layoutRevision != null) {
3928                            return layoutRevision;
3929                    }
3930    
3931                    StringBundler msg = new StringBundler(8);
3932    
3933                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3934    
3935                    msg.append("layoutSetBranchId=");
3936                    msg.append(layoutSetBranchId);
3937    
3938                    msg.append(", layoutBranchId=");
3939                    msg.append(layoutBranchId);
3940    
3941                    msg.append(", plid=");
3942                    msg.append(plid);
3943    
3944                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3945    
3946                    throw new NoSuchLayoutRevisionException(msg.toString());
3947            }
3948    
3949            /**
3950             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63;.
3951             *
3952             * @param layoutSetBranchId the layout set branch ID
3953             * @param layoutBranchId the layout branch ID
3954             * @param plid the plid
3955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3956             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
3957             * @throws SystemException if a system exception occurred
3958             */
3959            public LayoutRevision fetchByL_L_P_First(long layoutSetBranchId,
3960                    long layoutBranchId, long plid, OrderByComparator orderByComparator)
3961                    throws SystemException {
3962                    List<LayoutRevision> list = findByL_L_P(layoutSetBranchId,
3963                                    layoutBranchId, plid, 0, 1, orderByComparator);
3964    
3965                    if (!list.isEmpty()) {
3966                            return list.get(0);
3967                    }
3968    
3969                    return null;
3970            }
3971    
3972            /**
3973             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63;.
3974             *
3975             * @param layoutSetBranchId the layout set branch ID
3976             * @param layoutBranchId the layout branch ID
3977             * @param plid the plid
3978             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3979             * @return the last matching layout revision
3980             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
3981             * @throws SystemException if a system exception occurred
3982             */
3983            public LayoutRevision findByL_L_P_Last(long layoutSetBranchId,
3984                    long layoutBranchId, long plid, OrderByComparator orderByComparator)
3985                    throws NoSuchLayoutRevisionException, SystemException {
3986                    LayoutRevision layoutRevision = fetchByL_L_P_Last(layoutSetBranchId,
3987                                    layoutBranchId, plid, orderByComparator);
3988    
3989                    if (layoutRevision != null) {
3990                            return layoutRevision;
3991                    }
3992    
3993                    StringBundler msg = new StringBundler(8);
3994    
3995                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3996    
3997                    msg.append("layoutSetBranchId=");
3998                    msg.append(layoutSetBranchId);
3999    
4000                    msg.append(", layoutBranchId=");
4001                    msg.append(layoutBranchId);
4002    
4003                    msg.append(", plid=");
4004                    msg.append(plid);
4005    
4006                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4007    
4008                    throw new NoSuchLayoutRevisionException(msg.toString());
4009            }
4010    
4011            /**
4012             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63;.
4013             *
4014             * @param layoutSetBranchId the layout set branch ID
4015             * @param layoutBranchId the layout branch ID
4016             * @param plid the plid
4017             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4018             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
4019             * @throws SystemException if a system exception occurred
4020             */
4021            public LayoutRevision fetchByL_L_P_Last(long layoutSetBranchId,
4022                    long layoutBranchId, long plid, OrderByComparator orderByComparator)
4023                    throws SystemException {
4024                    int count = countByL_L_P(layoutSetBranchId, layoutBranchId, plid);
4025    
4026                    List<LayoutRevision> list = findByL_L_P(layoutSetBranchId,
4027                                    layoutBranchId, plid, count - 1, count, orderByComparator);
4028    
4029                    if (!list.isEmpty()) {
4030                            return list.get(0);
4031                    }
4032    
4033                    return null;
4034            }
4035    
4036            /**
4037             * Returns the layout revisions before and after the current layout revision in the ordered set where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63;.
4038             *
4039             * @param layoutRevisionId the primary key of the current layout revision
4040             * @param layoutSetBranchId the layout set branch ID
4041             * @param layoutBranchId the layout branch ID
4042             * @param plid the plid
4043             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4044             * @return the previous, current, and next layout revision
4045             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
4046             * @throws SystemException if a system exception occurred
4047             */
4048            public LayoutRevision[] findByL_L_P_PrevAndNext(long layoutRevisionId,
4049                    long layoutSetBranchId, long layoutBranchId, long plid,
4050                    OrderByComparator orderByComparator)
4051                    throws NoSuchLayoutRevisionException, SystemException {
4052                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
4053    
4054                    Session session = null;
4055    
4056                    try {
4057                            session = openSession();
4058    
4059                            LayoutRevision[] array = new LayoutRevisionImpl[3];
4060    
4061                            array[0] = getByL_L_P_PrevAndNext(session, layoutRevision,
4062                                            layoutSetBranchId, layoutBranchId, plid, orderByComparator,
4063                                            true);
4064    
4065                            array[1] = layoutRevision;
4066    
4067                            array[2] = getByL_L_P_PrevAndNext(session, layoutRevision,
4068                                            layoutSetBranchId, layoutBranchId, plid, orderByComparator,
4069                                            false);
4070    
4071                            return array;
4072                    }
4073                    catch (Exception e) {
4074                            throw processException(e);
4075                    }
4076                    finally {
4077                            closeSession(session);
4078                    }
4079            }
4080    
4081            protected LayoutRevision getByL_L_P_PrevAndNext(Session session,
4082                    LayoutRevision layoutRevision, long layoutSetBranchId,
4083                    long layoutBranchId, long plid, OrderByComparator orderByComparator,
4084                    boolean previous) {
4085                    StringBundler query = null;
4086    
4087                    if (orderByComparator != null) {
4088                            query = new StringBundler(6 +
4089                                            (orderByComparator.getOrderByFields().length * 6));
4090                    }
4091                    else {
4092                            query = new StringBundler(3);
4093                    }
4094    
4095                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4096    
4097                    query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
4098    
4099                    query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
4100    
4101                    query.append(_FINDER_COLUMN_L_L_P_PLID_2);
4102    
4103                    if (orderByComparator != null) {
4104                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4105    
4106                            if (orderByConditionFields.length > 0) {
4107                                    query.append(WHERE_AND);
4108                            }
4109    
4110                            for (int i = 0; i < orderByConditionFields.length; i++) {
4111                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4112                                    query.append(orderByConditionFields[i]);
4113    
4114                                    if ((i + 1) < orderByConditionFields.length) {
4115                                            if (orderByComparator.isAscending() ^ previous) {
4116                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4117                                            }
4118                                            else {
4119                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4120                                            }
4121                                    }
4122                                    else {
4123                                            if (orderByComparator.isAscending() ^ previous) {
4124                                                    query.append(WHERE_GREATER_THAN);
4125                                            }
4126                                            else {
4127                                                    query.append(WHERE_LESSER_THAN);
4128                                            }
4129                                    }
4130                            }
4131    
4132                            query.append(ORDER_BY_CLAUSE);
4133    
4134                            String[] orderByFields = orderByComparator.getOrderByFields();
4135    
4136                            for (int i = 0; i < orderByFields.length; i++) {
4137                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4138                                    query.append(orderByFields[i]);
4139    
4140                                    if ((i + 1) < orderByFields.length) {
4141                                            if (orderByComparator.isAscending() ^ previous) {
4142                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4143                                            }
4144                                            else {
4145                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4146                                            }
4147                                    }
4148                                    else {
4149                                            if (orderByComparator.isAscending() ^ previous) {
4150                                                    query.append(ORDER_BY_ASC);
4151                                            }
4152                                            else {
4153                                                    query.append(ORDER_BY_DESC);
4154                                            }
4155                                    }
4156                            }
4157                    }
4158    
4159                    else {
4160                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4161                    }
4162    
4163                    String sql = query.toString();
4164    
4165                    Query q = session.createQuery(sql);
4166    
4167                    q.setFirstResult(0);
4168                    q.setMaxResults(2);
4169    
4170                    QueryPos qPos = QueryPos.getInstance(q);
4171    
4172                    qPos.add(layoutSetBranchId);
4173    
4174                    qPos.add(layoutBranchId);
4175    
4176                    qPos.add(plid);
4177    
4178                    if (orderByComparator != null) {
4179                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
4180    
4181                            for (Object value : values) {
4182                                    qPos.add(value);
4183                            }
4184                    }
4185    
4186                    List<LayoutRevision> list = q.list();
4187    
4188                    if (list.size() == 2) {
4189                            return list.get(1);
4190                    }
4191                    else {
4192                            return null;
4193                    }
4194            }
4195    
4196            /**
4197             * Returns all the layout revisions where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63;.
4198             *
4199             * @param layoutSetBranchId the layout set branch ID
4200             * @param parentLayoutRevisionId the parent layout revision ID
4201             * @param plid the plid
4202             * @return the matching layout revisions
4203             * @throws SystemException if a system exception occurred
4204             */
4205            public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4206                    long parentLayoutRevisionId, long plid) throws SystemException {
4207                    return findByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid,
4208                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4209            }
4210    
4211            /**
4212             * Returns a range of all the layout revisions where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63;.
4213             *
4214             * <p>
4215             * 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.
4216             * </p>
4217             *
4218             * @param layoutSetBranchId the layout set branch ID
4219             * @param parentLayoutRevisionId the parent layout revision ID
4220             * @param plid the plid
4221             * @param start the lower bound of the range of layout revisions
4222             * @param end the upper bound of the range of layout revisions (not inclusive)
4223             * @return the range of matching layout revisions
4224             * @throws SystemException if a system exception occurred
4225             */
4226            public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4227                    long parentLayoutRevisionId, long plid, int start, int end)
4228                    throws SystemException {
4229                    return findByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid,
4230                            start, end, null);
4231            }
4232    
4233            /**
4234             * Returns an ordered range of all the layout revisions where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63;.
4235             *
4236             * <p>
4237             * 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.
4238             * </p>
4239             *
4240             * @param layoutSetBranchId the layout set branch ID
4241             * @param parentLayoutRevisionId the parent layout revision ID
4242             * @param plid the plid
4243             * @param start the lower bound of the range of layout revisions
4244             * @param end the upper bound of the range of layout revisions (not inclusive)
4245             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4246             * @return the ordered range of matching layout revisions
4247             * @throws SystemException if a system exception occurred
4248             */
4249            public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4250                    long parentLayoutRevisionId, long plid, int start, int end,
4251                    OrderByComparator orderByComparator) throws SystemException {
4252                    FinderPath finderPath = null;
4253                    Object[] finderArgs = null;
4254    
4255                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4256                                    (orderByComparator == null)) {
4257                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P;
4258                            finderArgs = new Object[] {
4259                                            layoutSetBranchId, parentLayoutRevisionId, plid
4260                                    };
4261                    }
4262                    else {
4263                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_P;
4264                            finderArgs = new Object[] {
4265                                            layoutSetBranchId, parentLayoutRevisionId, plid,
4266                                            
4267                                            start, end, orderByComparator
4268                                    };
4269                    }
4270    
4271                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
4272                                    finderArgs, this);
4273    
4274                    if ((list != null) && !list.isEmpty()) {
4275                            for (LayoutRevision layoutRevision : list) {
4276                                    if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4277                                                    (parentLayoutRevisionId != layoutRevision.getParentLayoutRevisionId()) ||
4278                                                    (plid != layoutRevision.getPlid())) {
4279                                            list = null;
4280    
4281                                            break;
4282                                    }
4283                            }
4284                    }
4285    
4286                    if (list == null) {
4287                            StringBundler query = null;
4288    
4289                            if (orderByComparator != null) {
4290                                    query = new StringBundler(5 +
4291                                                    (orderByComparator.getOrderByFields().length * 3));
4292                            }
4293                            else {
4294                                    query = new StringBundler(5);
4295                            }
4296    
4297                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4298    
4299                            query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
4300    
4301                            query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
4302    
4303                            query.append(_FINDER_COLUMN_L_P_P_PLID_2);
4304    
4305                            if (orderByComparator != null) {
4306                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4307                                            orderByComparator);
4308                            }
4309    
4310                            else {
4311                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4312                            }
4313    
4314                            String sql = query.toString();
4315    
4316                            Session session = null;
4317    
4318                            try {
4319                                    session = openSession();
4320    
4321                                    Query q = session.createQuery(sql);
4322    
4323                                    QueryPos qPos = QueryPos.getInstance(q);
4324    
4325                                    qPos.add(layoutSetBranchId);
4326    
4327                                    qPos.add(parentLayoutRevisionId);
4328    
4329                                    qPos.add(plid);
4330    
4331                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
4332                                                    start, end);
4333                            }
4334                            catch (Exception e) {
4335                                    throw processException(e);
4336                            }
4337                            finally {
4338                                    if (list == null) {
4339                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4340                                    }
4341                                    else {
4342                                            cacheResult(list);
4343    
4344                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4345                                    }
4346    
4347                                    closeSession(session);
4348                            }
4349                    }
4350    
4351                    return list;
4352            }
4353    
4354            /**
4355             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63;.
4356             *
4357             * @param layoutSetBranchId the layout set branch ID
4358             * @param parentLayoutRevisionId the parent layout revision ID
4359             * @param plid the plid
4360             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4361             * @return the first matching layout revision
4362             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
4363             * @throws SystemException if a system exception occurred
4364             */
4365            public LayoutRevision findByL_P_P_First(long layoutSetBranchId,
4366                    long parentLayoutRevisionId, long plid,
4367                    OrderByComparator orderByComparator)
4368                    throws NoSuchLayoutRevisionException, SystemException {
4369                    LayoutRevision layoutRevision = fetchByL_P_P_First(layoutSetBranchId,
4370                                    parentLayoutRevisionId, plid, orderByComparator);
4371    
4372                    if (layoutRevision != null) {
4373                            return layoutRevision;
4374                    }
4375    
4376                    StringBundler msg = new StringBundler(8);
4377    
4378                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4379    
4380                    msg.append("layoutSetBranchId=");
4381                    msg.append(layoutSetBranchId);
4382    
4383                    msg.append(", parentLayoutRevisionId=");
4384                    msg.append(parentLayoutRevisionId);
4385    
4386                    msg.append(", plid=");
4387                    msg.append(plid);
4388    
4389                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4390    
4391                    throw new NoSuchLayoutRevisionException(msg.toString());
4392            }
4393    
4394            /**
4395             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63;.
4396             *
4397             * @param layoutSetBranchId the layout set branch ID
4398             * @param parentLayoutRevisionId the parent layout revision ID
4399             * @param plid the plid
4400             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4401             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
4402             * @throws SystemException if a system exception occurred
4403             */
4404            public LayoutRevision fetchByL_P_P_First(long layoutSetBranchId,
4405                    long parentLayoutRevisionId, long plid,
4406                    OrderByComparator orderByComparator) throws SystemException {
4407                    List<LayoutRevision> list = findByL_P_P(layoutSetBranchId,
4408                                    parentLayoutRevisionId, plid, 0, 1, orderByComparator);
4409    
4410                    if (!list.isEmpty()) {
4411                            return list.get(0);
4412                    }
4413    
4414                    return null;
4415            }
4416    
4417            /**
4418             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63;.
4419             *
4420             * @param layoutSetBranchId the layout set branch ID
4421             * @param parentLayoutRevisionId the parent layout revision ID
4422             * @param plid the plid
4423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4424             * @return the last matching layout revision
4425             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
4426             * @throws SystemException if a system exception occurred
4427             */
4428            public LayoutRevision findByL_P_P_Last(long layoutSetBranchId,
4429                    long parentLayoutRevisionId, long plid,
4430                    OrderByComparator orderByComparator)
4431                    throws NoSuchLayoutRevisionException, SystemException {
4432                    LayoutRevision layoutRevision = fetchByL_P_P_Last(layoutSetBranchId,
4433                                    parentLayoutRevisionId, plid, orderByComparator);
4434    
4435                    if (layoutRevision != null) {
4436                            return layoutRevision;
4437                    }
4438    
4439                    StringBundler msg = new StringBundler(8);
4440    
4441                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4442    
4443                    msg.append("layoutSetBranchId=");
4444                    msg.append(layoutSetBranchId);
4445    
4446                    msg.append(", parentLayoutRevisionId=");
4447                    msg.append(parentLayoutRevisionId);
4448    
4449                    msg.append(", plid=");
4450                    msg.append(plid);
4451    
4452                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4453    
4454                    throw new NoSuchLayoutRevisionException(msg.toString());
4455            }
4456    
4457            /**
4458             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63;.
4459             *
4460             * @param layoutSetBranchId the layout set branch ID
4461             * @param parentLayoutRevisionId the parent layout revision ID
4462             * @param plid the plid
4463             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4464             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
4465             * @throws SystemException if a system exception occurred
4466             */
4467            public LayoutRevision fetchByL_P_P_Last(long layoutSetBranchId,
4468                    long parentLayoutRevisionId, long plid,
4469                    OrderByComparator orderByComparator) throws SystemException {
4470                    int count = countByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid);
4471    
4472                    List<LayoutRevision> list = findByL_P_P(layoutSetBranchId,
4473                                    parentLayoutRevisionId, plid, count - 1, count,
4474                                    orderByComparator);
4475    
4476                    if (!list.isEmpty()) {
4477                            return list.get(0);
4478                    }
4479    
4480                    return null;
4481            }
4482    
4483            /**
4484             * Returns the layout revisions before and after the current layout revision in the ordered set where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63;.
4485             *
4486             * @param layoutRevisionId the primary key of the current layout revision
4487             * @param layoutSetBranchId the layout set branch ID
4488             * @param parentLayoutRevisionId the parent layout revision ID
4489             * @param plid the plid
4490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4491             * @return the previous, current, and next layout revision
4492             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
4493             * @throws SystemException if a system exception occurred
4494             */
4495            public LayoutRevision[] findByL_P_P_PrevAndNext(long layoutRevisionId,
4496                    long layoutSetBranchId, long parentLayoutRevisionId, long plid,
4497                    OrderByComparator orderByComparator)
4498                    throws NoSuchLayoutRevisionException, SystemException {
4499                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
4500    
4501                    Session session = null;
4502    
4503                    try {
4504                            session = openSession();
4505    
4506                            LayoutRevision[] array = new LayoutRevisionImpl[3];
4507    
4508                            array[0] = getByL_P_P_PrevAndNext(session, layoutRevision,
4509                                            layoutSetBranchId, parentLayoutRevisionId, plid,
4510                                            orderByComparator, true);
4511    
4512                            array[1] = layoutRevision;
4513    
4514                            array[2] = getByL_P_P_PrevAndNext(session, layoutRevision,
4515                                            layoutSetBranchId, parentLayoutRevisionId, plid,
4516                                            orderByComparator, false);
4517    
4518                            return array;
4519                    }
4520                    catch (Exception e) {
4521                            throw processException(e);
4522                    }
4523                    finally {
4524                            closeSession(session);
4525                    }
4526            }
4527    
4528            protected LayoutRevision getByL_P_P_PrevAndNext(Session session,
4529                    LayoutRevision layoutRevision, long layoutSetBranchId,
4530                    long parentLayoutRevisionId, long plid,
4531                    OrderByComparator orderByComparator, boolean previous) {
4532                    StringBundler query = null;
4533    
4534                    if (orderByComparator != null) {
4535                            query = new StringBundler(6 +
4536                                            (orderByComparator.getOrderByFields().length * 6));
4537                    }
4538                    else {
4539                            query = new StringBundler(3);
4540                    }
4541    
4542                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4543    
4544                    query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
4545    
4546                    query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
4547    
4548                    query.append(_FINDER_COLUMN_L_P_P_PLID_2);
4549    
4550                    if (orderByComparator != null) {
4551                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4552    
4553                            if (orderByConditionFields.length > 0) {
4554                                    query.append(WHERE_AND);
4555                            }
4556    
4557                            for (int i = 0; i < orderByConditionFields.length; i++) {
4558                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4559                                    query.append(orderByConditionFields[i]);
4560    
4561                                    if ((i + 1) < orderByConditionFields.length) {
4562                                            if (orderByComparator.isAscending() ^ previous) {
4563                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4564                                            }
4565                                            else {
4566                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4567                                            }
4568                                    }
4569                                    else {
4570                                            if (orderByComparator.isAscending() ^ previous) {
4571                                                    query.append(WHERE_GREATER_THAN);
4572                                            }
4573                                            else {
4574                                                    query.append(WHERE_LESSER_THAN);
4575                                            }
4576                                    }
4577                            }
4578    
4579                            query.append(ORDER_BY_CLAUSE);
4580    
4581                            String[] orderByFields = orderByComparator.getOrderByFields();
4582    
4583                            for (int i = 0; i < orderByFields.length; i++) {
4584                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4585                                    query.append(orderByFields[i]);
4586    
4587                                    if ((i + 1) < orderByFields.length) {
4588                                            if (orderByComparator.isAscending() ^ previous) {
4589                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4590                                            }
4591                                            else {
4592                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4593                                            }
4594                                    }
4595                                    else {
4596                                            if (orderByComparator.isAscending() ^ previous) {
4597                                                    query.append(ORDER_BY_ASC);
4598                                            }
4599                                            else {
4600                                                    query.append(ORDER_BY_DESC);
4601                                            }
4602                                    }
4603                            }
4604                    }
4605    
4606                    else {
4607                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4608                    }
4609    
4610                    String sql = query.toString();
4611    
4612                    Query q = session.createQuery(sql);
4613    
4614                    q.setFirstResult(0);
4615                    q.setMaxResults(2);
4616    
4617                    QueryPos qPos = QueryPos.getInstance(q);
4618    
4619                    qPos.add(layoutSetBranchId);
4620    
4621                    qPos.add(parentLayoutRevisionId);
4622    
4623                    qPos.add(plid);
4624    
4625                    if (orderByComparator != null) {
4626                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
4627    
4628                            for (Object value : values) {
4629                                    qPos.add(value);
4630                            }
4631                    }
4632    
4633                    List<LayoutRevision> list = q.list();
4634    
4635                    if (list.size() == 2) {
4636                            return list.get(1);
4637                    }
4638                    else {
4639                            return null;
4640                    }
4641            }
4642    
4643            /**
4644             * 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.
4645             *
4646             * @param layoutSetBranchId the layout set branch ID
4647             * @param head the head
4648             * @param plid the plid
4649             * @return the matching layout revision
4650             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
4651             * @throws SystemException if a system exception occurred
4652             */
4653            public LayoutRevision findByL_H_P(long layoutSetBranchId, boolean head,
4654                    long plid) throws NoSuchLayoutRevisionException, SystemException {
4655                    LayoutRevision layoutRevision = fetchByL_H_P(layoutSetBranchId, head,
4656                                    plid);
4657    
4658                    if (layoutRevision == null) {
4659                            StringBundler msg = new StringBundler(8);
4660    
4661                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4662    
4663                            msg.append("layoutSetBranchId=");
4664                            msg.append(layoutSetBranchId);
4665    
4666                            msg.append(", head=");
4667                            msg.append(head);
4668    
4669                            msg.append(", plid=");
4670                            msg.append(plid);
4671    
4672                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4673    
4674                            if (_log.isWarnEnabled()) {
4675                                    _log.warn(msg.toString());
4676                            }
4677    
4678                            throw new NoSuchLayoutRevisionException(msg.toString());
4679                    }
4680    
4681                    return layoutRevision;
4682            }
4683    
4684            /**
4685             * 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.
4686             *
4687             * @param layoutSetBranchId the layout set branch ID
4688             * @param head the head
4689             * @param plid the plid
4690             * @return the matching layout revision, or <code>null</code> if a matching layout revision could not be found
4691             * @throws SystemException if a system exception occurred
4692             */
4693            public LayoutRevision fetchByL_H_P(long layoutSetBranchId, boolean head,
4694                    long plid) throws SystemException {
4695                    return fetchByL_H_P(layoutSetBranchId, head, plid, true);
4696            }
4697    
4698            /**
4699             * 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.
4700             *
4701             * @param layoutSetBranchId the layout set branch ID
4702             * @param head the head
4703             * @param plid the plid
4704             * @param retrieveFromCache whether to use the finder cache
4705             * @return the matching layout revision, or <code>null</code> if a matching layout revision could not be found
4706             * @throws SystemException if a system exception occurred
4707             */
4708            public LayoutRevision fetchByL_H_P(long layoutSetBranchId, boolean head,
4709                    long plid, boolean retrieveFromCache) throws SystemException {
4710                    Object[] finderArgs = new Object[] { layoutSetBranchId, head, plid };
4711    
4712                    Object result = null;
4713    
4714                    if (retrieveFromCache) {
4715                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_L_H_P,
4716                                            finderArgs, this);
4717                    }
4718    
4719                    if (result instanceof LayoutRevision) {
4720                            LayoutRevision layoutRevision = (LayoutRevision)result;
4721    
4722                            if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4723                                            (head != layoutRevision.getHead()) ||
4724                                            (plid != layoutRevision.getPlid())) {
4725                                    result = null;
4726                            }
4727                    }
4728    
4729                    if (result == null) {
4730                            StringBundler query = new StringBundler(5);
4731    
4732                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4733    
4734                            query.append(_FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2);
4735    
4736                            query.append(_FINDER_COLUMN_L_H_P_HEAD_2);
4737    
4738                            query.append(_FINDER_COLUMN_L_H_P_PLID_2);
4739    
4740                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4741    
4742                            String sql = query.toString();
4743    
4744                            Session session = null;
4745    
4746                            try {
4747                                    session = openSession();
4748    
4749                                    Query q = session.createQuery(sql);
4750    
4751                                    QueryPos qPos = QueryPos.getInstance(q);
4752    
4753                                    qPos.add(layoutSetBranchId);
4754    
4755                                    qPos.add(head);
4756    
4757                                    qPos.add(plid);
4758    
4759                                    List<LayoutRevision> list = q.list();
4760    
4761                                    result = list;
4762    
4763                                    LayoutRevision layoutRevision = null;
4764    
4765                                    if (list.isEmpty()) {
4766                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
4767                                                    finderArgs, list);
4768                                    }
4769                                    else {
4770                                            layoutRevision = list.get(0);
4771    
4772                                            cacheResult(layoutRevision);
4773    
4774                                            if ((layoutRevision.getLayoutSetBranchId() != layoutSetBranchId) ||
4775                                                            (layoutRevision.getHead() != head) ||
4776                                                            (layoutRevision.getPlid() != plid)) {
4777                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
4778                                                            finderArgs, layoutRevision);
4779                                            }
4780                                    }
4781    
4782                                    return layoutRevision;
4783                            }
4784                            catch (Exception e) {
4785                                    throw processException(e);
4786                            }
4787                            finally {
4788                                    if (result == null) {
4789                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P,
4790                                                    finderArgs);
4791                                    }
4792    
4793                                    closeSession(session);
4794                            }
4795                    }
4796                    else {
4797                            if (result instanceof List<?>) {
4798                                    return null;
4799                            }
4800                            else {
4801                                    return (LayoutRevision)result;
4802                            }
4803                    }
4804            }
4805    
4806            /**
4807             * Returns all the layout revisions where layoutSetBranchId = &#63; and plid = &#63; and status = &#63;.
4808             *
4809             * @param layoutSetBranchId the layout set branch ID
4810             * @param plid the plid
4811             * @param status the status
4812             * @return the matching layout revisions
4813             * @throws SystemException if a system exception occurred
4814             */
4815            public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
4816                    int status) throws SystemException {
4817                    return findByL_P_S(layoutSetBranchId, plid, status, QueryUtil.ALL_POS,
4818                            QueryUtil.ALL_POS, null);
4819            }
4820    
4821            /**
4822             * Returns a range of all the layout revisions where layoutSetBranchId = &#63; and plid = &#63; and status = &#63;.
4823             *
4824             * <p>
4825             * 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.
4826             * </p>
4827             *
4828             * @param layoutSetBranchId the layout set branch ID
4829             * @param plid the plid
4830             * @param status the status
4831             * @param start the lower bound of the range of layout revisions
4832             * @param end the upper bound of the range of layout revisions (not inclusive)
4833             * @return the range of matching layout revisions
4834             * @throws SystemException if a system exception occurred
4835             */
4836            public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
4837                    int status, int start, int end) throws SystemException {
4838                    return findByL_P_S(layoutSetBranchId, plid, status, start, end, null);
4839            }
4840    
4841            /**
4842             * Returns an ordered range of all the layout revisions where layoutSetBranchId = &#63; and plid = &#63; and status = &#63;.
4843             *
4844             * <p>
4845             * 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.
4846             * </p>
4847             *
4848             * @param layoutSetBranchId the layout set branch ID
4849             * @param plid the plid
4850             * @param status the status
4851             * @param start the lower bound of the range of layout revisions
4852             * @param end the upper bound of the range of layout revisions (not inclusive)
4853             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4854             * @return the ordered range of matching layout revisions
4855             * @throws SystemException if a system exception occurred
4856             */
4857            public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
4858                    int status, int start, int end, OrderByComparator orderByComparator)
4859                    throws SystemException {
4860                    FinderPath finderPath = null;
4861                    Object[] finderArgs = null;
4862    
4863                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4864                                    (orderByComparator == null)) {
4865                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S;
4866                            finderArgs = new Object[] { layoutSetBranchId, plid, status };
4867                    }
4868                    else {
4869                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_S;
4870                            finderArgs = new Object[] {
4871                                            layoutSetBranchId, plid, status,
4872                                            
4873                                            start, end, orderByComparator
4874                                    };
4875                    }
4876    
4877                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
4878                                    finderArgs, this);
4879    
4880                    if ((list != null) && !list.isEmpty()) {
4881                            for (LayoutRevision layoutRevision : list) {
4882                                    if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4883                                                    (plid != layoutRevision.getPlid()) ||
4884                                                    (status != layoutRevision.getStatus())) {
4885                                            list = null;
4886    
4887                                            break;
4888                                    }
4889                            }
4890                    }
4891    
4892                    if (list == null) {
4893                            StringBundler query = null;
4894    
4895                            if (orderByComparator != null) {
4896                                    query = new StringBundler(5 +
4897                                                    (orderByComparator.getOrderByFields().length * 3));
4898                            }
4899                            else {
4900                                    query = new StringBundler(5);
4901                            }
4902    
4903                            query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4904    
4905                            query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
4906    
4907                            query.append(_FINDER_COLUMN_L_P_S_PLID_2);
4908    
4909                            query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
4910    
4911                            if (orderByComparator != null) {
4912                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4913                                            orderByComparator);
4914                            }
4915    
4916                            else {
4917                                    query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4918                            }
4919    
4920                            String sql = query.toString();
4921    
4922                            Session session = null;
4923    
4924                            try {
4925                                    session = openSession();
4926    
4927                                    Query q = session.createQuery(sql);
4928    
4929                                    QueryPos qPos = QueryPos.getInstance(q);
4930    
4931                                    qPos.add(layoutSetBranchId);
4932    
4933                                    qPos.add(plid);
4934    
4935                                    qPos.add(status);
4936    
4937                                    list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
4938                                                    start, end);
4939                            }
4940                            catch (Exception e) {
4941                                    throw processException(e);
4942                            }
4943                            finally {
4944                                    if (list == null) {
4945                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4946                                    }
4947                                    else {
4948                                            cacheResult(list);
4949    
4950                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4951                                    }
4952    
4953                                    closeSession(session);
4954                            }
4955                    }
4956    
4957                    return list;
4958            }
4959    
4960            /**
4961             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63; and status = &#63;.
4962             *
4963             * @param layoutSetBranchId the layout set branch ID
4964             * @param plid the plid
4965             * @param status the status
4966             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4967             * @return the first matching layout revision
4968             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
4969             * @throws SystemException if a system exception occurred
4970             */
4971            public LayoutRevision findByL_P_S_First(long layoutSetBranchId, long plid,
4972                    int status, OrderByComparator orderByComparator)
4973                    throws NoSuchLayoutRevisionException, SystemException {
4974                    LayoutRevision layoutRevision = fetchByL_P_S_First(layoutSetBranchId,
4975                                    plid, status, orderByComparator);
4976    
4977                    if (layoutRevision != null) {
4978                            return layoutRevision;
4979                    }
4980    
4981                    StringBundler msg = new StringBundler(8);
4982    
4983                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4984    
4985                    msg.append("layoutSetBranchId=");
4986                    msg.append(layoutSetBranchId);
4987    
4988                    msg.append(", plid=");
4989                    msg.append(plid);
4990    
4991                    msg.append(", status=");
4992                    msg.append(status);
4993    
4994                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4995    
4996                    throw new NoSuchLayoutRevisionException(msg.toString());
4997            }
4998    
4999            /**
5000             * Returns the first layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63; and status = &#63;.
5001             *
5002             * @param layoutSetBranchId the layout set branch ID
5003             * @param plid the plid
5004             * @param status the status
5005             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5006             * @return the first matching layout revision, or <code>null</code> if a matching layout revision could not be found
5007             * @throws SystemException if a system exception occurred
5008             */
5009            public LayoutRevision fetchByL_P_S_First(long layoutSetBranchId, long plid,
5010                    int status, OrderByComparator orderByComparator)
5011                    throws SystemException {
5012                    List<LayoutRevision> list = findByL_P_S(layoutSetBranchId, plid,
5013                                    status, 0, 1, orderByComparator);
5014    
5015                    if (!list.isEmpty()) {
5016                            return list.get(0);
5017                    }
5018    
5019                    return null;
5020            }
5021    
5022            /**
5023             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63; and status = &#63;.
5024             *
5025             * @param layoutSetBranchId the layout set branch ID
5026             * @param plid the plid
5027             * @param status the status
5028             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5029             * @return the last matching layout revision
5030             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a matching layout revision could not be found
5031             * @throws SystemException if a system exception occurred
5032             */
5033            public LayoutRevision findByL_P_S_Last(long layoutSetBranchId, long plid,
5034                    int status, OrderByComparator orderByComparator)
5035                    throws NoSuchLayoutRevisionException, SystemException {
5036                    LayoutRevision layoutRevision = fetchByL_P_S_Last(layoutSetBranchId,
5037                                    plid, status, orderByComparator);
5038    
5039                    if (layoutRevision != null) {
5040                            return layoutRevision;
5041                    }
5042    
5043                    StringBundler msg = new StringBundler(8);
5044    
5045                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5046    
5047                    msg.append("layoutSetBranchId=");
5048                    msg.append(layoutSetBranchId);
5049    
5050                    msg.append(", plid=");
5051                    msg.append(plid);
5052    
5053                    msg.append(", status=");
5054                    msg.append(status);
5055    
5056                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5057    
5058                    throw new NoSuchLayoutRevisionException(msg.toString());
5059            }
5060    
5061            /**
5062             * Returns the last layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63; and status = &#63;.
5063             *
5064             * @param layoutSetBranchId the layout set branch ID
5065             * @param plid the plid
5066             * @param status the status
5067             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5068             * @return the last matching layout revision, or <code>null</code> if a matching layout revision could not be found
5069             * @throws SystemException if a system exception occurred
5070             */
5071            public LayoutRevision fetchByL_P_S_Last(long layoutSetBranchId, long plid,
5072                    int status, OrderByComparator orderByComparator)
5073                    throws SystemException {
5074                    int count = countByL_P_S(layoutSetBranchId, plid, status);
5075    
5076                    List<LayoutRevision> list = findByL_P_S(layoutSetBranchId, plid,
5077                                    status, count - 1, count, orderByComparator);
5078    
5079                    if (!list.isEmpty()) {
5080                            return list.get(0);
5081                    }
5082    
5083                    return null;
5084            }
5085    
5086            /**
5087             * Returns the layout revisions before and after the current layout revision in the ordered set where layoutSetBranchId = &#63; and plid = &#63; and status = &#63;.
5088             *
5089             * @param layoutRevisionId the primary key of the current layout revision
5090             * @param layoutSetBranchId the layout set branch ID
5091             * @param plid the plid
5092             * @param status the status
5093             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5094             * @return the previous, current, and next layout revision
5095             * @throws com.liferay.portal.NoSuchLayoutRevisionException if a layout revision with the primary key could not be found
5096             * @throws SystemException if a system exception occurred
5097             */
5098            public LayoutRevision[] findByL_P_S_PrevAndNext(long layoutRevisionId,
5099                    long layoutSetBranchId, long plid, int status,
5100                    OrderByComparator orderByComparator)
5101                    throws NoSuchLayoutRevisionException, SystemException {
5102                    LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
5103    
5104                    Session session = null;
5105    
5106                    try {
5107                            session = openSession();
5108    
5109                            LayoutRevision[] array = new LayoutRevisionImpl[3];
5110    
5111                            array[0] = getByL_P_S_PrevAndNext(session, layoutRevision,
5112                                            layoutSetBranchId, plid, status, orderByComparator, true);
5113    
5114                            array[1] = layoutRevision;
5115    
5116                            array[2] = getByL_P_S_PrevAndNext(session, layoutRevision,
5117                                            layoutSetBranchId, plid, status, orderByComparator, false);
5118    
5119                            return array;
5120                    }
5121                    catch (Exception e) {
5122                            throw processException(e);
5123                    }
5124                    finally {
5125                            closeSession(session);
5126                    }
5127            }
5128    
5129            protected LayoutRevision getByL_P_S_PrevAndNext(Session session,
5130                    LayoutRevision layoutRevision, long layoutSetBranchId, long plid,
5131                    int status, OrderByComparator orderByComparator, boolean previous) {
5132                    StringBundler query = null;
5133    
5134                    if (orderByComparator != null) {
5135                            query = new StringBundler(6 +
5136                                            (orderByComparator.getOrderByFields().length * 6));
5137                    }
5138                    else {
5139                            query = new StringBundler(3);
5140                    }
5141    
5142                    query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
5143    
5144                    query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
5145    
5146                    query.append(_FINDER_COLUMN_L_P_S_PLID_2);
5147    
5148                    query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
5149    
5150                    if (orderByComparator != null) {
5151                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5152    
5153                            if (orderByConditionFields.length > 0) {
5154                                    query.append(WHERE_AND);
5155                            }
5156    
5157                            for (int i = 0; i < orderByConditionFields.length; i++) {
5158                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5159                                    query.append(orderByConditionFields[i]);
5160    
5161                                    if ((i + 1) < orderByConditionFields.length) {
5162                                            if (orderByComparator.isAscending() ^ previous) {
5163                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5164                                            }
5165                                            else {
5166                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5167                                            }
5168                                    }
5169                                    else {
5170                                            if (orderByComparator.isAscending() ^ previous) {
5171                                                    query.append(WHERE_GREATER_THAN);
5172                                            }
5173                                            else {
5174                                                    query.append(WHERE_LESSER_THAN);
5175                                            }
5176                                    }
5177                            }
5178    
5179                            query.append(ORDER_BY_CLAUSE);
5180    
5181                            String[] orderByFields = orderByComparator.getOrderByFields();
5182    
5183                            for (int i = 0; i < orderByFields.length; i++) {
5184                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5185                                    query.append(orderByFields[i]);
5186    
5187                                    if ((i + 1) < orderByFields.length) {
5188                                            if (orderByComparator.isAscending() ^ previous) {
5189                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5190                                            }
5191                                            else {
5192                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5193                                            }
5194                                    }
5195                                    else {
5196                                            if (orderByComparator.isAscending() ^ previous) {
5197                                                    query.append(ORDER_BY_ASC);
5198                                            }
5199                                            else {
5200                                                    query.append(ORDER_BY_DESC);
5201                                            }
5202                                    }
5203                            }
5204                    }
5205    
5206                    else {
5207                            query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
5208                    }
5209    
5210                    String sql = query.toString();
5211    
5212                    Query q = session.createQuery(sql);
5213    
5214                    q.setFirstResult(0);
5215                    q.setMaxResults(2);
5216    
5217                    QueryPos qPos = QueryPos.getInstance(q);
5218    
5219                    qPos.add(layoutSetBranchId);
5220    
5221                    qPos.add(plid);
5222    
5223                    qPos.add(status);
5224    
5225                    if (orderByComparator != null) {
5226                            Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
5227    
5228                            for (Object value : values) {
5229                                    qPos.add(value);
5230                            }
5231                    }
5232    
5233                    List<LayoutRevision> list = q.list();
5234    
5235                    if (list.size() == 2) {
5236                            return list.get(1);
5237                    }
5238                    else {
5239                            return null;
5240                    }
5241            }
5242    
5243            /**
5244             * Returns all the layout revisions.
5245             *
5246             * @return the layout revisions
5247             * @throws SystemException if a system exception occurred
5248             */
5249            public List<LayoutRevision> findAll() throws SystemException {
5250                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5251            }
5252    
5253            /**
5254             * Returns a range of all the layout revisions.
5255             *
5256             * <p>
5257             * 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.
5258             * </p>
5259             *
5260             * @param start the lower bound of the range of layout revisions
5261             * @param end the upper bound of the range of layout revisions (not inclusive)
5262             * @return the range of layout revisions
5263             * @throws SystemException if a system exception occurred
5264             */
5265            public List<LayoutRevision> findAll(int start, int end)
5266                    throws SystemException {
5267                    return findAll(start, end, null);
5268            }
5269    
5270            /**
5271             * Returns an ordered range of all the layout revisions.
5272             *
5273             * <p>
5274             * 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.
5275             * </p>
5276             *
5277             * @param start the lower bound of the range of layout revisions
5278             * @param end the upper bound of the range of layout revisions (not inclusive)
5279             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5280             * @return the ordered range of layout revisions
5281             * @throws SystemException if a system exception occurred
5282             */
5283            public List<LayoutRevision> findAll(int start, int end,
5284                    OrderByComparator orderByComparator) throws SystemException {
5285                    FinderPath finderPath = null;
5286                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
5287    
5288                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5289                                    (orderByComparator == null)) {
5290                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5291                            finderArgs = FINDER_ARGS_EMPTY;
5292                    }
5293                    else {
5294                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5295                            finderArgs = new Object[] { start, end, orderByComparator };
5296                    }
5297    
5298                    List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
5299                                    finderArgs, this);
5300    
5301                    if (list == null) {
5302                            StringBundler query = null;
5303                            String sql = null;
5304    
5305                            if (orderByComparator != null) {
5306                                    query = new StringBundler(2 +
5307                                                    (orderByComparator.getOrderByFields().length * 3));
5308    
5309                                    query.append(_SQL_SELECT_LAYOUTREVISION);
5310    
5311                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5312                                            orderByComparator);
5313    
5314                                    sql = query.toString();
5315                            }
5316                            else {
5317                                    sql = _SQL_SELECT_LAYOUTREVISION.concat(LayoutRevisionModelImpl.ORDER_BY_JPQL);
5318                            }
5319    
5320                            Session session = null;
5321    
5322                            try {
5323                                    session = openSession();
5324    
5325                                    Query q = session.createQuery(sql);
5326    
5327                                    if (orderByComparator == null) {
5328                                            list = (List<LayoutRevision>)QueryUtil.list(q,
5329                                                            getDialect(), start, end, false);
5330    
5331                                            Collections.sort(list);
5332                                    }
5333                                    else {
5334                                            list = (List<LayoutRevision>)QueryUtil.list(q,
5335                                                            getDialect(), start, end);
5336                                    }
5337                            }
5338                            catch (Exception e) {
5339                                    throw processException(e);
5340                            }
5341                            finally {
5342                                    if (list == null) {
5343                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5344                                    }
5345                                    else {
5346                                            cacheResult(list);
5347    
5348                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5349                                    }
5350    
5351                                    closeSession(session);
5352                            }
5353                    }
5354    
5355                    return list;
5356            }
5357    
5358            /**
5359             * Removes all the layout revisions where layoutSetBranchId = &#63; from the database.
5360             *
5361             * @param layoutSetBranchId the layout set branch ID
5362             * @throws SystemException if a system exception occurred
5363             */
5364            public void removeByLayoutSetBranchId(long layoutSetBranchId)
5365                    throws SystemException {
5366                    for (LayoutRevision layoutRevision : findByLayoutSetBranchId(
5367                                    layoutSetBranchId)) {
5368                            remove(layoutRevision);
5369                    }
5370            }
5371    
5372            /**
5373             * Removes all the layout revisions where plid = &#63; from the database.
5374             *
5375             * @param plid the plid
5376             * @throws SystemException if a system exception occurred
5377             */
5378            public void removeByPlid(long plid) throws SystemException {
5379                    for (LayoutRevision layoutRevision : findByPlid(plid)) {
5380                            remove(layoutRevision);
5381                    }
5382            }
5383    
5384            /**
5385             * Removes all the layout revisions where layoutSetBranchId = &#63; and head = &#63; from the database.
5386             *
5387             * @param layoutSetBranchId the layout set branch ID
5388             * @param head the head
5389             * @throws SystemException if a system exception occurred
5390             */
5391            public void removeByL_H(long layoutSetBranchId, boolean head)
5392                    throws SystemException {
5393                    for (LayoutRevision layoutRevision : findByL_H(layoutSetBranchId, head)) {
5394                            remove(layoutRevision);
5395                    }
5396            }
5397    
5398            /**
5399             * Removes all the layout revisions where layoutSetBranchId = &#63; and plid = &#63; from the database.
5400             *
5401             * @param layoutSetBranchId the layout set branch ID
5402             * @param plid the plid
5403             * @throws SystemException if a system exception occurred
5404             */
5405            public void removeByL_P(long layoutSetBranchId, long plid)
5406                    throws SystemException {
5407                    for (LayoutRevision layoutRevision : findByL_P(layoutSetBranchId, plid)) {
5408                            remove(layoutRevision);
5409                    }
5410            }
5411    
5412            /**
5413             * Removes all the layout revisions where layoutSetBranchId = &#63; and status = &#63; from the database.
5414             *
5415             * @param layoutSetBranchId the layout set branch ID
5416             * @param status the status
5417             * @throws SystemException if a system exception occurred
5418             */
5419            public void removeByL_S(long layoutSetBranchId, int status)
5420                    throws SystemException {
5421                    for (LayoutRevision layoutRevision : findByL_S(layoutSetBranchId, status)) {
5422                            remove(layoutRevision);
5423                    }
5424            }
5425    
5426            /**
5427             * Removes all the layout revisions where head = &#63; and plid = &#63; from the database.
5428             *
5429             * @param head the head
5430             * @param plid the plid
5431             * @throws SystemException if a system exception occurred
5432             */
5433            public void removeByH_P(boolean head, long plid) throws SystemException {
5434                    for (LayoutRevision layoutRevision : findByH_P(head, plid)) {
5435                            remove(layoutRevision);
5436                    }
5437            }
5438    
5439            /**
5440             * Removes all the layout revisions where plid = &#63; and status &ne; &#63; from the database.
5441             *
5442             * @param plid the plid
5443             * @param status the status
5444             * @throws SystemException if a system exception occurred
5445             */
5446            public void removeByP_NotS(long plid, int status) throws SystemException {
5447                    for (LayoutRevision layoutRevision : findByP_NotS(plid, status)) {
5448                            remove(layoutRevision);
5449                    }
5450            }
5451    
5452            /**
5453             * Removes all the layout revisions where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63; from the database.
5454             *
5455             * @param layoutSetBranchId the layout set branch ID
5456             * @param layoutBranchId the layout branch ID
5457             * @param plid the plid
5458             * @throws SystemException if a system exception occurred
5459             */
5460            public void removeByL_L_P(long layoutSetBranchId, long layoutBranchId,
5461                    long plid) throws SystemException {
5462                    for (LayoutRevision layoutRevision : findByL_L_P(layoutSetBranchId,
5463                                    layoutBranchId, plid)) {
5464                            remove(layoutRevision);
5465                    }
5466            }
5467    
5468            /**
5469             * Removes all the layout revisions where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63; from the database.
5470             *
5471             * @param layoutSetBranchId the layout set branch ID
5472             * @param parentLayoutRevisionId the parent layout revision ID
5473             * @param plid the plid
5474             * @throws SystemException if a system exception occurred
5475             */
5476            public void removeByL_P_P(long layoutSetBranchId,
5477                    long parentLayoutRevisionId, long plid) throws SystemException {
5478                    for (LayoutRevision layoutRevision : findByL_P_P(layoutSetBranchId,
5479                                    parentLayoutRevisionId, plid)) {
5480                            remove(layoutRevision);
5481                    }
5482            }
5483    
5484            /**
5485             * Removes the layout revision where layoutSetBranchId = &#63; and head = &#63; and plid = &#63; from the database.
5486             *
5487             * @param layoutSetBranchId the layout set branch ID
5488             * @param head the head
5489             * @param plid the plid
5490             * @return the layout revision that was removed
5491             * @throws SystemException if a system exception occurred
5492             */
5493            public LayoutRevision removeByL_H_P(long layoutSetBranchId, boolean head,
5494                    long plid) throws NoSuchLayoutRevisionException, SystemException {
5495                    LayoutRevision layoutRevision = findByL_H_P(layoutSetBranchId, head,
5496                                    plid);
5497    
5498                    return remove(layoutRevision);
5499            }
5500    
5501            /**
5502             * Removes all the layout revisions where layoutSetBranchId = &#63; and plid = &#63; and status = &#63; from the database.
5503             *
5504             * @param layoutSetBranchId the layout set branch ID
5505             * @param plid the plid
5506             * @param status the status
5507             * @throws SystemException if a system exception occurred
5508             */
5509            public void removeByL_P_S(long layoutSetBranchId, long plid, int status)
5510                    throws SystemException {
5511                    for (LayoutRevision layoutRevision : findByL_P_S(layoutSetBranchId,
5512                                    plid, status)) {
5513                            remove(layoutRevision);
5514                    }
5515            }
5516    
5517            /**
5518             * Removes all the layout revisions from the database.
5519             *
5520             * @throws SystemException if a system exception occurred
5521             */
5522            public void removeAll() throws SystemException {
5523                    for (LayoutRevision layoutRevision : findAll()) {
5524                            remove(layoutRevision);
5525                    }
5526            }
5527    
5528            /**
5529             * Returns the number of layout revisions where layoutSetBranchId = &#63;.
5530             *
5531             * @param layoutSetBranchId the layout set branch ID
5532             * @return the number of matching layout revisions
5533             * @throws SystemException if a system exception occurred
5534             */
5535            public int countByLayoutSetBranchId(long layoutSetBranchId)
5536                    throws SystemException {
5537                    Object[] finderArgs = new Object[] { layoutSetBranchId };
5538    
5539                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
5540                                    finderArgs, this);
5541    
5542                    if (count == null) {
5543                            StringBundler query = new StringBundler(2);
5544    
5545                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5546    
5547                            query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
5548    
5549                            String sql = query.toString();
5550    
5551                            Session session = null;
5552    
5553                            try {
5554                                    session = openSession();
5555    
5556                                    Query q = session.createQuery(sql);
5557    
5558                                    QueryPos qPos = QueryPos.getInstance(q);
5559    
5560                                    qPos.add(layoutSetBranchId);
5561    
5562                                    count = (Long)q.uniqueResult();
5563                            }
5564                            catch (Exception e) {
5565                                    throw processException(e);
5566                            }
5567                            finally {
5568                                    if (count == null) {
5569                                            count = Long.valueOf(0);
5570                                    }
5571    
5572                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
5573                                            finderArgs, count);
5574    
5575                                    closeSession(session);
5576                            }
5577                    }
5578    
5579                    return count.intValue();
5580            }
5581    
5582            /**
5583             * Returns the number of layout revisions where plid = &#63;.
5584             *
5585             * @param plid the plid
5586             * @return the number of matching layout revisions
5587             * @throws SystemException if a system exception occurred
5588             */
5589            public int countByPlid(long plid) throws SystemException {
5590                    Object[] finderArgs = new Object[] { plid };
5591    
5592                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PLID,
5593                                    finderArgs, this);
5594    
5595                    if (count == null) {
5596                            StringBundler query = new StringBundler(2);
5597    
5598                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5599    
5600                            query.append(_FINDER_COLUMN_PLID_PLID_2);
5601    
5602                            String sql = query.toString();
5603    
5604                            Session session = null;
5605    
5606                            try {
5607                                    session = openSession();
5608    
5609                                    Query q = session.createQuery(sql);
5610    
5611                                    QueryPos qPos = QueryPos.getInstance(q);
5612    
5613                                    qPos.add(plid);
5614    
5615                                    count = (Long)q.uniqueResult();
5616                            }
5617                            catch (Exception e) {
5618                                    throw processException(e);
5619                            }
5620                            finally {
5621                                    if (count == null) {
5622                                            count = Long.valueOf(0);
5623                                    }
5624    
5625                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PLID,
5626                                            finderArgs, count);
5627    
5628                                    closeSession(session);
5629                            }
5630                    }
5631    
5632                    return count.intValue();
5633            }
5634    
5635            /**
5636             * Returns the number of layout revisions where layoutSetBranchId = &#63; and head = &#63;.
5637             *
5638             * @param layoutSetBranchId the layout set branch ID
5639             * @param head the head
5640             * @return the number of matching layout revisions
5641             * @throws SystemException if a system exception occurred
5642             */
5643            public int countByL_H(long layoutSetBranchId, boolean head)
5644                    throws SystemException {
5645                    Object[] finderArgs = new Object[] { layoutSetBranchId, head };
5646    
5647                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_H,
5648                                    finderArgs, this);
5649    
5650                    if (count == null) {
5651                            StringBundler query = new StringBundler(3);
5652    
5653                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5654    
5655                            query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
5656    
5657                            query.append(_FINDER_COLUMN_L_H_HEAD_2);
5658    
5659                            String sql = query.toString();
5660    
5661                            Session session = null;
5662    
5663                            try {
5664                                    session = openSession();
5665    
5666                                    Query q = session.createQuery(sql);
5667    
5668                                    QueryPos qPos = QueryPos.getInstance(q);
5669    
5670                                    qPos.add(layoutSetBranchId);
5671    
5672                                    qPos.add(head);
5673    
5674                                    count = (Long)q.uniqueResult();
5675                            }
5676                            catch (Exception e) {
5677                                    throw processException(e);
5678                            }
5679                            finally {
5680                                    if (count == null) {
5681                                            count = Long.valueOf(0);
5682                                    }
5683    
5684                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H, finderArgs,
5685                                            count);
5686    
5687                                    closeSession(session);
5688                            }
5689                    }
5690    
5691                    return count.intValue();
5692            }
5693    
5694            /**
5695             * Returns the number of layout revisions where layoutSetBranchId = &#63; and plid = &#63;.
5696             *
5697             * @param layoutSetBranchId the layout set branch ID
5698             * @param plid the plid
5699             * @return the number of matching layout revisions
5700             * @throws SystemException if a system exception occurred
5701             */
5702            public int countByL_P(long layoutSetBranchId, long plid)
5703                    throws SystemException {
5704                    Object[] finderArgs = new Object[] { layoutSetBranchId, plid };
5705    
5706                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P,
5707                                    finderArgs, this);
5708    
5709                    if (count == null) {
5710                            StringBundler query = new StringBundler(3);
5711    
5712                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5713    
5714                            query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
5715    
5716                            query.append(_FINDER_COLUMN_L_P_PLID_2);
5717    
5718                            String sql = query.toString();
5719    
5720                            Session session = null;
5721    
5722                            try {
5723                                    session = openSession();
5724    
5725                                    Query q = session.createQuery(sql);
5726    
5727                                    QueryPos qPos = QueryPos.getInstance(q);
5728    
5729                                    qPos.add(layoutSetBranchId);
5730    
5731                                    qPos.add(plid);
5732    
5733                                    count = (Long)q.uniqueResult();
5734                            }
5735                            catch (Exception e) {
5736                                    throw processException(e);
5737                            }
5738                            finally {
5739                                    if (count == null) {
5740                                            count = Long.valueOf(0);
5741                                    }
5742    
5743                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P, finderArgs,
5744                                            count);
5745    
5746                                    closeSession(session);
5747                            }
5748                    }
5749    
5750                    return count.intValue();
5751            }
5752    
5753            /**
5754             * Returns the number of layout revisions where layoutSetBranchId = &#63; and status = &#63;.
5755             *
5756             * @param layoutSetBranchId the layout set branch ID
5757             * @param status the status
5758             * @return the number of matching layout revisions
5759             * @throws SystemException if a system exception occurred
5760             */
5761            public int countByL_S(long layoutSetBranchId, int status)
5762                    throws SystemException {
5763                    Object[] finderArgs = new Object[] { layoutSetBranchId, status };
5764    
5765                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_S,
5766                                    finderArgs, this);
5767    
5768                    if (count == null) {
5769                            StringBundler query = new StringBundler(3);
5770    
5771                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5772    
5773                            query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
5774    
5775                            query.append(_FINDER_COLUMN_L_S_STATUS_2);
5776    
5777                            String sql = query.toString();
5778    
5779                            Session session = null;
5780    
5781                            try {
5782                                    session = openSession();
5783    
5784                                    Query q = session.createQuery(sql);
5785    
5786                                    QueryPos qPos = QueryPos.getInstance(q);
5787    
5788                                    qPos.add(layoutSetBranchId);
5789    
5790                                    qPos.add(status);
5791    
5792                                    count = (Long)q.uniqueResult();
5793                            }
5794                            catch (Exception e) {
5795                                    throw processException(e);
5796                            }
5797                            finally {
5798                                    if (count == null) {
5799                                            count = Long.valueOf(0);
5800                                    }
5801    
5802                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_S, finderArgs,
5803                                            count);
5804    
5805                                    closeSession(session);
5806                            }
5807                    }
5808    
5809                    return count.intValue();
5810            }
5811    
5812            /**
5813             * Returns the number of layout revisions where head = &#63; and plid = &#63;.
5814             *
5815             * @param head the head
5816             * @param plid the plid
5817             * @return the number of matching layout revisions
5818             * @throws SystemException if a system exception occurred
5819             */
5820            public int countByH_P(boolean head, long plid) throws SystemException {
5821                    Object[] finderArgs = new Object[] { head, plid };
5822    
5823                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_H_P,
5824                                    finderArgs, this);
5825    
5826                    if (count == null) {
5827                            StringBundler query = new StringBundler(3);
5828    
5829                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5830    
5831                            query.append(_FINDER_COLUMN_H_P_HEAD_2);
5832    
5833                            query.append(_FINDER_COLUMN_H_P_PLID_2);
5834    
5835                            String sql = query.toString();
5836    
5837                            Session session = null;
5838    
5839                            try {
5840                                    session = openSession();
5841    
5842                                    Query q = session.createQuery(sql);
5843    
5844                                    QueryPos qPos = QueryPos.getInstance(q);
5845    
5846                                    qPos.add(head);
5847    
5848                                    qPos.add(plid);
5849    
5850                                    count = (Long)q.uniqueResult();
5851                            }
5852                            catch (Exception e) {
5853                                    throw processException(e);
5854                            }
5855                            finally {
5856                                    if (count == null) {
5857                                            count = Long.valueOf(0);
5858                                    }
5859    
5860                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_H_P, finderArgs,
5861                                            count);
5862    
5863                                    closeSession(session);
5864                            }
5865                    }
5866    
5867                    return count.intValue();
5868            }
5869    
5870            /**
5871             * Returns the number of layout revisions where plid = &#63; and status &ne; &#63;.
5872             *
5873             * @param plid the plid
5874             * @param status the status
5875             * @return the number of matching layout revisions
5876             * @throws SystemException if a system exception occurred
5877             */
5878            public int countByP_NotS(long plid, int status) throws SystemException {
5879                    Object[] finderArgs = new Object[] { plid, status };
5880    
5881                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS,
5882                                    finderArgs, this);
5883    
5884                    if (count == null) {
5885                            StringBundler query = new StringBundler(3);
5886    
5887                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5888    
5889                            query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
5890    
5891                            query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
5892    
5893                            String sql = query.toString();
5894    
5895                            Session session = null;
5896    
5897                            try {
5898                                    session = openSession();
5899    
5900                                    Query q = session.createQuery(sql);
5901    
5902                                    QueryPos qPos = QueryPos.getInstance(q);
5903    
5904                                    qPos.add(plid);
5905    
5906                                    qPos.add(status);
5907    
5908                                    count = (Long)q.uniqueResult();
5909                            }
5910                            catch (Exception e) {
5911                                    throw processException(e);
5912                            }
5913                            finally {
5914                                    if (count == null) {
5915                                            count = Long.valueOf(0);
5916                                    }
5917    
5918                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS,
5919                                            finderArgs, count);
5920    
5921                                    closeSession(session);
5922                            }
5923                    }
5924    
5925                    return count.intValue();
5926            }
5927    
5928            /**
5929             * Returns the number of layout revisions where layoutSetBranchId = &#63; and layoutBranchId = &#63; and plid = &#63;.
5930             *
5931             * @param layoutSetBranchId the layout set branch ID
5932             * @param layoutBranchId the layout branch ID
5933             * @param plid the plid
5934             * @return the number of matching layout revisions
5935             * @throws SystemException if a system exception occurred
5936             */
5937            public int countByL_L_P(long layoutSetBranchId, long layoutBranchId,
5938                    long plid) throws SystemException {
5939                    Object[] finderArgs = new Object[] {
5940                                    layoutSetBranchId, layoutBranchId, plid
5941                            };
5942    
5943                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_L_P,
5944                                    finderArgs, this);
5945    
5946                    if (count == null) {
5947                            StringBundler query = new StringBundler(4);
5948    
5949                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5950    
5951                            query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
5952    
5953                            query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
5954    
5955                            query.append(_FINDER_COLUMN_L_L_P_PLID_2);
5956    
5957                            String sql = query.toString();
5958    
5959                            Session session = null;
5960    
5961                            try {
5962                                    session = openSession();
5963    
5964                                    Query q = session.createQuery(sql);
5965    
5966                                    QueryPos qPos = QueryPos.getInstance(q);
5967    
5968                                    qPos.add(layoutSetBranchId);
5969    
5970                                    qPos.add(layoutBranchId);
5971    
5972                                    qPos.add(plid);
5973    
5974                                    count = (Long)q.uniqueResult();
5975                            }
5976                            catch (Exception e) {
5977                                    throw processException(e);
5978                            }
5979                            finally {
5980                                    if (count == null) {
5981                                            count = Long.valueOf(0);
5982                                    }
5983    
5984                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_L_P,
5985                                            finderArgs, count);
5986    
5987                                    closeSession(session);
5988                            }
5989                    }
5990    
5991                    return count.intValue();
5992            }
5993    
5994            /**
5995             * Returns the number of layout revisions where layoutSetBranchId = &#63; and parentLayoutRevisionId = &#63; and plid = &#63;.
5996             *
5997             * @param layoutSetBranchId the layout set branch ID
5998             * @param parentLayoutRevisionId the parent layout revision ID
5999             * @param plid the plid
6000             * @return the number of matching layout revisions
6001             * @throws SystemException if a system exception occurred
6002             */
6003            public int countByL_P_P(long layoutSetBranchId,
6004                    long parentLayoutRevisionId, long plid) throws SystemException {
6005                    Object[] finderArgs = new Object[] {
6006                                    layoutSetBranchId, parentLayoutRevisionId, plid
6007                            };
6008    
6009                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P_P,
6010                                    finderArgs, this);
6011    
6012                    if (count == null) {
6013                            StringBundler query = new StringBundler(4);
6014    
6015                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
6016    
6017                            query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
6018    
6019                            query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
6020    
6021                            query.append(_FINDER_COLUMN_L_P_P_PLID_2);
6022    
6023                            String sql = query.toString();
6024    
6025                            Session session = null;
6026    
6027                            try {
6028                                    session = openSession();
6029    
6030                                    Query q = session.createQuery(sql);
6031    
6032                                    QueryPos qPos = QueryPos.getInstance(q);
6033    
6034                                    qPos.add(layoutSetBranchId);
6035    
6036                                    qPos.add(parentLayoutRevisionId);
6037    
6038                                    qPos.add(plid);
6039    
6040                                    count = (Long)q.uniqueResult();
6041                            }
6042                            catch (Exception e) {
6043                                    throw processException(e);
6044                            }
6045                            finally {
6046                                    if (count == null) {
6047                                            count = Long.valueOf(0);
6048                                    }
6049    
6050                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P_P,
6051                                            finderArgs, count);
6052    
6053                                    closeSession(session);
6054                            }
6055                    }
6056    
6057                    return count.intValue();
6058            }
6059    
6060            /**
6061             * Returns the number of layout revisions where layoutSetBranchId = &#63; and head = &#63; and plid = &#63;.
6062             *
6063             * @param layoutSetBranchId the layout set branch ID
6064             * @param head the head
6065             * @param plid the plid
6066             * @return the number of matching layout revisions
6067             * @throws SystemException if a system exception occurred
6068             */
6069            public int countByL_H_P(long layoutSetBranchId, boolean head, long plid)
6070                    throws SystemException {
6071                    Object[] finderArgs = new Object[] { layoutSetBranchId, head, plid };
6072    
6073                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_H_P,
6074                                    finderArgs, this);
6075    
6076                    if (count == null) {
6077                            StringBundler query = new StringBundler(4);
6078    
6079                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
6080    
6081                            query.append(_FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2);
6082    
6083                            query.append(_FINDER_COLUMN_L_H_P_HEAD_2);
6084    
6085                            query.append(_FINDER_COLUMN_L_H_P_PLID_2);
6086    
6087                            String sql = query.toString();
6088    
6089                            Session session = null;
6090    
6091                            try {
6092                                    session = openSession();
6093    
6094                                    Query q = session.createQuery(sql);
6095    
6096                                    QueryPos qPos = QueryPos.getInstance(q);
6097    
6098                                    qPos.add(layoutSetBranchId);
6099    
6100                                    qPos.add(head);
6101    
6102                                    qPos.add(plid);
6103    
6104                                    count = (Long)q.uniqueResult();
6105                            }
6106                            catch (Exception e) {
6107                                    throw processException(e);
6108                            }
6109                            finally {
6110                                    if (count == null) {
6111                                            count = Long.valueOf(0);
6112                                    }
6113    
6114                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H_P,
6115                                            finderArgs, count);
6116    
6117                                    closeSession(session);
6118                            }
6119                    }
6120    
6121                    return count.intValue();
6122            }
6123    
6124            /**
6125             * Returns the number of layout revisions where layoutSetBranchId = &#63; and plid = &#63; and status = &#63;.
6126             *
6127             * @param layoutSetBranchId the layout set branch ID
6128             * @param plid the plid
6129             * @param status the status
6130             * @return the number of matching layout revisions
6131             * @throws SystemException if a system exception occurred
6132             */
6133            public int countByL_P_S(long layoutSetBranchId, long plid, int status)
6134                    throws SystemException {
6135                    Object[] finderArgs = new Object[] { layoutSetBranchId, plid, status };
6136    
6137                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P_S,
6138                                    finderArgs, this);
6139    
6140                    if (count == null) {
6141                            StringBundler query = new StringBundler(4);
6142    
6143                            query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
6144    
6145                            query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
6146    
6147                            query.append(_FINDER_COLUMN_L_P_S_PLID_2);
6148    
6149                            query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
6150    
6151                            String sql = query.toString();
6152    
6153                            Session session = null;
6154    
6155                            try {
6156                                    session = openSession();
6157    
6158                                    Query q = session.createQuery(sql);
6159    
6160                                    QueryPos qPos = QueryPos.getInstance(q);
6161    
6162                                    qPos.add(layoutSetBranchId);
6163    
6164                                    qPos.add(plid);
6165    
6166                                    qPos.add(status);
6167    
6168                                    count = (Long)q.uniqueResult();
6169                            }
6170                            catch (Exception e) {
6171                                    throw processException(e);
6172                            }
6173                            finally {
6174                                    if (count == null) {
6175                                            count = Long.valueOf(0);
6176                                    }
6177    
6178                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P_S,
6179                                            finderArgs, count);
6180    
6181                                    closeSession(session);
6182                            }
6183                    }
6184    
6185                    return count.intValue();
6186            }
6187    
6188            /**
6189             * Returns the number of layout revisions.
6190             *
6191             * @return the number of layout revisions
6192             * @throws SystemException if a system exception occurred
6193             */
6194            public int countAll() throws SystemException {
6195                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
6196                                    FINDER_ARGS_EMPTY, this);
6197    
6198                    if (count == null) {
6199                            Session session = null;
6200    
6201                            try {
6202                                    session = openSession();
6203    
6204                                    Query q = session.createQuery(_SQL_COUNT_LAYOUTREVISION);
6205    
6206                                    count = (Long)q.uniqueResult();
6207                            }
6208                            catch (Exception e) {
6209                                    throw processException(e);
6210                            }
6211                            finally {
6212                                    if (count == null) {
6213                                            count = Long.valueOf(0);
6214                                    }
6215    
6216                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
6217                                            FINDER_ARGS_EMPTY, count);
6218    
6219                                    closeSession(session);
6220                            }
6221                    }
6222    
6223                    return count.intValue();
6224            }
6225    
6226            /**
6227             * Initializes the layout revision persistence.
6228             */
6229            public void afterPropertiesSet() {
6230                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6231                                            com.liferay.portal.util.PropsUtil.get(
6232                                                    "value.object.listener.com.liferay.portal.model.LayoutRevision")));
6233    
6234                    if (listenerClassNames.length > 0) {
6235                            try {
6236                                    List<ModelListener<LayoutRevision>> listenersList = new ArrayList<ModelListener<LayoutRevision>>();
6237    
6238                                    for (String listenerClassName : listenerClassNames) {
6239                                            Class<?> clazz = getClass();
6240    
6241                                            listenersList.add((ModelListener<LayoutRevision>)InstanceFactory.newInstance(
6242                                                            clazz.getClassLoader(), listenerClassName));
6243                                    }
6244    
6245                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6246                            }
6247                            catch (Exception e) {
6248                                    _log.error(e);
6249                            }
6250                    }
6251            }
6252    
6253            public void destroy() {
6254                    EntityCacheUtil.removeCache(LayoutRevisionImpl.class.getName());
6255                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6256                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6257            }
6258    
6259            @BeanReference(type = AccountPersistence.class)
6260            protected AccountPersistence accountPersistence;
6261            @BeanReference(type = AddressPersistence.class)
6262            protected AddressPersistence addressPersistence;
6263            @BeanReference(type = BrowserTrackerPersistence.class)
6264            protected BrowserTrackerPersistence browserTrackerPersistence;
6265            @BeanReference(type = ClassNamePersistence.class)
6266            protected ClassNamePersistence classNamePersistence;
6267            @BeanReference(type = ClusterGroupPersistence.class)
6268            protected ClusterGroupPersistence clusterGroupPersistence;
6269            @BeanReference(type = CompanyPersistence.class)
6270            protected CompanyPersistence companyPersistence;
6271            @BeanReference(type = ContactPersistence.class)
6272            protected ContactPersistence contactPersistence;
6273            @BeanReference(type = CountryPersistence.class)
6274            protected CountryPersistence countryPersistence;
6275            @BeanReference(type = EmailAddressPersistence.class)
6276            protected EmailAddressPersistence emailAddressPersistence;
6277            @BeanReference(type = GroupPersistence.class)
6278            protected GroupPersistence groupPersistence;
6279            @BeanReference(type = ImagePersistence.class)
6280            protected ImagePersistence imagePersistence;
6281            @BeanReference(type = LayoutPersistence.class)
6282            protected LayoutPersistence layoutPersistence;
6283            @BeanReference(type = LayoutBranchPersistence.class)
6284            protected LayoutBranchPersistence layoutBranchPersistence;
6285            @BeanReference(type = LayoutPrototypePersistence.class)
6286            protected LayoutPrototypePersistence layoutPrototypePersistence;
6287            @BeanReference(type = LayoutRevisionPersistence.class)
6288            protected LayoutRevisionPersistence layoutRevisionPersistence;
6289            @BeanReference(type = LayoutSetPersistence.class)
6290            protected LayoutSetPersistence layoutSetPersistence;
6291            @BeanReference(type = LayoutSetBranchPersistence.class)
6292            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
6293            @BeanReference(type = LayoutSetPrototypePersistence.class)
6294            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
6295            @BeanReference(type = ListTypePersistence.class)
6296            protected ListTypePersistence listTypePersistence;
6297            @BeanReference(type = LockPersistence.class)
6298            protected LockPersistence lockPersistence;
6299            @BeanReference(type = MembershipRequestPersistence.class)
6300            protected MembershipRequestPersistence membershipRequestPersistence;
6301            @BeanReference(type = OrganizationPersistence.class)
6302            protected OrganizationPersistence organizationPersistence;
6303            @BeanReference(type = OrgGroupPermissionPersistence.class)
6304            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
6305            @BeanReference(type = OrgGroupRolePersistence.class)
6306            protected OrgGroupRolePersistence orgGroupRolePersistence;
6307            @BeanReference(type = OrgLaborPersistence.class)
6308            protected OrgLaborPersistence orgLaborPersistence;
6309            @BeanReference(type = PasswordPolicyPersistence.class)
6310            protected PasswordPolicyPersistence passwordPolicyPersistence;
6311            @BeanReference(type = PasswordPolicyRelPersistence.class)
6312            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
6313            @BeanReference(type = PasswordTrackerPersistence.class)
6314            protected PasswordTrackerPersistence passwordTrackerPersistence;
6315            @BeanReference(type = PermissionPersistence.class)
6316            protected PermissionPersistence permissionPersistence;
6317            @BeanReference(type = PhonePersistence.class)
6318            protected PhonePersistence phonePersistence;
6319            @BeanReference(type = PluginSettingPersistence.class)
6320            protected PluginSettingPersistence pluginSettingPersistence;
6321            @BeanReference(type = PortalPreferencesPersistence.class)
6322            protected PortalPreferencesPersistence portalPreferencesPersistence;
6323            @BeanReference(type = PortletPersistence.class)
6324            protected PortletPersistence portletPersistence;
6325            @BeanReference(type = PortletItemPersistence.class)
6326            protected PortletItemPersistence portletItemPersistence;
6327            @BeanReference(type = PortletPreferencesPersistence.class)
6328            protected PortletPreferencesPersistence portletPreferencesPersistence;
6329            @BeanReference(type = RegionPersistence.class)
6330            protected RegionPersistence regionPersistence;
6331            @BeanReference(type = ReleasePersistence.class)
6332            protected ReleasePersistence releasePersistence;
6333            @BeanReference(type = RepositoryPersistence.class)
6334            protected RepositoryPersistence repositoryPersistence;
6335            @BeanReference(type = RepositoryEntryPersistence.class)
6336            protected RepositoryEntryPersistence repositoryEntryPersistence;
6337            @BeanReference(type = ResourcePersistence.class)
6338            protected ResourcePersistence resourcePersistence;
6339            @BeanReference(type = ResourceActionPersistence.class)
6340            protected ResourceActionPersistence resourceActionPersistence;
6341            @BeanReference(type = ResourceBlockPersistence.class)
6342            protected ResourceBlockPersistence resourceBlockPersistence;
6343            @BeanReference(type = ResourceBlockPermissionPersistence.class)
6344            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
6345            @BeanReference(type = ResourceCodePersistence.class)
6346            protected ResourceCodePersistence resourceCodePersistence;
6347            @BeanReference(type = ResourcePermissionPersistence.class)
6348            protected ResourcePermissionPersistence resourcePermissionPersistence;
6349            @BeanReference(type = ResourceTypePermissionPersistence.class)
6350            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
6351            @BeanReference(type = RolePersistence.class)
6352            protected RolePersistence rolePersistence;
6353            @BeanReference(type = ServiceComponentPersistence.class)
6354            protected ServiceComponentPersistence serviceComponentPersistence;
6355            @BeanReference(type = ShardPersistence.class)
6356            protected ShardPersistence shardPersistence;
6357            @BeanReference(type = SubscriptionPersistence.class)
6358            protected SubscriptionPersistence subscriptionPersistence;
6359            @BeanReference(type = TeamPersistence.class)
6360            protected TeamPersistence teamPersistence;
6361            @BeanReference(type = TicketPersistence.class)
6362            protected TicketPersistence ticketPersistence;
6363            @BeanReference(type = UserPersistence.class)
6364            protected UserPersistence userPersistence;
6365            @BeanReference(type = UserGroupPersistence.class)
6366            protected UserGroupPersistence userGroupPersistence;
6367            @BeanReference(type = UserGroupGroupRolePersistence.class)
6368            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
6369            @BeanReference(type = UserGroupRolePersistence.class)
6370            protected UserGroupRolePersistence userGroupRolePersistence;
6371            @BeanReference(type = UserIdMapperPersistence.class)
6372            protected UserIdMapperPersistence userIdMapperPersistence;
6373            @BeanReference(type = UserNotificationEventPersistence.class)
6374            protected UserNotificationEventPersistence userNotificationEventPersistence;
6375            @BeanReference(type = UserTrackerPersistence.class)
6376            protected UserTrackerPersistence userTrackerPersistence;
6377            @BeanReference(type = UserTrackerPathPersistence.class)
6378            protected UserTrackerPathPersistence userTrackerPathPersistence;
6379            @BeanReference(type = VirtualHostPersistence.class)
6380            protected VirtualHostPersistence virtualHostPersistence;
6381            @BeanReference(type = WebDAVPropsPersistence.class)
6382            protected WebDAVPropsPersistence webDAVPropsPersistence;
6383            @BeanReference(type = WebsitePersistence.class)
6384            protected WebsitePersistence websitePersistence;
6385            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6386            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6387            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6388            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6389            private static final String _SQL_SELECT_LAYOUTREVISION = "SELECT layoutRevision FROM LayoutRevision layoutRevision";
6390            private static final String _SQL_SELECT_LAYOUTREVISION_WHERE = "SELECT layoutRevision FROM LayoutRevision layoutRevision WHERE ";
6391            private static final String _SQL_COUNT_LAYOUTREVISION = "SELECT COUNT(layoutRevision) FROM LayoutRevision layoutRevision";
6392            private static final String _SQL_COUNT_LAYOUTREVISION_WHERE = "SELECT COUNT(layoutRevision) FROM LayoutRevision layoutRevision WHERE ";
6393            private static final String _FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2 =
6394                    "layoutRevision.layoutSetBranchId = ?";
6395            private static final String _FINDER_COLUMN_PLID_PLID_2 = "layoutRevision.plid = ?";
6396            private static final String _FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6397            private static final String _FINDER_COLUMN_L_H_HEAD_2 = "layoutRevision.head = ?";
6398            private static final String _FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6399            private static final String _FINDER_COLUMN_L_P_PLID_2 = "layoutRevision.plid = ?";
6400            private static final String _FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6401            private static final String _FINDER_COLUMN_L_S_STATUS_2 = "layoutRevision.status = ?";
6402            private static final String _FINDER_COLUMN_H_P_HEAD_2 = "layoutRevision.head = ? AND ";
6403            private static final String _FINDER_COLUMN_H_P_PLID_2 = "layoutRevision.plid = ?";
6404            private static final String _FINDER_COLUMN_P_NOTS_PLID_2 = "layoutRevision.plid = ? AND ";
6405            private static final String _FINDER_COLUMN_P_NOTS_STATUS_2 = "layoutRevision.status != ?";
6406            private static final String _FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6407            private static final String _FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2 = "layoutRevision.layoutBranchId = ? AND ";
6408            private static final String _FINDER_COLUMN_L_L_P_PLID_2 = "layoutRevision.plid = ? AND layoutRevision.status != 5";
6409            private static final String _FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6410            private static final String _FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2 = "layoutRevision.parentLayoutRevisionId = ? AND ";
6411            private static final String _FINDER_COLUMN_L_P_P_PLID_2 = "layoutRevision.plid = ?";
6412            private static final String _FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6413            private static final String _FINDER_COLUMN_L_H_P_HEAD_2 = "layoutRevision.head = ? AND ";
6414            private static final String _FINDER_COLUMN_L_H_P_PLID_2 = "layoutRevision.plid = ?";
6415            private static final String _FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6416            private static final String _FINDER_COLUMN_L_P_S_PLID_2 = "layoutRevision.plid = ? AND ";
6417            private static final String _FINDER_COLUMN_L_P_S_STATUS_2 = "layoutRevision.status = ?";
6418            private static final String _ORDER_BY_ENTITY_ALIAS = "layoutRevision.";
6419            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutRevision exists with the primary key ";
6420            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutRevision exists with the key {";
6421            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6422            private static Log _log = LogFactoryUtil.getLog(LayoutRevisionPersistenceImpl.class);
6423            private static LayoutRevision _nullLayoutRevision = new LayoutRevisionImpl() {
6424                            @Override
6425                            public Object clone() {
6426                                    return this;
6427                            }
6428    
6429                            @Override
6430                            public CacheModel<LayoutRevision> toCacheModel() {
6431                                    return _nullLayoutRevisionCacheModel;
6432                            }
6433                    };
6434    
6435            private static CacheModel<LayoutRevision> _nullLayoutRevisionCacheModel = new CacheModel<LayoutRevision>() {
6436                            public LayoutRevision toEntityModel() {
6437                                    return _nullLayoutRevision;
6438                            }
6439                    };
6440    }