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