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