001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchLayoutSetBranchException;
018    import com.liferay.portal.NoSuchModelException;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
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.UnmodifiableList;
038    import com.liferay.portal.kernel.util.Validator;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.LayoutSetBranch;
041    import com.liferay.portal.model.ModelListener;
042    import com.liferay.portal.model.impl.LayoutSetBranchImpl;
043    import com.liferay.portal.model.impl.LayoutSetBranchModelImpl;
044    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    
047    import java.io.Serializable;
048    
049    import java.util.ArrayList;
050    import java.util.Collections;
051    import java.util.List;
052    
053    /**
054     * The persistence implementation for the layout set branch service.
055     *
056     * <p>
057     * Caching information and settings can be found in <code>portal.properties</code>
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see LayoutSetBranchPersistence
062     * @see LayoutSetBranchUtil
063     * @generated
064     */
065    public class LayoutSetBranchPersistenceImpl extends BasePersistenceImpl<LayoutSetBranch>
066            implements LayoutSetBranchPersistence {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link LayoutSetBranchUtil} to access the layout set branch persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
071             */
072            public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetBranchImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List1";
075            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List2";
077            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
078                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
079                            LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
080                            "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
082                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
083                            LayoutSetBranchImpl.class,
084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
086                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
089                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
090                            LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
091                            "findByGroupId",
092                            new String[] {
093                                    Long.class.getName(),
094                                    
095                            Integer.class.getName(), Integer.class.getName(),
096                                    OrderByComparator.class.getName()
097                            });
098            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
099                    new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
100                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
101                            LayoutSetBranchImpl.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
103                            new String[] { Long.class.getName() },
104                            LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
105                            LayoutSetBranchModelImpl.NAME_COLUMN_BITMASK);
106            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
107                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
109                            new String[] { Long.class.getName() });
110    
111            /**
112             * Returns all the layout set branchs where groupId = &#63;.
113             *
114             * @param groupId the group ID
115             * @return the matching layout set branchs
116             * @throws SystemException if a system exception occurred
117             */
118            public List<LayoutSetBranch> findByGroupId(long groupId)
119                    throws SystemException {
120                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121            }
122    
123            /**
124             * Returns a range of all the layout set branchs where groupId = &#63;.
125             *
126             * <p>
127             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
128             * </p>
129             *
130             * @param groupId the group ID
131             * @param start the lower bound of the range of layout set branchs
132             * @param end the upper bound of the range of layout set branchs (not inclusive)
133             * @return the range of matching layout set branchs
134             * @throws SystemException if a system exception occurred
135             */
136            public List<LayoutSetBranch> findByGroupId(long groupId, int start, int end)
137                    throws SystemException {
138                    return findByGroupId(groupId, start, end, null);
139            }
140    
141            /**
142             * Returns an ordered range of all the layout set branchs where groupId = &#63;.
143             *
144             * <p>
145             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
146             * </p>
147             *
148             * @param groupId the group ID
149             * @param start the lower bound of the range of layout set branchs
150             * @param end the upper bound of the range of layout set branchs (not inclusive)
151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
152             * @return the ordered range of matching layout set branchs
153             * @throws SystemException if a system exception occurred
154             */
155            public List<LayoutSetBranch> findByGroupId(long groupId, int start,
156                    int end, OrderByComparator orderByComparator) throws SystemException {
157                    boolean pagination = true;
158                    FinderPath finderPath = null;
159                    Object[] finderArgs = null;
160    
161                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
162                                    (orderByComparator == null)) {
163                            pagination = false;
164                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
165                            finderArgs = new Object[] { groupId };
166                    }
167                    else {
168                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
169                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
170                    }
171    
172                    List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
173                                    finderArgs, this);
174    
175                    if ((list != null) && !list.isEmpty()) {
176                            for (LayoutSetBranch layoutSetBranch : list) {
177                                    if ((groupId != layoutSetBranch.getGroupId())) {
178                                            list = null;
179    
180                                            break;
181                                    }
182                            }
183                    }
184    
185                    if (list == null) {
186                            StringBundler query = null;
187    
188                            if (orderByComparator != null) {
189                                    query = new StringBundler(3 +
190                                                    (orderByComparator.getOrderByFields().length * 3));
191                            }
192                            else {
193                                    query = new StringBundler(3);
194                            }
195    
196                            query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
197    
198                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
199    
200                            if (orderByComparator != null) {
201                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
202                                            orderByComparator);
203                            }
204                            else
205                             if (pagination) {
206                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
207                            }
208    
209                            String sql = query.toString();
210    
211                            Session session = null;
212    
213                            try {
214                                    session = openSession();
215    
216                                    Query q = session.createQuery(sql);
217    
218                                    QueryPos qPos = QueryPos.getInstance(q);
219    
220                                    qPos.add(groupId);
221    
222                                    if (!pagination) {
223                                            list = (List<LayoutSetBranch>)QueryUtil.list(q,
224                                                            getDialect(), start, end, false);
225    
226                                            Collections.sort(list);
227    
228                                            list = new UnmodifiableList<LayoutSetBranch>(list);
229                                    }
230                                    else {
231                                            list = (List<LayoutSetBranch>)QueryUtil.list(q,
232                                                            getDialect(), start, end);
233                                    }
234    
235                                    cacheResult(list);
236    
237                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
238                            }
239                            catch (Exception e) {
240                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
241    
242                                    throw processException(e);
243                            }
244                            finally {
245                                    closeSession(session);
246                            }
247                    }
248    
249                    return list;
250            }
251    
252            /**
253             * Returns the first layout set branch in the ordered set where groupId = &#63;.
254             *
255             * @param groupId the group ID
256             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
257             * @return the first matching layout set branch
258             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a matching layout set branch could not be found
259             * @throws SystemException if a system exception occurred
260             */
261            public LayoutSetBranch findByGroupId_First(long groupId,
262                    OrderByComparator orderByComparator)
263                    throws NoSuchLayoutSetBranchException, SystemException {
264                    LayoutSetBranch layoutSetBranch = fetchByGroupId_First(groupId,
265                                    orderByComparator);
266    
267                    if (layoutSetBranch != null) {
268                            return layoutSetBranch;
269                    }
270    
271                    StringBundler msg = new StringBundler(4);
272    
273                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
274    
275                    msg.append("groupId=");
276                    msg.append(groupId);
277    
278                    msg.append(StringPool.CLOSE_CURLY_BRACE);
279    
280                    throw new NoSuchLayoutSetBranchException(msg.toString());
281            }
282    
283            /**
284             * Returns the first layout set branch in the ordered set where groupId = &#63;.
285             *
286             * @param groupId the group ID
287             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
288             * @return the first matching layout set branch, or <code>null</code> if a matching layout set branch could not be found
289             * @throws SystemException if a system exception occurred
290             */
291            public LayoutSetBranch fetchByGroupId_First(long groupId,
292                    OrderByComparator orderByComparator) throws SystemException {
293                    List<LayoutSetBranch> list = findByGroupId(groupId, 0, 1,
294                                    orderByComparator);
295    
296                    if (!list.isEmpty()) {
297                            return list.get(0);
298                    }
299    
300                    return null;
301            }
302    
303            /**
304             * Returns the last layout set branch in the ordered set where groupId = &#63;.
305             *
306             * @param groupId the group ID
307             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
308             * @return the last matching layout set branch
309             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a matching layout set branch could not be found
310             * @throws SystemException if a system exception occurred
311             */
312            public LayoutSetBranch findByGroupId_Last(long groupId,
313                    OrderByComparator orderByComparator)
314                    throws NoSuchLayoutSetBranchException, SystemException {
315                    LayoutSetBranch layoutSetBranch = fetchByGroupId_Last(groupId,
316                                    orderByComparator);
317    
318                    if (layoutSetBranch != null) {
319                            return layoutSetBranch;
320                    }
321    
322                    StringBundler msg = new StringBundler(4);
323    
324                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
325    
326                    msg.append("groupId=");
327                    msg.append(groupId);
328    
329                    msg.append(StringPool.CLOSE_CURLY_BRACE);
330    
331                    throw new NoSuchLayoutSetBranchException(msg.toString());
332            }
333    
334            /**
335             * Returns the last layout set branch in the ordered set where groupId = &#63;.
336             *
337             * @param groupId the group ID
338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
339             * @return the last matching layout set branch, or <code>null</code> if a matching layout set branch could not be found
340             * @throws SystemException if a system exception occurred
341             */
342            public LayoutSetBranch fetchByGroupId_Last(long groupId,
343                    OrderByComparator orderByComparator) throws SystemException {
344                    int count = countByGroupId(groupId);
345    
346                    List<LayoutSetBranch> list = findByGroupId(groupId, count - 1, count,
347                                    orderByComparator);
348    
349                    if (!list.isEmpty()) {
350                            return list.get(0);
351                    }
352    
353                    return null;
354            }
355    
356            /**
357             * Returns the layout set branchs before and after the current layout set branch in the ordered set where groupId = &#63;.
358             *
359             * @param layoutSetBranchId the primary key of the current layout set branch
360             * @param groupId the group ID
361             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
362             * @return the previous, current, and next layout set branch
363             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a layout set branch with the primary key could not be found
364             * @throws SystemException if a system exception occurred
365             */
366            public LayoutSetBranch[] findByGroupId_PrevAndNext(long layoutSetBranchId,
367                    long groupId, OrderByComparator orderByComparator)
368                    throws NoSuchLayoutSetBranchException, SystemException {
369                    LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
370    
371                    Session session = null;
372    
373                    try {
374                            session = openSession();
375    
376                            LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
377    
378                            array[0] = getByGroupId_PrevAndNext(session, layoutSetBranch,
379                                            groupId, orderByComparator, true);
380    
381                            array[1] = layoutSetBranch;
382    
383                            array[2] = getByGroupId_PrevAndNext(session, layoutSetBranch,
384                                            groupId, orderByComparator, false);
385    
386                            return array;
387                    }
388                    catch (Exception e) {
389                            throw processException(e);
390                    }
391                    finally {
392                            closeSession(session);
393                    }
394            }
395    
396            protected LayoutSetBranch getByGroupId_PrevAndNext(Session session,
397                    LayoutSetBranch layoutSetBranch, long groupId,
398                    OrderByComparator orderByComparator, boolean previous) {
399                    StringBundler query = null;
400    
401                    if (orderByComparator != null) {
402                            query = new StringBundler(6 +
403                                            (orderByComparator.getOrderByFields().length * 6));
404                    }
405                    else {
406                            query = new StringBundler(3);
407                    }
408    
409                    query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
410    
411                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
412    
413                    if (orderByComparator != null) {
414                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
415    
416                            if (orderByConditionFields.length > 0) {
417                                    query.append(WHERE_AND);
418                            }
419    
420                            for (int i = 0; i < orderByConditionFields.length; i++) {
421                                    query.append(_ORDER_BY_ENTITY_ALIAS);
422                                    query.append(orderByConditionFields[i]);
423    
424                                    if ((i + 1) < orderByConditionFields.length) {
425                                            if (orderByComparator.isAscending() ^ previous) {
426                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
427                                            }
428                                            else {
429                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
430                                            }
431                                    }
432                                    else {
433                                            if (orderByComparator.isAscending() ^ previous) {
434                                                    query.append(WHERE_GREATER_THAN);
435                                            }
436                                            else {
437                                                    query.append(WHERE_LESSER_THAN);
438                                            }
439                                    }
440                            }
441    
442                            query.append(ORDER_BY_CLAUSE);
443    
444                            String[] orderByFields = orderByComparator.getOrderByFields();
445    
446                            for (int i = 0; i < orderByFields.length; i++) {
447                                    query.append(_ORDER_BY_ENTITY_ALIAS);
448                                    query.append(orderByFields[i]);
449    
450                                    if ((i + 1) < orderByFields.length) {
451                                            if (orderByComparator.isAscending() ^ previous) {
452                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
453                                            }
454                                            else {
455                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
456                                            }
457                                    }
458                                    else {
459                                            if (orderByComparator.isAscending() ^ previous) {
460                                                    query.append(ORDER_BY_ASC);
461                                            }
462                                            else {
463                                                    query.append(ORDER_BY_DESC);
464                                            }
465                                    }
466                            }
467                    }
468                    else {
469                            query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
470                    }
471    
472                    String sql = query.toString();
473    
474                    Query q = session.createQuery(sql);
475    
476                    q.setFirstResult(0);
477                    q.setMaxResults(2);
478    
479                    QueryPos qPos = QueryPos.getInstance(q);
480    
481                    qPos.add(groupId);
482    
483                    if (orderByComparator != null) {
484                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
485    
486                            for (Object value : values) {
487                                    qPos.add(value);
488                            }
489                    }
490    
491                    List<LayoutSetBranch> list = q.list();
492    
493                    if (list.size() == 2) {
494                            return list.get(1);
495                    }
496                    else {
497                            return null;
498                    }
499            }
500    
501            /**
502             * Returns all the layout set branchs that the user has permission to view where groupId = &#63;.
503             *
504             * @param groupId the group ID
505             * @return the matching layout set branchs that the user has permission to view
506             * @throws SystemException if a system exception occurred
507             */
508            public List<LayoutSetBranch> filterFindByGroupId(long groupId)
509                    throws SystemException {
510                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
511                            QueryUtil.ALL_POS, null);
512            }
513    
514            /**
515             * Returns a range of all the layout set branchs that the user has permission to view where groupId = &#63;.
516             *
517             * <p>
518             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
519             * </p>
520             *
521             * @param groupId the group ID
522             * @param start the lower bound of the range of layout set branchs
523             * @param end the upper bound of the range of layout set branchs (not inclusive)
524             * @return the range of matching layout set branchs that the user has permission to view
525             * @throws SystemException if a system exception occurred
526             */
527            public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
528                    int end) throws SystemException {
529                    return filterFindByGroupId(groupId, start, end, null);
530            }
531    
532            /**
533             * Returns an ordered range of all the layout set branchs that the user has permissions to view where groupId = &#63;.
534             *
535             * <p>
536             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
537             * </p>
538             *
539             * @param groupId the group ID
540             * @param start the lower bound of the range of layout set branchs
541             * @param end the upper bound of the range of layout set branchs (not inclusive)
542             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
543             * @return the ordered range of matching layout set branchs that the user has permission to view
544             * @throws SystemException if a system exception occurred
545             */
546            public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
547                    int end, OrderByComparator orderByComparator) throws SystemException {
548                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
549                            return findByGroupId(groupId, start, end, orderByComparator);
550                    }
551    
552                    StringBundler query = null;
553    
554                    if (orderByComparator != null) {
555                            query = new StringBundler(3 +
556                                            (orderByComparator.getOrderByFields().length * 3));
557                    }
558                    else {
559                            query = new StringBundler(3);
560                    }
561    
562                    if (getDB().isSupportsInlineDistinct()) {
563                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
564                    }
565                    else {
566                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
567                    }
568    
569                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
570    
571                    if (!getDB().isSupportsInlineDistinct()) {
572                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
573                    }
574    
575                    if (orderByComparator != null) {
576                            if (getDB().isSupportsInlineDistinct()) {
577                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
578                                            orderByComparator);
579                            }
580                            else {
581                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
582                                            orderByComparator);
583                            }
584                    }
585                    else {
586                            if (getDB().isSupportsInlineDistinct()) {
587                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
588                            }
589                            else {
590                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
591                            }
592                    }
593    
594                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
595                                    LayoutSetBranch.class.getName(),
596                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
597    
598                    Session session = null;
599    
600                    try {
601                            session = openSession();
602    
603                            SQLQuery q = session.createSQLQuery(sql);
604    
605                            if (getDB().isSupportsInlineDistinct()) {
606                                    q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
607                            }
608                            else {
609                                    q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
610                            }
611    
612                            QueryPos qPos = QueryPos.getInstance(q);
613    
614                            qPos.add(groupId);
615    
616                            return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
617                                    start, end);
618                    }
619                    catch (Exception e) {
620                            throw processException(e);
621                    }
622                    finally {
623                            closeSession(session);
624                    }
625            }
626    
627            /**
628             * Returns the layout set branchs before and after the current layout set branch in the ordered set of layout set branchs that the user has permission to view where groupId = &#63;.
629             *
630             * @param layoutSetBranchId the primary key of the current layout set branch
631             * @param groupId the group ID
632             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
633             * @return the previous, current, and next layout set branch
634             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a layout set branch with the primary key could not be found
635             * @throws SystemException if a system exception occurred
636             */
637            public LayoutSetBranch[] filterFindByGroupId_PrevAndNext(
638                    long layoutSetBranchId, long groupId,
639                    OrderByComparator orderByComparator)
640                    throws NoSuchLayoutSetBranchException, SystemException {
641                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
642                            return findByGroupId_PrevAndNext(layoutSetBranchId, groupId,
643                                    orderByComparator);
644                    }
645    
646                    LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
647    
648                    Session session = null;
649    
650                    try {
651                            session = openSession();
652    
653                            LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
654    
655                            array[0] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
656                                            groupId, orderByComparator, true);
657    
658                            array[1] = layoutSetBranch;
659    
660                            array[2] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
661                                            groupId, orderByComparator, false);
662    
663                            return array;
664                    }
665                    catch (Exception e) {
666                            throw processException(e);
667                    }
668                    finally {
669                            closeSession(session);
670                    }
671            }
672    
673            protected LayoutSetBranch filterGetByGroupId_PrevAndNext(Session session,
674                    LayoutSetBranch layoutSetBranch, long groupId,
675                    OrderByComparator orderByComparator, boolean previous) {
676                    StringBundler query = null;
677    
678                    if (orderByComparator != null) {
679                            query = new StringBundler(6 +
680                                            (orderByComparator.getOrderByFields().length * 6));
681                    }
682                    else {
683                            query = new StringBundler(3);
684                    }
685    
686                    if (getDB().isSupportsInlineDistinct()) {
687                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
688                    }
689                    else {
690                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
691                    }
692    
693                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
694    
695                    if (!getDB().isSupportsInlineDistinct()) {
696                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
697                    }
698    
699                    if (orderByComparator != null) {
700                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
701    
702                            if (orderByConditionFields.length > 0) {
703                                    query.append(WHERE_AND);
704                            }
705    
706                            for (int i = 0; i < orderByConditionFields.length; i++) {
707                                    if (getDB().isSupportsInlineDistinct()) {
708                                            query.append(_ORDER_BY_ENTITY_ALIAS);
709                                    }
710                                    else {
711                                            query.append(_ORDER_BY_ENTITY_TABLE);
712                                    }
713    
714                                    query.append(orderByConditionFields[i]);
715    
716                                    if ((i + 1) < orderByConditionFields.length) {
717                                            if (orderByComparator.isAscending() ^ previous) {
718                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
719                                            }
720                                            else {
721                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
722                                            }
723                                    }
724                                    else {
725                                            if (orderByComparator.isAscending() ^ previous) {
726                                                    query.append(WHERE_GREATER_THAN);
727                                            }
728                                            else {
729                                                    query.append(WHERE_LESSER_THAN);
730                                            }
731                                    }
732                            }
733    
734                            query.append(ORDER_BY_CLAUSE);
735    
736                            String[] orderByFields = orderByComparator.getOrderByFields();
737    
738                            for (int i = 0; i < orderByFields.length; i++) {
739                                    if (getDB().isSupportsInlineDistinct()) {
740                                            query.append(_ORDER_BY_ENTITY_ALIAS);
741                                    }
742                                    else {
743                                            query.append(_ORDER_BY_ENTITY_TABLE);
744                                    }
745    
746                                    query.append(orderByFields[i]);
747    
748                                    if ((i + 1) < orderByFields.length) {
749                                            if (orderByComparator.isAscending() ^ previous) {
750                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
751                                            }
752                                            else {
753                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
754                                            }
755                                    }
756                                    else {
757                                            if (orderByComparator.isAscending() ^ previous) {
758                                                    query.append(ORDER_BY_ASC);
759                                            }
760                                            else {
761                                                    query.append(ORDER_BY_DESC);
762                                            }
763                                    }
764                            }
765                    }
766                    else {
767                            if (getDB().isSupportsInlineDistinct()) {
768                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
769                            }
770                            else {
771                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
772                            }
773                    }
774    
775                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
776                                    LayoutSetBranch.class.getName(),
777                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
778    
779                    SQLQuery q = session.createSQLQuery(sql);
780    
781                    q.setFirstResult(0);
782                    q.setMaxResults(2);
783    
784                    if (getDB().isSupportsInlineDistinct()) {
785                            q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
786                    }
787                    else {
788                            q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
789                    }
790    
791                    QueryPos qPos = QueryPos.getInstance(q);
792    
793                    qPos.add(groupId);
794    
795                    if (orderByComparator != null) {
796                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
797    
798                            for (Object value : values) {
799                                    qPos.add(value);
800                            }
801                    }
802    
803                    List<LayoutSetBranch> list = q.list();
804    
805                    if (list.size() == 2) {
806                            return list.get(1);
807                    }
808                    else {
809                            return null;
810                    }
811            }
812    
813            /**
814             * Removes all the layout set branchs where groupId = &#63; from the database.
815             *
816             * @param groupId the group ID
817             * @throws SystemException if a system exception occurred
818             */
819            public void removeByGroupId(long groupId) throws SystemException {
820                    for (LayoutSetBranch layoutSetBranch : findByGroupId(groupId,
821                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
822                            remove(layoutSetBranch);
823                    }
824            }
825    
826            /**
827             * Returns the number of layout set branchs where groupId = &#63;.
828             *
829             * @param groupId the group ID
830             * @return the number of matching layout set branchs
831             * @throws SystemException if a system exception occurred
832             */
833            public int countByGroupId(long groupId) throws SystemException {
834                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
835    
836                    Object[] finderArgs = new Object[] { groupId };
837    
838                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
839                                    this);
840    
841                    if (count == null) {
842                            StringBundler query = new StringBundler(2);
843    
844                            query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
845    
846                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
847    
848                            String sql = query.toString();
849    
850                            Session session = null;
851    
852                            try {
853                                    session = openSession();
854    
855                                    Query q = session.createQuery(sql);
856    
857                                    QueryPos qPos = QueryPos.getInstance(q);
858    
859                                    qPos.add(groupId);
860    
861                                    count = (Long)q.uniqueResult();
862    
863                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
864                            }
865                            catch (Exception e) {
866                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
867    
868                                    throw processException(e);
869                            }
870                            finally {
871                                    closeSession(session);
872                            }
873                    }
874    
875                    return count.intValue();
876            }
877    
878            /**
879             * Returns the number of layout set branchs that the user has permission to view where groupId = &#63;.
880             *
881             * @param groupId the group ID
882             * @return the number of matching layout set branchs that the user has permission to view
883             * @throws SystemException if a system exception occurred
884             */
885            public int filterCountByGroupId(long groupId) throws SystemException {
886                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
887                            return countByGroupId(groupId);
888                    }
889    
890                    StringBundler query = new StringBundler(2);
891    
892                    query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
893    
894                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
895    
896                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
897                                    LayoutSetBranch.class.getName(),
898                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
899    
900                    Session session = null;
901    
902                    try {
903                            session = openSession();
904    
905                            SQLQuery q = session.createSQLQuery(sql);
906    
907                            q.addScalar(COUNT_COLUMN_NAME,
908                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
909    
910                            QueryPos qPos = QueryPos.getInstance(q);
911    
912                            qPos.add(groupId);
913    
914                            Long count = (Long)q.uniqueResult();
915    
916                            return count.intValue();
917                    }
918                    catch (Exception e) {
919                            throw processException(e);
920                    }
921                    finally {
922                            closeSession(session);
923                    }
924            }
925    
926            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "layoutSetBranch.groupId = ?";
927            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
928                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
929                            LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
930                            "findByG_P",
931                            new String[] {
932                                    Long.class.getName(), Boolean.class.getName(),
933                                    
934                            Integer.class.getName(), Integer.class.getName(),
935                                    OrderByComparator.class.getName()
936                            });
937            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
938                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
939                            LayoutSetBranchImpl.class,
940                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
941                            new String[] { Long.class.getName(), Boolean.class.getName() },
942                            LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
943                            LayoutSetBranchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
944                            LayoutSetBranchModelImpl.NAME_COLUMN_BITMASK);
945            public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
946                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
947                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
948                            new String[] { Long.class.getName(), Boolean.class.getName() });
949    
950            /**
951             * Returns all the layout set branchs where groupId = &#63; and privateLayout = &#63;.
952             *
953             * @param groupId the group ID
954             * @param privateLayout the private layout
955             * @return the matching layout set branchs
956             * @throws SystemException if a system exception occurred
957             */
958            public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout)
959                    throws SystemException {
960                    return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
961                            QueryUtil.ALL_POS, null);
962            }
963    
964            /**
965             * Returns a range of all the layout set branchs where groupId = &#63; and privateLayout = &#63;.
966             *
967             * <p>
968             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
969             * </p>
970             *
971             * @param groupId the group ID
972             * @param privateLayout the private layout
973             * @param start the lower bound of the range of layout set branchs
974             * @param end the upper bound of the range of layout set branchs (not inclusive)
975             * @return the range of matching layout set branchs
976             * @throws SystemException if a system exception occurred
977             */
978            public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
979                    int start, int end) throws SystemException {
980                    return findByG_P(groupId, privateLayout, start, end, null);
981            }
982    
983            /**
984             * Returns an ordered range of all the layout set branchs where groupId = &#63; and privateLayout = &#63;.
985             *
986             * <p>
987             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
988             * </p>
989             *
990             * @param groupId the group ID
991             * @param privateLayout the private layout
992             * @param start the lower bound of the range of layout set branchs
993             * @param end the upper bound of the range of layout set branchs (not inclusive)
994             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
995             * @return the ordered range of matching layout set branchs
996             * @throws SystemException if a system exception occurred
997             */
998            public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
999                    int start, int end, OrderByComparator orderByComparator)
1000                    throws SystemException {
1001                    boolean pagination = true;
1002                    FinderPath finderPath = null;
1003                    Object[] finderArgs = null;
1004    
1005                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1006                                    (orderByComparator == null)) {
1007                            pagination = false;
1008                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1009                            finderArgs = new Object[] { groupId, privateLayout };
1010                    }
1011                    else {
1012                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1013                            finderArgs = new Object[] {
1014                                            groupId, privateLayout,
1015                                            
1016                                            start, end, orderByComparator
1017                                    };
1018                    }
1019    
1020                    List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
1021                                    finderArgs, this);
1022    
1023                    if ((list != null) && !list.isEmpty()) {
1024                            for (LayoutSetBranch layoutSetBranch : list) {
1025                                    if ((groupId != layoutSetBranch.getGroupId()) ||
1026                                                    (privateLayout != layoutSetBranch.getPrivateLayout())) {
1027                                            list = null;
1028    
1029                                            break;
1030                                    }
1031                            }
1032                    }
1033    
1034                    if (list == null) {
1035                            StringBundler query = null;
1036    
1037                            if (orderByComparator != null) {
1038                                    query = new StringBundler(4 +
1039                                                    (orderByComparator.getOrderByFields().length * 3));
1040                            }
1041                            else {
1042                                    query = new StringBundler(4);
1043                            }
1044    
1045                            query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1046    
1047                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1048    
1049                            query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1050    
1051                            if (orderByComparator != null) {
1052                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1053                                            orderByComparator);
1054                            }
1055                            else
1056                             if (pagination) {
1057                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1058                            }
1059    
1060                            String sql = query.toString();
1061    
1062                            Session session = null;
1063    
1064                            try {
1065                                    session = openSession();
1066    
1067                                    Query q = session.createQuery(sql);
1068    
1069                                    QueryPos qPos = QueryPos.getInstance(q);
1070    
1071                                    qPos.add(groupId);
1072    
1073                                    qPos.add(privateLayout);
1074    
1075                                    if (!pagination) {
1076                                            list = (List<LayoutSetBranch>)QueryUtil.list(q,
1077                                                            getDialect(), start, end, false);
1078    
1079                                            Collections.sort(list);
1080    
1081                                            list = new UnmodifiableList<LayoutSetBranch>(list);
1082                                    }
1083                                    else {
1084                                            list = (List<LayoutSetBranch>)QueryUtil.list(q,
1085                                                            getDialect(), start, end);
1086                                    }
1087    
1088                                    cacheResult(list);
1089    
1090                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1091                            }
1092                            catch (Exception e) {
1093                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1094    
1095                                    throw processException(e);
1096                            }
1097                            finally {
1098                                    closeSession(session);
1099                            }
1100                    }
1101    
1102                    return list;
1103            }
1104    
1105            /**
1106             * Returns the first layout set branch in the ordered set where groupId = &#63; and privateLayout = &#63;.
1107             *
1108             * @param groupId the group ID
1109             * @param privateLayout the private layout
1110             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1111             * @return the first matching layout set branch
1112             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a matching layout set branch could not be found
1113             * @throws SystemException if a system exception occurred
1114             */
1115            public LayoutSetBranch findByG_P_First(long groupId, boolean privateLayout,
1116                    OrderByComparator orderByComparator)
1117                    throws NoSuchLayoutSetBranchException, SystemException {
1118                    LayoutSetBranch layoutSetBranch = fetchByG_P_First(groupId,
1119                                    privateLayout, orderByComparator);
1120    
1121                    if (layoutSetBranch != null) {
1122                            return layoutSetBranch;
1123                    }
1124    
1125                    StringBundler msg = new StringBundler(6);
1126    
1127                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1128    
1129                    msg.append("groupId=");
1130                    msg.append(groupId);
1131    
1132                    msg.append(", privateLayout=");
1133                    msg.append(privateLayout);
1134    
1135                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1136    
1137                    throw new NoSuchLayoutSetBranchException(msg.toString());
1138            }
1139    
1140            /**
1141             * Returns the first layout set branch in the ordered set where groupId = &#63; and privateLayout = &#63;.
1142             *
1143             * @param groupId the group ID
1144             * @param privateLayout the private layout
1145             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1146             * @return the first matching layout set branch, or <code>null</code> if a matching layout set branch could not be found
1147             * @throws SystemException if a system exception occurred
1148             */
1149            public LayoutSetBranch fetchByG_P_First(long groupId,
1150                    boolean privateLayout, OrderByComparator orderByComparator)
1151                    throws SystemException {
1152                    List<LayoutSetBranch> list = findByG_P(groupId, privateLayout, 0, 1,
1153                                    orderByComparator);
1154    
1155                    if (!list.isEmpty()) {
1156                            return list.get(0);
1157                    }
1158    
1159                    return null;
1160            }
1161    
1162            /**
1163             * Returns the last layout set branch in the ordered set where groupId = &#63; and privateLayout = &#63;.
1164             *
1165             * @param groupId the group ID
1166             * @param privateLayout the private layout
1167             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1168             * @return the last matching layout set branch
1169             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a matching layout set branch could not be found
1170             * @throws SystemException if a system exception occurred
1171             */
1172            public LayoutSetBranch findByG_P_Last(long groupId, boolean privateLayout,
1173                    OrderByComparator orderByComparator)
1174                    throws NoSuchLayoutSetBranchException, SystemException {
1175                    LayoutSetBranch layoutSetBranch = fetchByG_P_Last(groupId,
1176                                    privateLayout, orderByComparator);
1177    
1178                    if (layoutSetBranch != null) {
1179                            return layoutSetBranch;
1180                    }
1181    
1182                    StringBundler msg = new StringBundler(6);
1183    
1184                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1185    
1186                    msg.append("groupId=");
1187                    msg.append(groupId);
1188    
1189                    msg.append(", privateLayout=");
1190                    msg.append(privateLayout);
1191    
1192                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1193    
1194                    throw new NoSuchLayoutSetBranchException(msg.toString());
1195            }
1196    
1197            /**
1198             * Returns the last layout set branch in the ordered set where groupId = &#63; and privateLayout = &#63;.
1199             *
1200             * @param groupId the group ID
1201             * @param privateLayout the private layout
1202             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1203             * @return the last matching layout set branch, or <code>null</code> if a matching layout set branch could not be found
1204             * @throws SystemException if a system exception occurred
1205             */
1206            public LayoutSetBranch fetchByG_P_Last(long groupId, boolean privateLayout,
1207                    OrderByComparator orderByComparator) throws SystemException {
1208                    int count = countByG_P(groupId, privateLayout);
1209    
1210                    List<LayoutSetBranch> list = findByG_P(groupId, privateLayout,
1211                                    count - 1, count, orderByComparator);
1212    
1213                    if (!list.isEmpty()) {
1214                            return list.get(0);
1215                    }
1216    
1217                    return null;
1218            }
1219    
1220            /**
1221             * Returns the layout set branchs before and after the current layout set branch in the ordered set where groupId = &#63; and privateLayout = &#63;.
1222             *
1223             * @param layoutSetBranchId the primary key of the current layout set branch
1224             * @param groupId the group ID
1225             * @param privateLayout the private layout
1226             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1227             * @return the previous, current, and next layout set branch
1228             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a layout set branch with the primary key could not be found
1229             * @throws SystemException if a system exception occurred
1230             */
1231            public LayoutSetBranch[] findByG_P_PrevAndNext(long layoutSetBranchId,
1232                    long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1233                    throws NoSuchLayoutSetBranchException, SystemException {
1234                    LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1235    
1236                    Session session = null;
1237    
1238                    try {
1239                            session = openSession();
1240    
1241                            LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1242    
1243                            array[0] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1244                                            privateLayout, orderByComparator, true);
1245    
1246                            array[1] = layoutSetBranch;
1247    
1248                            array[2] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1249                                            privateLayout, orderByComparator, false);
1250    
1251                            return array;
1252                    }
1253                    catch (Exception e) {
1254                            throw processException(e);
1255                    }
1256                    finally {
1257                            closeSession(session);
1258                    }
1259            }
1260    
1261            protected LayoutSetBranch getByG_P_PrevAndNext(Session session,
1262                    LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1263                    OrderByComparator orderByComparator, boolean previous) {
1264                    StringBundler query = null;
1265    
1266                    if (orderByComparator != null) {
1267                            query = new StringBundler(6 +
1268                                            (orderByComparator.getOrderByFields().length * 6));
1269                    }
1270                    else {
1271                            query = new StringBundler(3);
1272                    }
1273    
1274                    query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1275    
1276                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1277    
1278                    query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1279    
1280                    if (orderByComparator != null) {
1281                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1282    
1283                            if (orderByConditionFields.length > 0) {
1284                                    query.append(WHERE_AND);
1285                            }
1286    
1287                            for (int i = 0; i < orderByConditionFields.length; i++) {
1288                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1289                                    query.append(orderByConditionFields[i]);
1290    
1291                                    if ((i + 1) < orderByConditionFields.length) {
1292                                            if (orderByComparator.isAscending() ^ previous) {
1293                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1294                                            }
1295                                            else {
1296                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1297                                            }
1298                                    }
1299                                    else {
1300                                            if (orderByComparator.isAscending() ^ previous) {
1301                                                    query.append(WHERE_GREATER_THAN);
1302                                            }
1303                                            else {
1304                                                    query.append(WHERE_LESSER_THAN);
1305                                            }
1306                                    }
1307                            }
1308    
1309                            query.append(ORDER_BY_CLAUSE);
1310    
1311                            String[] orderByFields = orderByComparator.getOrderByFields();
1312    
1313                            for (int i = 0; i < orderByFields.length; i++) {
1314                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1315                                    query.append(orderByFields[i]);
1316    
1317                                    if ((i + 1) < orderByFields.length) {
1318                                            if (orderByComparator.isAscending() ^ previous) {
1319                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1320                                            }
1321                                            else {
1322                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1323                                            }
1324                                    }
1325                                    else {
1326                                            if (orderByComparator.isAscending() ^ previous) {
1327                                                    query.append(ORDER_BY_ASC);
1328                                            }
1329                                            else {
1330                                                    query.append(ORDER_BY_DESC);
1331                                            }
1332                                    }
1333                            }
1334                    }
1335                    else {
1336                            query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1337                    }
1338    
1339                    String sql = query.toString();
1340    
1341                    Query q = session.createQuery(sql);
1342    
1343                    q.setFirstResult(0);
1344                    q.setMaxResults(2);
1345    
1346                    QueryPos qPos = QueryPos.getInstance(q);
1347    
1348                    qPos.add(groupId);
1349    
1350                    qPos.add(privateLayout);
1351    
1352                    if (orderByComparator != null) {
1353                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1354    
1355                            for (Object value : values) {
1356                                    qPos.add(value);
1357                            }
1358                    }
1359    
1360                    List<LayoutSetBranch> list = q.list();
1361    
1362                    if (list.size() == 2) {
1363                            return list.get(1);
1364                    }
1365                    else {
1366                            return null;
1367                    }
1368            }
1369    
1370            /**
1371             * Returns all the layout set branchs that the user has permission to view where groupId = &#63; and privateLayout = &#63;.
1372             *
1373             * @param groupId the group ID
1374             * @param privateLayout the private layout
1375             * @return the matching layout set branchs that the user has permission to view
1376             * @throws SystemException if a system exception occurred
1377             */
1378            public List<LayoutSetBranch> filterFindByG_P(long groupId,
1379                    boolean privateLayout) throws SystemException {
1380                    return filterFindByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1381                            QueryUtil.ALL_POS, null);
1382            }
1383    
1384            /**
1385             * Returns a range of all the layout set branchs that the user has permission to view where groupId = &#63; and privateLayout = &#63;.
1386             *
1387             * <p>
1388             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1389             * </p>
1390             *
1391             * @param groupId the group ID
1392             * @param privateLayout the private layout
1393             * @param start the lower bound of the range of layout set branchs
1394             * @param end the upper bound of the range of layout set branchs (not inclusive)
1395             * @return the range of matching layout set branchs that the user has permission to view
1396             * @throws SystemException if a system exception occurred
1397             */
1398            public List<LayoutSetBranch> filterFindByG_P(long groupId,
1399                    boolean privateLayout, int start, int end) throws SystemException {
1400                    return filterFindByG_P(groupId, privateLayout, start, end, null);
1401            }
1402    
1403            /**
1404             * Returns an ordered range of all the layout set branchs that the user has permissions to view where groupId = &#63; and privateLayout = &#63;.
1405             *
1406             * <p>
1407             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1408             * </p>
1409             *
1410             * @param groupId the group ID
1411             * @param privateLayout the private layout
1412             * @param start the lower bound of the range of layout set branchs
1413             * @param end the upper bound of the range of layout set branchs (not inclusive)
1414             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1415             * @return the ordered range of matching layout set branchs that the user has permission to view
1416             * @throws SystemException if a system exception occurred
1417             */
1418            public List<LayoutSetBranch> filterFindByG_P(long groupId,
1419                    boolean privateLayout, int start, int end,
1420                    OrderByComparator orderByComparator) throws SystemException {
1421                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1422                            return findByG_P(groupId, privateLayout, start, end,
1423                                    orderByComparator);
1424                    }
1425    
1426                    StringBundler query = null;
1427    
1428                    if (orderByComparator != null) {
1429                            query = new StringBundler(4 +
1430                                            (orderByComparator.getOrderByFields().length * 3));
1431                    }
1432                    else {
1433                            query = new StringBundler(4);
1434                    }
1435    
1436                    if (getDB().isSupportsInlineDistinct()) {
1437                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1438                    }
1439                    else {
1440                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1441                    }
1442    
1443                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1444    
1445                    query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1446    
1447                    if (!getDB().isSupportsInlineDistinct()) {
1448                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1449                    }
1450    
1451                    if (orderByComparator != null) {
1452                            if (getDB().isSupportsInlineDistinct()) {
1453                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1454                                            orderByComparator);
1455                            }
1456                            else {
1457                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1458                                            orderByComparator);
1459                            }
1460                    }
1461                    else {
1462                            if (getDB().isSupportsInlineDistinct()) {
1463                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1464                            }
1465                            else {
1466                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1467                            }
1468                    }
1469    
1470                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1471                                    LayoutSetBranch.class.getName(),
1472                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1473    
1474                    Session session = null;
1475    
1476                    try {
1477                            session = openSession();
1478    
1479                            SQLQuery q = session.createSQLQuery(sql);
1480    
1481                            if (getDB().isSupportsInlineDistinct()) {
1482                                    q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1483                            }
1484                            else {
1485                                    q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1486                            }
1487    
1488                            QueryPos qPos = QueryPos.getInstance(q);
1489    
1490                            qPos.add(groupId);
1491    
1492                            qPos.add(privateLayout);
1493    
1494                            return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1495                                    start, end);
1496                    }
1497                    catch (Exception e) {
1498                            throw processException(e);
1499                    }
1500                    finally {
1501                            closeSession(session);
1502                    }
1503            }
1504    
1505            /**
1506             * Returns the layout set branchs before and after the current layout set branch in the ordered set of layout set branchs that the user has permission to view where groupId = &#63; and privateLayout = &#63;.
1507             *
1508             * @param layoutSetBranchId the primary key of the current layout set branch
1509             * @param groupId the group ID
1510             * @param privateLayout the private layout
1511             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1512             * @return the previous, current, and next layout set branch
1513             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a layout set branch with the primary key could not be found
1514             * @throws SystemException if a system exception occurred
1515             */
1516            public LayoutSetBranch[] filterFindByG_P_PrevAndNext(
1517                    long layoutSetBranchId, long groupId, boolean privateLayout,
1518                    OrderByComparator orderByComparator)
1519                    throws NoSuchLayoutSetBranchException, SystemException {
1520                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1521                            return findByG_P_PrevAndNext(layoutSetBranchId, groupId,
1522                                    privateLayout, orderByComparator);
1523                    }
1524    
1525                    LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1526    
1527                    Session session = null;
1528    
1529                    try {
1530                            session = openSession();
1531    
1532                            LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1533    
1534                            array[0] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1535                                            groupId, privateLayout, orderByComparator, true);
1536    
1537                            array[1] = layoutSetBranch;
1538    
1539                            array[2] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1540                                            groupId, privateLayout, orderByComparator, false);
1541    
1542                            return array;
1543                    }
1544                    catch (Exception e) {
1545                            throw processException(e);
1546                    }
1547                    finally {
1548                            closeSession(session);
1549                    }
1550            }
1551    
1552            protected LayoutSetBranch filterGetByG_P_PrevAndNext(Session session,
1553                    LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1554                    OrderByComparator orderByComparator, boolean previous) {
1555                    StringBundler query = null;
1556    
1557                    if (orderByComparator != null) {
1558                            query = new StringBundler(6 +
1559                                            (orderByComparator.getOrderByFields().length * 6));
1560                    }
1561                    else {
1562                            query = new StringBundler(3);
1563                    }
1564    
1565                    if (getDB().isSupportsInlineDistinct()) {
1566                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1567                    }
1568                    else {
1569                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1570                    }
1571    
1572                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1573    
1574                    query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1575    
1576                    if (!getDB().isSupportsInlineDistinct()) {
1577                            query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1578                    }
1579    
1580                    if (orderByComparator != null) {
1581                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1582    
1583                            if (orderByConditionFields.length > 0) {
1584                                    query.append(WHERE_AND);
1585                            }
1586    
1587                            for (int i = 0; i < orderByConditionFields.length; i++) {
1588                                    if (getDB().isSupportsInlineDistinct()) {
1589                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1590                                    }
1591                                    else {
1592                                            query.append(_ORDER_BY_ENTITY_TABLE);
1593                                    }
1594    
1595                                    query.append(orderByConditionFields[i]);
1596    
1597                                    if ((i + 1) < orderByConditionFields.length) {
1598                                            if (orderByComparator.isAscending() ^ previous) {
1599                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1600                                            }
1601                                            else {
1602                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1603                                            }
1604                                    }
1605                                    else {
1606                                            if (orderByComparator.isAscending() ^ previous) {
1607                                                    query.append(WHERE_GREATER_THAN);
1608                                            }
1609                                            else {
1610                                                    query.append(WHERE_LESSER_THAN);
1611                                            }
1612                                    }
1613                            }
1614    
1615                            query.append(ORDER_BY_CLAUSE);
1616    
1617                            String[] orderByFields = orderByComparator.getOrderByFields();
1618    
1619                            for (int i = 0; i < orderByFields.length; i++) {
1620                                    if (getDB().isSupportsInlineDistinct()) {
1621                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1622                                    }
1623                                    else {
1624                                            query.append(_ORDER_BY_ENTITY_TABLE);
1625                                    }
1626    
1627                                    query.append(orderByFields[i]);
1628    
1629                                    if ((i + 1) < orderByFields.length) {
1630                                            if (orderByComparator.isAscending() ^ previous) {
1631                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1632                                            }
1633                                            else {
1634                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1635                                            }
1636                                    }
1637                                    else {
1638                                            if (orderByComparator.isAscending() ^ previous) {
1639                                                    query.append(ORDER_BY_ASC);
1640                                            }
1641                                            else {
1642                                                    query.append(ORDER_BY_DESC);
1643                                            }
1644                                    }
1645                            }
1646                    }
1647                    else {
1648                            if (getDB().isSupportsInlineDistinct()) {
1649                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1650                            }
1651                            else {
1652                                    query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1653                            }
1654                    }
1655    
1656                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1657                                    LayoutSetBranch.class.getName(),
1658                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1659    
1660                    SQLQuery q = session.createSQLQuery(sql);
1661    
1662                    q.setFirstResult(0);
1663                    q.setMaxResults(2);
1664    
1665                    if (getDB().isSupportsInlineDistinct()) {
1666                            q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1667                    }
1668                    else {
1669                            q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1670                    }
1671    
1672                    QueryPos qPos = QueryPos.getInstance(q);
1673    
1674                    qPos.add(groupId);
1675    
1676                    qPos.add(privateLayout);
1677    
1678                    if (orderByComparator != null) {
1679                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1680    
1681                            for (Object value : values) {
1682                                    qPos.add(value);
1683                            }
1684                    }
1685    
1686                    List<LayoutSetBranch> list = q.list();
1687    
1688                    if (list.size() == 2) {
1689                            return list.get(1);
1690                    }
1691                    else {
1692                            return null;
1693                    }
1694            }
1695    
1696            /**
1697             * Removes all the layout set branchs where groupId = &#63; and privateLayout = &#63; from the database.
1698             *
1699             * @param groupId the group ID
1700             * @param privateLayout the private layout
1701             * @throws SystemException if a system exception occurred
1702             */
1703            public void removeByG_P(long groupId, boolean privateLayout)
1704                    throws SystemException {
1705                    for (LayoutSetBranch layoutSetBranch : findByG_P(groupId,
1706                                    privateLayout, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1707                            remove(layoutSetBranch);
1708                    }
1709            }
1710    
1711            /**
1712             * Returns the number of layout set branchs where groupId = &#63; and privateLayout = &#63;.
1713             *
1714             * @param groupId the group ID
1715             * @param privateLayout the private layout
1716             * @return the number of matching layout set branchs
1717             * @throws SystemException if a system exception occurred
1718             */
1719            public int countByG_P(long groupId, boolean privateLayout)
1720                    throws SystemException {
1721                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
1722    
1723                    Object[] finderArgs = new Object[] { groupId, privateLayout };
1724    
1725                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1726                                    this);
1727    
1728                    if (count == null) {
1729                            StringBundler query = new StringBundler(3);
1730    
1731                            query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
1732    
1733                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1734    
1735                            query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1736    
1737                            String sql = query.toString();
1738    
1739                            Session session = null;
1740    
1741                            try {
1742                                    session = openSession();
1743    
1744                                    Query q = session.createQuery(sql);
1745    
1746                                    QueryPos qPos = QueryPos.getInstance(q);
1747    
1748                                    qPos.add(groupId);
1749    
1750                                    qPos.add(privateLayout);
1751    
1752                                    count = (Long)q.uniqueResult();
1753    
1754                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1755                            }
1756                            catch (Exception e) {
1757                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1758    
1759                                    throw processException(e);
1760                            }
1761                            finally {
1762                                    closeSession(session);
1763                            }
1764                    }
1765    
1766                    return count.intValue();
1767            }
1768    
1769            /**
1770             * Returns the number of layout set branchs that the user has permission to view where groupId = &#63; and privateLayout = &#63;.
1771             *
1772             * @param groupId the group ID
1773             * @param privateLayout the private layout
1774             * @return the number of matching layout set branchs that the user has permission to view
1775             * @throws SystemException if a system exception occurred
1776             */
1777            public int filterCountByG_P(long groupId, boolean privateLayout)
1778                    throws SystemException {
1779                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1780                            return countByG_P(groupId, privateLayout);
1781                    }
1782    
1783                    StringBundler query = new StringBundler(3);
1784    
1785                    query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
1786    
1787                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1788    
1789                    query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1790    
1791                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1792                                    LayoutSetBranch.class.getName(),
1793                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1794    
1795                    Session session = null;
1796    
1797                    try {
1798                            session = openSession();
1799    
1800                            SQLQuery q = session.createSQLQuery(sql);
1801    
1802                            q.addScalar(COUNT_COLUMN_NAME,
1803                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1804    
1805                            QueryPos qPos = QueryPos.getInstance(q);
1806    
1807                            qPos.add(groupId);
1808    
1809                            qPos.add(privateLayout);
1810    
1811                            Long count = (Long)q.uniqueResult();
1812    
1813                            return count.intValue();
1814                    }
1815                    catch (Exception e) {
1816                            throw processException(e);
1817                    }
1818                    finally {
1819                            closeSession(session);
1820                    }
1821            }
1822    
1823            private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
1824            private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ?";
1825            public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
1826                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
1827                            LayoutSetBranchImpl.class, FINDER_CLASS_NAME_ENTITY,
1828                            "fetchByG_P_N",
1829                            new String[] {
1830                                    Long.class.getName(), Boolean.class.getName(),
1831                                    String.class.getName()
1832                            },
1833                            LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
1834                            LayoutSetBranchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
1835                            LayoutSetBranchModelImpl.NAME_COLUMN_BITMASK);
1836            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
1837                            LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
1838                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
1839                            new String[] {
1840                                    Long.class.getName(), Boolean.class.getName(),
1841                                    String.class.getName()
1842                            });
1843    
1844            /**
1845             * Returns the layout set branch where groupId = &#63; and privateLayout = &#63; and name = &#63; or throws a {@link com.liferay.portal.NoSuchLayoutSetBranchException} if it could not be found.
1846             *
1847             * @param groupId the group ID
1848             * @param privateLayout the private layout
1849             * @param name the name
1850             * @return the matching layout set branch
1851             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a matching layout set branch could not be found
1852             * @throws SystemException if a system exception occurred
1853             */
1854            public LayoutSetBranch findByG_P_N(long groupId, boolean privateLayout,
1855                    String name) throws NoSuchLayoutSetBranchException, SystemException {
1856                    LayoutSetBranch layoutSetBranch = fetchByG_P_N(groupId, privateLayout,
1857                                    name);
1858    
1859                    if (layoutSetBranch == null) {
1860                            StringBundler msg = new StringBundler(8);
1861    
1862                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1863    
1864                            msg.append("groupId=");
1865                            msg.append(groupId);
1866    
1867                            msg.append(", privateLayout=");
1868                            msg.append(privateLayout);
1869    
1870                            msg.append(", name=");
1871                            msg.append(name);
1872    
1873                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1874    
1875                            if (_log.isWarnEnabled()) {
1876                                    _log.warn(msg.toString());
1877                            }
1878    
1879                            throw new NoSuchLayoutSetBranchException(msg.toString());
1880                    }
1881    
1882                    return layoutSetBranch;
1883            }
1884    
1885            /**
1886             * Returns the layout set branch where groupId = &#63; and privateLayout = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1887             *
1888             * @param groupId the group ID
1889             * @param privateLayout the private layout
1890             * @param name the name
1891             * @return the matching layout set branch, or <code>null</code> if a matching layout set branch could not be found
1892             * @throws SystemException if a system exception occurred
1893             */
1894            public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
1895                    String name) throws SystemException {
1896                    return fetchByG_P_N(groupId, privateLayout, name, true);
1897            }
1898    
1899            /**
1900             * Returns the layout set branch where groupId = &#63; and privateLayout = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1901             *
1902             * @param groupId the group ID
1903             * @param privateLayout the private layout
1904             * @param name the name
1905             * @param retrieveFromCache whether to use the finder cache
1906             * @return the matching layout set branch, or <code>null</code> if a matching layout set branch could not be found
1907             * @throws SystemException if a system exception occurred
1908             */
1909            public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
1910                    String name, boolean retrieveFromCache) throws SystemException {
1911                    Object[] finderArgs = new Object[] { groupId, privateLayout, name };
1912    
1913                    Object result = null;
1914    
1915                    if (retrieveFromCache) {
1916                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
1917                                            finderArgs, this);
1918                    }
1919    
1920                    if (result instanceof LayoutSetBranch) {
1921                            LayoutSetBranch layoutSetBranch = (LayoutSetBranch)result;
1922    
1923                            if ((groupId != layoutSetBranch.getGroupId()) ||
1924                                            (privateLayout != layoutSetBranch.getPrivateLayout()) ||
1925                                            !Validator.equals(name, layoutSetBranch.getName())) {
1926                                    result = null;
1927                            }
1928                    }
1929    
1930                    if (result == null) {
1931                            StringBundler query = new StringBundler(5);
1932    
1933                            query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1934    
1935                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
1936    
1937                            query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
1938    
1939                            if (name == null) {
1940                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
1941                            }
1942                            else {
1943                                    if (name.equals(StringPool.BLANK)) {
1944                                            query.append(_FINDER_COLUMN_G_P_N_NAME_3);
1945                                    }
1946                                    else {
1947                                            query.append(_FINDER_COLUMN_G_P_N_NAME_2);
1948                                    }
1949                            }
1950    
1951                            String sql = query.toString();
1952    
1953                            Session session = null;
1954    
1955                            try {
1956                                    session = openSession();
1957    
1958                                    Query q = session.createQuery(sql);
1959    
1960                                    QueryPos qPos = QueryPos.getInstance(q);
1961    
1962                                    qPos.add(groupId);
1963    
1964                                    qPos.add(privateLayout);
1965    
1966                                    if (name != null) {
1967                                            qPos.add(name);
1968                                    }
1969    
1970                                    List<LayoutSetBranch> list = q.list();
1971    
1972                                    if (list.isEmpty()) {
1973                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
1974                                                    finderArgs, list);
1975                                    }
1976                                    else {
1977                                            LayoutSetBranch layoutSetBranch = list.get(0);
1978    
1979                                            result = layoutSetBranch;
1980    
1981                                            cacheResult(layoutSetBranch);
1982    
1983                                            if ((layoutSetBranch.getGroupId() != groupId) ||
1984                                                            (layoutSetBranch.getPrivateLayout() != privateLayout) ||
1985                                                            (layoutSetBranch.getName() == null) ||
1986                                                            !layoutSetBranch.getName().equals(name)) {
1987                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
1988                                                            finderArgs, layoutSetBranch);
1989                                            }
1990                                    }
1991                            }
1992                            catch (Exception e) {
1993                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
1994                                            finderArgs);
1995    
1996                                    throw processException(e);
1997                            }
1998                            finally {
1999                                    closeSession(session);
2000                            }
2001                    }
2002    
2003                    if (result instanceof List<?>) {
2004                            return null;
2005                    }
2006                    else {
2007                            return (LayoutSetBranch)result;
2008                    }
2009            }
2010    
2011            /**
2012             * Removes the layout set branch where groupId = &#63; and privateLayout = &#63; and name = &#63; from the database.
2013             *
2014             * @param groupId the group ID
2015             * @param privateLayout the private layout
2016             * @param name the name
2017             * @return the layout set branch that was removed
2018             * @throws SystemException if a system exception occurred
2019             */
2020            public LayoutSetBranch removeByG_P_N(long groupId, boolean privateLayout,
2021                    String name) throws NoSuchLayoutSetBranchException, SystemException {
2022                    LayoutSetBranch layoutSetBranch = findByG_P_N(groupId, privateLayout,
2023                                    name);
2024    
2025                    return remove(layoutSetBranch);
2026            }
2027    
2028            /**
2029             * Returns the number of layout set branchs where groupId = &#63; and privateLayout = &#63; and name = &#63;.
2030             *
2031             * @param groupId the group ID
2032             * @param privateLayout the private layout
2033             * @param name the name
2034             * @return the number of matching layout set branchs
2035             * @throws SystemException if a system exception occurred
2036             */
2037            public int countByG_P_N(long groupId, boolean privateLayout, String name)
2038                    throws SystemException {
2039                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N;
2040    
2041                    Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2042    
2043                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2044                                    this);
2045    
2046                    if (count == null) {
2047                            StringBundler query = new StringBundler(4);
2048    
2049                            query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2050    
2051                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2052    
2053                            query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2054    
2055                            if (name == null) {
2056                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2057                            }
2058                            else {
2059                                    if (name.equals(StringPool.BLANK)) {
2060                                            query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2061                                    }
2062                                    else {
2063                                            query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2064                                    }
2065                            }
2066    
2067                            String sql = query.toString();
2068    
2069                            Session session = null;
2070    
2071                            try {
2072                                    session = openSession();
2073    
2074                                    Query q = session.createQuery(sql);
2075    
2076                                    QueryPos qPos = QueryPos.getInstance(q);
2077    
2078                                    qPos.add(groupId);
2079    
2080                                    qPos.add(privateLayout);
2081    
2082                                    if (name != null) {
2083                                            qPos.add(name);
2084                                    }
2085    
2086                                    count = (Long)q.uniqueResult();
2087    
2088                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2089                            }
2090                            catch (Exception e) {
2091                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2092    
2093                                    throw processException(e);
2094                            }
2095                            finally {
2096                                    closeSession(session);
2097                            }
2098                    }
2099    
2100                    return count.intValue();
2101            }
2102    
2103            private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2104            private static final String _FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ? AND ";
2105            private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "layoutSetBranch.name IS NULL";
2106            private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "layoutSetBranch.name = ?";
2107            private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(layoutSetBranch.name IS NULL OR layoutSetBranch.name = ?)";
2108    
2109            /**
2110             * Caches the layout set branch in the entity cache if it is enabled.
2111             *
2112             * @param layoutSetBranch the layout set branch
2113             */
2114            public void cacheResult(LayoutSetBranch layoutSetBranch) {
2115                    EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2116                            LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
2117                            layoutSetBranch);
2118    
2119                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2120                            new Object[] {
2121                                    Long.valueOf(layoutSetBranch.getGroupId()),
2122                                    Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
2123                                    
2124                            layoutSetBranch.getName()
2125                            }, layoutSetBranch);
2126    
2127                    layoutSetBranch.resetOriginalValues();
2128            }
2129    
2130            /**
2131             * Caches the layout set branchs in the entity cache if it is enabled.
2132             *
2133             * @param layoutSetBranchs the layout set branchs
2134             */
2135            public void cacheResult(List<LayoutSetBranch> layoutSetBranchs) {
2136                    for (LayoutSetBranch layoutSetBranch : layoutSetBranchs) {
2137                            if (EntityCacheUtil.getResult(
2138                                                    LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2139                                                    LayoutSetBranchImpl.class,
2140                                                    layoutSetBranch.getPrimaryKey()) == null) {
2141                                    cacheResult(layoutSetBranch);
2142                            }
2143                            else {
2144                                    layoutSetBranch.resetOriginalValues();
2145                            }
2146                    }
2147            }
2148    
2149            /**
2150             * Clears the cache for all layout set branchs.
2151             *
2152             * <p>
2153             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2154             * </p>
2155             */
2156            @Override
2157            public void clearCache() {
2158                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2159                            CacheRegistryUtil.clear(LayoutSetBranchImpl.class.getName());
2160                    }
2161    
2162                    EntityCacheUtil.clearCache(LayoutSetBranchImpl.class.getName());
2163    
2164                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2165                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2166                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2167            }
2168    
2169            /**
2170             * Clears the cache for the layout set branch.
2171             *
2172             * <p>
2173             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2174             * </p>
2175             */
2176            @Override
2177            public void clearCache(LayoutSetBranch layoutSetBranch) {
2178                    EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2179                            LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey());
2180    
2181                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2182                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2183    
2184                    clearUniqueFindersCache(layoutSetBranch);
2185            }
2186    
2187            @Override
2188            public void clearCache(List<LayoutSetBranch> layoutSetBranchs) {
2189                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2190                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2191    
2192                    for (LayoutSetBranch layoutSetBranch : layoutSetBranchs) {
2193                            EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2194                                    LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey());
2195    
2196                            clearUniqueFindersCache(layoutSetBranch);
2197                    }
2198            }
2199    
2200            protected void cacheUniqueFindersCache(LayoutSetBranch layoutSetBranch) {
2201                    if (layoutSetBranch.isNew()) {
2202                            Object[] args = new Object[] {
2203                                            Long.valueOf(layoutSetBranch.getGroupId()),
2204                                            Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
2205                                            
2206                                            layoutSetBranch.getName()
2207                                    };
2208    
2209                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
2210                                    Long.valueOf(1));
2211                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
2212                                    layoutSetBranch);
2213                    }
2214                    else {
2215                            LayoutSetBranchModelImpl layoutSetBranchModelImpl = (LayoutSetBranchModelImpl)layoutSetBranch;
2216    
2217                            if ((layoutSetBranchModelImpl.getColumnBitmask() &
2218                                            FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
2219                                    Object[] args = new Object[] {
2220                                                    Long.valueOf(layoutSetBranch.getGroupId()),
2221                                                    Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
2222                                                    
2223                                                    layoutSetBranch.getName()
2224                                            };
2225    
2226                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
2227                                            Long.valueOf(1));
2228                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
2229                                            layoutSetBranch);
2230                            }
2231                    }
2232            }
2233    
2234            protected void clearUniqueFindersCache(LayoutSetBranch layoutSetBranch) {
2235                    LayoutSetBranchModelImpl layoutSetBranchModelImpl = (LayoutSetBranchModelImpl)layoutSetBranch;
2236    
2237                    Object[] args = new Object[] {
2238                                    Long.valueOf(layoutSetBranch.getGroupId()),
2239                                    Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
2240                                    
2241                                    layoutSetBranch.getName()
2242                            };
2243    
2244                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
2245                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
2246    
2247                    if ((layoutSetBranchModelImpl.getColumnBitmask() &
2248                                    FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
2249                            args = new Object[] {
2250                                            Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
2251                                            Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout()),
2252                                            
2253                                            layoutSetBranchModelImpl.getOriginalName()
2254                                    };
2255    
2256                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
2257                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
2258                    }
2259            }
2260    
2261            /**
2262             * Creates a new layout set branch with the primary key. Does not add the layout set branch to the database.
2263             *
2264             * @param layoutSetBranchId the primary key for the new layout set branch
2265             * @return the new layout set branch
2266             */
2267            public LayoutSetBranch create(long layoutSetBranchId) {
2268                    LayoutSetBranch layoutSetBranch = new LayoutSetBranchImpl();
2269    
2270                    layoutSetBranch.setNew(true);
2271                    layoutSetBranch.setPrimaryKey(layoutSetBranchId);
2272    
2273                    return layoutSetBranch;
2274            }
2275    
2276            /**
2277             * Removes the layout set branch with the primary key from the database. Also notifies the appropriate model listeners.
2278             *
2279             * @param layoutSetBranchId the primary key of the layout set branch
2280             * @return the layout set branch that was removed
2281             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a layout set branch with the primary key could not be found
2282             * @throws SystemException if a system exception occurred
2283             */
2284            public LayoutSetBranch remove(long layoutSetBranchId)
2285                    throws NoSuchLayoutSetBranchException, SystemException {
2286                    return remove(Long.valueOf(layoutSetBranchId));
2287            }
2288    
2289            /**
2290             * Removes the layout set branch with the primary key from the database. Also notifies the appropriate model listeners.
2291             *
2292             * @param primaryKey the primary key of the layout set branch
2293             * @return the layout set branch that was removed
2294             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a layout set branch with the primary key could not be found
2295             * @throws SystemException if a system exception occurred
2296             */
2297            @Override
2298            public LayoutSetBranch remove(Serializable primaryKey)
2299                    throws NoSuchLayoutSetBranchException, SystemException {
2300                    Session session = null;
2301    
2302                    try {
2303                            session = openSession();
2304    
2305                            LayoutSetBranch layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
2306                                            primaryKey);
2307    
2308                            if (layoutSetBranch == null) {
2309                                    if (_log.isWarnEnabled()) {
2310                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2311                                    }
2312    
2313                                    throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2314                                            primaryKey);
2315                            }
2316    
2317                            return remove(layoutSetBranch);
2318                    }
2319                    catch (NoSuchLayoutSetBranchException nsee) {
2320                            throw nsee;
2321                    }
2322                    catch (Exception e) {
2323                            throw processException(e);
2324                    }
2325                    finally {
2326                            closeSession(session);
2327                    }
2328            }
2329    
2330            @Override
2331            protected LayoutSetBranch removeImpl(LayoutSetBranch layoutSetBranch)
2332                    throws SystemException {
2333                    layoutSetBranch = toUnwrappedModel(layoutSetBranch);
2334    
2335                    Session session = null;
2336    
2337                    try {
2338                            session = openSession();
2339    
2340                            if (!session.contains(layoutSetBranch)) {
2341                                    layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
2342                                                    layoutSetBranch.getPrimaryKeyObj());
2343                            }
2344    
2345                            if (layoutSetBranch != null) {
2346                                    session.delete(layoutSetBranch);
2347                            }
2348                    }
2349                    catch (Exception e) {
2350                            throw processException(e);
2351                    }
2352                    finally {
2353                            closeSession(session);
2354                    }
2355    
2356                    if (layoutSetBranch != null) {
2357                            clearCache(layoutSetBranch);
2358                    }
2359    
2360                    return layoutSetBranch;
2361            }
2362    
2363            @Override
2364            public LayoutSetBranch updateImpl(
2365                    com.liferay.portal.model.LayoutSetBranch layoutSetBranch)
2366                    throws SystemException {
2367                    layoutSetBranch = toUnwrappedModel(layoutSetBranch);
2368    
2369                    boolean isNew = layoutSetBranch.isNew();
2370    
2371                    LayoutSetBranchModelImpl layoutSetBranchModelImpl = (LayoutSetBranchModelImpl)layoutSetBranch;
2372    
2373                    Session session = null;
2374    
2375                    try {
2376                            session = openSession();
2377    
2378                            if (layoutSetBranch.isNew()) {
2379                                    session.save(layoutSetBranch);
2380    
2381                                    layoutSetBranch.setNew(false);
2382                            }
2383                            else {
2384                                    session.merge(layoutSetBranch);
2385                            }
2386                    }
2387                    catch (Exception e) {
2388                            throw processException(e);
2389                    }
2390                    finally {
2391                            closeSession(session);
2392                    }
2393    
2394                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2395    
2396                    if (isNew || !LayoutSetBranchModelImpl.COLUMN_BITMASK_ENABLED) {
2397                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2398                    }
2399    
2400                    else {
2401                            if ((layoutSetBranchModelImpl.getColumnBitmask() &
2402                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2403                                    Object[] args = new Object[] {
2404                                                    Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId())
2405                                            };
2406    
2407                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2408                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2409                                            args);
2410    
2411                                    args = new Object[] {
2412                                                    Long.valueOf(layoutSetBranchModelImpl.getGroupId())
2413                                            };
2414    
2415                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2416                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2417                                            args);
2418                            }
2419    
2420                            if ((layoutSetBranchModelImpl.getColumnBitmask() &
2421                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
2422                                    Object[] args = new Object[] {
2423                                                    Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
2424                                                    Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout())
2425                                            };
2426    
2427                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
2428                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
2429                                            args);
2430    
2431                                    args = new Object[] {
2432                                                    Long.valueOf(layoutSetBranchModelImpl.getGroupId()),
2433                                                    Boolean.valueOf(layoutSetBranchModelImpl.getPrivateLayout())
2434                                            };
2435    
2436                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
2437                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
2438                                            args);
2439                            }
2440                    }
2441    
2442                    EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2443                            LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
2444                            layoutSetBranch);
2445    
2446                    clearUniqueFindersCache(layoutSetBranch);
2447                    cacheUniqueFindersCache(layoutSetBranch);
2448    
2449                    return layoutSetBranch;
2450            }
2451    
2452            protected LayoutSetBranch toUnwrappedModel(LayoutSetBranch layoutSetBranch) {
2453                    if (layoutSetBranch instanceof LayoutSetBranchImpl) {
2454                            return layoutSetBranch;
2455                    }
2456    
2457                    LayoutSetBranchImpl layoutSetBranchImpl = new LayoutSetBranchImpl();
2458    
2459                    layoutSetBranchImpl.setNew(layoutSetBranch.isNew());
2460                    layoutSetBranchImpl.setPrimaryKey(layoutSetBranch.getPrimaryKey());
2461    
2462                    layoutSetBranchImpl.setLayoutSetBranchId(layoutSetBranch.getLayoutSetBranchId());
2463                    layoutSetBranchImpl.setGroupId(layoutSetBranch.getGroupId());
2464                    layoutSetBranchImpl.setCompanyId(layoutSetBranch.getCompanyId());
2465                    layoutSetBranchImpl.setUserId(layoutSetBranch.getUserId());
2466                    layoutSetBranchImpl.setUserName(layoutSetBranch.getUserName());
2467                    layoutSetBranchImpl.setCreateDate(layoutSetBranch.getCreateDate());
2468                    layoutSetBranchImpl.setModifiedDate(layoutSetBranch.getModifiedDate());
2469                    layoutSetBranchImpl.setPrivateLayout(layoutSetBranch.isPrivateLayout());
2470                    layoutSetBranchImpl.setName(layoutSetBranch.getName());
2471                    layoutSetBranchImpl.setDescription(layoutSetBranch.getDescription());
2472                    layoutSetBranchImpl.setMaster(layoutSetBranch.isMaster());
2473                    layoutSetBranchImpl.setLogo(layoutSetBranch.isLogo());
2474                    layoutSetBranchImpl.setLogoId(layoutSetBranch.getLogoId());
2475                    layoutSetBranchImpl.setThemeId(layoutSetBranch.getThemeId());
2476                    layoutSetBranchImpl.setColorSchemeId(layoutSetBranch.getColorSchemeId());
2477                    layoutSetBranchImpl.setWapThemeId(layoutSetBranch.getWapThemeId());
2478                    layoutSetBranchImpl.setWapColorSchemeId(layoutSetBranch.getWapColorSchemeId());
2479                    layoutSetBranchImpl.setCss(layoutSetBranch.getCss());
2480                    layoutSetBranchImpl.setSettings(layoutSetBranch.getSettings());
2481                    layoutSetBranchImpl.setLayoutSetPrototypeUuid(layoutSetBranch.getLayoutSetPrototypeUuid());
2482                    layoutSetBranchImpl.setLayoutSetPrototypeLinkEnabled(layoutSetBranch.isLayoutSetPrototypeLinkEnabled());
2483    
2484                    return layoutSetBranchImpl;
2485            }
2486    
2487            /**
2488             * Returns the layout set branch with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2489             *
2490             * @param primaryKey the primary key of the layout set branch
2491             * @return the layout set branch
2492             * @throws com.liferay.portal.NoSuchModelException if a layout set branch with the primary key could not be found
2493             * @throws SystemException if a system exception occurred
2494             */
2495            @Override
2496            public LayoutSetBranch findByPrimaryKey(Serializable primaryKey)
2497                    throws NoSuchModelException, SystemException {
2498                    return findByPrimaryKey(((Long)primaryKey).longValue());
2499            }
2500    
2501            /**
2502             * Returns the layout set branch with the primary key or throws a {@link com.liferay.portal.NoSuchLayoutSetBranchException} if it could not be found.
2503             *
2504             * @param layoutSetBranchId the primary key of the layout set branch
2505             * @return the layout set branch
2506             * @throws com.liferay.portal.NoSuchLayoutSetBranchException if a layout set branch with the primary key could not be found
2507             * @throws SystemException if a system exception occurred
2508             */
2509            public LayoutSetBranch findByPrimaryKey(long layoutSetBranchId)
2510                    throws NoSuchLayoutSetBranchException, SystemException {
2511                    LayoutSetBranch layoutSetBranch = fetchByPrimaryKey(layoutSetBranchId);
2512    
2513                    if (layoutSetBranch == null) {
2514                            if (_log.isWarnEnabled()) {
2515                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutSetBranchId);
2516                            }
2517    
2518                            throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2519                                    layoutSetBranchId);
2520                    }
2521    
2522                    return layoutSetBranch;
2523            }
2524    
2525            /**
2526             * Returns the layout set branch with the primary key or returns <code>null</code> if it could not be found.
2527             *
2528             * @param primaryKey the primary key of the layout set branch
2529             * @return the layout set branch, or <code>null</code> if a layout set branch with the primary key could not be found
2530             * @throws SystemException if a system exception occurred
2531             */
2532            @Override
2533            public LayoutSetBranch fetchByPrimaryKey(Serializable primaryKey)
2534                    throws SystemException {
2535                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
2536            }
2537    
2538            /**
2539             * Returns the layout set branch with the primary key or returns <code>null</code> if it could not be found.
2540             *
2541             * @param layoutSetBranchId the primary key of the layout set branch
2542             * @return the layout set branch, or <code>null</code> if a layout set branch with the primary key could not be found
2543             * @throws SystemException if a system exception occurred
2544             */
2545            public LayoutSetBranch fetchByPrimaryKey(long layoutSetBranchId)
2546                    throws SystemException {
2547                    LayoutSetBranch layoutSetBranch = (LayoutSetBranch)EntityCacheUtil.getResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2548                                    LayoutSetBranchImpl.class, layoutSetBranchId);
2549    
2550                    if (layoutSetBranch == _nullLayoutSetBranch) {
2551                            return null;
2552                    }
2553    
2554                    if (layoutSetBranch == null) {
2555                            Session session = null;
2556    
2557                            try {
2558                                    session = openSession();
2559    
2560                                    layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
2561                                                    Long.valueOf(layoutSetBranchId));
2562    
2563                                    if (layoutSetBranch != null) {
2564                                            cacheResult(layoutSetBranch);
2565                                    }
2566                                    else {
2567                                            EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2568                                                    LayoutSetBranchImpl.class, layoutSetBranchId,
2569                                                    _nullLayoutSetBranch);
2570                                    }
2571                            }
2572                            catch (Exception e) {
2573                                    EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2574                                            LayoutSetBranchImpl.class, layoutSetBranchId);
2575    
2576                                    throw processException(e);
2577                            }
2578                            finally {
2579                                    closeSession(session);
2580                            }
2581                    }
2582    
2583                    return layoutSetBranch;
2584            }
2585    
2586            /**
2587             * Returns all the layout set branchs.
2588             *
2589             * @return the layout set branchs
2590             * @throws SystemException if a system exception occurred
2591             */
2592            public List<LayoutSetBranch> findAll() throws SystemException {
2593                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2594            }
2595    
2596            /**
2597             * Returns a range of all the layout set branchs.
2598             *
2599             * <p>
2600             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2601             * </p>
2602             *
2603             * @param start the lower bound of the range of layout set branchs
2604             * @param end the upper bound of the range of layout set branchs (not inclusive)
2605             * @return the range of layout set branchs
2606             * @throws SystemException if a system exception occurred
2607             */
2608            public List<LayoutSetBranch> findAll(int start, int end)
2609                    throws SystemException {
2610                    return findAll(start, end, null);
2611            }
2612    
2613            /**
2614             * Returns an ordered range of all the layout set branchs.
2615             *
2616             * <p>
2617             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.LayoutSetBranchModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2618             * </p>
2619             *
2620             * @param start the lower bound of the range of layout set branchs
2621             * @param end the upper bound of the range of layout set branchs (not inclusive)
2622             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2623             * @return the ordered range of layout set branchs
2624             * @throws SystemException if a system exception occurred
2625             */
2626            public List<LayoutSetBranch> findAll(int start, int end,
2627                    OrderByComparator orderByComparator) throws SystemException {
2628                    boolean pagination = true;
2629                    FinderPath finderPath = null;
2630                    Object[] finderArgs = null;
2631    
2632                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2633                                    (orderByComparator == null)) {
2634                            pagination = false;
2635                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2636                            finderArgs = FINDER_ARGS_EMPTY;
2637                    }
2638                    else {
2639                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2640                            finderArgs = new Object[] { start, end, orderByComparator };
2641                    }
2642    
2643                    List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
2644                                    finderArgs, this);
2645    
2646                    if (list == null) {
2647                            StringBundler query = null;
2648                            String sql = null;
2649    
2650                            if (orderByComparator != null) {
2651                                    query = new StringBundler(2 +
2652                                                    (orderByComparator.getOrderByFields().length * 3));
2653    
2654                                    query.append(_SQL_SELECT_LAYOUTSETBRANCH);
2655    
2656                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2657                                            orderByComparator);
2658    
2659                                    sql = query.toString();
2660                            }
2661                            else {
2662                                    sql = _SQL_SELECT_LAYOUTSETBRANCH;
2663    
2664                                    if (pagination) {
2665                                            sql = sql.concat(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2666                                    }
2667                            }
2668    
2669                            Session session = null;
2670    
2671                            try {
2672                                    session = openSession();
2673    
2674                                    Query q = session.createQuery(sql);
2675    
2676                                    if (!pagination) {
2677                                            list = (List<LayoutSetBranch>)QueryUtil.list(q,
2678                                                            getDialect(), start, end, false);
2679    
2680                                            Collections.sort(list);
2681    
2682                                            list = new UnmodifiableList<LayoutSetBranch>(list);
2683                                    }
2684                                    else {
2685                                            list = (List<LayoutSetBranch>)QueryUtil.list(q,
2686                                                            getDialect(), start, end);
2687                                    }
2688    
2689                                    cacheResult(list);
2690    
2691                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2692                            }
2693                            catch (Exception e) {
2694                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2695    
2696                                    throw processException(e);
2697                            }
2698                            finally {
2699                                    closeSession(session);
2700                            }
2701                    }
2702    
2703                    return list;
2704            }
2705    
2706            /**
2707             * Removes all the layout set branchs from the database.
2708             *
2709             * @throws SystemException if a system exception occurred
2710             */
2711            public void removeAll() throws SystemException {
2712                    for (LayoutSetBranch layoutSetBranch : findAll()) {
2713                            remove(layoutSetBranch);
2714                    }
2715            }
2716    
2717            /**
2718             * Returns the number of layout set branchs.
2719             *
2720             * @return the number of layout set branchs
2721             * @throws SystemException if a system exception occurred
2722             */
2723            public int countAll() throws SystemException {
2724                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2725                                    FINDER_ARGS_EMPTY, this);
2726    
2727                    if (count == null) {
2728                            Session session = null;
2729    
2730                            try {
2731                                    session = openSession();
2732    
2733                                    Query q = session.createQuery(_SQL_COUNT_LAYOUTSETBRANCH);
2734    
2735                                    count = (Long)q.uniqueResult();
2736    
2737                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2738                                            FINDER_ARGS_EMPTY, count);
2739                            }
2740                            catch (Exception e) {
2741                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2742                                            FINDER_ARGS_EMPTY);
2743    
2744                                    throw processException(e);
2745                            }
2746                            finally {
2747                                    closeSession(session);
2748                            }
2749                    }
2750    
2751                    return count.intValue();
2752            }
2753    
2754            /**
2755             * Initializes the layout set branch persistence.
2756             */
2757            public void afterPropertiesSet() {
2758                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2759                                            com.liferay.portal.util.PropsUtil.get(
2760                                                    "value.object.listener.com.liferay.portal.model.LayoutSetBranch")));
2761    
2762                    if (listenerClassNames.length > 0) {
2763                            try {
2764                                    List<ModelListener<LayoutSetBranch>> listenersList = new ArrayList<ModelListener<LayoutSetBranch>>();
2765    
2766                                    for (String listenerClassName : listenerClassNames) {
2767                                            listenersList.add((ModelListener<LayoutSetBranch>)InstanceFactory.newInstance(
2768                                                            listenerClassName));
2769                                    }
2770    
2771                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2772                            }
2773                            catch (Exception e) {
2774                                    _log.error(e);
2775                            }
2776                    }
2777            }
2778    
2779            public void destroy() {
2780                    EntityCacheUtil.removeCache(LayoutSetBranchImpl.class.getName());
2781                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2782                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2783                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2784            }
2785    
2786            private static final String _SQL_SELECT_LAYOUTSETBRANCH = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch";
2787            private static final String _SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch WHERE ";
2788            private static final String _SQL_COUNT_LAYOUTSETBRANCH = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch";
2789            private static final String _SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch WHERE ";
2790            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "layoutSetBranch.layoutSetBranchId";
2791            private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT DISTINCT {layoutSetBranch.*} FROM LayoutSetBranch layoutSetBranch WHERE ";
2792            private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1 =
2793                    "SELECT {LayoutSetBranch.*} FROM (SELECT DISTINCT layoutSetBranch.layoutSetBranchId FROM LayoutSetBranch layoutSetBranch WHERE ";
2794            private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2 =
2795                    ") TEMP_TABLE INNER JOIN LayoutSetBranch ON TEMP_TABLE.layoutSetBranchId = LayoutSetBranch.layoutSetBranchId";
2796            private static final String _FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(DISTINCT layoutSetBranch.layoutSetBranchId) AS COUNT_VALUE FROM LayoutSetBranch layoutSetBranch WHERE ";
2797            private static final String _FILTER_ENTITY_ALIAS = "layoutSetBranch";
2798            private static final String _FILTER_ENTITY_TABLE = "LayoutSetBranch";
2799            private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetBranch.";
2800            private static final String _ORDER_BY_ENTITY_TABLE = "LayoutSetBranch.";
2801            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetBranch exists with the primary key ";
2802            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetBranch exists with the key {";
2803            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2804            private static Log _log = LogFactoryUtil.getLog(LayoutSetBranchPersistenceImpl.class);
2805            private static LayoutSetBranch _nullLayoutSetBranch = new LayoutSetBranchImpl() {
2806                            @Override
2807                            public Object clone() {
2808                                    return this;
2809                            }
2810    
2811                            @Override
2812                            public CacheModel<LayoutSetBranch> toCacheModel() {
2813                                    return _nullLayoutSetBranchCacheModel;
2814                            }
2815                    };
2816    
2817            private static CacheModel<LayoutSetBranch> _nullLayoutSetBranchCacheModel = new CacheModel<LayoutSetBranch>() {
2818                            public LayoutSetBranch toEntityModel() {
2819                                    return _nullLayoutSetBranch;
2820                            }
2821                    };
2822    }