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