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