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