001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchLayoutBranchException;
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.LayoutBranch;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.model.impl.LayoutBranchImpl;
041    import com.liferay.portal.model.impl.LayoutBranchModelImpl;
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 branch 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 LayoutBranchPersistence
059     * @see LayoutBranchUtil
060     * @generated
061     */
062    public class LayoutBranchPersistenceImpl extends BasePersistenceImpl<LayoutBranch>
063            implements LayoutBranchPersistence {
064            /*
065             * NOTE FOR DEVELOPERS:
066             *
067             * Never modify or reference this class directly. Always use {@link LayoutBranchUtil} to access the layout branch persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
068             */
069            public static final String FINDER_CLASS_NAME_ENTITY = LayoutBranchImpl.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(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
076                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class,
077                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLayoutSetBranchId",
078                            new String[] {
079                                    Long.class.getName(),
080                                    
081                            "java.lang.Integer", "java.lang.Integer",
082                                    "com.liferay.portal.kernel.util.OrderByComparator"
083                            });
084            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID =
085                    new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
086                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
088                            "findByLayoutSetBranchId", new String[] { Long.class.getName() },
089                            LayoutBranchModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK);
090            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
091                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
093                            "countByLayoutSetBranchId", new String[] { Long.class.getName() });
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
095                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByL_P",
097                            new String[] {
098                                    Long.class.getName(), Long.class.getName(),
099                                    
100                            "java.lang.Integer", "java.lang.Integer",
101                                    "com.liferay.portal.kernel.util.OrderByComparator"
102                            });
103            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
104                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P",
106                            new String[] { Long.class.getName(), Long.class.getName() },
107                            LayoutBranchModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
108                            LayoutBranchModelImpl.PLID_COLUMN_BITMASK);
109            public static final FinderPath FINDER_PATH_COUNT_BY_L_P = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
110                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P",
112                            new String[] { Long.class.getName(), Long.class.getName() });
113            public static final FinderPath FINDER_PATH_FETCH_BY_L_P_N = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
114                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class,
115                            FINDER_CLASS_NAME_ENTITY, "fetchByL_P_N",
116                            new String[] {
117                                    Long.class.getName(), Long.class.getName(),
118                                    String.class.getName()
119                            },
120                            LayoutBranchModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
121                            LayoutBranchModelImpl.PLID_COLUMN_BITMASK |
122                            LayoutBranchModelImpl.NAME_COLUMN_BITMASK);
123            public static final FinderPath FINDER_PATH_COUNT_BY_L_P_N = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
124                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
125                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_N",
126                            new String[] {
127                                    Long.class.getName(), Long.class.getName(),
128                                    String.class.getName()
129                            });
130            public static final FinderPath FINDER_PATH_FETCH_BY_L_P_M = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
131                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class,
132                            FINDER_CLASS_NAME_ENTITY, "fetchByL_P_M",
133                            new String[] {
134                                    Long.class.getName(), Long.class.getName(),
135                                    Boolean.class.getName()
136                            },
137                            LayoutBranchModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
138                            LayoutBranchModelImpl.PLID_COLUMN_BITMASK |
139                            LayoutBranchModelImpl.MASTER_COLUMN_BITMASK);
140            public static final FinderPath FINDER_PATH_COUNT_BY_L_P_M = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
141                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
142                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_M",
143                            new String[] {
144                                    Long.class.getName(), Long.class.getName(),
145                                    Boolean.class.getName()
146                            });
147            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
148                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class,
149                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
150            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
151                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class,
152                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
153            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
154                            LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
155                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
156    
157            /**
158             * Caches the layout branch in the entity cache if it is enabled.
159             *
160             * @param layoutBranch the layout branch
161             */
162            public void cacheResult(LayoutBranch layoutBranch) {
163                    EntityCacheUtil.putResult(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
164                            LayoutBranchImpl.class, layoutBranch.getPrimaryKey(), layoutBranch);
165    
166                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_N,
167                            new Object[] {
168                                    Long.valueOf(layoutBranch.getLayoutSetBranchId()),
169                                    Long.valueOf(layoutBranch.getPlid()),
170                                    
171                            layoutBranch.getName()
172                            }, layoutBranch);
173    
174                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_M,
175                            new Object[] {
176                                    Long.valueOf(layoutBranch.getLayoutSetBranchId()),
177                                    Long.valueOf(layoutBranch.getPlid()),
178                                    Boolean.valueOf(layoutBranch.getMaster())
179                            }, layoutBranch);
180    
181                    layoutBranch.resetOriginalValues();
182            }
183    
184            /**
185             * Caches the layout branchs in the entity cache if it is enabled.
186             *
187             * @param layoutBranchs the layout branchs
188             */
189            public void cacheResult(List<LayoutBranch> layoutBranchs) {
190                    for (LayoutBranch layoutBranch : layoutBranchs) {
191                            if (EntityCacheUtil.getResult(
192                                                    LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
193                                                    LayoutBranchImpl.class, layoutBranch.getPrimaryKey()) == null) {
194                                    cacheResult(layoutBranch);
195                            }
196                            else {
197                                    layoutBranch.resetOriginalValues();
198                            }
199                    }
200            }
201    
202            /**
203             * Clears the cache for all layout branchs.
204             *
205             * <p>
206             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
207             * </p>
208             */
209            @Override
210            public void clearCache() {
211                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
212                            CacheRegistryUtil.clear(LayoutBranchImpl.class.getName());
213                    }
214    
215                    EntityCacheUtil.clearCache(LayoutBranchImpl.class.getName());
216    
217                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
218                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
219                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
220            }
221    
222            /**
223             * Clears the cache for the layout branch.
224             *
225             * <p>
226             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
227             * </p>
228             */
229            @Override
230            public void clearCache(LayoutBranch layoutBranch) {
231                    EntityCacheUtil.removeResult(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
232                            LayoutBranchImpl.class, layoutBranch.getPrimaryKey());
233    
234                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
235                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
236    
237                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_P_N,
238                            new Object[] {
239                                    Long.valueOf(layoutBranch.getLayoutSetBranchId()),
240                                    Long.valueOf(layoutBranch.getPlid()),
241                                    
242                            layoutBranch.getName()
243                            });
244    
245                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_P_M,
246                            new Object[] {
247                                    Long.valueOf(layoutBranch.getLayoutSetBranchId()),
248                                    Long.valueOf(layoutBranch.getPlid()),
249                                    Boolean.valueOf(layoutBranch.getMaster())
250                            });
251            }
252    
253            /**
254             * Creates a new layout branch with the primary key. Does not add the layout branch to the database.
255             *
256             * @param LayoutBranchId the primary key for the new layout branch
257             * @return the new layout branch
258             */
259            public LayoutBranch create(long LayoutBranchId) {
260                    LayoutBranch layoutBranch = new LayoutBranchImpl();
261    
262                    layoutBranch.setNew(true);
263                    layoutBranch.setPrimaryKey(LayoutBranchId);
264    
265                    return layoutBranch;
266            }
267    
268            /**
269             * Removes the layout branch with the primary key from the database. Also notifies the appropriate model listeners.
270             *
271             * @param primaryKey the primary key of the layout branch
272             * @return the layout branch that was removed
273             * @throws com.liferay.portal.NoSuchModelException if a layout branch with the primary key could not be found
274             * @throws SystemException if a system exception occurred
275             */
276            @Override
277            public LayoutBranch remove(Serializable primaryKey)
278                    throws NoSuchModelException, SystemException {
279                    return remove(((Long)primaryKey).longValue());
280            }
281    
282            /**
283             * Removes the layout branch with the primary key from the database. Also notifies the appropriate model listeners.
284             *
285             * @param LayoutBranchId the primary key of the layout branch
286             * @return the layout branch that was removed
287             * @throws com.liferay.portal.NoSuchLayoutBranchException if a layout branch with the primary key could not be found
288             * @throws SystemException if a system exception occurred
289             */
290            public LayoutBranch remove(long LayoutBranchId)
291                    throws NoSuchLayoutBranchException, SystemException {
292                    Session session = null;
293    
294                    try {
295                            session = openSession();
296    
297                            LayoutBranch layoutBranch = (LayoutBranch)session.get(LayoutBranchImpl.class,
298                                            Long.valueOf(LayoutBranchId));
299    
300                            if (layoutBranch == null) {
301                                    if (_log.isWarnEnabled()) {
302                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
303                                                    LayoutBranchId);
304                                    }
305    
306                                    throw new NoSuchLayoutBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
307                                            LayoutBranchId);
308                            }
309    
310                            return layoutBranchPersistence.remove(layoutBranch);
311                    }
312                    catch (NoSuchLayoutBranchException nsee) {
313                            throw nsee;
314                    }
315                    catch (Exception e) {
316                            throw processException(e);
317                    }
318                    finally {
319                            closeSession(session);
320                    }
321            }
322    
323            /**
324             * Removes the layout branch from the database. Also notifies the appropriate model listeners.
325             *
326             * @param layoutBranch the layout branch
327             * @return the layout branch that was removed
328             * @throws SystemException if a system exception occurred
329             */
330            @Override
331            public LayoutBranch remove(LayoutBranch layoutBranch)
332                    throws SystemException {
333                    return super.remove(layoutBranch);
334            }
335    
336            @Override
337            protected LayoutBranch removeImpl(LayoutBranch layoutBranch)
338                    throws SystemException {
339                    layoutBranch = toUnwrappedModel(layoutBranch);
340    
341                    Session session = null;
342    
343                    try {
344                            session = openSession();
345    
346                            BatchSessionUtil.delete(session, layoutBranch);
347                    }
348                    catch (Exception e) {
349                            throw processException(e);
350                    }
351                    finally {
352                            closeSession(session);
353                    }
354    
355                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
356                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
357    
358                    LayoutBranchModelImpl layoutBranchModelImpl = (LayoutBranchModelImpl)layoutBranch;
359    
360                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_P_N,
361                            new Object[] {
362                                    Long.valueOf(layoutBranchModelImpl.getLayoutSetBranchId()),
363                                    Long.valueOf(layoutBranchModelImpl.getPlid()),
364                                    
365                            layoutBranchModelImpl.getName()
366                            });
367    
368                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_P_M,
369                            new Object[] {
370                                    Long.valueOf(layoutBranchModelImpl.getLayoutSetBranchId()),
371                                    Long.valueOf(layoutBranchModelImpl.getPlid()),
372                                    Boolean.valueOf(layoutBranchModelImpl.getMaster())
373                            });
374    
375                    EntityCacheUtil.removeResult(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
376                            LayoutBranchImpl.class, layoutBranch.getPrimaryKey());
377    
378                    return layoutBranch;
379            }
380    
381            @Override
382            public LayoutBranch updateImpl(
383                    com.liferay.portal.model.LayoutBranch layoutBranch, boolean merge)
384                    throws SystemException {
385                    layoutBranch = toUnwrappedModel(layoutBranch);
386    
387                    boolean isNew = layoutBranch.isNew();
388    
389                    LayoutBranchModelImpl layoutBranchModelImpl = (LayoutBranchModelImpl)layoutBranch;
390    
391                    Session session = null;
392    
393                    try {
394                            session = openSession();
395    
396                            BatchSessionUtil.update(session, layoutBranch, merge);
397    
398                            layoutBranch.setNew(false);
399                    }
400                    catch (Exception e) {
401                            throw processException(e);
402                    }
403                    finally {
404                            closeSession(session);
405                    }
406    
407                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
408    
409                    if (isNew || !LayoutBranchModelImpl.COLUMN_BITMASK_ENABLED) {
410                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
411                    }
412    
413                    else {
414                            if ((layoutBranchModelImpl.getColumnBitmask() &
415                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID.getColumnBitmask()) != 0) {
416                                    Object[] args = new Object[] {
417                                                    Long.valueOf(layoutBranchModelImpl.getOriginalLayoutSetBranchId())
418                                            };
419    
420                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
421                                            args);
422                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
423                                            args);
424    
425                                    args = new Object[] {
426                                                    Long.valueOf(layoutBranchModelImpl.getLayoutSetBranchId())
427                                            };
428    
429                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
430                                            args);
431                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
432                                            args);
433                            }
434    
435                            if ((layoutBranchModelImpl.getColumnBitmask() &
436                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) {
437                                    Object[] args = new Object[] {
438                                                    Long.valueOf(layoutBranchModelImpl.getOriginalLayoutSetBranchId()),
439                                                    Long.valueOf(layoutBranchModelImpl.getOriginalPlid())
440                                            };
441    
442                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
443                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
444                                            args);
445    
446                                    args = new Object[] {
447                                                    Long.valueOf(layoutBranchModelImpl.getLayoutSetBranchId()),
448                                                    Long.valueOf(layoutBranchModelImpl.getPlid())
449                                            };
450    
451                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
452                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
453                                            args);
454                            }
455                    }
456    
457                    EntityCacheUtil.putResult(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
458                            LayoutBranchImpl.class, layoutBranch.getPrimaryKey(), layoutBranch);
459    
460                    if (isNew) {
461                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_N,
462                                    new Object[] {
463                                            Long.valueOf(layoutBranch.getLayoutSetBranchId()),
464                                            Long.valueOf(layoutBranch.getPlid()),
465                                            
466                                    layoutBranch.getName()
467                                    }, layoutBranch);
468    
469                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_M,
470                                    new Object[] {
471                                            Long.valueOf(layoutBranch.getLayoutSetBranchId()),
472                                            Long.valueOf(layoutBranch.getPlid()),
473                                            Boolean.valueOf(layoutBranch.getMaster())
474                                    }, layoutBranch);
475                    }
476                    else {
477                            if ((layoutBranchModelImpl.getColumnBitmask() &
478                                            FINDER_PATH_FETCH_BY_L_P_N.getColumnBitmask()) != 0) {
479                                    Object[] args = new Object[] {
480                                                    Long.valueOf(layoutBranchModelImpl.getOriginalLayoutSetBranchId()),
481                                                    Long.valueOf(layoutBranchModelImpl.getOriginalPlid()),
482                                                    
483                                                    layoutBranchModelImpl.getOriginalName()
484                                            };
485    
486                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_N, args);
487                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_P_N, args);
488    
489                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_N,
490                                            new Object[] {
491                                                    Long.valueOf(layoutBranch.getLayoutSetBranchId()),
492                                                    Long.valueOf(layoutBranch.getPlid()),
493                                                    
494                                            layoutBranch.getName()
495                                            }, layoutBranch);
496                            }
497    
498                            if ((layoutBranchModelImpl.getColumnBitmask() &
499                                            FINDER_PATH_FETCH_BY_L_P_M.getColumnBitmask()) != 0) {
500                                    Object[] args = new Object[] {
501                                                    Long.valueOf(layoutBranchModelImpl.getOriginalLayoutSetBranchId()),
502                                                    Long.valueOf(layoutBranchModelImpl.getOriginalPlid()),
503                                                    Boolean.valueOf(layoutBranchModelImpl.getOriginalMaster())
504                                            };
505    
506                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_M, args);
507                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_P_M, args);
508    
509                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_M,
510                                            new Object[] {
511                                                    Long.valueOf(layoutBranch.getLayoutSetBranchId()),
512                                                    Long.valueOf(layoutBranch.getPlid()),
513                                                    Boolean.valueOf(layoutBranch.getMaster())
514                                            }, layoutBranch);
515                            }
516                    }
517    
518                    return layoutBranch;
519            }
520    
521            protected LayoutBranch toUnwrappedModel(LayoutBranch layoutBranch) {
522                    if (layoutBranch instanceof LayoutBranchImpl) {
523                            return layoutBranch;
524                    }
525    
526                    LayoutBranchImpl layoutBranchImpl = new LayoutBranchImpl();
527    
528                    layoutBranchImpl.setNew(layoutBranch.isNew());
529                    layoutBranchImpl.setPrimaryKey(layoutBranch.getPrimaryKey());
530    
531                    layoutBranchImpl.setLayoutBranchId(layoutBranch.getLayoutBranchId());
532                    layoutBranchImpl.setGroupId(layoutBranch.getGroupId());
533                    layoutBranchImpl.setCompanyId(layoutBranch.getCompanyId());
534                    layoutBranchImpl.setUserId(layoutBranch.getUserId());
535                    layoutBranchImpl.setUserName(layoutBranch.getUserName());
536                    layoutBranchImpl.setLayoutSetBranchId(layoutBranch.getLayoutSetBranchId());
537                    layoutBranchImpl.setPlid(layoutBranch.getPlid());
538                    layoutBranchImpl.setName(layoutBranch.getName());
539                    layoutBranchImpl.setDescription(layoutBranch.getDescription());
540                    layoutBranchImpl.setMaster(layoutBranch.isMaster());
541    
542                    return layoutBranchImpl;
543            }
544    
545            /**
546             * Returns the layout branch with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
547             *
548             * @param primaryKey the primary key of the layout branch
549             * @return the layout branch
550             * @throws com.liferay.portal.NoSuchModelException if a layout branch with the primary key could not be found
551             * @throws SystemException if a system exception occurred
552             */
553            @Override
554            public LayoutBranch findByPrimaryKey(Serializable primaryKey)
555                    throws NoSuchModelException, SystemException {
556                    return findByPrimaryKey(((Long)primaryKey).longValue());
557            }
558    
559            /**
560             * Returns the layout branch with the primary key or throws a {@link com.liferay.portal.NoSuchLayoutBranchException} if it could not be found.
561             *
562             * @param LayoutBranchId the primary key of the layout branch
563             * @return the layout branch
564             * @throws com.liferay.portal.NoSuchLayoutBranchException if a layout branch with the primary key could not be found
565             * @throws SystemException if a system exception occurred
566             */
567            public LayoutBranch findByPrimaryKey(long LayoutBranchId)
568                    throws NoSuchLayoutBranchException, SystemException {
569                    LayoutBranch layoutBranch = fetchByPrimaryKey(LayoutBranchId);
570    
571                    if (layoutBranch == null) {
572                            if (_log.isWarnEnabled()) {
573                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + LayoutBranchId);
574                            }
575    
576                            throw new NoSuchLayoutBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
577                                    LayoutBranchId);
578                    }
579    
580                    return layoutBranch;
581            }
582    
583            /**
584             * Returns the layout branch with the primary key or returns <code>null</code> if it could not be found.
585             *
586             * @param primaryKey the primary key of the layout branch
587             * @return the layout branch, or <code>null</code> if a layout branch with the primary key could not be found
588             * @throws SystemException if a system exception occurred
589             */
590            @Override
591            public LayoutBranch fetchByPrimaryKey(Serializable primaryKey)
592                    throws SystemException {
593                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
594            }
595    
596            /**
597             * Returns the layout branch with the primary key or returns <code>null</code> if it could not be found.
598             *
599             * @param LayoutBranchId the primary key of the layout branch
600             * @return the layout branch, or <code>null</code> if a layout branch with the primary key could not be found
601             * @throws SystemException if a system exception occurred
602             */
603            public LayoutBranch fetchByPrimaryKey(long LayoutBranchId)
604                    throws SystemException {
605                    LayoutBranch layoutBranch = (LayoutBranch)EntityCacheUtil.getResult(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
606                                    LayoutBranchImpl.class, LayoutBranchId);
607    
608                    if (layoutBranch == _nullLayoutBranch) {
609                            return null;
610                    }
611    
612                    if (layoutBranch == null) {
613                            Session session = null;
614    
615                            boolean hasException = false;
616    
617                            try {
618                                    session = openSession();
619    
620                                    layoutBranch = (LayoutBranch)session.get(LayoutBranchImpl.class,
621                                                    Long.valueOf(LayoutBranchId));
622                            }
623                            catch (Exception e) {
624                                    hasException = true;
625    
626                                    throw processException(e);
627                            }
628                            finally {
629                                    if (layoutBranch != null) {
630                                            cacheResult(layoutBranch);
631                                    }
632                                    else if (!hasException) {
633                                            EntityCacheUtil.putResult(LayoutBranchModelImpl.ENTITY_CACHE_ENABLED,
634                                                    LayoutBranchImpl.class, LayoutBranchId,
635                                                    _nullLayoutBranch);
636                                    }
637    
638                                    closeSession(session);
639                            }
640                    }
641    
642                    return layoutBranch;
643            }
644    
645            /**
646             * Returns all the layout branchs where layoutSetBranchId = &#63;.
647             *
648             * @param layoutSetBranchId the layout set branch ID
649             * @return the matching layout branchs
650             * @throws SystemException if a system exception occurred
651             */
652            public List<LayoutBranch> findByLayoutSetBranchId(long layoutSetBranchId)
653                    throws SystemException {
654                    return findByLayoutSetBranchId(layoutSetBranchId, QueryUtil.ALL_POS,
655                            QueryUtil.ALL_POS, null);
656            }
657    
658            /**
659             * Returns a range of all the layout branchs where layoutSetBranchId = &#63;.
660             *
661             * <p>
662             * 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.
663             * </p>
664             *
665             * @param layoutSetBranchId the layout set branch ID
666             * @param start the lower bound of the range of layout branchs
667             * @param end the upper bound of the range of layout branchs (not inclusive)
668             * @return the range of matching layout branchs
669             * @throws SystemException if a system exception occurred
670             */
671            public List<LayoutBranch> findByLayoutSetBranchId(long layoutSetBranchId,
672                    int start, int end) throws SystemException {
673                    return findByLayoutSetBranchId(layoutSetBranchId, start, end, null);
674            }
675    
676            /**
677             * Returns an ordered range of all the layout branchs where layoutSetBranchId = &#63;.
678             *
679             * <p>
680             * 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.
681             * </p>
682             *
683             * @param layoutSetBranchId the layout set branch ID
684             * @param start the lower bound of the range of layout branchs
685             * @param end the upper bound of the range of layout branchs (not inclusive)
686             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
687             * @return the ordered range of matching layout branchs
688             * @throws SystemException if a system exception occurred
689             */
690            public List<LayoutBranch> findByLayoutSetBranchId(long layoutSetBranchId,
691                    int start, int end, OrderByComparator orderByComparator)
692                    throws SystemException {
693                    FinderPath finderPath = null;
694                    Object[] finderArgs = null;
695    
696                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
697                                    (orderByComparator == null)) {
698                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
699                            finderArgs = new Object[] { layoutSetBranchId };
700                    }
701                    else {
702                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
703                            finderArgs = new Object[] {
704                                            layoutSetBranchId,
705                                            
706                                            start, end, orderByComparator
707                                    };
708                    }
709    
710                    List<LayoutBranch> list = (List<LayoutBranch>)FinderCacheUtil.getResult(finderPath,
711                                    finderArgs, this);
712    
713                    if (list == null) {
714                            StringBundler query = null;
715    
716                            if (orderByComparator != null) {
717                                    query = new StringBundler(3 +
718                                                    (orderByComparator.getOrderByFields().length * 3));
719                            }
720                            else {
721                                    query = new StringBundler(2);
722                            }
723    
724                            query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE);
725    
726                            query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
727    
728                            if (orderByComparator != null) {
729                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
730                                            orderByComparator);
731                            }
732    
733                            String sql = query.toString();
734    
735                            Session session = null;
736    
737                            try {
738                                    session = openSession();
739    
740                                    Query q = session.createQuery(sql);
741    
742                                    QueryPos qPos = QueryPos.getInstance(q);
743    
744                                    qPos.add(layoutSetBranchId);
745    
746                                    list = (List<LayoutBranch>)QueryUtil.list(q, getDialect(),
747                                                    start, end);
748                            }
749                            catch (Exception e) {
750                                    throw processException(e);
751                            }
752                            finally {
753                                    if (list == null) {
754                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
755                                    }
756                                    else {
757                                            cacheResult(list);
758    
759                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
760                                    }
761    
762                                    closeSession(session);
763                            }
764                    }
765    
766                    return list;
767            }
768    
769            /**
770             * Returns the first layout branch in the ordered set where layoutSetBranchId = &#63;.
771             *
772             * <p>
773             * 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.
774             * </p>
775             *
776             * @param layoutSetBranchId the layout set branch ID
777             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
778             * @return the first matching layout branch
779             * @throws com.liferay.portal.NoSuchLayoutBranchException if a matching layout branch could not be found
780             * @throws SystemException if a system exception occurred
781             */
782            public LayoutBranch findByLayoutSetBranchId_First(long layoutSetBranchId,
783                    OrderByComparator orderByComparator)
784                    throws NoSuchLayoutBranchException, SystemException {
785                    List<LayoutBranch> list = findByLayoutSetBranchId(layoutSetBranchId, 0,
786                                    1, orderByComparator);
787    
788                    if (list.isEmpty()) {
789                            StringBundler msg = new StringBundler(4);
790    
791                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
792    
793                            msg.append("layoutSetBranchId=");
794                            msg.append(layoutSetBranchId);
795    
796                            msg.append(StringPool.CLOSE_CURLY_BRACE);
797    
798                            throw new NoSuchLayoutBranchException(msg.toString());
799                    }
800                    else {
801                            return list.get(0);
802                    }
803            }
804    
805            /**
806             * Returns the last layout branch in the ordered set where layoutSetBranchId = &#63;.
807             *
808             * <p>
809             * 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.
810             * </p>
811             *
812             * @param layoutSetBranchId the layout set branch ID
813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
814             * @return the last matching layout branch
815             * @throws com.liferay.portal.NoSuchLayoutBranchException if a matching layout branch could not be found
816             * @throws SystemException if a system exception occurred
817             */
818            public LayoutBranch findByLayoutSetBranchId_Last(long layoutSetBranchId,
819                    OrderByComparator orderByComparator)
820                    throws NoSuchLayoutBranchException, SystemException {
821                    int count = countByLayoutSetBranchId(layoutSetBranchId);
822    
823                    List<LayoutBranch> list = findByLayoutSetBranchId(layoutSetBranchId,
824                                    count - 1, count, orderByComparator);
825    
826                    if (list.isEmpty()) {
827                            StringBundler msg = new StringBundler(4);
828    
829                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
830    
831                            msg.append("layoutSetBranchId=");
832                            msg.append(layoutSetBranchId);
833    
834                            msg.append(StringPool.CLOSE_CURLY_BRACE);
835    
836                            throw new NoSuchLayoutBranchException(msg.toString());
837                    }
838                    else {
839                            return list.get(0);
840                    }
841            }
842    
843            /**
844             * Returns the layout branchs before and after the current layout branch in the ordered set where layoutSetBranchId = &#63;.
845             *
846             * <p>
847             * 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.
848             * </p>
849             *
850             * @param LayoutBranchId the primary key of the current layout branch
851             * @param layoutSetBranchId the layout set branch ID
852             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
853             * @return the previous, current, and next layout branch
854             * @throws com.liferay.portal.NoSuchLayoutBranchException if a layout branch with the primary key could not be found
855             * @throws SystemException if a system exception occurred
856             */
857            public LayoutBranch[] findByLayoutSetBranchId_PrevAndNext(
858                    long LayoutBranchId, long layoutSetBranchId,
859                    OrderByComparator orderByComparator)
860                    throws NoSuchLayoutBranchException, SystemException {
861                    LayoutBranch layoutBranch = findByPrimaryKey(LayoutBranchId);
862    
863                    Session session = null;
864    
865                    try {
866                            session = openSession();
867    
868                            LayoutBranch[] array = new LayoutBranchImpl[3];
869    
870                            array[0] = getByLayoutSetBranchId_PrevAndNext(session,
871                                            layoutBranch, layoutSetBranchId, orderByComparator, true);
872    
873                            array[1] = layoutBranch;
874    
875                            array[2] = getByLayoutSetBranchId_PrevAndNext(session,
876                                            layoutBranch, layoutSetBranchId, orderByComparator, false);
877    
878                            return array;
879                    }
880                    catch (Exception e) {
881                            throw processException(e);
882                    }
883                    finally {
884                            closeSession(session);
885                    }
886            }
887    
888            protected LayoutBranch getByLayoutSetBranchId_PrevAndNext(Session session,
889                    LayoutBranch layoutBranch, long layoutSetBranchId,
890                    OrderByComparator orderByComparator, boolean previous) {
891                    StringBundler query = null;
892    
893                    if (orderByComparator != null) {
894                            query = new StringBundler(6 +
895                                            (orderByComparator.getOrderByFields().length * 6));
896                    }
897                    else {
898                            query = new StringBundler(3);
899                    }
900    
901                    query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE);
902    
903                    query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
904    
905                    if (orderByComparator != null) {
906                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
907    
908                            if (orderByConditionFields.length > 0) {
909                                    query.append(WHERE_AND);
910                            }
911    
912                            for (int i = 0; i < orderByConditionFields.length; i++) {
913                                    query.append(_ORDER_BY_ENTITY_ALIAS);
914                                    query.append(orderByConditionFields[i]);
915    
916                                    if ((i + 1) < orderByConditionFields.length) {
917                                            if (orderByComparator.isAscending() ^ previous) {
918                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
919                                            }
920                                            else {
921                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
922                                            }
923                                    }
924                                    else {
925                                            if (orderByComparator.isAscending() ^ previous) {
926                                                    query.append(WHERE_GREATER_THAN);
927                                            }
928                                            else {
929                                                    query.append(WHERE_LESSER_THAN);
930                                            }
931                                    }
932                            }
933    
934                            query.append(ORDER_BY_CLAUSE);
935    
936                            String[] orderByFields = orderByComparator.getOrderByFields();
937    
938                            for (int i = 0; i < orderByFields.length; i++) {
939                                    query.append(_ORDER_BY_ENTITY_ALIAS);
940                                    query.append(orderByFields[i]);
941    
942                                    if ((i + 1) < orderByFields.length) {
943                                            if (orderByComparator.isAscending() ^ previous) {
944                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
945                                            }
946                                            else {
947                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
948                                            }
949                                    }
950                                    else {
951                                            if (orderByComparator.isAscending() ^ previous) {
952                                                    query.append(ORDER_BY_ASC);
953                                            }
954                                            else {
955                                                    query.append(ORDER_BY_DESC);
956                                            }
957                                    }
958                            }
959                    }
960    
961                    String sql = query.toString();
962    
963                    Query q = session.createQuery(sql);
964    
965                    q.setFirstResult(0);
966                    q.setMaxResults(2);
967    
968                    QueryPos qPos = QueryPos.getInstance(q);
969    
970                    qPos.add(layoutSetBranchId);
971    
972                    if (orderByComparator != null) {
973                            Object[] values = orderByComparator.getOrderByConditionValues(layoutBranch);
974    
975                            for (Object value : values) {
976                                    qPos.add(value);
977                            }
978                    }
979    
980                    List<LayoutBranch> list = q.list();
981    
982                    if (list.size() == 2) {
983                            return list.get(1);
984                    }
985                    else {
986                            return null;
987                    }
988            }
989    
990            /**
991             * Returns all the layout branchs where layoutSetBranchId = &#63; and plid = &#63;.
992             *
993             * @param layoutSetBranchId the layout set branch ID
994             * @param plid the plid
995             * @return the matching layout branchs
996             * @throws SystemException if a system exception occurred
997             */
998            public List<LayoutBranch> findByL_P(long layoutSetBranchId, long plid)
999                    throws SystemException {
1000                    return findByL_P(layoutSetBranchId, plid, QueryUtil.ALL_POS,
1001                            QueryUtil.ALL_POS, null);
1002            }
1003    
1004            /**
1005             * Returns a range of all the layout branchs where layoutSetBranchId = &#63; and plid = &#63;.
1006             *
1007             * <p>
1008             * 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.
1009             * </p>
1010             *
1011             * @param layoutSetBranchId the layout set branch ID
1012             * @param plid the plid
1013             * @param start the lower bound of the range of layout branchs
1014             * @param end the upper bound of the range of layout branchs (not inclusive)
1015             * @return the range of matching layout branchs
1016             * @throws SystemException if a system exception occurred
1017             */
1018            public List<LayoutBranch> findByL_P(long layoutSetBranchId, long plid,
1019                    int start, int end) throws SystemException {
1020                    return findByL_P(layoutSetBranchId, plid, start, end, null);
1021            }
1022    
1023            /**
1024             * Returns an ordered range of all the layout branchs where layoutSetBranchId = &#63; and plid = &#63;.
1025             *
1026             * <p>
1027             * 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.
1028             * </p>
1029             *
1030             * @param layoutSetBranchId the layout set branch ID
1031             * @param plid the plid
1032             * @param start the lower bound of the range of layout branchs
1033             * @param end the upper bound of the range of layout branchs (not inclusive)
1034             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1035             * @return the ordered range of matching layout branchs
1036             * @throws SystemException if a system exception occurred
1037             */
1038            public List<LayoutBranch> findByL_P(long layoutSetBranchId, long plid,
1039                    int start, int end, OrderByComparator orderByComparator)
1040                    throws SystemException {
1041                    FinderPath finderPath = null;
1042                    Object[] finderArgs = null;
1043    
1044                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1045                                    (orderByComparator == null)) {
1046                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P;
1047                            finderArgs = new Object[] { layoutSetBranchId, plid };
1048                    }
1049                    else {
1050                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P;
1051                            finderArgs = new Object[] {
1052                                            layoutSetBranchId, plid,
1053                                            
1054                                            start, end, orderByComparator
1055                                    };
1056                    }
1057    
1058                    List<LayoutBranch> list = (List<LayoutBranch>)FinderCacheUtil.getResult(finderPath,
1059                                    finderArgs, this);
1060    
1061                    if (list == null) {
1062                            StringBundler query = null;
1063    
1064                            if (orderByComparator != null) {
1065                                    query = new StringBundler(4 +
1066                                                    (orderByComparator.getOrderByFields().length * 3));
1067                            }
1068                            else {
1069                                    query = new StringBundler(3);
1070                            }
1071    
1072                            query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE);
1073    
1074                            query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
1075    
1076                            query.append(_FINDER_COLUMN_L_P_PLID_2);
1077    
1078                            if (orderByComparator != null) {
1079                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1080                                            orderByComparator);
1081                            }
1082    
1083                            String sql = query.toString();
1084    
1085                            Session session = null;
1086    
1087                            try {
1088                                    session = openSession();
1089    
1090                                    Query q = session.createQuery(sql);
1091    
1092                                    QueryPos qPos = QueryPos.getInstance(q);
1093    
1094                                    qPos.add(layoutSetBranchId);
1095    
1096                                    qPos.add(plid);
1097    
1098                                    list = (List<LayoutBranch>)QueryUtil.list(q, getDialect(),
1099                                                    start, end);
1100                            }
1101                            catch (Exception e) {
1102                                    throw processException(e);
1103                            }
1104                            finally {
1105                                    if (list == null) {
1106                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1107                                    }
1108                                    else {
1109                                            cacheResult(list);
1110    
1111                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1112                                    }
1113    
1114                                    closeSession(session);
1115                            }
1116                    }
1117    
1118                    return list;
1119            }
1120    
1121            /**
1122             * Returns the first layout branch in the ordered set where layoutSetBranchId = &#63; and plid = &#63;.
1123             *
1124             * <p>
1125             * 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.
1126             * </p>
1127             *
1128             * @param layoutSetBranchId the layout set branch ID
1129             * @param plid the plid
1130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1131             * @return the first matching layout branch
1132             * @throws com.liferay.portal.NoSuchLayoutBranchException if a matching layout branch could not be found
1133             * @throws SystemException if a system exception occurred
1134             */
1135            public LayoutBranch findByL_P_First(long layoutSetBranchId, long plid,
1136                    OrderByComparator orderByComparator)
1137                    throws NoSuchLayoutBranchException, SystemException {
1138                    List<LayoutBranch> list = findByL_P(layoutSetBranchId, plid, 0, 1,
1139                                    orderByComparator);
1140    
1141                    if (list.isEmpty()) {
1142                            StringBundler msg = new StringBundler(6);
1143    
1144                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1145    
1146                            msg.append("layoutSetBranchId=");
1147                            msg.append(layoutSetBranchId);
1148    
1149                            msg.append(", plid=");
1150                            msg.append(plid);
1151    
1152                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1153    
1154                            throw new NoSuchLayoutBranchException(msg.toString());
1155                    }
1156                    else {
1157                            return list.get(0);
1158                    }
1159            }
1160    
1161            /**
1162             * Returns the last layout branch in the ordered set where layoutSetBranchId = &#63; and plid = &#63;.
1163             *
1164             * <p>
1165             * 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.
1166             * </p>
1167             *
1168             * @param layoutSetBranchId the layout set branch ID
1169             * @param plid the plid
1170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1171             * @return the last matching layout branch
1172             * @throws com.liferay.portal.NoSuchLayoutBranchException if a matching layout branch could not be found
1173             * @throws SystemException if a system exception occurred
1174             */
1175            public LayoutBranch findByL_P_Last(long layoutSetBranchId, long plid,
1176                    OrderByComparator orderByComparator)
1177                    throws NoSuchLayoutBranchException, SystemException {
1178                    int count = countByL_P(layoutSetBranchId, plid);
1179    
1180                    List<LayoutBranch> list = findByL_P(layoutSetBranchId, plid, count - 1,
1181                                    count, orderByComparator);
1182    
1183                    if (list.isEmpty()) {
1184                            StringBundler msg = new StringBundler(6);
1185    
1186                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1187    
1188                            msg.append("layoutSetBranchId=");
1189                            msg.append(layoutSetBranchId);
1190    
1191                            msg.append(", plid=");
1192                            msg.append(plid);
1193    
1194                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1195    
1196                            throw new NoSuchLayoutBranchException(msg.toString());
1197                    }
1198                    else {
1199                            return list.get(0);
1200                    }
1201            }
1202    
1203            /**
1204             * Returns the layout branchs before and after the current layout branch in the ordered set where layoutSetBranchId = &#63; and plid = &#63;.
1205             *
1206             * <p>
1207             * 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.
1208             * </p>
1209             *
1210             * @param LayoutBranchId the primary key of the current layout branch
1211             * @param layoutSetBranchId the layout set branch ID
1212             * @param plid the plid
1213             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1214             * @return the previous, current, and next layout branch
1215             * @throws com.liferay.portal.NoSuchLayoutBranchException if a layout branch with the primary key could not be found
1216             * @throws SystemException if a system exception occurred
1217             */
1218            public LayoutBranch[] findByL_P_PrevAndNext(long LayoutBranchId,
1219                    long layoutSetBranchId, long plid, OrderByComparator orderByComparator)
1220                    throws NoSuchLayoutBranchException, SystemException {
1221                    LayoutBranch layoutBranch = findByPrimaryKey(LayoutBranchId);
1222    
1223                    Session session = null;
1224    
1225                    try {
1226                            session = openSession();
1227    
1228                            LayoutBranch[] array = new LayoutBranchImpl[3];
1229    
1230                            array[0] = getByL_P_PrevAndNext(session, layoutBranch,
1231                                            layoutSetBranchId, plid, orderByComparator, true);
1232    
1233                            array[1] = layoutBranch;
1234    
1235                            array[2] = getByL_P_PrevAndNext(session, layoutBranch,
1236                                            layoutSetBranchId, plid, orderByComparator, false);
1237    
1238                            return array;
1239                    }
1240                    catch (Exception e) {
1241                            throw processException(e);
1242                    }
1243                    finally {
1244                            closeSession(session);
1245                    }
1246            }
1247    
1248            protected LayoutBranch getByL_P_PrevAndNext(Session session,
1249                    LayoutBranch layoutBranch, long layoutSetBranchId, long plid,
1250                    OrderByComparator orderByComparator, boolean previous) {
1251                    StringBundler query = null;
1252    
1253                    if (orderByComparator != null) {
1254                            query = new StringBundler(6 +
1255                                            (orderByComparator.getOrderByFields().length * 6));
1256                    }
1257                    else {
1258                            query = new StringBundler(3);
1259                    }
1260    
1261                    query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE);
1262    
1263                    query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
1264    
1265                    query.append(_FINDER_COLUMN_L_P_PLID_2);
1266    
1267                    if (orderByComparator != null) {
1268                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1269    
1270                            if (orderByConditionFields.length > 0) {
1271                                    query.append(WHERE_AND);
1272                            }
1273    
1274                            for (int i = 0; i < orderByConditionFields.length; i++) {
1275                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1276                                    query.append(orderByConditionFields[i]);
1277    
1278                                    if ((i + 1) < orderByConditionFields.length) {
1279                                            if (orderByComparator.isAscending() ^ previous) {
1280                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1281                                            }
1282                                            else {
1283                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1284                                            }
1285                                    }
1286                                    else {
1287                                            if (orderByComparator.isAscending() ^ previous) {
1288                                                    query.append(WHERE_GREATER_THAN);
1289                                            }
1290                                            else {
1291                                                    query.append(WHERE_LESSER_THAN);
1292                                            }
1293                                    }
1294                            }
1295    
1296                            query.append(ORDER_BY_CLAUSE);
1297    
1298                            String[] orderByFields = orderByComparator.getOrderByFields();
1299    
1300                            for (int i = 0; i < orderByFields.length; i++) {
1301                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1302                                    query.append(orderByFields[i]);
1303    
1304                                    if ((i + 1) < orderByFields.length) {
1305                                            if (orderByComparator.isAscending() ^ previous) {
1306                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1307                                            }
1308                                            else {
1309                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1310                                            }
1311                                    }
1312                                    else {
1313                                            if (orderByComparator.isAscending() ^ previous) {
1314                                                    query.append(ORDER_BY_ASC);
1315                                            }
1316                                            else {
1317                                                    query.append(ORDER_BY_DESC);
1318                                            }
1319                                    }
1320                            }
1321                    }
1322    
1323                    String sql = query.toString();
1324    
1325                    Query q = session.createQuery(sql);
1326    
1327                    q.setFirstResult(0);
1328                    q.setMaxResults(2);
1329    
1330                    QueryPos qPos = QueryPos.getInstance(q);
1331    
1332                    qPos.add(layoutSetBranchId);
1333    
1334                    qPos.add(plid);
1335    
1336                    if (orderByComparator != null) {
1337                            Object[] values = orderByComparator.getOrderByConditionValues(layoutBranch);
1338    
1339                            for (Object value : values) {
1340                                    qPos.add(value);
1341                            }
1342                    }
1343    
1344                    List<LayoutBranch> list = q.list();
1345    
1346                    if (list.size() == 2) {
1347                            return list.get(1);
1348                    }
1349                    else {
1350                            return null;
1351                    }
1352            }
1353    
1354            /**
1355             * Returns the layout branch where layoutSetBranchId = &#63; and plid = &#63; and name = &#63; or throws a {@link com.liferay.portal.NoSuchLayoutBranchException} if it could not be found.
1356             *
1357             * @param layoutSetBranchId the layout set branch ID
1358             * @param plid the plid
1359             * @param name the name
1360             * @return the matching layout branch
1361             * @throws com.liferay.portal.NoSuchLayoutBranchException if a matching layout branch could not be found
1362             * @throws SystemException if a system exception occurred
1363             */
1364            public LayoutBranch findByL_P_N(long layoutSetBranchId, long plid,
1365                    String name) throws NoSuchLayoutBranchException, SystemException {
1366                    LayoutBranch layoutBranch = fetchByL_P_N(layoutSetBranchId, plid, name);
1367    
1368                    if (layoutBranch == null) {
1369                            StringBundler msg = new StringBundler(8);
1370    
1371                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1372    
1373                            msg.append("layoutSetBranchId=");
1374                            msg.append(layoutSetBranchId);
1375    
1376                            msg.append(", plid=");
1377                            msg.append(plid);
1378    
1379                            msg.append(", name=");
1380                            msg.append(name);
1381    
1382                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1383    
1384                            if (_log.isWarnEnabled()) {
1385                                    _log.warn(msg.toString());
1386                            }
1387    
1388                            throw new NoSuchLayoutBranchException(msg.toString());
1389                    }
1390    
1391                    return layoutBranch;
1392            }
1393    
1394            /**
1395             * Returns the layout branch where layoutSetBranchId = &#63; and plid = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1396             *
1397             * @param layoutSetBranchId the layout set branch ID
1398             * @param plid the plid
1399             * @param name the name
1400             * @return the matching layout branch, or <code>null</code> if a matching layout branch could not be found
1401             * @throws SystemException if a system exception occurred
1402             */
1403            public LayoutBranch fetchByL_P_N(long layoutSetBranchId, long plid,
1404                    String name) throws SystemException {
1405                    return fetchByL_P_N(layoutSetBranchId, plid, name, true);
1406            }
1407    
1408            /**
1409             * Returns the layout branch where layoutSetBranchId = &#63; and plid = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1410             *
1411             * @param layoutSetBranchId the layout set branch ID
1412             * @param plid the plid
1413             * @param name the name
1414             * @param retrieveFromCache whether to use the finder cache
1415             * @return the matching layout branch, or <code>null</code> if a matching layout branch could not be found
1416             * @throws SystemException if a system exception occurred
1417             */
1418            public LayoutBranch fetchByL_P_N(long layoutSetBranchId, long plid,
1419                    String name, boolean retrieveFromCache) throws SystemException {
1420                    Object[] finderArgs = new Object[] { layoutSetBranchId, plid, name };
1421    
1422                    Object result = null;
1423    
1424                    if (retrieveFromCache) {
1425                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_L_P_N,
1426                                            finderArgs, this);
1427                    }
1428    
1429                    if (result == null) {
1430                            StringBundler query = new StringBundler(4);
1431    
1432                            query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE);
1433    
1434                            query.append(_FINDER_COLUMN_L_P_N_LAYOUTSETBRANCHID_2);
1435    
1436                            query.append(_FINDER_COLUMN_L_P_N_PLID_2);
1437    
1438                            if (name == null) {
1439                                    query.append(_FINDER_COLUMN_L_P_N_NAME_1);
1440                            }
1441                            else {
1442                                    if (name.equals(StringPool.BLANK)) {
1443                                            query.append(_FINDER_COLUMN_L_P_N_NAME_3);
1444                                    }
1445                                    else {
1446                                            query.append(_FINDER_COLUMN_L_P_N_NAME_2);
1447                                    }
1448                            }
1449    
1450                            String sql = query.toString();
1451    
1452                            Session session = null;
1453    
1454                            try {
1455                                    session = openSession();
1456    
1457                                    Query q = session.createQuery(sql);
1458    
1459                                    QueryPos qPos = QueryPos.getInstance(q);
1460    
1461                                    qPos.add(layoutSetBranchId);
1462    
1463                                    qPos.add(plid);
1464    
1465                                    if (name != null) {
1466                                            qPos.add(name);
1467                                    }
1468    
1469                                    List<LayoutBranch> list = q.list();
1470    
1471                                    result = list;
1472    
1473                                    LayoutBranch layoutBranch = null;
1474    
1475                                    if (list.isEmpty()) {
1476                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_N,
1477                                                    finderArgs, list);
1478                                    }
1479                                    else {
1480                                            layoutBranch = list.get(0);
1481    
1482                                            cacheResult(layoutBranch);
1483    
1484                                            if ((layoutBranch.getLayoutSetBranchId() != layoutSetBranchId) ||
1485                                                            (layoutBranch.getPlid() != plid) ||
1486                                                            (layoutBranch.getName() == null) ||
1487                                                            !layoutBranch.getName().equals(name)) {
1488                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_N,
1489                                                            finderArgs, layoutBranch);
1490                                            }
1491                                    }
1492    
1493                                    return layoutBranch;
1494                            }
1495                            catch (Exception e) {
1496                                    throw processException(e);
1497                            }
1498                            finally {
1499                                    if (result == null) {
1500                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_P_N,
1501                                                    finderArgs);
1502                                    }
1503    
1504                                    closeSession(session);
1505                            }
1506                    }
1507                    else {
1508                            if (result instanceof List<?>) {
1509                                    return null;
1510                            }
1511                            else {
1512                                    return (LayoutBranch)result;
1513                            }
1514                    }
1515            }
1516    
1517            /**
1518             * Returns the layout branch where layoutSetBranchId = &#63; and plid = &#63; and master = &#63; or throws a {@link com.liferay.portal.NoSuchLayoutBranchException} if it could not be found.
1519             *
1520             * @param layoutSetBranchId the layout set branch ID
1521             * @param plid the plid
1522             * @param master the master
1523             * @return the matching layout branch
1524             * @throws com.liferay.portal.NoSuchLayoutBranchException if a matching layout branch could not be found
1525             * @throws SystemException if a system exception occurred
1526             */
1527            public LayoutBranch findByL_P_M(long layoutSetBranchId, long plid,
1528                    boolean master) throws NoSuchLayoutBranchException, SystemException {
1529                    LayoutBranch layoutBranch = fetchByL_P_M(layoutSetBranchId, plid, master);
1530    
1531                    if (layoutBranch == null) {
1532                            StringBundler msg = new StringBundler(8);
1533    
1534                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1535    
1536                            msg.append("layoutSetBranchId=");
1537                            msg.append(layoutSetBranchId);
1538    
1539                            msg.append(", plid=");
1540                            msg.append(plid);
1541    
1542                            msg.append(", master=");
1543                            msg.append(master);
1544    
1545                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1546    
1547                            if (_log.isWarnEnabled()) {
1548                                    _log.warn(msg.toString());
1549                            }
1550    
1551                            throw new NoSuchLayoutBranchException(msg.toString());
1552                    }
1553    
1554                    return layoutBranch;
1555            }
1556    
1557            /**
1558             * Returns the layout branch where layoutSetBranchId = &#63; and plid = &#63; and master = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1559             *
1560             * @param layoutSetBranchId the layout set branch ID
1561             * @param plid the plid
1562             * @param master the master
1563             * @return the matching layout branch, or <code>null</code> if a matching layout branch could not be found
1564             * @throws SystemException if a system exception occurred
1565             */
1566            public LayoutBranch fetchByL_P_M(long layoutSetBranchId, long plid,
1567                    boolean master) throws SystemException {
1568                    return fetchByL_P_M(layoutSetBranchId, plid, master, true);
1569            }
1570    
1571            /**
1572             * Returns the layout branch where layoutSetBranchId = &#63; and plid = &#63; and master = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1573             *
1574             * @param layoutSetBranchId the layout set branch ID
1575             * @param plid the plid
1576             * @param master the master
1577             * @param retrieveFromCache whether to use the finder cache
1578             * @return the matching layout branch, or <code>null</code> if a matching layout branch could not be found
1579             * @throws SystemException if a system exception occurred
1580             */
1581            public LayoutBranch fetchByL_P_M(long layoutSetBranchId, long plid,
1582                    boolean master, boolean retrieveFromCache) throws SystemException {
1583                    Object[] finderArgs = new Object[] { layoutSetBranchId, plid, master };
1584    
1585                    Object result = null;
1586    
1587                    if (retrieveFromCache) {
1588                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_L_P_M,
1589                                            finderArgs, this);
1590                    }
1591    
1592                    if (result == null) {
1593                            StringBundler query = new StringBundler(4);
1594    
1595                            query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE);
1596    
1597                            query.append(_FINDER_COLUMN_L_P_M_LAYOUTSETBRANCHID_2);
1598    
1599                            query.append(_FINDER_COLUMN_L_P_M_PLID_2);
1600    
1601                            query.append(_FINDER_COLUMN_L_P_M_MASTER_2);
1602    
1603                            String sql = query.toString();
1604    
1605                            Session session = null;
1606    
1607                            try {
1608                                    session = openSession();
1609    
1610                                    Query q = session.createQuery(sql);
1611    
1612                                    QueryPos qPos = QueryPos.getInstance(q);
1613    
1614                                    qPos.add(layoutSetBranchId);
1615    
1616                                    qPos.add(plid);
1617    
1618                                    qPos.add(master);
1619    
1620                                    List<LayoutBranch> list = q.list();
1621    
1622                                    result = list;
1623    
1624                                    LayoutBranch layoutBranch = null;
1625    
1626                                    if (list.isEmpty()) {
1627                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_M,
1628                                                    finderArgs, list);
1629                                    }
1630                                    else {
1631                                            layoutBranch = list.get(0);
1632    
1633                                            cacheResult(layoutBranch);
1634    
1635                                            if ((layoutBranch.getLayoutSetBranchId() != layoutSetBranchId) ||
1636                                                            (layoutBranch.getPlid() != plid) ||
1637                                                            (layoutBranch.getMaster() != master)) {
1638                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_P_M,
1639                                                            finderArgs, layoutBranch);
1640                                            }
1641                                    }
1642    
1643                                    return layoutBranch;
1644                            }
1645                            catch (Exception e) {
1646                                    throw processException(e);
1647                            }
1648                            finally {
1649                                    if (result == null) {
1650                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_P_M,
1651                                                    finderArgs);
1652                                    }
1653    
1654                                    closeSession(session);
1655                            }
1656                    }
1657                    else {
1658                            if (result instanceof List<?>) {
1659                                    return null;
1660                            }
1661                            else {
1662                                    return (LayoutBranch)result;
1663                            }
1664                    }
1665            }
1666    
1667            /**
1668             * Returns all the layout branchs.
1669             *
1670             * @return the layout branchs
1671             * @throws SystemException if a system exception occurred
1672             */
1673            public List<LayoutBranch> findAll() throws SystemException {
1674                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1675            }
1676    
1677            /**
1678             * Returns a range of all the layout branchs.
1679             *
1680             * <p>
1681             * 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.
1682             * </p>
1683             *
1684             * @param start the lower bound of the range of layout branchs
1685             * @param end the upper bound of the range of layout branchs (not inclusive)
1686             * @return the range of layout branchs
1687             * @throws SystemException if a system exception occurred
1688             */
1689            public List<LayoutBranch> findAll(int start, int end)
1690                    throws SystemException {
1691                    return findAll(start, end, null);
1692            }
1693    
1694            /**
1695             * Returns an ordered range of all the layout branchs.
1696             *
1697             * <p>
1698             * 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.
1699             * </p>
1700             *
1701             * @param start the lower bound of the range of layout branchs
1702             * @param end the upper bound of the range of layout branchs (not inclusive)
1703             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1704             * @return the ordered range of layout branchs
1705             * @throws SystemException if a system exception occurred
1706             */
1707            public List<LayoutBranch> findAll(int start, int end,
1708                    OrderByComparator orderByComparator) throws SystemException {
1709                    FinderPath finderPath = null;
1710                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1711    
1712                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1713                                    (orderByComparator == null)) {
1714                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1715                            finderArgs = FINDER_ARGS_EMPTY;
1716                    }
1717                    else {
1718                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1719                            finderArgs = new Object[] { start, end, orderByComparator };
1720                    }
1721    
1722                    List<LayoutBranch> list = (List<LayoutBranch>)FinderCacheUtil.getResult(finderPath,
1723                                    finderArgs, this);
1724    
1725                    if (list == null) {
1726                            StringBundler query = null;
1727                            String sql = null;
1728    
1729                            if (orderByComparator != null) {
1730                                    query = new StringBundler(2 +
1731                                                    (orderByComparator.getOrderByFields().length * 3));
1732    
1733                                    query.append(_SQL_SELECT_LAYOUTBRANCH);
1734    
1735                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1736                                            orderByComparator);
1737    
1738                                    sql = query.toString();
1739                            }
1740                            else {
1741                                    sql = _SQL_SELECT_LAYOUTBRANCH;
1742                            }
1743    
1744                            Session session = null;
1745    
1746                            try {
1747                                    session = openSession();
1748    
1749                                    Query q = session.createQuery(sql);
1750    
1751                                    if (orderByComparator == null) {
1752                                            list = (List<LayoutBranch>)QueryUtil.list(q, getDialect(),
1753                                                            start, end, false);
1754    
1755                                            Collections.sort(list);
1756                                    }
1757                                    else {
1758                                            list = (List<LayoutBranch>)QueryUtil.list(q, getDialect(),
1759                                                            start, end);
1760                                    }
1761                            }
1762                            catch (Exception e) {
1763                                    throw processException(e);
1764                            }
1765                            finally {
1766                                    if (list == null) {
1767                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1768                                    }
1769                                    else {
1770                                            cacheResult(list);
1771    
1772                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1773                                    }
1774    
1775                                    closeSession(session);
1776                            }
1777                    }
1778    
1779                    return list;
1780            }
1781    
1782            /**
1783             * Removes all the layout branchs where layoutSetBranchId = &#63; from the database.
1784             *
1785             * @param layoutSetBranchId the layout set branch ID
1786             * @throws SystemException if a system exception occurred
1787             */
1788            public void removeByLayoutSetBranchId(long layoutSetBranchId)
1789                    throws SystemException {
1790                    for (LayoutBranch layoutBranch : findByLayoutSetBranchId(
1791                                    layoutSetBranchId)) {
1792                            layoutBranchPersistence.remove(layoutBranch);
1793                    }
1794            }
1795    
1796            /**
1797             * Removes all the layout branchs where layoutSetBranchId = &#63; and plid = &#63; from the database.
1798             *
1799             * @param layoutSetBranchId the layout set branch ID
1800             * @param plid the plid
1801             * @throws SystemException if a system exception occurred
1802             */
1803            public void removeByL_P(long layoutSetBranchId, long plid)
1804                    throws SystemException {
1805                    for (LayoutBranch layoutBranch : findByL_P(layoutSetBranchId, plid)) {
1806                            layoutBranchPersistence.remove(layoutBranch);
1807                    }
1808            }
1809    
1810            /**
1811             * Removes the layout branch where layoutSetBranchId = &#63; and plid = &#63; and name = &#63; from the database.
1812             *
1813             * @param layoutSetBranchId the layout set branch ID
1814             * @param plid the plid
1815             * @param name the name
1816             * @throws SystemException if a system exception occurred
1817             */
1818            public void removeByL_P_N(long layoutSetBranchId, long plid, String name)
1819                    throws NoSuchLayoutBranchException, SystemException {
1820                    LayoutBranch layoutBranch = findByL_P_N(layoutSetBranchId, plid, name);
1821    
1822                    layoutBranchPersistence.remove(layoutBranch);
1823            }
1824    
1825            /**
1826             * Removes the layout branch where layoutSetBranchId = &#63; and plid = &#63; and master = &#63; from the database.
1827             *
1828             * @param layoutSetBranchId the layout set branch ID
1829             * @param plid the plid
1830             * @param master the master
1831             * @throws SystemException if a system exception occurred
1832             */
1833            public void removeByL_P_M(long layoutSetBranchId, long plid, boolean master)
1834                    throws NoSuchLayoutBranchException, SystemException {
1835                    LayoutBranch layoutBranch = findByL_P_M(layoutSetBranchId, plid, master);
1836    
1837                    layoutBranchPersistence.remove(layoutBranch);
1838            }
1839    
1840            /**
1841             * Removes all the layout branchs from the database.
1842             *
1843             * @throws SystemException if a system exception occurred
1844             */
1845            public void removeAll() throws SystemException {
1846                    for (LayoutBranch layoutBranch : findAll()) {
1847                            layoutBranchPersistence.remove(layoutBranch);
1848                    }
1849            }
1850    
1851            /**
1852             * Returns the number of layout branchs where layoutSetBranchId = &#63;.
1853             *
1854             * @param layoutSetBranchId the layout set branch ID
1855             * @return the number of matching layout branchs
1856             * @throws SystemException if a system exception occurred
1857             */
1858            public int countByLayoutSetBranchId(long layoutSetBranchId)
1859                    throws SystemException {
1860                    Object[] finderArgs = new Object[] { layoutSetBranchId };
1861    
1862                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
1863                                    finderArgs, this);
1864    
1865                    if (count == null) {
1866                            StringBundler query = new StringBundler(2);
1867    
1868                            query.append(_SQL_COUNT_LAYOUTBRANCH_WHERE);
1869    
1870                            query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
1871    
1872                            String sql = query.toString();
1873    
1874                            Session session = null;
1875    
1876                            try {
1877                                    session = openSession();
1878    
1879                                    Query q = session.createQuery(sql);
1880    
1881                                    QueryPos qPos = QueryPos.getInstance(q);
1882    
1883                                    qPos.add(layoutSetBranchId);
1884    
1885                                    count = (Long)q.uniqueResult();
1886                            }
1887                            catch (Exception e) {
1888                                    throw processException(e);
1889                            }
1890                            finally {
1891                                    if (count == null) {
1892                                            count = Long.valueOf(0);
1893                                    }
1894    
1895                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
1896                                            finderArgs, count);
1897    
1898                                    closeSession(session);
1899                            }
1900                    }
1901    
1902                    return count.intValue();
1903            }
1904    
1905            /**
1906             * Returns the number of layout branchs where layoutSetBranchId = &#63; and plid = &#63;.
1907             *
1908             * @param layoutSetBranchId the layout set branch ID
1909             * @param plid the plid
1910             * @return the number of matching layout branchs
1911             * @throws SystemException if a system exception occurred
1912             */
1913            public int countByL_P(long layoutSetBranchId, long plid)
1914                    throws SystemException {
1915                    Object[] finderArgs = new Object[] { layoutSetBranchId, plid };
1916    
1917                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P,
1918                                    finderArgs, this);
1919    
1920                    if (count == null) {
1921                            StringBundler query = new StringBundler(3);
1922    
1923                            query.append(_SQL_COUNT_LAYOUTBRANCH_WHERE);
1924    
1925                            query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
1926    
1927                            query.append(_FINDER_COLUMN_L_P_PLID_2);
1928    
1929                            String sql = query.toString();
1930    
1931                            Session session = null;
1932    
1933                            try {
1934                                    session = openSession();
1935    
1936                                    Query q = session.createQuery(sql);
1937    
1938                                    QueryPos qPos = QueryPos.getInstance(q);
1939    
1940                                    qPos.add(layoutSetBranchId);
1941    
1942                                    qPos.add(plid);
1943    
1944                                    count = (Long)q.uniqueResult();
1945                            }
1946                            catch (Exception e) {
1947                                    throw processException(e);
1948                            }
1949                            finally {
1950                                    if (count == null) {
1951                                            count = Long.valueOf(0);
1952                                    }
1953    
1954                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P, finderArgs,
1955                                            count);
1956    
1957                                    closeSession(session);
1958                            }
1959                    }
1960    
1961                    return count.intValue();
1962            }
1963    
1964            /**
1965             * Returns the number of layout branchs where layoutSetBranchId = &#63; and plid = &#63; and name = &#63;.
1966             *
1967             * @param layoutSetBranchId the layout set branch ID
1968             * @param plid the plid
1969             * @param name the name
1970             * @return the number of matching layout branchs
1971             * @throws SystemException if a system exception occurred
1972             */
1973            public int countByL_P_N(long layoutSetBranchId, long plid, String name)
1974                    throws SystemException {
1975                    Object[] finderArgs = new Object[] { layoutSetBranchId, plid, name };
1976    
1977                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P_N,
1978                                    finderArgs, this);
1979    
1980                    if (count == null) {
1981                            StringBundler query = new StringBundler(4);
1982    
1983                            query.append(_SQL_COUNT_LAYOUTBRANCH_WHERE);
1984    
1985                            query.append(_FINDER_COLUMN_L_P_N_LAYOUTSETBRANCHID_2);
1986    
1987                            query.append(_FINDER_COLUMN_L_P_N_PLID_2);
1988    
1989                            if (name == null) {
1990                                    query.append(_FINDER_COLUMN_L_P_N_NAME_1);
1991                            }
1992                            else {
1993                                    if (name.equals(StringPool.BLANK)) {
1994                                            query.append(_FINDER_COLUMN_L_P_N_NAME_3);
1995                                    }
1996                                    else {
1997                                            query.append(_FINDER_COLUMN_L_P_N_NAME_2);
1998                                    }
1999                            }
2000    
2001                            String sql = query.toString();
2002    
2003                            Session session = null;
2004    
2005                            try {
2006                                    session = openSession();
2007    
2008                                    Query q = session.createQuery(sql);
2009    
2010                                    QueryPos qPos = QueryPos.getInstance(q);
2011    
2012                                    qPos.add(layoutSetBranchId);
2013    
2014                                    qPos.add(plid);
2015    
2016                                    if (name != null) {
2017                                            qPos.add(name);
2018                                    }
2019    
2020                                    count = (Long)q.uniqueResult();
2021                            }
2022                            catch (Exception e) {
2023                                    throw processException(e);
2024                            }
2025                            finally {
2026                                    if (count == null) {
2027                                            count = Long.valueOf(0);
2028                                    }
2029    
2030                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P_N,
2031                                            finderArgs, count);
2032    
2033                                    closeSession(session);
2034                            }
2035                    }
2036    
2037                    return count.intValue();
2038            }
2039    
2040            /**
2041             * Returns the number of layout branchs where layoutSetBranchId = &#63; and plid = &#63; and master = &#63;.
2042             *
2043             * @param layoutSetBranchId the layout set branch ID
2044             * @param plid the plid
2045             * @param master the master
2046             * @return the number of matching layout branchs
2047             * @throws SystemException if a system exception occurred
2048             */
2049            public int countByL_P_M(long layoutSetBranchId, long plid, boolean master)
2050                    throws SystemException {
2051                    Object[] finderArgs = new Object[] { layoutSetBranchId, plid, master };
2052    
2053                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P_M,
2054                                    finderArgs, this);
2055    
2056                    if (count == null) {
2057                            StringBundler query = new StringBundler(4);
2058    
2059                            query.append(_SQL_COUNT_LAYOUTBRANCH_WHERE);
2060    
2061                            query.append(_FINDER_COLUMN_L_P_M_LAYOUTSETBRANCHID_2);
2062    
2063                            query.append(_FINDER_COLUMN_L_P_M_PLID_2);
2064    
2065                            query.append(_FINDER_COLUMN_L_P_M_MASTER_2);
2066    
2067                            String sql = query.toString();
2068    
2069                            Session session = null;
2070    
2071                            try {
2072                                    session = openSession();
2073    
2074                                    Query q = session.createQuery(sql);
2075    
2076                                    QueryPos qPos = QueryPos.getInstance(q);
2077    
2078                                    qPos.add(layoutSetBranchId);
2079    
2080                                    qPos.add(plid);
2081    
2082                                    qPos.add(master);
2083    
2084                                    count = (Long)q.uniqueResult();
2085                            }
2086                            catch (Exception e) {
2087                                    throw processException(e);
2088                            }
2089                            finally {
2090                                    if (count == null) {
2091                                            count = Long.valueOf(0);
2092                                    }
2093    
2094                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P_M,
2095                                            finderArgs, count);
2096    
2097                                    closeSession(session);
2098                            }
2099                    }
2100    
2101                    return count.intValue();
2102            }
2103    
2104            /**
2105             * Returns the number of layout branchs.
2106             *
2107             * @return the number of layout branchs
2108             * @throws SystemException if a system exception occurred
2109             */
2110            public int countAll() throws SystemException {
2111                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2112                                    FINDER_ARGS_EMPTY, this);
2113    
2114                    if (count == null) {
2115                            Session session = null;
2116    
2117                            try {
2118                                    session = openSession();
2119    
2120                                    Query q = session.createQuery(_SQL_COUNT_LAYOUTBRANCH);
2121    
2122                                    count = (Long)q.uniqueResult();
2123                            }
2124                            catch (Exception e) {
2125                                    throw processException(e);
2126                            }
2127                            finally {
2128                                    if (count == null) {
2129                                            count = Long.valueOf(0);
2130                                    }
2131    
2132                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2133                                            FINDER_ARGS_EMPTY, count);
2134    
2135                                    closeSession(session);
2136                            }
2137                    }
2138    
2139                    return count.intValue();
2140            }
2141    
2142            /**
2143             * Initializes the layout branch persistence.
2144             */
2145            public void afterPropertiesSet() {
2146                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2147                                            com.liferay.portal.util.PropsUtil.get(
2148                                                    "value.object.listener.com.liferay.portal.model.LayoutBranch")));
2149    
2150                    if (listenerClassNames.length > 0) {
2151                            try {
2152                                    List<ModelListener<LayoutBranch>> listenersList = new ArrayList<ModelListener<LayoutBranch>>();
2153    
2154                                    for (String listenerClassName : listenerClassNames) {
2155                                            listenersList.add((ModelListener<LayoutBranch>)InstanceFactory.newInstance(
2156                                                            listenerClassName));
2157                                    }
2158    
2159                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2160                            }
2161                            catch (Exception e) {
2162                                    _log.error(e);
2163                            }
2164                    }
2165            }
2166    
2167            public void destroy() {
2168                    EntityCacheUtil.removeCache(LayoutBranchImpl.class.getName());
2169                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2170                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2171            }
2172    
2173            @BeanReference(type = AccountPersistence.class)
2174            protected AccountPersistence accountPersistence;
2175            @BeanReference(type = AddressPersistence.class)
2176            protected AddressPersistence addressPersistence;
2177            @BeanReference(type = BrowserTrackerPersistence.class)
2178            protected BrowserTrackerPersistence browserTrackerPersistence;
2179            @BeanReference(type = ClassNamePersistence.class)
2180            protected ClassNamePersistence classNamePersistence;
2181            @BeanReference(type = ClusterGroupPersistence.class)
2182            protected ClusterGroupPersistence clusterGroupPersistence;
2183            @BeanReference(type = CompanyPersistence.class)
2184            protected CompanyPersistence companyPersistence;
2185            @BeanReference(type = ContactPersistence.class)
2186            protected ContactPersistence contactPersistence;
2187            @BeanReference(type = CountryPersistence.class)
2188            protected CountryPersistence countryPersistence;
2189            @BeanReference(type = EmailAddressPersistence.class)
2190            protected EmailAddressPersistence emailAddressPersistence;
2191            @BeanReference(type = GroupPersistence.class)
2192            protected GroupPersistence groupPersistence;
2193            @BeanReference(type = ImagePersistence.class)
2194            protected ImagePersistence imagePersistence;
2195            @BeanReference(type = LayoutPersistence.class)
2196            protected LayoutPersistence layoutPersistence;
2197            @BeanReference(type = LayoutBranchPersistence.class)
2198            protected LayoutBranchPersistence layoutBranchPersistence;
2199            @BeanReference(type = LayoutPrototypePersistence.class)
2200            protected LayoutPrototypePersistence layoutPrototypePersistence;
2201            @BeanReference(type = LayoutRevisionPersistence.class)
2202            protected LayoutRevisionPersistence layoutRevisionPersistence;
2203            @BeanReference(type = LayoutSetPersistence.class)
2204            protected LayoutSetPersistence layoutSetPersistence;
2205            @BeanReference(type = LayoutSetBranchPersistence.class)
2206            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2207            @BeanReference(type = LayoutSetPrototypePersistence.class)
2208            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2209            @BeanReference(type = ListTypePersistence.class)
2210            protected ListTypePersistence listTypePersistence;
2211            @BeanReference(type = LockPersistence.class)
2212            protected LockPersistence lockPersistence;
2213            @BeanReference(type = MembershipRequestPersistence.class)
2214            protected MembershipRequestPersistence membershipRequestPersistence;
2215            @BeanReference(type = OrganizationPersistence.class)
2216            protected OrganizationPersistence organizationPersistence;
2217            @BeanReference(type = OrgGroupPermissionPersistence.class)
2218            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2219            @BeanReference(type = OrgGroupRolePersistence.class)
2220            protected OrgGroupRolePersistence orgGroupRolePersistence;
2221            @BeanReference(type = OrgLaborPersistence.class)
2222            protected OrgLaborPersistence orgLaborPersistence;
2223            @BeanReference(type = PasswordPolicyPersistence.class)
2224            protected PasswordPolicyPersistence passwordPolicyPersistence;
2225            @BeanReference(type = PasswordPolicyRelPersistence.class)
2226            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2227            @BeanReference(type = PasswordTrackerPersistence.class)
2228            protected PasswordTrackerPersistence passwordTrackerPersistence;
2229            @BeanReference(type = PermissionPersistence.class)
2230            protected PermissionPersistence permissionPersistence;
2231            @BeanReference(type = PhonePersistence.class)
2232            protected PhonePersistence phonePersistence;
2233            @BeanReference(type = PluginSettingPersistence.class)
2234            protected PluginSettingPersistence pluginSettingPersistence;
2235            @BeanReference(type = PortalPreferencesPersistence.class)
2236            protected PortalPreferencesPersistence portalPreferencesPersistence;
2237            @BeanReference(type = PortletPersistence.class)
2238            protected PortletPersistence portletPersistence;
2239            @BeanReference(type = PortletItemPersistence.class)
2240            protected PortletItemPersistence portletItemPersistence;
2241            @BeanReference(type = PortletPreferencesPersistence.class)
2242            protected PortletPreferencesPersistence portletPreferencesPersistence;
2243            @BeanReference(type = RegionPersistence.class)
2244            protected RegionPersistence regionPersistence;
2245            @BeanReference(type = ReleasePersistence.class)
2246            protected ReleasePersistence releasePersistence;
2247            @BeanReference(type = RepositoryPersistence.class)
2248            protected RepositoryPersistence repositoryPersistence;
2249            @BeanReference(type = RepositoryEntryPersistence.class)
2250            protected RepositoryEntryPersistence repositoryEntryPersistence;
2251            @BeanReference(type = ResourcePersistence.class)
2252            protected ResourcePersistence resourcePersistence;
2253            @BeanReference(type = ResourceActionPersistence.class)
2254            protected ResourceActionPersistence resourceActionPersistence;
2255            @BeanReference(type = ResourceBlockPersistence.class)
2256            protected ResourceBlockPersistence resourceBlockPersistence;
2257            @BeanReference(type = ResourceBlockPermissionPersistence.class)
2258            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2259            @BeanReference(type = ResourceCodePersistence.class)
2260            protected ResourceCodePersistence resourceCodePersistence;
2261            @BeanReference(type = ResourcePermissionPersistence.class)
2262            protected ResourcePermissionPersistence resourcePermissionPersistence;
2263            @BeanReference(type = ResourceTypePermissionPersistence.class)
2264            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2265            @BeanReference(type = RolePersistence.class)
2266            protected RolePersistence rolePersistence;
2267            @BeanReference(type = ServiceComponentPersistence.class)
2268            protected ServiceComponentPersistence serviceComponentPersistence;
2269            @BeanReference(type = ShardPersistence.class)
2270            protected ShardPersistence shardPersistence;
2271            @BeanReference(type = SubscriptionPersistence.class)
2272            protected SubscriptionPersistence subscriptionPersistence;
2273            @BeanReference(type = TeamPersistence.class)
2274            protected TeamPersistence teamPersistence;
2275            @BeanReference(type = TicketPersistence.class)
2276            protected TicketPersistence ticketPersistence;
2277            @BeanReference(type = UserPersistence.class)
2278            protected UserPersistence userPersistence;
2279            @BeanReference(type = UserGroupPersistence.class)
2280            protected UserGroupPersistence userGroupPersistence;
2281            @BeanReference(type = UserGroupGroupRolePersistence.class)
2282            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2283            @BeanReference(type = UserGroupRolePersistence.class)
2284            protected UserGroupRolePersistence userGroupRolePersistence;
2285            @BeanReference(type = UserIdMapperPersistence.class)
2286            protected UserIdMapperPersistence userIdMapperPersistence;
2287            @BeanReference(type = UserNotificationEventPersistence.class)
2288            protected UserNotificationEventPersistence userNotificationEventPersistence;
2289            @BeanReference(type = UserTrackerPersistence.class)
2290            protected UserTrackerPersistence userTrackerPersistence;
2291            @BeanReference(type = UserTrackerPathPersistence.class)
2292            protected UserTrackerPathPersistence userTrackerPathPersistence;
2293            @BeanReference(type = VirtualHostPersistence.class)
2294            protected VirtualHostPersistence virtualHostPersistence;
2295            @BeanReference(type = WebDAVPropsPersistence.class)
2296            protected WebDAVPropsPersistence webDAVPropsPersistence;
2297            @BeanReference(type = WebsitePersistence.class)
2298            protected WebsitePersistence websitePersistence;
2299            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2300            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2301            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2302            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2303            private static final String _SQL_SELECT_LAYOUTBRANCH = "SELECT layoutBranch FROM LayoutBranch layoutBranch";
2304            private static final String _SQL_SELECT_LAYOUTBRANCH_WHERE = "SELECT layoutBranch FROM LayoutBranch layoutBranch WHERE ";
2305            private static final String _SQL_COUNT_LAYOUTBRANCH = "SELECT COUNT(layoutBranch) FROM LayoutBranch layoutBranch";
2306            private static final String _SQL_COUNT_LAYOUTBRANCH_WHERE = "SELECT COUNT(layoutBranch) FROM LayoutBranch layoutBranch WHERE ";
2307            private static final String _FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2 =
2308                    "layoutBranch.layoutSetBranchId = ?";
2309            private static final String _FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2 = "layoutBranch.layoutSetBranchId = ? AND ";
2310            private static final String _FINDER_COLUMN_L_P_PLID_2 = "layoutBranch.plid = ?";
2311            private static final String _FINDER_COLUMN_L_P_N_LAYOUTSETBRANCHID_2 = "layoutBranch.layoutSetBranchId = ? AND ";
2312            private static final String _FINDER_COLUMN_L_P_N_PLID_2 = "layoutBranch.plid = ? AND ";
2313            private static final String _FINDER_COLUMN_L_P_N_NAME_1 = "layoutBranch.name IS NULL";
2314            private static final String _FINDER_COLUMN_L_P_N_NAME_2 = "layoutBranch.name = ?";
2315            private static final String _FINDER_COLUMN_L_P_N_NAME_3 = "(layoutBranch.name IS NULL OR layoutBranch.name = ?)";
2316            private static final String _FINDER_COLUMN_L_P_M_LAYOUTSETBRANCHID_2 = "layoutBranch.layoutSetBranchId = ? AND ";
2317            private static final String _FINDER_COLUMN_L_P_M_PLID_2 = "layoutBranch.plid = ? AND ";
2318            private static final String _FINDER_COLUMN_L_P_M_MASTER_2 = "layoutBranch.master = ?";
2319            private static final String _ORDER_BY_ENTITY_ALIAS = "layoutBranch.";
2320            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutBranch exists with the primary key ";
2321            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutBranch exists with the key {";
2322            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2323            private static Log _log = LogFactoryUtil.getLog(LayoutBranchPersistenceImpl.class);
2324            private static LayoutBranch _nullLayoutBranch = new LayoutBranchImpl() {
2325                            @Override
2326                            public Object clone() {
2327                                    return this;
2328                            }
2329    
2330                            @Override
2331                            public CacheModel<LayoutBranch> toCacheModel() {
2332                                    return _nullLayoutBranchCacheModel;
2333                            }
2334                    };
2335    
2336            private static CacheModel<LayoutBranch> _nullLayoutBranchCacheModel = new CacheModel<LayoutBranch>() {
2337                            public LayoutBranch toEntityModel() {
2338                                    return _nullLayoutBranch;
2339                            }
2340                    };
2341    }