001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.NoSuchLayoutSetPrototypeException;
020    import com.liferay.portal.kernel.bean.BeanReference;
021    import com.liferay.portal.kernel.dao.orm.EntityCache;
022    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderCache;
024    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
025    import com.liferay.portal.kernel.dao.orm.FinderPath;
026    import com.liferay.portal.kernel.dao.orm.Query;
027    import com.liferay.portal.kernel.dao.orm.QueryPos;
028    import com.liferay.portal.kernel.dao.orm.QueryUtil;
029    import com.liferay.portal.kernel.dao.orm.SQLQuery;
030    import com.liferay.portal.kernel.dao.orm.Session;
031    import com.liferay.portal.kernel.log.Log;
032    import com.liferay.portal.kernel.log.LogFactoryUtil;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.SetUtil;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.LayoutSetPrototype;
041    import com.liferay.portal.model.MVCCModel;
042    import com.liferay.portal.model.impl.LayoutSetPrototypeImpl;
043    import com.liferay.portal.model.impl.LayoutSetPrototypeModelImpl;
044    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
045    import com.liferay.portal.service.ServiceContext;
046    import com.liferay.portal.service.ServiceContextThreadLocal;
047    import com.liferay.portal.service.persistence.CompanyProvider;
048    import com.liferay.portal.service.persistence.LayoutSetPrototypePersistence;
049    
050    import java.io.Serializable;
051    
052    import java.util.Collections;
053    import java.util.Date;
054    import java.util.HashMap;
055    import java.util.HashSet;
056    import java.util.Iterator;
057    import java.util.List;
058    import java.util.Map;
059    import java.util.Set;
060    
061    /**
062     * The persistence implementation for the layout set prototype service.
063     *
064     * <p>
065     * Caching information and settings can be found in <code>portal.properties</code>
066     * </p>
067     *
068     * @author Brian Wing Shun Chan
069     * @see LayoutSetPrototypePersistence
070     * @see com.liferay.portal.service.persistence.LayoutSetPrototypeUtil
071     * @generated
072     */
073    @ProviderType
074    public class LayoutSetPrototypePersistenceImpl extends BasePersistenceImpl<LayoutSetPrototype>
075            implements LayoutSetPrototypePersistence {
076            /*
077             * NOTE FOR DEVELOPERS:
078             *
079             * Never modify or reference this class directly. Always use {@link LayoutSetPrototypeUtil} to access the layout set prototype persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
080             */
081            public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetPrototypeImpl.class.getName();
082            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List1";
084            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085                    ".List2";
086            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
087                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
088                            LayoutSetPrototypeImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
090            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
091                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
092                            LayoutSetPrototypeImpl.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
094            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
095                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
097            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
098                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
099                            LayoutSetPrototypeImpl.class,
100                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
101                            new String[] {
102                                    String.class.getName(),
103                                    
104                            Integer.class.getName(), Integer.class.getName(),
105                                    OrderByComparator.class.getName()
106                            });
107            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
108                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
109                            LayoutSetPrototypeImpl.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
111                            new String[] { String.class.getName() },
112                            LayoutSetPrototypeModelImpl.UUID_COLUMN_BITMASK);
113            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
114                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
116                            new String[] { String.class.getName() });
117    
118            /**
119             * Returns all the layout set prototypes where uuid = &#63;.
120             *
121             * @param uuid the uuid
122             * @return the matching layout set prototypes
123             */
124            @Override
125            public List<LayoutSetPrototype> findByUuid(String uuid) {
126                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
127            }
128    
129            /**
130             * Returns a range of all the layout set prototypes where uuid = &#63;.
131             *
132             * <p>
133             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
134             * </p>
135             *
136             * @param uuid the uuid
137             * @param start the lower bound of the range of layout set prototypes
138             * @param end the upper bound of the range of layout set prototypes (not inclusive)
139             * @return the range of matching layout set prototypes
140             */
141            @Override
142            public List<LayoutSetPrototype> findByUuid(String uuid, int start, int end) {
143                    return findByUuid(uuid, start, end, null);
144            }
145    
146            /**
147             * Returns an ordered range of all the layout set prototypes where uuid = &#63;.
148             *
149             * <p>
150             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
151             * </p>
152             *
153             * @param uuid the uuid
154             * @param start the lower bound of the range of layout set prototypes
155             * @param end the upper bound of the range of layout set prototypes (not inclusive)
156             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
157             * @return the ordered range of matching layout set prototypes
158             */
159            @Override
160            public List<LayoutSetPrototype> findByUuid(String uuid, int start, int end,
161                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
162                    return findByUuid(uuid, start, end, orderByComparator, true);
163            }
164    
165            /**
166             * Returns an ordered range of all the layout set prototypes where uuid = &#63;.
167             *
168             * <p>
169             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
170             * </p>
171             *
172             * @param uuid the uuid
173             * @param start the lower bound of the range of layout set prototypes
174             * @param end the upper bound of the range of layout set prototypes (not inclusive)
175             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
176             * @param retrieveFromCache whether to retrieve from the finder cache
177             * @return the ordered range of matching layout set prototypes
178             */
179            @Override
180            public List<LayoutSetPrototype> findByUuid(String uuid, int start, int end,
181                    OrderByComparator<LayoutSetPrototype> orderByComparator,
182                    boolean retrieveFromCache) {
183                    boolean pagination = true;
184                    FinderPath finderPath = null;
185                    Object[] finderArgs = null;
186    
187                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
188                                    (orderByComparator == null)) {
189                            pagination = false;
190                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
191                            finderArgs = new Object[] { uuid };
192                    }
193                    else {
194                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
195                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
196                    }
197    
198                    List<LayoutSetPrototype> list = null;
199    
200                    if (retrieveFromCache) {
201                            list = (List<LayoutSetPrototype>)finderCache.getResult(finderPath,
202                                            finderArgs, this);
203    
204                            if ((list != null) && !list.isEmpty()) {
205                                    for (LayoutSetPrototype layoutSetPrototype : list) {
206                                            if (!Validator.equals(uuid, layoutSetPrototype.getUuid())) {
207                                                    list = null;
208    
209                                                    break;
210                                            }
211                                    }
212                            }
213                    }
214    
215                    if (list == null) {
216                            StringBundler query = null;
217    
218                            if (orderByComparator != null) {
219                                    query = new StringBundler(3 +
220                                                    (orderByComparator.getOrderByFields().length * 3));
221                            }
222                            else {
223                                    query = new StringBundler(3);
224                            }
225    
226                            query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
227    
228                            boolean bindUuid = false;
229    
230                            if (uuid == null) {
231                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
232                            }
233                            else if (uuid.equals(StringPool.BLANK)) {
234                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
235                            }
236                            else {
237                                    bindUuid = true;
238    
239                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
240                            }
241    
242                            if (orderByComparator != null) {
243                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
244                                            orderByComparator);
245                            }
246                            else
247                             if (pagination) {
248                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
249                            }
250    
251                            String sql = query.toString();
252    
253                            Session session = null;
254    
255                            try {
256                                    session = openSession();
257    
258                                    Query q = session.createQuery(sql);
259    
260                                    QueryPos qPos = QueryPos.getInstance(q);
261    
262                                    if (bindUuid) {
263                                            qPos.add(uuid);
264                                    }
265    
266                                    if (!pagination) {
267                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
268                                                            getDialect(), start, end, false);
269    
270                                            Collections.sort(list);
271    
272                                            list = Collections.unmodifiableList(list);
273                                    }
274                                    else {
275                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
276                                                            getDialect(), start, end);
277                                    }
278    
279                                    cacheResult(list);
280    
281                                    finderCache.putResult(finderPath, finderArgs, list);
282                            }
283                            catch (Exception e) {
284                                    finderCache.removeResult(finderPath, finderArgs);
285    
286                                    throw processException(e);
287                            }
288                            finally {
289                                    closeSession(session);
290                            }
291                    }
292    
293                    return list;
294            }
295    
296            /**
297             * Returns the first layout set prototype in the ordered set where uuid = &#63;.
298             *
299             * @param uuid the uuid
300             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
301             * @return the first matching layout set prototype
302             * @throws NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
303             */
304            @Override
305            public LayoutSetPrototype findByUuid_First(String uuid,
306                    OrderByComparator<LayoutSetPrototype> orderByComparator)
307                    throws NoSuchLayoutSetPrototypeException {
308                    LayoutSetPrototype layoutSetPrototype = fetchByUuid_First(uuid,
309                                    orderByComparator);
310    
311                    if (layoutSetPrototype != null) {
312                            return layoutSetPrototype;
313                    }
314    
315                    StringBundler msg = new StringBundler(4);
316    
317                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
318    
319                    msg.append("uuid=");
320                    msg.append(uuid);
321    
322                    msg.append(StringPool.CLOSE_CURLY_BRACE);
323    
324                    throw new NoSuchLayoutSetPrototypeException(msg.toString());
325            }
326    
327            /**
328             * Returns the first layout set prototype in the ordered set where uuid = &#63;.
329             *
330             * @param uuid the uuid
331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
332             * @return the first matching layout set prototype, or <code>null</code> if a matching layout set prototype could not be found
333             */
334            @Override
335            public LayoutSetPrototype fetchByUuid_First(String uuid,
336                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
337                    List<LayoutSetPrototype> list = findByUuid(uuid, 0, 1, orderByComparator);
338    
339                    if (!list.isEmpty()) {
340                            return list.get(0);
341                    }
342    
343                    return null;
344            }
345    
346            /**
347             * Returns the last layout set prototype in the ordered set where uuid = &#63;.
348             *
349             * @param uuid the uuid
350             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
351             * @return the last matching layout set prototype
352             * @throws NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
353             */
354            @Override
355            public LayoutSetPrototype findByUuid_Last(String uuid,
356                    OrderByComparator<LayoutSetPrototype> orderByComparator)
357                    throws NoSuchLayoutSetPrototypeException {
358                    LayoutSetPrototype layoutSetPrototype = fetchByUuid_Last(uuid,
359                                    orderByComparator);
360    
361                    if (layoutSetPrototype != null) {
362                            return layoutSetPrototype;
363                    }
364    
365                    StringBundler msg = new StringBundler(4);
366    
367                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
368    
369                    msg.append("uuid=");
370                    msg.append(uuid);
371    
372                    msg.append(StringPool.CLOSE_CURLY_BRACE);
373    
374                    throw new NoSuchLayoutSetPrototypeException(msg.toString());
375            }
376    
377            /**
378             * Returns the last layout set prototype in the ordered set where uuid = &#63;.
379             *
380             * @param uuid the uuid
381             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
382             * @return the last matching layout set prototype, or <code>null</code> if a matching layout set prototype could not be found
383             */
384            @Override
385            public LayoutSetPrototype fetchByUuid_Last(String uuid,
386                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
387                    int count = countByUuid(uuid);
388    
389                    if (count == 0) {
390                            return null;
391                    }
392    
393                    List<LayoutSetPrototype> list = findByUuid(uuid, count - 1, count,
394                                    orderByComparator);
395    
396                    if (!list.isEmpty()) {
397                            return list.get(0);
398                    }
399    
400                    return null;
401            }
402    
403            /**
404             * Returns the layout set prototypes before and after the current layout set prototype in the ordered set where uuid = &#63;.
405             *
406             * @param layoutSetPrototypeId the primary key of the current layout set prototype
407             * @param uuid the uuid
408             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
409             * @return the previous, current, and next layout set prototype
410             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
411             */
412            @Override
413            public LayoutSetPrototype[] findByUuid_PrevAndNext(
414                    long layoutSetPrototypeId, String uuid,
415                    OrderByComparator<LayoutSetPrototype> orderByComparator)
416                    throws NoSuchLayoutSetPrototypeException {
417                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
418    
419                    Session session = null;
420    
421                    try {
422                            session = openSession();
423    
424                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
425    
426                            array[0] = getByUuid_PrevAndNext(session, layoutSetPrototype, uuid,
427                                            orderByComparator, true);
428    
429                            array[1] = layoutSetPrototype;
430    
431                            array[2] = getByUuid_PrevAndNext(session, layoutSetPrototype, uuid,
432                                            orderByComparator, false);
433    
434                            return array;
435                    }
436                    catch (Exception e) {
437                            throw processException(e);
438                    }
439                    finally {
440                            closeSession(session);
441                    }
442            }
443    
444            protected LayoutSetPrototype getByUuid_PrevAndNext(Session session,
445                    LayoutSetPrototype layoutSetPrototype, String uuid,
446                    OrderByComparator<LayoutSetPrototype> orderByComparator,
447                    boolean previous) {
448                    StringBundler query = null;
449    
450                    if (orderByComparator != null) {
451                            query = new StringBundler(6 +
452                                            (orderByComparator.getOrderByFields().length * 6));
453                    }
454                    else {
455                            query = new StringBundler(3);
456                    }
457    
458                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
459    
460                    boolean bindUuid = false;
461    
462                    if (uuid == null) {
463                            query.append(_FINDER_COLUMN_UUID_UUID_1);
464                    }
465                    else if (uuid.equals(StringPool.BLANK)) {
466                            query.append(_FINDER_COLUMN_UUID_UUID_3);
467                    }
468                    else {
469                            bindUuid = true;
470    
471                            query.append(_FINDER_COLUMN_UUID_UUID_2);
472                    }
473    
474                    if (orderByComparator != null) {
475                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
476    
477                            if (orderByConditionFields.length > 0) {
478                                    query.append(WHERE_AND);
479                            }
480    
481                            for (int i = 0; i < orderByConditionFields.length; i++) {
482                                    query.append(_ORDER_BY_ENTITY_ALIAS);
483                                    query.append(orderByConditionFields[i]);
484    
485                                    if ((i + 1) < orderByConditionFields.length) {
486                                            if (orderByComparator.isAscending() ^ previous) {
487                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
488                                            }
489                                            else {
490                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
491                                            }
492                                    }
493                                    else {
494                                            if (orderByComparator.isAscending() ^ previous) {
495                                                    query.append(WHERE_GREATER_THAN);
496                                            }
497                                            else {
498                                                    query.append(WHERE_LESSER_THAN);
499                                            }
500                                    }
501                            }
502    
503                            query.append(ORDER_BY_CLAUSE);
504    
505                            String[] orderByFields = orderByComparator.getOrderByFields();
506    
507                            for (int i = 0; i < orderByFields.length; i++) {
508                                    query.append(_ORDER_BY_ENTITY_ALIAS);
509                                    query.append(orderByFields[i]);
510    
511                                    if ((i + 1) < orderByFields.length) {
512                                            if (orderByComparator.isAscending() ^ previous) {
513                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
514                                            }
515                                            else {
516                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
517                                            }
518                                    }
519                                    else {
520                                            if (orderByComparator.isAscending() ^ previous) {
521                                                    query.append(ORDER_BY_ASC);
522                                            }
523                                            else {
524                                                    query.append(ORDER_BY_DESC);
525                                            }
526                                    }
527                            }
528                    }
529                    else {
530                            query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
531                    }
532    
533                    String sql = query.toString();
534    
535                    Query q = session.createQuery(sql);
536    
537                    q.setFirstResult(0);
538                    q.setMaxResults(2);
539    
540                    QueryPos qPos = QueryPos.getInstance(q);
541    
542                    if (bindUuid) {
543                            qPos.add(uuid);
544                    }
545    
546                    if (orderByComparator != null) {
547                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
548    
549                            for (Object value : values) {
550                                    qPos.add(value);
551                            }
552                    }
553    
554                    List<LayoutSetPrototype> list = q.list();
555    
556                    if (list.size() == 2) {
557                            return list.get(1);
558                    }
559                    else {
560                            return null;
561                    }
562            }
563    
564            /**
565             * Returns all the layout set prototypes that the user has permission to view where uuid = &#63;.
566             *
567             * @param uuid the uuid
568             * @return the matching layout set prototypes that the user has permission to view
569             */
570            @Override
571            public List<LayoutSetPrototype> filterFindByUuid(String uuid) {
572                    return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
573            }
574    
575            /**
576             * Returns a range of all the layout set prototypes that the user has permission to view where uuid = &#63;.
577             *
578             * <p>
579             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
580             * </p>
581             *
582             * @param uuid the uuid
583             * @param start the lower bound of the range of layout set prototypes
584             * @param end the upper bound of the range of layout set prototypes (not inclusive)
585             * @return the range of matching layout set prototypes that the user has permission to view
586             */
587            @Override
588            public List<LayoutSetPrototype> filterFindByUuid(String uuid, int start,
589                    int end) {
590                    return filterFindByUuid(uuid, start, end, null);
591            }
592    
593            /**
594             * Returns an ordered range of all the layout set prototypes that the user has permissions to view where uuid = &#63;.
595             *
596             * <p>
597             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
598             * </p>
599             *
600             * @param uuid the uuid
601             * @param start the lower bound of the range of layout set prototypes
602             * @param end the upper bound of the range of layout set prototypes (not inclusive)
603             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
604             * @return the ordered range of matching layout set prototypes that the user has permission to view
605             */
606            @Override
607            public List<LayoutSetPrototype> filterFindByUuid(String uuid, int start,
608                    int end, OrderByComparator<LayoutSetPrototype> orderByComparator) {
609                    if (!InlineSQLHelperUtil.isEnabled()) {
610                            return findByUuid(uuid, start, end, orderByComparator);
611                    }
612    
613                    StringBundler query = null;
614    
615                    if (orderByComparator != null) {
616                            query = new StringBundler(3 +
617                                            (orderByComparator.getOrderByFields().length * 3));
618                    }
619                    else {
620                            query = new StringBundler(3);
621                    }
622    
623                    if (getDB().isSupportsInlineDistinct()) {
624                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
625                    }
626                    else {
627                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
628                    }
629    
630                    boolean bindUuid = false;
631    
632                    if (uuid == null) {
633                            query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
634                    }
635                    else if (uuid.equals(StringPool.BLANK)) {
636                            query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
637                    }
638                    else {
639                            bindUuid = true;
640    
641                            query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
642                    }
643    
644                    if (!getDB().isSupportsInlineDistinct()) {
645                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
646                    }
647    
648                    if (orderByComparator != null) {
649                            if (getDB().isSupportsInlineDistinct()) {
650                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
651                                            orderByComparator, true);
652                            }
653                            else {
654                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
655                                            orderByComparator, true);
656                            }
657                    }
658                    else {
659                            if (getDB().isSupportsInlineDistinct()) {
660                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
661                            }
662                            else {
663                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
664                            }
665                    }
666    
667                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
668                                    LayoutSetPrototype.class.getName(),
669                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
670    
671                    Session session = null;
672    
673                    try {
674                            session = openSession();
675    
676                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
677    
678                            if (getDB().isSupportsInlineDistinct()) {
679                                    q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
680                            }
681                            else {
682                                    q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
683                            }
684    
685                            QueryPos qPos = QueryPos.getInstance(q);
686    
687                            if (bindUuid) {
688                                    qPos.add(uuid);
689                            }
690    
691                            return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
692                                    start, end);
693                    }
694                    catch (Exception e) {
695                            throw processException(e);
696                    }
697                    finally {
698                            closeSession(session);
699                    }
700            }
701    
702            /**
703             * Returns the layout set prototypes before and after the current layout set prototype in the ordered set of layout set prototypes that the user has permission to view where uuid = &#63;.
704             *
705             * @param layoutSetPrototypeId the primary key of the current layout set prototype
706             * @param uuid the uuid
707             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
708             * @return the previous, current, and next layout set prototype
709             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
710             */
711            @Override
712            public LayoutSetPrototype[] filterFindByUuid_PrevAndNext(
713                    long layoutSetPrototypeId, String uuid,
714                    OrderByComparator<LayoutSetPrototype> orderByComparator)
715                    throws NoSuchLayoutSetPrototypeException {
716                    if (!InlineSQLHelperUtil.isEnabled()) {
717                            return findByUuid_PrevAndNext(layoutSetPrototypeId, uuid,
718                                    orderByComparator);
719                    }
720    
721                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
722    
723                    Session session = null;
724    
725                    try {
726                            session = openSession();
727    
728                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
729    
730                            array[0] = filterGetByUuid_PrevAndNext(session, layoutSetPrototype,
731                                            uuid, orderByComparator, true);
732    
733                            array[1] = layoutSetPrototype;
734    
735                            array[2] = filterGetByUuid_PrevAndNext(session, layoutSetPrototype,
736                                            uuid, orderByComparator, false);
737    
738                            return array;
739                    }
740                    catch (Exception e) {
741                            throw processException(e);
742                    }
743                    finally {
744                            closeSession(session);
745                    }
746            }
747    
748            protected LayoutSetPrototype filterGetByUuid_PrevAndNext(Session session,
749                    LayoutSetPrototype layoutSetPrototype, String uuid,
750                    OrderByComparator<LayoutSetPrototype> orderByComparator,
751                    boolean previous) {
752                    StringBundler query = null;
753    
754                    if (orderByComparator != null) {
755                            query = new StringBundler(6 +
756                                            (orderByComparator.getOrderByFields().length * 6));
757                    }
758                    else {
759                            query = new StringBundler(3);
760                    }
761    
762                    if (getDB().isSupportsInlineDistinct()) {
763                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
764                    }
765                    else {
766                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
767                    }
768    
769                    boolean bindUuid = false;
770    
771                    if (uuid == null) {
772                            query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
773                    }
774                    else if (uuid.equals(StringPool.BLANK)) {
775                            query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
776                    }
777                    else {
778                            bindUuid = true;
779    
780                            query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
781                    }
782    
783                    if (!getDB().isSupportsInlineDistinct()) {
784                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
785                    }
786    
787                    if (orderByComparator != null) {
788                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
789    
790                            if (orderByConditionFields.length > 0) {
791                                    query.append(WHERE_AND);
792                            }
793    
794                            for (int i = 0; i < orderByConditionFields.length; i++) {
795                                    if (getDB().isSupportsInlineDistinct()) {
796                                            query.append(_ORDER_BY_ENTITY_ALIAS);
797                                    }
798                                    else {
799                                            query.append(_ORDER_BY_ENTITY_TABLE);
800                                    }
801    
802                                    query.append(orderByConditionFields[i]);
803    
804                                    if ((i + 1) < orderByConditionFields.length) {
805                                            if (orderByComparator.isAscending() ^ previous) {
806                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
807                                            }
808                                            else {
809                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
810                                            }
811                                    }
812                                    else {
813                                            if (orderByComparator.isAscending() ^ previous) {
814                                                    query.append(WHERE_GREATER_THAN);
815                                            }
816                                            else {
817                                                    query.append(WHERE_LESSER_THAN);
818                                            }
819                                    }
820                            }
821    
822                            query.append(ORDER_BY_CLAUSE);
823    
824                            String[] orderByFields = orderByComparator.getOrderByFields();
825    
826                            for (int i = 0; i < orderByFields.length; i++) {
827                                    if (getDB().isSupportsInlineDistinct()) {
828                                            query.append(_ORDER_BY_ENTITY_ALIAS);
829                                    }
830                                    else {
831                                            query.append(_ORDER_BY_ENTITY_TABLE);
832                                    }
833    
834                                    query.append(orderByFields[i]);
835    
836                                    if ((i + 1) < orderByFields.length) {
837                                            if (orderByComparator.isAscending() ^ previous) {
838                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
839                                            }
840                                            else {
841                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
842                                            }
843                                    }
844                                    else {
845                                            if (orderByComparator.isAscending() ^ previous) {
846                                                    query.append(ORDER_BY_ASC);
847                                            }
848                                            else {
849                                                    query.append(ORDER_BY_DESC);
850                                            }
851                                    }
852                            }
853                    }
854                    else {
855                            if (getDB().isSupportsInlineDistinct()) {
856                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
857                            }
858                            else {
859                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
860                            }
861                    }
862    
863                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
864                                    LayoutSetPrototype.class.getName(),
865                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
866    
867                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
868    
869                    q.setFirstResult(0);
870                    q.setMaxResults(2);
871    
872                    if (getDB().isSupportsInlineDistinct()) {
873                            q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
874                    }
875                    else {
876                            q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
877                    }
878    
879                    QueryPos qPos = QueryPos.getInstance(q);
880    
881                    if (bindUuid) {
882                            qPos.add(uuid);
883                    }
884    
885                    if (orderByComparator != null) {
886                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
887    
888                            for (Object value : values) {
889                                    qPos.add(value);
890                            }
891                    }
892    
893                    List<LayoutSetPrototype> list = q.list();
894    
895                    if (list.size() == 2) {
896                            return list.get(1);
897                    }
898                    else {
899                            return null;
900                    }
901            }
902    
903            /**
904             * Removes all the layout set prototypes where uuid = &#63; from the database.
905             *
906             * @param uuid the uuid
907             */
908            @Override
909            public void removeByUuid(String uuid) {
910                    for (LayoutSetPrototype layoutSetPrototype : findByUuid(uuid,
911                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
912                            remove(layoutSetPrototype);
913                    }
914            }
915    
916            /**
917             * Returns the number of layout set prototypes where uuid = &#63;.
918             *
919             * @param uuid the uuid
920             * @return the number of matching layout set prototypes
921             */
922            @Override
923            public int countByUuid(String uuid) {
924                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
925    
926                    Object[] finderArgs = new Object[] { uuid };
927    
928                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
929    
930                    if (count == null) {
931                            StringBundler query = new StringBundler(2);
932    
933                            query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
934    
935                            boolean bindUuid = false;
936    
937                            if (uuid == null) {
938                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
939                            }
940                            else if (uuid.equals(StringPool.BLANK)) {
941                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
942                            }
943                            else {
944                                    bindUuid = true;
945    
946                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
947                            }
948    
949                            String sql = query.toString();
950    
951                            Session session = null;
952    
953                            try {
954                                    session = openSession();
955    
956                                    Query q = session.createQuery(sql);
957    
958                                    QueryPos qPos = QueryPos.getInstance(q);
959    
960                                    if (bindUuid) {
961                                            qPos.add(uuid);
962                                    }
963    
964                                    count = (Long)q.uniqueResult();
965    
966                                    finderCache.putResult(finderPath, finderArgs, count);
967                            }
968                            catch (Exception e) {
969                                    finderCache.removeResult(finderPath, finderArgs);
970    
971                                    throw processException(e);
972                            }
973                            finally {
974                                    closeSession(session);
975                            }
976                    }
977    
978                    return count.intValue();
979            }
980    
981            /**
982             * Returns the number of layout set prototypes that the user has permission to view where uuid = &#63;.
983             *
984             * @param uuid the uuid
985             * @return the number of matching layout set prototypes that the user has permission to view
986             */
987            @Override
988            public int filterCountByUuid(String uuid) {
989                    if (!InlineSQLHelperUtil.isEnabled()) {
990                            return countByUuid(uuid);
991                    }
992    
993                    StringBundler query = new StringBundler(2);
994    
995                    query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
996    
997                    boolean bindUuid = false;
998    
999                    if (uuid == null) {
1000                            query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
1001                    }
1002                    else if (uuid.equals(StringPool.BLANK)) {
1003                            query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
1004                    }
1005                    else {
1006                            bindUuid = true;
1007    
1008                            query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
1009                    }
1010    
1011                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1012                                    LayoutSetPrototype.class.getName(),
1013                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1014    
1015                    Session session = null;
1016    
1017                    try {
1018                            session = openSession();
1019    
1020                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1021    
1022                            q.addScalar(COUNT_COLUMN_NAME,
1023                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1024    
1025                            QueryPos qPos = QueryPos.getInstance(q);
1026    
1027                            if (bindUuid) {
1028                                    qPos.add(uuid);
1029                            }
1030    
1031                            Long count = (Long)q.uniqueResult();
1032    
1033                            return count.intValue();
1034                    }
1035                    catch (Exception e) {
1036                            throw processException(e);
1037                    }
1038                    finally {
1039                            closeSession(session);
1040                    }
1041            }
1042    
1043            private static final String _FINDER_COLUMN_UUID_UUID_1 = "layoutSetPrototype.uuid IS NULL";
1044            private static final String _FINDER_COLUMN_UUID_UUID_2 = "layoutSetPrototype.uuid = ?";
1045            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(layoutSetPrototype.uuid IS NULL OR layoutSetPrototype.uuid = '')";
1046            private static final String _FINDER_COLUMN_UUID_UUID_1_SQL = "layoutSetPrototype.uuid_ IS NULL";
1047            private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "layoutSetPrototype.uuid_ = ?";
1048            private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(layoutSetPrototype.uuid_ IS NULL OR layoutSetPrototype.uuid_ = '')";
1049            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1050                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
1051                            LayoutSetPrototypeImpl.class,
1052                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
1053                            new String[] {
1054                                    String.class.getName(), Long.class.getName(),
1055                                    
1056                            Integer.class.getName(), Integer.class.getName(),
1057                                    OrderByComparator.class.getName()
1058                            });
1059            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1060                    new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1061                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
1062                            LayoutSetPrototypeImpl.class,
1063                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1064                            new String[] { String.class.getName(), Long.class.getName() },
1065                            LayoutSetPrototypeModelImpl.UUID_COLUMN_BITMASK |
1066                            LayoutSetPrototypeModelImpl.COMPANYID_COLUMN_BITMASK);
1067            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1068                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
1069                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1070                            new String[] { String.class.getName(), Long.class.getName() });
1071    
1072            /**
1073             * Returns all the layout set prototypes where uuid = &#63; and companyId = &#63;.
1074             *
1075             * @param uuid the uuid
1076             * @param companyId the company ID
1077             * @return the matching layout set prototypes
1078             */
1079            @Override
1080            public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId) {
1081                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1082                            QueryUtil.ALL_POS, null);
1083            }
1084    
1085            /**
1086             * Returns a range of all the layout set prototypes where uuid = &#63; and companyId = &#63;.
1087             *
1088             * <p>
1089             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
1090             * </p>
1091             *
1092             * @param uuid the uuid
1093             * @param companyId the company ID
1094             * @param start the lower bound of the range of layout set prototypes
1095             * @param end the upper bound of the range of layout set prototypes (not inclusive)
1096             * @return the range of matching layout set prototypes
1097             */
1098            @Override
1099            public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId,
1100                    int start, int end) {
1101                    return findByUuid_C(uuid, companyId, start, end, null);
1102            }
1103    
1104            /**
1105             * Returns an ordered range of all the layout set prototypes where uuid = &#63; and companyId = &#63;.
1106             *
1107             * <p>
1108             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
1109             * </p>
1110             *
1111             * @param uuid the uuid
1112             * @param companyId the company ID
1113             * @param start the lower bound of the range of layout set prototypes
1114             * @param end the upper bound of the range of layout set prototypes (not inclusive)
1115             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1116             * @return the ordered range of matching layout set prototypes
1117             */
1118            @Override
1119            public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId,
1120                    int start, int end,
1121                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
1122                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
1123            }
1124    
1125            /**
1126             * Returns an ordered range of all the layout set prototypes where uuid = &#63; and companyId = &#63;.
1127             *
1128             * <p>
1129             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
1130             * </p>
1131             *
1132             * @param uuid the uuid
1133             * @param companyId the company ID
1134             * @param start the lower bound of the range of layout set prototypes
1135             * @param end the upper bound of the range of layout set prototypes (not inclusive)
1136             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1137             * @param retrieveFromCache whether to retrieve from the finder cache
1138             * @return the ordered range of matching layout set prototypes
1139             */
1140            @Override
1141            public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId,
1142                    int start, int end,
1143                    OrderByComparator<LayoutSetPrototype> orderByComparator,
1144                    boolean retrieveFromCache) {
1145                    boolean pagination = true;
1146                    FinderPath finderPath = null;
1147                    Object[] finderArgs = null;
1148    
1149                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1150                                    (orderByComparator == null)) {
1151                            pagination = false;
1152                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1153                            finderArgs = new Object[] { uuid, companyId };
1154                    }
1155                    else {
1156                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1157                            finderArgs = new Object[] {
1158                                            uuid, companyId,
1159                                            
1160                                            start, end, orderByComparator
1161                                    };
1162                    }
1163    
1164                    List<LayoutSetPrototype> list = null;
1165    
1166                    if (retrieveFromCache) {
1167                            list = (List<LayoutSetPrototype>)finderCache.getResult(finderPath,
1168                                            finderArgs, this);
1169    
1170                            if ((list != null) && !list.isEmpty()) {
1171                                    for (LayoutSetPrototype layoutSetPrototype : list) {
1172                                            if (!Validator.equals(uuid, layoutSetPrototype.getUuid()) ||
1173                                                            (companyId != layoutSetPrototype.getCompanyId())) {
1174                                                    list = null;
1175    
1176                                                    break;
1177                                            }
1178                                    }
1179                            }
1180                    }
1181    
1182                    if (list == null) {
1183                            StringBundler query = null;
1184    
1185                            if (orderByComparator != null) {
1186                                    query = new StringBundler(4 +
1187                                                    (orderByComparator.getOrderByFields().length * 3));
1188                            }
1189                            else {
1190                                    query = new StringBundler(4);
1191                            }
1192    
1193                            query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1194    
1195                            boolean bindUuid = false;
1196    
1197                            if (uuid == null) {
1198                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1199                            }
1200                            else if (uuid.equals(StringPool.BLANK)) {
1201                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1202                            }
1203                            else {
1204                                    bindUuid = true;
1205    
1206                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1207                            }
1208    
1209                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1210    
1211                            if (orderByComparator != null) {
1212                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1213                                            orderByComparator);
1214                            }
1215                            else
1216                             if (pagination) {
1217                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1218                            }
1219    
1220                            String sql = query.toString();
1221    
1222                            Session session = null;
1223    
1224                            try {
1225                                    session = openSession();
1226    
1227                                    Query q = session.createQuery(sql);
1228    
1229                                    QueryPos qPos = QueryPos.getInstance(q);
1230    
1231                                    if (bindUuid) {
1232                                            qPos.add(uuid);
1233                                    }
1234    
1235                                    qPos.add(companyId);
1236    
1237                                    if (!pagination) {
1238                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
1239                                                            getDialect(), start, end, false);
1240    
1241                                            Collections.sort(list);
1242    
1243                                            list = Collections.unmodifiableList(list);
1244                                    }
1245                                    else {
1246                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
1247                                                            getDialect(), start, end);
1248                                    }
1249    
1250                                    cacheResult(list);
1251    
1252                                    finderCache.putResult(finderPath, finderArgs, list);
1253                            }
1254                            catch (Exception e) {
1255                                    finderCache.removeResult(finderPath, finderArgs);
1256    
1257                                    throw processException(e);
1258                            }
1259                            finally {
1260                                    closeSession(session);
1261                            }
1262                    }
1263    
1264                    return list;
1265            }
1266    
1267            /**
1268             * Returns the first layout set prototype in the ordered set where uuid = &#63; and companyId = &#63;.
1269             *
1270             * @param uuid the uuid
1271             * @param companyId the company ID
1272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1273             * @return the first matching layout set prototype
1274             * @throws NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
1275             */
1276            @Override
1277            public LayoutSetPrototype findByUuid_C_First(String uuid, long companyId,
1278                    OrderByComparator<LayoutSetPrototype> orderByComparator)
1279                    throws NoSuchLayoutSetPrototypeException {
1280                    LayoutSetPrototype layoutSetPrototype = fetchByUuid_C_First(uuid,
1281                                    companyId, orderByComparator);
1282    
1283                    if (layoutSetPrototype != null) {
1284                            return layoutSetPrototype;
1285                    }
1286    
1287                    StringBundler msg = new StringBundler(6);
1288    
1289                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1290    
1291                    msg.append("uuid=");
1292                    msg.append(uuid);
1293    
1294                    msg.append(", companyId=");
1295                    msg.append(companyId);
1296    
1297                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1298    
1299                    throw new NoSuchLayoutSetPrototypeException(msg.toString());
1300            }
1301    
1302            /**
1303             * Returns the first layout set prototype in the ordered set where uuid = &#63; and companyId = &#63;.
1304             *
1305             * @param uuid the uuid
1306             * @param companyId the company ID
1307             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1308             * @return the first matching layout set prototype, or <code>null</code> if a matching layout set prototype could not be found
1309             */
1310            @Override
1311            public LayoutSetPrototype fetchByUuid_C_First(String uuid, long companyId,
1312                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
1313                    List<LayoutSetPrototype> list = findByUuid_C(uuid, companyId, 0, 1,
1314                                    orderByComparator);
1315    
1316                    if (!list.isEmpty()) {
1317                            return list.get(0);
1318                    }
1319    
1320                    return null;
1321            }
1322    
1323            /**
1324             * Returns the last layout set prototype in the ordered set where uuid = &#63; and companyId = &#63;.
1325             *
1326             * @param uuid the uuid
1327             * @param companyId the company ID
1328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1329             * @return the last matching layout set prototype
1330             * @throws NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
1331             */
1332            @Override
1333            public LayoutSetPrototype findByUuid_C_Last(String uuid, long companyId,
1334                    OrderByComparator<LayoutSetPrototype> orderByComparator)
1335                    throws NoSuchLayoutSetPrototypeException {
1336                    LayoutSetPrototype layoutSetPrototype = fetchByUuid_C_Last(uuid,
1337                                    companyId, orderByComparator);
1338    
1339                    if (layoutSetPrototype != null) {
1340                            return layoutSetPrototype;
1341                    }
1342    
1343                    StringBundler msg = new StringBundler(6);
1344    
1345                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1346    
1347                    msg.append("uuid=");
1348                    msg.append(uuid);
1349    
1350                    msg.append(", companyId=");
1351                    msg.append(companyId);
1352    
1353                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1354    
1355                    throw new NoSuchLayoutSetPrototypeException(msg.toString());
1356            }
1357    
1358            /**
1359             * Returns the last layout set prototype in the ordered set where uuid = &#63; and companyId = &#63;.
1360             *
1361             * @param uuid the uuid
1362             * @param companyId the company ID
1363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1364             * @return the last matching layout set prototype, or <code>null</code> if a matching layout set prototype could not be found
1365             */
1366            @Override
1367            public LayoutSetPrototype fetchByUuid_C_Last(String uuid, long companyId,
1368                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
1369                    int count = countByUuid_C(uuid, companyId);
1370    
1371                    if (count == 0) {
1372                            return null;
1373                    }
1374    
1375                    List<LayoutSetPrototype> list = findByUuid_C(uuid, companyId,
1376                                    count - 1, count, orderByComparator);
1377    
1378                    if (!list.isEmpty()) {
1379                            return list.get(0);
1380                    }
1381    
1382                    return null;
1383            }
1384    
1385            /**
1386             * Returns the layout set prototypes before and after the current layout set prototype in the ordered set where uuid = &#63; and companyId = &#63;.
1387             *
1388             * @param layoutSetPrototypeId the primary key of the current layout set prototype
1389             * @param uuid the uuid
1390             * @param companyId the company ID
1391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1392             * @return the previous, current, and next layout set prototype
1393             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
1394             */
1395            @Override
1396            public LayoutSetPrototype[] findByUuid_C_PrevAndNext(
1397                    long layoutSetPrototypeId, String uuid, long companyId,
1398                    OrderByComparator<LayoutSetPrototype> orderByComparator)
1399                    throws NoSuchLayoutSetPrototypeException {
1400                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
1401    
1402                    Session session = null;
1403    
1404                    try {
1405                            session = openSession();
1406    
1407                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
1408    
1409                            array[0] = getByUuid_C_PrevAndNext(session, layoutSetPrototype,
1410                                            uuid, companyId, orderByComparator, true);
1411    
1412                            array[1] = layoutSetPrototype;
1413    
1414                            array[2] = getByUuid_C_PrevAndNext(session, layoutSetPrototype,
1415                                            uuid, companyId, orderByComparator, false);
1416    
1417                            return array;
1418                    }
1419                    catch (Exception e) {
1420                            throw processException(e);
1421                    }
1422                    finally {
1423                            closeSession(session);
1424                    }
1425            }
1426    
1427            protected LayoutSetPrototype getByUuid_C_PrevAndNext(Session session,
1428                    LayoutSetPrototype layoutSetPrototype, String uuid, long companyId,
1429                    OrderByComparator<LayoutSetPrototype> orderByComparator,
1430                    boolean previous) {
1431                    StringBundler query = null;
1432    
1433                    if (orderByComparator != null) {
1434                            query = new StringBundler(6 +
1435                                            (orderByComparator.getOrderByFields().length * 6));
1436                    }
1437                    else {
1438                            query = new StringBundler(3);
1439                    }
1440    
1441                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1442    
1443                    boolean bindUuid = false;
1444    
1445                    if (uuid == null) {
1446                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1447                    }
1448                    else if (uuid.equals(StringPool.BLANK)) {
1449                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1450                    }
1451                    else {
1452                            bindUuid = true;
1453    
1454                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1455                    }
1456    
1457                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1458    
1459                    if (orderByComparator != null) {
1460                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1461    
1462                            if (orderByConditionFields.length > 0) {
1463                                    query.append(WHERE_AND);
1464                            }
1465    
1466                            for (int i = 0; i < orderByConditionFields.length; i++) {
1467                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1468                                    query.append(orderByConditionFields[i]);
1469    
1470                                    if ((i + 1) < orderByConditionFields.length) {
1471                                            if (orderByComparator.isAscending() ^ previous) {
1472                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1473                                            }
1474                                            else {
1475                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1476                                            }
1477                                    }
1478                                    else {
1479                                            if (orderByComparator.isAscending() ^ previous) {
1480                                                    query.append(WHERE_GREATER_THAN);
1481                                            }
1482                                            else {
1483                                                    query.append(WHERE_LESSER_THAN);
1484                                            }
1485                                    }
1486                            }
1487    
1488                            query.append(ORDER_BY_CLAUSE);
1489    
1490                            String[] orderByFields = orderByComparator.getOrderByFields();
1491    
1492                            for (int i = 0; i < orderByFields.length; i++) {
1493                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1494                                    query.append(orderByFields[i]);
1495    
1496                                    if ((i + 1) < orderByFields.length) {
1497                                            if (orderByComparator.isAscending() ^ previous) {
1498                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1499                                            }
1500                                            else {
1501                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1502                                            }
1503                                    }
1504                                    else {
1505                                            if (orderByComparator.isAscending() ^ previous) {
1506                                                    query.append(ORDER_BY_ASC);
1507                                            }
1508                                            else {
1509                                                    query.append(ORDER_BY_DESC);
1510                                            }
1511                                    }
1512                            }
1513                    }
1514                    else {
1515                            query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1516                    }
1517    
1518                    String sql = query.toString();
1519    
1520                    Query q = session.createQuery(sql);
1521    
1522                    q.setFirstResult(0);
1523                    q.setMaxResults(2);
1524    
1525                    QueryPos qPos = QueryPos.getInstance(q);
1526    
1527                    if (bindUuid) {
1528                            qPos.add(uuid);
1529                    }
1530    
1531                    qPos.add(companyId);
1532    
1533                    if (orderByComparator != null) {
1534                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
1535    
1536                            for (Object value : values) {
1537                                    qPos.add(value);
1538                            }
1539                    }
1540    
1541                    List<LayoutSetPrototype> list = q.list();
1542    
1543                    if (list.size() == 2) {
1544                            return list.get(1);
1545                    }
1546                    else {
1547                            return null;
1548                    }
1549            }
1550    
1551            /**
1552             * Returns all the layout set prototypes that the user has permission to view where uuid = &#63; and companyId = &#63;.
1553             *
1554             * @param uuid the uuid
1555             * @param companyId the company ID
1556             * @return the matching layout set prototypes that the user has permission to view
1557             */
1558            @Override
1559            public List<LayoutSetPrototype> filterFindByUuid_C(String uuid,
1560                    long companyId) {
1561                    return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1562                            QueryUtil.ALL_POS, null);
1563            }
1564    
1565            /**
1566             * Returns a range of all the layout set prototypes that the user has permission to view where uuid = &#63; and companyId = &#63;.
1567             *
1568             * <p>
1569             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
1570             * </p>
1571             *
1572             * @param uuid the uuid
1573             * @param companyId the company ID
1574             * @param start the lower bound of the range of layout set prototypes
1575             * @param end the upper bound of the range of layout set prototypes (not inclusive)
1576             * @return the range of matching layout set prototypes that the user has permission to view
1577             */
1578            @Override
1579            public List<LayoutSetPrototype> filterFindByUuid_C(String uuid,
1580                    long companyId, int start, int end) {
1581                    return filterFindByUuid_C(uuid, companyId, start, end, null);
1582            }
1583    
1584            /**
1585             * Returns an ordered range of all the layout set prototypes that the user has permissions to view where uuid = &#63; and companyId = &#63;.
1586             *
1587             * <p>
1588             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
1589             * </p>
1590             *
1591             * @param uuid the uuid
1592             * @param companyId the company ID
1593             * @param start the lower bound of the range of layout set prototypes
1594             * @param end the upper bound of the range of layout set prototypes (not inclusive)
1595             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1596             * @return the ordered range of matching layout set prototypes that the user has permission to view
1597             */
1598            @Override
1599            public List<LayoutSetPrototype> filterFindByUuid_C(String uuid,
1600                    long companyId, int start, int end,
1601                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
1602                    if (!InlineSQLHelperUtil.isEnabled()) {
1603                            return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1604                    }
1605    
1606                    StringBundler query = null;
1607    
1608                    if (orderByComparator != null) {
1609                            query = new StringBundler(4 +
1610                                            (orderByComparator.getOrderByFields().length * 3));
1611                    }
1612                    else {
1613                            query = new StringBundler(4);
1614                    }
1615    
1616                    if (getDB().isSupportsInlineDistinct()) {
1617                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1618                    }
1619                    else {
1620                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
1621                    }
1622    
1623                    boolean bindUuid = false;
1624    
1625                    if (uuid == null) {
1626                            query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1627                    }
1628                    else if (uuid.equals(StringPool.BLANK)) {
1629                            query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1630                    }
1631                    else {
1632                            bindUuid = true;
1633    
1634                            query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1635                    }
1636    
1637                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1638    
1639                    if (!getDB().isSupportsInlineDistinct()) {
1640                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
1641                    }
1642    
1643                    if (orderByComparator != null) {
1644                            if (getDB().isSupportsInlineDistinct()) {
1645                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1646                                            orderByComparator, true);
1647                            }
1648                            else {
1649                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1650                                            orderByComparator, true);
1651                            }
1652                    }
1653                    else {
1654                            if (getDB().isSupportsInlineDistinct()) {
1655                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1656                            }
1657                            else {
1658                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
1659                            }
1660                    }
1661    
1662                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1663                                    LayoutSetPrototype.class.getName(),
1664                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1665    
1666                    Session session = null;
1667    
1668                    try {
1669                            session = openSession();
1670    
1671                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1672    
1673                            if (getDB().isSupportsInlineDistinct()) {
1674                                    q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
1675                            }
1676                            else {
1677                                    q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
1678                            }
1679    
1680                            QueryPos qPos = QueryPos.getInstance(q);
1681    
1682                            if (bindUuid) {
1683                                    qPos.add(uuid);
1684                            }
1685    
1686                            qPos.add(companyId);
1687    
1688                            return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
1689                                    start, end);
1690                    }
1691                    catch (Exception e) {
1692                            throw processException(e);
1693                    }
1694                    finally {
1695                            closeSession(session);
1696                    }
1697            }
1698    
1699            /**
1700             * Returns the layout set prototypes before and after the current layout set prototype in the ordered set of layout set prototypes that the user has permission to view where uuid = &#63; and companyId = &#63;.
1701             *
1702             * @param layoutSetPrototypeId the primary key of the current layout set prototype
1703             * @param uuid the uuid
1704             * @param companyId the company ID
1705             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1706             * @return the previous, current, and next layout set prototype
1707             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
1708             */
1709            @Override
1710            public LayoutSetPrototype[] filterFindByUuid_C_PrevAndNext(
1711                    long layoutSetPrototypeId, String uuid, long companyId,
1712                    OrderByComparator<LayoutSetPrototype> orderByComparator)
1713                    throws NoSuchLayoutSetPrototypeException {
1714                    if (!InlineSQLHelperUtil.isEnabled()) {
1715                            return findByUuid_C_PrevAndNext(layoutSetPrototypeId, uuid,
1716                                    companyId, orderByComparator);
1717                    }
1718    
1719                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
1720    
1721                    Session session = null;
1722    
1723                    try {
1724                            session = openSession();
1725    
1726                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
1727    
1728                            array[0] = filterGetByUuid_C_PrevAndNext(session,
1729                                            layoutSetPrototype, uuid, companyId, orderByComparator, true);
1730    
1731                            array[1] = layoutSetPrototype;
1732    
1733                            array[2] = filterGetByUuid_C_PrevAndNext(session,
1734                                            layoutSetPrototype, uuid, companyId, orderByComparator,
1735                                            false);
1736    
1737                            return array;
1738                    }
1739                    catch (Exception e) {
1740                            throw processException(e);
1741                    }
1742                    finally {
1743                            closeSession(session);
1744                    }
1745            }
1746    
1747            protected LayoutSetPrototype filterGetByUuid_C_PrevAndNext(
1748                    Session session, LayoutSetPrototype layoutSetPrototype, String uuid,
1749                    long companyId,
1750                    OrderByComparator<LayoutSetPrototype> orderByComparator,
1751                    boolean previous) {
1752                    StringBundler query = null;
1753    
1754                    if (orderByComparator != null) {
1755                            query = new StringBundler(6 +
1756                                            (orderByComparator.getOrderByFields().length * 6));
1757                    }
1758                    else {
1759                            query = new StringBundler(3);
1760                    }
1761    
1762                    if (getDB().isSupportsInlineDistinct()) {
1763                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1764                    }
1765                    else {
1766                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
1767                    }
1768    
1769                    boolean bindUuid = false;
1770    
1771                    if (uuid == null) {
1772                            query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1773                    }
1774                    else if (uuid.equals(StringPool.BLANK)) {
1775                            query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1776                    }
1777                    else {
1778                            bindUuid = true;
1779    
1780                            query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1781                    }
1782    
1783                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1784    
1785                    if (!getDB().isSupportsInlineDistinct()) {
1786                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
1787                    }
1788    
1789                    if (orderByComparator != null) {
1790                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1791    
1792                            if (orderByConditionFields.length > 0) {
1793                                    query.append(WHERE_AND);
1794                            }
1795    
1796                            for (int i = 0; i < orderByConditionFields.length; i++) {
1797                                    if (getDB().isSupportsInlineDistinct()) {
1798                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1799                                    }
1800                                    else {
1801                                            query.append(_ORDER_BY_ENTITY_TABLE);
1802                                    }
1803    
1804                                    query.append(orderByConditionFields[i]);
1805    
1806                                    if ((i + 1) < orderByConditionFields.length) {
1807                                            if (orderByComparator.isAscending() ^ previous) {
1808                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1809                                            }
1810                                            else {
1811                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1812                                            }
1813                                    }
1814                                    else {
1815                                            if (orderByComparator.isAscending() ^ previous) {
1816                                                    query.append(WHERE_GREATER_THAN);
1817                                            }
1818                                            else {
1819                                                    query.append(WHERE_LESSER_THAN);
1820                                            }
1821                                    }
1822                            }
1823    
1824                            query.append(ORDER_BY_CLAUSE);
1825    
1826                            String[] orderByFields = orderByComparator.getOrderByFields();
1827    
1828                            for (int i = 0; i < orderByFields.length; i++) {
1829                                    if (getDB().isSupportsInlineDistinct()) {
1830                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1831                                    }
1832                                    else {
1833                                            query.append(_ORDER_BY_ENTITY_TABLE);
1834                                    }
1835    
1836                                    query.append(orderByFields[i]);
1837    
1838                                    if ((i + 1) < orderByFields.length) {
1839                                            if (orderByComparator.isAscending() ^ previous) {
1840                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1841                                            }
1842                                            else {
1843                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1844                                            }
1845                                    }
1846                                    else {
1847                                            if (orderByComparator.isAscending() ^ previous) {
1848                                                    query.append(ORDER_BY_ASC);
1849                                            }
1850                                            else {
1851                                                    query.append(ORDER_BY_DESC);
1852                                            }
1853                                    }
1854                            }
1855                    }
1856                    else {
1857                            if (getDB().isSupportsInlineDistinct()) {
1858                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1859                            }
1860                            else {
1861                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
1862                            }
1863                    }
1864    
1865                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1866                                    LayoutSetPrototype.class.getName(),
1867                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1868    
1869                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
1870    
1871                    q.setFirstResult(0);
1872                    q.setMaxResults(2);
1873    
1874                    if (getDB().isSupportsInlineDistinct()) {
1875                            q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
1876                    }
1877                    else {
1878                            q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
1879                    }
1880    
1881                    QueryPos qPos = QueryPos.getInstance(q);
1882    
1883                    if (bindUuid) {
1884                            qPos.add(uuid);
1885                    }
1886    
1887                    qPos.add(companyId);
1888    
1889                    if (orderByComparator != null) {
1890                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
1891    
1892                            for (Object value : values) {
1893                                    qPos.add(value);
1894                            }
1895                    }
1896    
1897                    List<LayoutSetPrototype> list = q.list();
1898    
1899                    if (list.size() == 2) {
1900                            return list.get(1);
1901                    }
1902                    else {
1903                            return null;
1904                    }
1905            }
1906    
1907            /**
1908             * Removes all the layout set prototypes where uuid = &#63; and companyId = &#63; from the database.
1909             *
1910             * @param uuid the uuid
1911             * @param companyId the company ID
1912             */
1913            @Override
1914            public void removeByUuid_C(String uuid, long companyId) {
1915                    for (LayoutSetPrototype layoutSetPrototype : findByUuid_C(uuid,
1916                                    companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1917                            remove(layoutSetPrototype);
1918                    }
1919            }
1920    
1921            /**
1922             * Returns the number of layout set prototypes where uuid = &#63; and companyId = &#63;.
1923             *
1924             * @param uuid the uuid
1925             * @param companyId the company ID
1926             * @return the number of matching layout set prototypes
1927             */
1928            @Override
1929            public int countByUuid_C(String uuid, long companyId) {
1930                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1931    
1932                    Object[] finderArgs = new Object[] { uuid, companyId };
1933    
1934                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1935    
1936                    if (count == null) {
1937                            StringBundler query = new StringBundler(3);
1938    
1939                            query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
1940    
1941                            boolean bindUuid = false;
1942    
1943                            if (uuid == null) {
1944                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1945                            }
1946                            else if (uuid.equals(StringPool.BLANK)) {
1947                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1948                            }
1949                            else {
1950                                    bindUuid = true;
1951    
1952                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1953                            }
1954    
1955                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1956    
1957                            String sql = query.toString();
1958    
1959                            Session session = null;
1960    
1961                            try {
1962                                    session = openSession();
1963    
1964                                    Query q = session.createQuery(sql);
1965    
1966                                    QueryPos qPos = QueryPos.getInstance(q);
1967    
1968                                    if (bindUuid) {
1969                                            qPos.add(uuid);
1970                                    }
1971    
1972                                    qPos.add(companyId);
1973    
1974                                    count = (Long)q.uniqueResult();
1975    
1976                                    finderCache.putResult(finderPath, finderArgs, count);
1977                            }
1978                            catch (Exception e) {
1979                                    finderCache.removeResult(finderPath, finderArgs);
1980    
1981                                    throw processException(e);
1982                            }
1983                            finally {
1984                                    closeSession(session);
1985                            }
1986                    }
1987    
1988                    return count.intValue();
1989            }
1990    
1991            /**
1992             * Returns the number of layout set prototypes that the user has permission to view where uuid = &#63; and companyId = &#63;.
1993             *
1994             * @param uuid the uuid
1995             * @param companyId the company ID
1996             * @return the number of matching layout set prototypes that the user has permission to view
1997             */
1998            @Override
1999            public int filterCountByUuid_C(String uuid, long companyId) {
2000                    if (!InlineSQLHelperUtil.isEnabled()) {
2001                            return countByUuid_C(uuid, companyId);
2002                    }
2003    
2004                    StringBundler query = new StringBundler(3);
2005    
2006                    query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
2007    
2008                    boolean bindUuid = false;
2009    
2010                    if (uuid == null) {
2011                            query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
2012                    }
2013                    else if (uuid.equals(StringPool.BLANK)) {
2014                            query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
2015                    }
2016                    else {
2017                            bindUuid = true;
2018    
2019                            query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
2020                    }
2021    
2022                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2023    
2024                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2025                                    LayoutSetPrototype.class.getName(),
2026                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2027    
2028                    Session session = null;
2029    
2030                    try {
2031                            session = openSession();
2032    
2033                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2034    
2035                            q.addScalar(COUNT_COLUMN_NAME,
2036                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2037    
2038                            QueryPos qPos = QueryPos.getInstance(q);
2039    
2040                            if (bindUuid) {
2041                                    qPos.add(uuid);
2042                            }
2043    
2044                            qPos.add(companyId);
2045    
2046                            Long count = (Long)q.uniqueResult();
2047    
2048                            return count.intValue();
2049                    }
2050                    catch (Exception e) {
2051                            throw processException(e);
2052                    }
2053                    finally {
2054                            closeSession(session);
2055                    }
2056            }
2057    
2058            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "layoutSetPrototype.uuid IS NULL AND ";
2059            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "layoutSetPrototype.uuid = ? AND ";
2060            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(layoutSetPrototype.uuid IS NULL OR layoutSetPrototype.uuid = '') AND ";
2061            private static final String _FINDER_COLUMN_UUID_C_UUID_1_SQL = "layoutSetPrototype.uuid_ IS NULL AND ";
2062            private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "layoutSetPrototype.uuid_ = ? AND ";
2063            private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(layoutSetPrototype.uuid_ IS NULL OR layoutSetPrototype.uuid_ = '') AND ";
2064            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "layoutSetPrototype.companyId = ?";
2065            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2066                    new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2067                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2068                            LayoutSetPrototypeImpl.class,
2069                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2070                            new String[] {
2071                                    Long.class.getName(),
2072                                    
2073                            Integer.class.getName(), Integer.class.getName(),
2074                                    OrderByComparator.class.getName()
2075                            });
2076            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2077                    new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2078                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2079                            LayoutSetPrototypeImpl.class,
2080                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2081                            new String[] { Long.class.getName() },
2082                            LayoutSetPrototypeModelImpl.COMPANYID_COLUMN_BITMASK);
2083            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2084                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2085                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2086                            new String[] { Long.class.getName() });
2087    
2088            /**
2089             * Returns all the layout set prototypes where companyId = &#63;.
2090             *
2091             * @param companyId the company ID
2092             * @return the matching layout set prototypes
2093             */
2094            @Override
2095            public List<LayoutSetPrototype> findByCompanyId(long companyId) {
2096                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2097                            null);
2098            }
2099    
2100            /**
2101             * Returns a range of all the layout set prototypes where companyId = &#63;.
2102             *
2103             * <p>
2104             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
2105             * </p>
2106             *
2107             * @param companyId the company ID
2108             * @param start the lower bound of the range of layout set prototypes
2109             * @param end the upper bound of the range of layout set prototypes (not inclusive)
2110             * @return the range of matching layout set prototypes
2111             */
2112            @Override
2113            public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
2114                    int end) {
2115                    return findByCompanyId(companyId, start, end, null);
2116            }
2117    
2118            /**
2119             * Returns an ordered range of all the layout set prototypes where companyId = &#63;.
2120             *
2121             * <p>
2122             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
2123             * </p>
2124             *
2125             * @param companyId the company ID
2126             * @param start the lower bound of the range of layout set prototypes
2127             * @param end the upper bound of the range of layout set prototypes (not inclusive)
2128             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2129             * @return the ordered range of matching layout set prototypes
2130             */
2131            @Override
2132            public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
2133                    int end, OrderByComparator<LayoutSetPrototype> orderByComparator) {
2134                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2135            }
2136    
2137            /**
2138             * Returns an ordered range of all the layout set prototypes where companyId = &#63;.
2139             *
2140             * <p>
2141             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
2142             * </p>
2143             *
2144             * @param companyId the company ID
2145             * @param start the lower bound of the range of layout set prototypes
2146             * @param end the upper bound of the range of layout set prototypes (not inclusive)
2147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2148             * @param retrieveFromCache whether to retrieve from the finder cache
2149             * @return the ordered range of matching layout set prototypes
2150             */
2151            @Override
2152            public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
2153                    int end, OrderByComparator<LayoutSetPrototype> orderByComparator,
2154                    boolean retrieveFromCache) {
2155                    boolean pagination = true;
2156                    FinderPath finderPath = null;
2157                    Object[] finderArgs = null;
2158    
2159                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2160                                    (orderByComparator == null)) {
2161                            pagination = false;
2162                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2163                            finderArgs = new Object[] { companyId };
2164                    }
2165                    else {
2166                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2167                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2168                    }
2169    
2170                    List<LayoutSetPrototype> list = null;
2171    
2172                    if (retrieveFromCache) {
2173                            list = (List<LayoutSetPrototype>)finderCache.getResult(finderPath,
2174                                            finderArgs, this);
2175    
2176                            if ((list != null) && !list.isEmpty()) {
2177                                    for (LayoutSetPrototype layoutSetPrototype : list) {
2178                                            if ((companyId != layoutSetPrototype.getCompanyId())) {
2179                                                    list = null;
2180    
2181                                                    break;
2182                                            }
2183                                    }
2184                            }
2185                    }
2186    
2187                    if (list == null) {
2188                            StringBundler query = null;
2189    
2190                            if (orderByComparator != null) {
2191                                    query = new StringBundler(3 +
2192                                                    (orderByComparator.getOrderByFields().length * 3));
2193                            }
2194                            else {
2195                                    query = new StringBundler(3);
2196                            }
2197    
2198                            query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2199    
2200                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2201    
2202                            if (orderByComparator != null) {
2203                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2204                                            orderByComparator);
2205                            }
2206                            else
2207                             if (pagination) {
2208                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2209                            }
2210    
2211                            String sql = query.toString();
2212    
2213                            Session session = null;
2214    
2215                            try {
2216                                    session = openSession();
2217    
2218                                    Query q = session.createQuery(sql);
2219    
2220                                    QueryPos qPos = QueryPos.getInstance(q);
2221    
2222                                    qPos.add(companyId);
2223    
2224                                    if (!pagination) {
2225                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
2226                                                            getDialect(), start, end, false);
2227    
2228                                            Collections.sort(list);
2229    
2230                                            list = Collections.unmodifiableList(list);
2231                                    }
2232                                    else {
2233                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
2234                                                            getDialect(), start, end);
2235                                    }
2236    
2237                                    cacheResult(list);
2238    
2239                                    finderCache.putResult(finderPath, finderArgs, list);
2240                            }
2241                            catch (Exception e) {
2242                                    finderCache.removeResult(finderPath, finderArgs);
2243    
2244                                    throw processException(e);
2245                            }
2246                            finally {
2247                                    closeSession(session);
2248                            }
2249                    }
2250    
2251                    return list;
2252            }
2253    
2254            /**
2255             * Returns the first layout set prototype in the ordered set where companyId = &#63;.
2256             *
2257             * @param companyId the company ID
2258             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2259             * @return the first matching layout set prototype
2260             * @throws NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
2261             */
2262            @Override
2263            public LayoutSetPrototype findByCompanyId_First(long companyId,
2264                    OrderByComparator<LayoutSetPrototype> orderByComparator)
2265                    throws NoSuchLayoutSetPrototypeException {
2266                    LayoutSetPrototype layoutSetPrototype = fetchByCompanyId_First(companyId,
2267                                    orderByComparator);
2268    
2269                    if (layoutSetPrototype != null) {
2270                            return layoutSetPrototype;
2271                    }
2272    
2273                    StringBundler msg = new StringBundler(4);
2274    
2275                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2276    
2277                    msg.append("companyId=");
2278                    msg.append(companyId);
2279    
2280                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2281    
2282                    throw new NoSuchLayoutSetPrototypeException(msg.toString());
2283            }
2284    
2285            /**
2286             * Returns the first layout set prototype in the ordered set where companyId = &#63;.
2287             *
2288             * @param companyId the company ID
2289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2290             * @return the first matching layout set prototype, or <code>null</code> if a matching layout set prototype could not be found
2291             */
2292            @Override
2293            public LayoutSetPrototype fetchByCompanyId_First(long companyId,
2294                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
2295                    List<LayoutSetPrototype> list = findByCompanyId(companyId, 0, 1,
2296                                    orderByComparator);
2297    
2298                    if (!list.isEmpty()) {
2299                            return list.get(0);
2300                    }
2301    
2302                    return null;
2303            }
2304    
2305            /**
2306             * Returns the last layout set prototype in the ordered set where companyId = &#63;.
2307             *
2308             * @param companyId the company ID
2309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2310             * @return the last matching layout set prototype
2311             * @throws NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
2312             */
2313            @Override
2314            public LayoutSetPrototype findByCompanyId_Last(long companyId,
2315                    OrderByComparator<LayoutSetPrototype> orderByComparator)
2316                    throws NoSuchLayoutSetPrototypeException {
2317                    LayoutSetPrototype layoutSetPrototype = fetchByCompanyId_Last(companyId,
2318                                    orderByComparator);
2319    
2320                    if (layoutSetPrototype != null) {
2321                            return layoutSetPrototype;
2322                    }
2323    
2324                    StringBundler msg = new StringBundler(4);
2325    
2326                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2327    
2328                    msg.append("companyId=");
2329                    msg.append(companyId);
2330    
2331                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2332    
2333                    throw new NoSuchLayoutSetPrototypeException(msg.toString());
2334            }
2335    
2336            /**
2337             * Returns the last layout set prototype in the ordered set where companyId = &#63;.
2338             *
2339             * @param companyId the company ID
2340             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2341             * @return the last matching layout set prototype, or <code>null</code> if a matching layout set prototype could not be found
2342             */
2343            @Override
2344            public LayoutSetPrototype fetchByCompanyId_Last(long companyId,
2345                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
2346                    int count = countByCompanyId(companyId);
2347    
2348                    if (count == 0) {
2349                            return null;
2350                    }
2351    
2352                    List<LayoutSetPrototype> list = findByCompanyId(companyId, count - 1,
2353                                    count, orderByComparator);
2354    
2355                    if (!list.isEmpty()) {
2356                            return list.get(0);
2357                    }
2358    
2359                    return null;
2360            }
2361    
2362            /**
2363             * Returns the layout set prototypes before and after the current layout set prototype in the ordered set where companyId = &#63;.
2364             *
2365             * @param layoutSetPrototypeId the primary key of the current layout set prototype
2366             * @param companyId the company ID
2367             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2368             * @return the previous, current, and next layout set prototype
2369             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
2370             */
2371            @Override
2372            public LayoutSetPrototype[] findByCompanyId_PrevAndNext(
2373                    long layoutSetPrototypeId, long companyId,
2374                    OrderByComparator<LayoutSetPrototype> orderByComparator)
2375                    throws NoSuchLayoutSetPrototypeException {
2376                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
2377    
2378                    Session session = null;
2379    
2380                    try {
2381                            session = openSession();
2382    
2383                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
2384    
2385                            array[0] = getByCompanyId_PrevAndNext(session, layoutSetPrototype,
2386                                            companyId, orderByComparator, true);
2387    
2388                            array[1] = layoutSetPrototype;
2389    
2390                            array[2] = getByCompanyId_PrevAndNext(session, layoutSetPrototype,
2391                                            companyId, orderByComparator, false);
2392    
2393                            return array;
2394                    }
2395                    catch (Exception e) {
2396                            throw processException(e);
2397                    }
2398                    finally {
2399                            closeSession(session);
2400                    }
2401            }
2402    
2403            protected LayoutSetPrototype getByCompanyId_PrevAndNext(Session session,
2404                    LayoutSetPrototype layoutSetPrototype, long companyId,
2405                    OrderByComparator<LayoutSetPrototype> orderByComparator,
2406                    boolean previous) {
2407                    StringBundler query = null;
2408    
2409                    if (orderByComparator != null) {
2410                            query = new StringBundler(6 +
2411                                            (orderByComparator.getOrderByFields().length * 6));
2412                    }
2413                    else {
2414                            query = new StringBundler(3);
2415                    }
2416    
2417                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2418    
2419                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2420    
2421                    if (orderByComparator != null) {
2422                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2423    
2424                            if (orderByConditionFields.length > 0) {
2425                                    query.append(WHERE_AND);
2426                            }
2427    
2428                            for (int i = 0; i < orderByConditionFields.length; i++) {
2429                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2430                                    query.append(orderByConditionFields[i]);
2431    
2432                                    if ((i + 1) < orderByConditionFields.length) {
2433                                            if (orderByComparator.isAscending() ^ previous) {
2434                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2435                                            }
2436                                            else {
2437                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2438                                            }
2439                                    }
2440                                    else {
2441                                            if (orderByComparator.isAscending() ^ previous) {
2442                                                    query.append(WHERE_GREATER_THAN);
2443                                            }
2444                                            else {
2445                                                    query.append(WHERE_LESSER_THAN);
2446                                            }
2447                                    }
2448                            }
2449    
2450                            query.append(ORDER_BY_CLAUSE);
2451    
2452                            String[] orderByFields = orderByComparator.getOrderByFields();
2453    
2454                            for (int i = 0; i < orderByFields.length; i++) {
2455                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2456                                    query.append(orderByFields[i]);
2457    
2458                                    if ((i + 1) < orderByFields.length) {
2459                                            if (orderByComparator.isAscending() ^ previous) {
2460                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2461                                            }
2462                                            else {
2463                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2464                                            }
2465                                    }
2466                                    else {
2467                                            if (orderByComparator.isAscending() ^ previous) {
2468                                                    query.append(ORDER_BY_ASC);
2469                                            }
2470                                            else {
2471                                                    query.append(ORDER_BY_DESC);
2472                                            }
2473                                    }
2474                            }
2475                    }
2476                    else {
2477                            query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2478                    }
2479    
2480                    String sql = query.toString();
2481    
2482                    Query q = session.createQuery(sql);
2483    
2484                    q.setFirstResult(0);
2485                    q.setMaxResults(2);
2486    
2487                    QueryPos qPos = QueryPos.getInstance(q);
2488    
2489                    qPos.add(companyId);
2490    
2491                    if (orderByComparator != null) {
2492                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
2493    
2494                            for (Object value : values) {
2495                                    qPos.add(value);
2496                            }
2497                    }
2498    
2499                    List<LayoutSetPrototype> list = q.list();
2500    
2501                    if (list.size() == 2) {
2502                            return list.get(1);
2503                    }
2504                    else {
2505                            return null;
2506                    }
2507            }
2508    
2509            /**
2510             * Returns all the layout set prototypes that the user has permission to view where companyId = &#63;.
2511             *
2512             * @param companyId the company ID
2513             * @return the matching layout set prototypes that the user has permission to view
2514             */
2515            @Override
2516            public List<LayoutSetPrototype> filterFindByCompanyId(long companyId) {
2517                    return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
2518                            QueryUtil.ALL_POS, null);
2519            }
2520    
2521            /**
2522             * Returns a range of all the layout set prototypes that the user has permission to view where companyId = &#63;.
2523             *
2524             * <p>
2525             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
2526             * </p>
2527             *
2528             * @param companyId the company ID
2529             * @param start the lower bound of the range of layout set prototypes
2530             * @param end the upper bound of the range of layout set prototypes (not inclusive)
2531             * @return the range of matching layout set prototypes that the user has permission to view
2532             */
2533            @Override
2534            public List<LayoutSetPrototype> filterFindByCompanyId(long companyId,
2535                    int start, int end) {
2536                    return filterFindByCompanyId(companyId, start, end, null);
2537            }
2538    
2539            /**
2540             * Returns an ordered range of all the layout set prototypes that the user has permissions to view where companyId = &#63;.
2541             *
2542             * <p>
2543             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
2544             * </p>
2545             *
2546             * @param companyId the company ID
2547             * @param start the lower bound of the range of layout set prototypes
2548             * @param end the upper bound of the range of layout set prototypes (not inclusive)
2549             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2550             * @return the ordered range of matching layout set prototypes that the user has permission to view
2551             */
2552            @Override
2553            public List<LayoutSetPrototype> filterFindByCompanyId(long companyId,
2554                    int start, int end,
2555                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
2556                    if (!InlineSQLHelperUtil.isEnabled()) {
2557                            return findByCompanyId(companyId, start, end, orderByComparator);
2558                    }
2559    
2560                    StringBundler query = null;
2561    
2562                    if (orderByComparator != null) {
2563                            query = new StringBundler(3 +
2564                                            (orderByComparator.getOrderByFields().length * 3));
2565                    }
2566                    else {
2567                            query = new StringBundler(3);
2568                    }
2569    
2570                    if (getDB().isSupportsInlineDistinct()) {
2571                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2572                    }
2573                    else {
2574                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
2575                    }
2576    
2577                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2578    
2579                    if (!getDB().isSupportsInlineDistinct()) {
2580                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
2581                    }
2582    
2583                    if (orderByComparator != null) {
2584                            if (getDB().isSupportsInlineDistinct()) {
2585                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2586                                            orderByComparator, true);
2587                            }
2588                            else {
2589                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2590                                            orderByComparator, true);
2591                            }
2592                    }
2593                    else {
2594                            if (getDB().isSupportsInlineDistinct()) {
2595                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2596                            }
2597                            else {
2598                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
2599                            }
2600                    }
2601    
2602                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2603                                    LayoutSetPrototype.class.getName(),
2604                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2605    
2606                    Session session = null;
2607    
2608                    try {
2609                            session = openSession();
2610    
2611                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2612    
2613                            if (getDB().isSupportsInlineDistinct()) {
2614                                    q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
2615                            }
2616                            else {
2617                                    q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
2618                            }
2619    
2620                            QueryPos qPos = QueryPos.getInstance(q);
2621    
2622                            qPos.add(companyId);
2623    
2624                            return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
2625                                    start, end);
2626                    }
2627                    catch (Exception e) {
2628                            throw processException(e);
2629                    }
2630                    finally {
2631                            closeSession(session);
2632                    }
2633            }
2634    
2635            /**
2636             * Returns the layout set prototypes before and after the current layout set prototype in the ordered set of layout set prototypes that the user has permission to view where companyId = &#63;.
2637             *
2638             * @param layoutSetPrototypeId the primary key of the current layout set prototype
2639             * @param companyId the company ID
2640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2641             * @return the previous, current, and next layout set prototype
2642             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
2643             */
2644            @Override
2645            public LayoutSetPrototype[] filterFindByCompanyId_PrevAndNext(
2646                    long layoutSetPrototypeId, long companyId,
2647                    OrderByComparator<LayoutSetPrototype> orderByComparator)
2648                    throws NoSuchLayoutSetPrototypeException {
2649                    if (!InlineSQLHelperUtil.isEnabled()) {
2650                            return findByCompanyId_PrevAndNext(layoutSetPrototypeId, companyId,
2651                                    orderByComparator);
2652                    }
2653    
2654                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
2655    
2656                    Session session = null;
2657    
2658                    try {
2659                            session = openSession();
2660    
2661                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
2662    
2663                            array[0] = filterGetByCompanyId_PrevAndNext(session,
2664                                            layoutSetPrototype, companyId, orderByComparator, true);
2665    
2666                            array[1] = layoutSetPrototype;
2667    
2668                            array[2] = filterGetByCompanyId_PrevAndNext(session,
2669                                            layoutSetPrototype, companyId, orderByComparator, false);
2670    
2671                            return array;
2672                    }
2673                    catch (Exception e) {
2674                            throw processException(e);
2675                    }
2676                    finally {
2677                            closeSession(session);
2678                    }
2679            }
2680    
2681            protected LayoutSetPrototype filterGetByCompanyId_PrevAndNext(
2682                    Session session, LayoutSetPrototype layoutSetPrototype, long companyId,
2683                    OrderByComparator<LayoutSetPrototype> orderByComparator,
2684                    boolean previous) {
2685                    StringBundler query = null;
2686    
2687                    if (orderByComparator != null) {
2688                            query = new StringBundler(6 +
2689                                            (orderByComparator.getOrderByFields().length * 6));
2690                    }
2691                    else {
2692                            query = new StringBundler(3);
2693                    }
2694    
2695                    if (getDB().isSupportsInlineDistinct()) {
2696                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2697                    }
2698                    else {
2699                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
2700                    }
2701    
2702                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2703    
2704                    if (!getDB().isSupportsInlineDistinct()) {
2705                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
2706                    }
2707    
2708                    if (orderByComparator != null) {
2709                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2710    
2711                            if (orderByConditionFields.length > 0) {
2712                                    query.append(WHERE_AND);
2713                            }
2714    
2715                            for (int i = 0; i < orderByConditionFields.length; i++) {
2716                                    if (getDB().isSupportsInlineDistinct()) {
2717                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2718                                    }
2719                                    else {
2720                                            query.append(_ORDER_BY_ENTITY_TABLE);
2721                                    }
2722    
2723                                    query.append(orderByConditionFields[i]);
2724    
2725                                    if ((i + 1) < orderByConditionFields.length) {
2726                                            if (orderByComparator.isAscending() ^ previous) {
2727                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2728                                            }
2729                                            else {
2730                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2731                                            }
2732                                    }
2733                                    else {
2734                                            if (orderByComparator.isAscending() ^ previous) {
2735                                                    query.append(WHERE_GREATER_THAN);
2736                                            }
2737                                            else {
2738                                                    query.append(WHERE_LESSER_THAN);
2739                                            }
2740                                    }
2741                            }
2742    
2743                            query.append(ORDER_BY_CLAUSE);
2744    
2745                            String[] orderByFields = orderByComparator.getOrderByFields();
2746    
2747                            for (int i = 0; i < orderByFields.length; i++) {
2748                                    if (getDB().isSupportsInlineDistinct()) {
2749                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2750                                    }
2751                                    else {
2752                                            query.append(_ORDER_BY_ENTITY_TABLE);
2753                                    }
2754    
2755                                    query.append(orderByFields[i]);
2756    
2757                                    if ((i + 1) < orderByFields.length) {
2758                                            if (orderByComparator.isAscending() ^ previous) {
2759                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2760                                            }
2761                                            else {
2762                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2763                                            }
2764                                    }
2765                                    else {
2766                                            if (orderByComparator.isAscending() ^ previous) {
2767                                                    query.append(ORDER_BY_ASC);
2768                                            }
2769                                            else {
2770                                                    query.append(ORDER_BY_DESC);
2771                                            }
2772                                    }
2773                            }
2774                    }
2775                    else {
2776                            if (getDB().isSupportsInlineDistinct()) {
2777                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2778                            }
2779                            else {
2780                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
2781                            }
2782                    }
2783    
2784                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2785                                    LayoutSetPrototype.class.getName(),
2786                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2787    
2788                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2789    
2790                    q.setFirstResult(0);
2791                    q.setMaxResults(2);
2792    
2793                    if (getDB().isSupportsInlineDistinct()) {
2794                            q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
2795                    }
2796                    else {
2797                            q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
2798                    }
2799    
2800                    QueryPos qPos = QueryPos.getInstance(q);
2801    
2802                    qPos.add(companyId);
2803    
2804                    if (orderByComparator != null) {
2805                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
2806    
2807                            for (Object value : values) {
2808                                    qPos.add(value);
2809                            }
2810                    }
2811    
2812                    List<LayoutSetPrototype> list = q.list();
2813    
2814                    if (list.size() == 2) {
2815                            return list.get(1);
2816                    }
2817                    else {
2818                            return null;
2819                    }
2820            }
2821    
2822            /**
2823             * Removes all the layout set prototypes where companyId = &#63; from the database.
2824             *
2825             * @param companyId the company ID
2826             */
2827            @Override
2828            public void removeByCompanyId(long companyId) {
2829                    for (LayoutSetPrototype layoutSetPrototype : findByCompanyId(
2830                                    companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2831                            remove(layoutSetPrototype);
2832                    }
2833            }
2834    
2835            /**
2836             * Returns the number of layout set prototypes where companyId = &#63;.
2837             *
2838             * @param companyId the company ID
2839             * @return the number of matching layout set prototypes
2840             */
2841            @Override
2842            public int countByCompanyId(long companyId) {
2843                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2844    
2845                    Object[] finderArgs = new Object[] { companyId };
2846    
2847                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2848    
2849                    if (count == null) {
2850                            StringBundler query = new StringBundler(2);
2851    
2852                            query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
2853    
2854                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2855    
2856                            String sql = query.toString();
2857    
2858                            Session session = null;
2859    
2860                            try {
2861                                    session = openSession();
2862    
2863                                    Query q = session.createQuery(sql);
2864    
2865                                    QueryPos qPos = QueryPos.getInstance(q);
2866    
2867                                    qPos.add(companyId);
2868    
2869                                    count = (Long)q.uniqueResult();
2870    
2871                                    finderCache.putResult(finderPath, finderArgs, count);
2872                            }
2873                            catch (Exception e) {
2874                                    finderCache.removeResult(finderPath, finderArgs);
2875    
2876                                    throw processException(e);
2877                            }
2878                            finally {
2879                                    closeSession(session);
2880                            }
2881                    }
2882    
2883                    return count.intValue();
2884            }
2885    
2886            /**
2887             * Returns the number of layout set prototypes that the user has permission to view where companyId = &#63;.
2888             *
2889             * @param companyId the company ID
2890             * @return the number of matching layout set prototypes that the user has permission to view
2891             */
2892            @Override
2893            public int filterCountByCompanyId(long companyId) {
2894                    if (!InlineSQLHelperUtil.isEnabled()) {
2895                            return countByCompanyId(companyId);
2896                    }
2897    
2898                    StringBundler query = new StringBundler(2);
2899    
2900                    query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
2901    
2902                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2903    
2904                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2905                                    LayoutSetPrototype.class.getName(),
2906                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2907    
2908                    Session session = null;
2909    
2910                    try {
2911                            session = openSession();
2912    
2913                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2914    
2915                            q.addScalar(COUNT_COLUMN_NAME,
2916                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2917    
2918                            QueryPos qPos = QueryPos.getInstance(q);
2919    
2920                            qPos.add(companyId);
2921    
2922                            Long count = (Long)q.uniqueResult();
2923    
2924                            return count.intValue();
2925                    }
2926                    catch (Exception e) {
2927                            throw processException(e);
2928                    }
2929                    finally {
2930                            closeSession(session);
2931                    }
2932            }
2933    
2934            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "layoutSetPrototype.companyId = ?";
2935            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2936                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2937                            LayoutSetPrototypeImpl.class,
2938                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_A",
2939                            new String[] {
2940                                    Long.class.getName(), Boolean.class.getName(),
2941                                    
2942                            Integer.class.getName(), Integer.class.getName(),
2943                                    OrderByComparator.class.getName()
2944                            });
2945            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2946                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2947                            LayoutSetPrototypeImpl.class,
2948                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_A",
2949                            new String[] { Long.class.getName(), Boolean.class.getName() },
2950                            LayoutSetPrototypeModelImpl.COMPANYID_COLUMN_BITMASK |
2951                            LayoutSetPrototypeModelImpl.ACTIVE_COLUMN_BITMASK);
2952            public static final FinderPath FINDER_PATH_COUNT_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2953                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2954                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_A",
2955                            new String[] { Long.class.getName(), Boolean.class.getName() });
2956    
2957            /**
2958             * Returns all the layout set prototypes where companyId = &#63; and active = &#63;.
2959             *
2960             * @param companyId the company ID
2961             * @param active the active
2962             * @return the matching layout set prototypes
2963             */
2964            @Override
2965            public List<LayoutSetPrototype> findByC_A(long companyId, boolean active) {
2966                    return findByC_A(companyId, active, QueryUtil.ALL_POS,
2967                            QueryUtil.ALL_POS, null);
2968            }
2969    
2970            /**
2971             * Returns a range of all the layout set prototypes where companyId = &#63; and active = &#63;.
2972             *
2973             * <p>
2974             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
2975             * </p>
2976             *
2977             * @param companyId the company ID
2978             * @param active the active
2979             * @param start the lower bound of the range of layout set prototypes
2980             * @param end the upper bound of the range of layout set prototypes (not inclusive)
2981             * @return the range of matching layout set prototypes
2982             */
2983            @Override
2984            public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
2985                    int start, int end) {
2986                    return findByC_A(companyId, active, start, end, null);
2987            }
2988    
2989            /**
2990             * Returns an ordered range of all the layout set prototypes where companyId = &#63; and active = &#63;.
2991             *
2992             * <p>
2993             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
2994             * </p>
2995             *
2996             * @param companyId the company ID
2997             * @param active the active
2998             * @param start the lower bound of the range of layout set prototypes
2999             * @param end the upper bound of the range of layout set prototypes (not inclusive)
3000             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3001             * @return the ordered range of matching layout set prototypes
3002             */
3003            @Override
3004            public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
3005                    int start, int end,
3006                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
3007                    return findByC_A(companyId, active, start, end, orderByComparator, true);
3008            }
3009    
3010            /**
3011             * Returns an ordered range of all the layout set prototypes where companyId = &#63; and active = &#63;.
3012             *
3013             * <p>
3014             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
3015             * </p>
3016             *
3017             * @param companyId the company ID
3018             * @param active the active
3019             * @param start the lower bound of the range of layout set prototypes
3020             * @param end the upper bound of the range of layout set prototypes (not inclusive)
3021             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3022             * @param retrieveFromCache whether to retrieve from the finder cache
3023             * @return the ordered range of matching layout set prototypes
3024             */
3025            @Override
3026            public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
3027                    int start, int end,
3028                    OrderByComparator<LayoutSetPrototype> orderByComparator,
3029                    boolean retrieveFromCache) {
3030                    boolean pagination = true;
3031                    FinderPath finderPath = null;
3032                    Object[] finderArgs = null;
3033    
3034                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3035                                    (orderByComparator == null)) {
3036                            pagination = false;
3037                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A;
3038                            finderArgs = new Object[] { companyId, active };
3039                    }
3040                    else {
3041                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_A;
3042                            finderArgs = new Object[] {
3043                                            companyId, active,
3044                                            
3045                                            start, end, orderByComparator
3046                                    };
3047                    }
3048    
3049                    List<LayoutSetPrototype> list = null;
3050    
3051                    if (retrieveFromCache) {
3052                            list = (List<LayoutSetPrototype>)finderCache.getResult(finderPath,
3053                                            finderArgs, this);
3054    
3055                            if ((list != null) && !list.isEmpty()) {
3056                                    for (LayoutSetPrototype layoutSetPrototype : list) {
3057                                            if ((companyId != layoutSetPrototype.getCompanyId()) ||
3058                                                            (active != layoutSetPrototype.getActive())) {
3059                                                    list = null;
3060    
3061                                                    break;
3062                                            }
3063                                    }
3064                            }
3065                    }
3066    
3067                    if (list == null) {
3068                            StringBundler query = null;
3069    
3070                            if (orderByComparator != null) {
3071                                    query = new StringBundler(4 +
3072                                                    (orderByComparator.getOrderByFields().length * 3));
3073                            }
3074                            else {
3075                                    query = new StringBundler(4);
3076                            }
3077    
3078                            query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3079    
3080                            query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3081    
3082                            query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3083    
3084                            if (orderByComparator != null) {
3085                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3086                                            orderByComparator);
3087                            }
3088                            else
3089                             if (pagination) {
3090                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3091                            }
3092    
3093                            String sql = query.toString();
3094    
3095                            Session session = null;
3096    
3097                            try {
3098                                    session = openSession();
3099    
3100                                    Query q = session.createQuery(sql);
3101    
3102                                    QueryPos qPos = QueryPos.getInstance(q);
3103    
3104                                    qPos.add(companyId);
3105    
3106                                    qPos.add(active);
3107    
3108                                    if (!pagination) {
3109                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
3110                                                            getDialect(), start, end, false);
3111    
3112                                            Collections.sort(list);
3113    
3114                                            list = Collections.unmodifiableList(list);
3115                                    }
3116                                    else {
3117                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
3118                                                            getDialect(), start, end);
3119                                    }
3120    
3121                                    cacheResult(list);
3122    
3123                                    finderCache.putResult(finderPath, finderArgs, list);
3124                            }
3125                            catch (Exception e) {
3126                                    finderCache.removeResult(finderPath, finderArgs);
3127    
3128                                    throw processException(e);
3129                            }
3130                            finally {
3131                                    closeSession(session);
3132                            }
3133                    }
3134    
3135                    return list;
3136            }
3137    
3138            /**
3139             * Returns the first layout set prototype in the ordered set where companyId = &#63; and active = &#63;.
3140             *
3141             * @param companyId the company ID
3142             * @param active the active
3143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3144             * @return the first matching layout set prototype
3145             * @throws NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
3146             */
3147            @Override
3148            public LayoutSetPrototype findByC_A_First(long companyId, boolean active,
3149                    OrderByComparator<LayoutSetPrototype> orderByComparator)
3150                    throws NoSuchLayoutSetPrototypeException {
3151                    LayoutSetPrototype layoutSetPrototype = fetchByC_A_First(companyId,
3152                                    active, orderByComparator);
3153    
3154                    if (layoutSetPrototype != null) {
3155                            return layoutSetPrototype;
3156                    }
3157    
3158                    StringBundler msg = new StringBundler(6);
3159    
3160                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3161    
3162                    msg.append("companyId=");
3163                    msg.append(companyId);
3164    
3165                    msg.append(", active=");
3166                    msg.append(active);
3167    
3168                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3169    
3170                    throw new NoSuchLayoutSetPrototypeException(msg.toString());
3171            }
3172    
3173            /**
3174             * Returns the first layout set prototype in the ordered set where companyId = &#63; and active = &#63;.
3175             *
3176             * @param companyId the company ID
3177             * @param active the active
3178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3179             * @return the first matching layout set prototype, or <code>null</code> if a matching layout set prototype could not be found
3180             */
3181            @Override
3182            public LayoutSetPrototype fetchByC_A_First(long companyId, boolean active,
3183                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
3184                    List<LayoutSetPrototype> list = findByC_A(companyId, active, 0, 1,
3185                                    orderByComparator);
3186    
3187                    if (!list.isEmpty()) {
3188                            return list.get(0);
3189                    }
3190    
3191                    return null;
3192            }
3193    
3194            /**
3195             * Returns the last layout set prototype in the ordered set where companyId = &#63; and active = &#63;.
3196             *
3197             * @param companyId the company ID
3198             * @param active the active
3199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3200             * @return the last matching layout set prototype
3201             * @throws NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
3202             */
3203            @Override
3204            public LayoutSetPrototype findByC_A_Last(long companyId, boolean active,
3205                    OrderByComparator<LayoutSetPrototype> orderByComparator)
3206                    throws NoSuchLayoutSetPrototypeException {
3207                    LayoutSetPrototype layoutSetPrototype = fetchByC_A_Last(companyId,
3208                                    active, orderByComparator);
3209    
3210                    if (layoutSetPrototype != null) {
3211                            return layoutSetPrototype;
3212                    }
3213    
3214                    StringBundler msg = new StringBundler(6);
3215    
3216                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3217    
3218                    msg.append("companyId=");
3219                    msg.append(companyId);
3220    
3221                    msg.append(", active=");
3222                    msg.append(active);
3223    
3224                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3225    
3226                    throw new NoSuchLayoutSetPrototypeException(msg.toString());
3227            }
3228    
3229            /**
3230             * Returns the last layout set prototype in the ordered set where companyId = &#63; and active = &#63;.
3231             *
3232             * @param companyId the company ID
3233             * @param active the active
3234             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3235             * @return the last matching layout set prototype, or <code>null</code> if a matching layout set prototype could not be found
3236             */
3237            @Override
3238            public LayoutSetPrototype fetchByC_A_Last(long companyId, boolean active,
3239                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
3240                    int count = countByC_A(companyId, active);
3241    
3242                    if (count == 0) {
3243                            return null;
3244                    }
3245    
3246                    List<LayoutSetPrototype> list = findByC_A(companyId, active, count - 1,
3247                                    count, orderByComparator);
3248    
3249                    if (!list.isEmpty()) {
3250                            return list.get(0);
3251                    }
3252    
3253                    return null;
3254            }
3255    
3256            /**
3257             * Returns the layout set prototypes before and after the current layout set prototype in the ordered set where companyId = &#63; and active = &#63;.
3258             *
3259             * @param layoutSetPrototypeId the primary key of the current layout set prototype
3260             * @param companyId the company ID
3261             * @param active the active
3262             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3263             * @return the previous, current, and next layout set prototype
3264             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
3265             */
3266            @Override
3267            public LayoutSetPrototype[] findByC_A_PrevAndNext(
3268                    long layoutSetPrototypeId, long companyId, boolean active,
3269                    OrderByComparator<LayoutSetPrototype> orderByComparator)
3270                    throws NoSuchLayoutSetPrototypeException {
3271                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
3272    
3273                    Session session = null;
3274    
3275                    try {
3276                            session = openSession();
3277    
3278                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
3279    
3280                            array[0] = getByC_A_PrevAndNext(session, layoutSetPrototype,
3281                                            companyId, active, orderByComparator, true);
3282    
3283                            array[1] = layoutSetPrototype;
3284    
3285                            array[2] = getByC_A_PrevAndNext(session, layoutSetPrototype,
3286                                            companyId, active, orderByComparator, false);
3287    
3288                            return array;
3289                    }
3290                    catch (Exception e) {
3291                            throw processException(e);
3292                    }
3293                    finally {
3294                            closeSession(session);
3295                    }
3296            }
3297    
3298            protected LayoutSetPrototype getByC_A_PrevAndNext(Session session,
3299                    LayoutSetPrototype layoutSetPrototype, long companyId, boolean active,
3300                    OrderByComparator<LayoutSetPrototype> orderByComparator,
3301                    boolean previous) {
3302                    StringBundler query = null;
3303    
3304                    if (orderByComparator != null) {
3305                            query = new StringBundler(6 +
3306                                            (orderByComparator.getOrderByFields().length * 6));
3307                    }
3308                    else {
3309                            query = new StringBundler(3);
3310                    }
3311    
3312                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3313    
3314                    query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3315    
3316                    query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3317    
3318                    if (orderByComparator != null) {
3319                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3320    
3321                            if (orderByConditionFields.length > 0) {
3322                                    query.append(WHERE_AND);
3323                            }
3324    
3325                            for (int i = 0; i < orderByConditionFields.length; i++) {
3326                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3327                                    query.append(orderByConditionFields[i]);
3328    
3329                                    if ((i + 1) < orderByConditionFields.length) {
3330                                            if (orderByComparator.isAscending() ^ previous) {
3331                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3332                                            }
3333                                            else {
3334                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3335                                            }
3336                                    }
3337                                    else {
3338                                            if (orderByComparator.isAscending() ^ previous) {
3339                                                    query.append(WHERE_GREATER_THAN);
3340                                            }
3341                                            else {
3342                                                    query.append(WHERE_LESSER_THAN);
3343                                            }
3344                                    }
3345                            }
3346    
3347                            query.append(ORDER_BY_CLAUSE);
3348    
3349                            String[] orderByFields = orderByComparator.getOrderByFields();
3350    
3351                            for (int i = 0; i < orderByFields.length; i++) {
3352                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3353                                    query.append(orderByFields[i]);
3354    
3355                                    if ((i + 1) < orderByFields.length) {
3356                                            if (orderByComparator.isAscending() ^ previous) {
3357                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3358                                            }
3359                                            else {
3360                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3361                                            }
3362                                    }
3363                                    else {
3364                                            if (orderByComparator.isAscending() ^ previous) {
3365                                                    query.append(ORDER_BY_ASC);
3366                                            }
3367                                            else {
3368                                                    query.append(ORDER_BY_DESC);
3369                                            }
3370                                    }
3371                            }
3372                    }
3373                    else {
3374                            query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3375                    }
3376    
3377                    String sql = query.toString();
3378    
3379                    Query q = session.createQuery(sql);
3380    
3381                    q.setFirstResult(0);
3382                    q.setMaxResults(2);
3383    
3384                    QueryPos qPos = QueryPos.getInstance(q);
3385    
3386                    qPos.add(companyId);
3387    
3388                    qPos.add(active);
3389    
3390                    if (orderByComparator != null) {
3391                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
3392    
3393                            for (Object value : values) {
3394                                    qPos.add(value);
3395                            }
3396                    }
3397    
3398                    List<LayoutSetPrototype> list = q.list();
3399    
3400                    if (list.size() == 2) {
3401                            return list.get(1);
3402                    }
3403                    else {
3404                            return null;
3405                    }
3406            }
3407    
3408            /**
3409             * Returns all the layout set prototypes that the user has permission to view where companyId = &#63; and active = &#63;.
3410             *
3411             * @param companyId the company ID
3412             * @param active the active
3413             * @return the matching layout set prototypes that the user has permission to view
3414             */
3415            @Override
3416            public List<LayoutSetPrototype> filterFindByC_A(long companyId,
3417                    boolean active) {
3418                    return filterFindByC_A(companyId, active, QueryUtil.ALL_POS,
3419                            QueryUtil.ALL_POS, null);
3420            }
3421    
3422            /**
3423             * Returns a range of all the layout set prototypes that the user has permission to view where companyId = &#63; and active = &#63;.
3424             *
3425             * <p>
3426             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
3427             * </p>
3428             *
3429             * @param companyId the company ID
3430             * @param active the active
3431             * @param start the lower bound of the range of layout set prototypes
3432             * @param end the upper bound of the range of layout set prototypes (not inclusive)
3433             * @return the range of matching layout set prototypes that the user has permission to view
3434             */
3435            @Override
3436            public List<LayoutSetPrototype> filterFindByC_A(long companyId,
3437                    boolean active, int start, int end) {
3438                    return filterFindByC_A(companyId, active, start, end, null);
3439            }
3440    
3441            /**
3442             * Returns an ordered range of all the layout set prototypes that the user has permissions to view where companyId = &#63; and active = &#63;.
3443             *
3444             * <p>
3445             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
3446             * </p>
3447             *
3448             * @param companyId the company ID
3449             * @param active the active
3450             * @param start the lower bound of the range of layout set prototypes
3451             * @param end the upper bound of the range of layout set prototypes (not inclusive)
3452             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3453             * @return the ordered range of matching layout set prototypes that the user has permission to view
3454             */
3455            @Override
3456            public List<LayoutSetPrototype> filterFindByC_A(long companyId,
3457                    boolean active, int start, int end,
3458                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
3459                    if (!InlineSQLHelperUtil.isEnabled()) {
3460                            return findByC_A(companyId, active, start, end, orderByComparator);
3461                    }
3462    
3463                    StringBundler query = null;
3464    
3465                    if (orderByComparator != null) {
3466                            query = new StringBundler(4 +
3467                                            (orderByComparator.getOrderByFields().length * 3));
3468                    }
3469                    else {
3470                            query = new StringBundler(4);
3471                    }
3472    
3473                    if (getDB().isSupportsInlineDistinct()) {
3474                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3475                    }
3476                    else {
3477                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
3478                    }
3479    
3480                    query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3481    
3482                    query.append(_FINDER_COLUMN_C_A_ACTIVE_2_SQL);
3483    
3484                    if (!getDB().isSupportsInlineDistinct()) {
3485                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
3486                    }
3487    
3488                    if (orderByComparator != null) {
3489                            if (getDB().isSupportsInlineDistinct()) {
3490                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3491                                            orderByComparator, true);
3492                            }
3493                            else {
3494                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3495                                            orderByComparator, true);
3496                            }
3497                    }
3498                    else {
3499                            if (getDB().isSupportsInlineDistinct()) {
3500                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3501                            }
3502                            else {
3503                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
3504                            }
3505                    }
3506    
3507                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3508                                    LayoutSetPrototype.class.getName(),
3509                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3510    
3511                    Session session = null;
3512    
3513                    try {
3514                            session = openSession();
3515    
3516                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3517    
3518                            if (getDB().isSupportsInlineDistinct()) {
3519                                    q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
3520                            }
3521                            else {
3522                                    q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
3523                            }
3524    
3525                            QueryPos qPos = QueryPos.getInstance(q);
3526    
3527                            qPos.add(companyId);
3528    
3529                            qPos.add(active);
3530    
3531                            return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
3532                                    start, end);
3533                    }
3534                    catch (Exception e) {
3535                            throw processException(e);
3536                    }
3537                    finally {
3538                            closeSession(session);
3539                    }
3540            }
3541    
3542            /**
3543             * Returns the layout set prototypes before and after the current layout set prototype in the ordered set of layout set prototypes that the user has permission to view where companyId = &#63; and active = &#63;.
3544             *
3545             * @param layoutSetPrototypeId the primary key of the current layout set prototype
3546             * @param companyId the company ID
3547             * @param active the active
3548             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3549             * @return the previous, current, and next layout set prototype
3550             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
3551             */
3552            @Override
3553            public LayoutSetPrototype[] filterFindByC_A_PrevAndNext(
3554                    long layoutSetPrototypeId, long companyId, boolean active,
3555                    OrderByComparator<LayoutSetPrototype> orderByComparator)
3556                    throws NoSuchLayoutSetPrototypeException {
3557                    if (!InlineSQLHelperUtil.isEnabled()) {
3558                            return findByC_A_PrevAndNext(layoutSetPrototypeId, companyId,
3559                                    active, orderByComparator);
3560                    }
3561    
3562                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
3563    
3564                    Session session = null;
3565    
3566                    try {
3567                            session = openSession();
3568    
3569                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
3570    
3571                            array[0] = filterGetByC_A_PrevAndNext(session, layoutSetPrototype,
3572                                            companyId, active, orderByComparator, true);
3573    
3574                            array[1] = layoutSetPrototype;
3575    
3576                            array[2] = filterGetByC_A_PrevAndNext(session, layoutSetPrototype,
3577                                            companyId, active, orderByComparator, false);
3578    
3579                            return array;
3580                    }
3581                    catch (Exception e) {
3582                            throw processException(e);
3583                    }
3584                    finally {
3585                            closeSession(session);
3586                    }
3587            }
3588    
3589            protected LayoutSetPrototype filterGetByC_A_PrevAndNext(Session session,
3590                    LayoutSetPrototype layoutSetPrototype, long companyId, boolean active,
3591                    OrderByComparator<LayoutSetPrototype> orderByComparator,
3592                    boolean previous) {
3593                    StringBundler query = null;
3594    
3595                    if (orderByComparator != null) {
3596                            query = new StringBundler(6 +
3597                                            (orderByComparator.getOrderByFields().length * 6));
3598                    }
3599                    else {
3600                            query = new StringBundler(3);
3601                    }
3602    
3603                    if (getDB().isSupportsInlineDistinct()) {
3604                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3605                    }
3606                    else {
3607                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
3608                    }
3609    
3610                    query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3611    
3612                    query.append(_FINDER_COLUMN_C_A_ACTIVE_2_SQL);
3613    
3614                    if (!getDB().isSupportsInlineDistinct()) {
3615                            query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
3616                    }
3617    
3618                    if (orderByComparator != null) {
3619                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3620    
3621                            if (orderByConditionFields.length > 0) {
3622                                    query.append(WHERE_AND);
3623                            }
3624    
3625                            for (int i = 0; i < orderByConditionFields.length; i++) {
3626                                    if (getDB().isSupportsInlineDistinct()) {
3627                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3628                                    }
3629                                    else {
3630                                            query.append(_ORDER_BY_ENTITY_TABLE);
3631                                    }
3632    
3633                                    query.append(orderByConditionFields[i]);
3634    
3635                                    if ((i + 1) < orderByConditionFields.length) {
3636                                            if (orderByComparator.isAscending() ^ previous) {
3637                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3638                                            }
3639                                            else {
3640                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3641                                            }
3642                                    }
3643                                    else {
3644                                            if (orderByComparator.isAscending() ^ previous) {
3645                                                    query.append(WHERE_GREATER_THAN);
3646                                            }
3647                                            else {
3648                                                    query.append(WHERE_LESSER_THAN);
3649                                            }
3650                                    }
3651                            }
3652    
3653                            query.append(ORDER_BY_CLAUSE);
3654    
3655                            String[] orderByFields = orderByComparator.getOrderByFields();
3656    
3657                            for (int i = 0; i < orderByFields.length; i++) {
3658                                    if (getDB().isSupportsInlineDistinct()) {
3659                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3660                                    }
3661                                    else {
3662                                            query.append(_ORDER_BY_ENTITY_TABLE);
3663                                    }
3664    
3665                                    query.append(orderByFields[i]);
3666    
3667                                    if ((i + 1) < orderByFields.length) {
3668                                            if (orderByComparator.isAscending() ^ previous) {
3669                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3670                                            }
3671                                            else {
3672                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3673                                            }
3674                                    }
3675                                    else {
3676                                            if (orderByComparator.isAscending() ^ previous) {
3677                                                    query.append(ORDER_BY_ASC);
3678                                            }
3679                                            else {
3680                                                    query.append(ORDER_BY_DESC);
3681                                            }
3682                                    }
3683                            }
3684                    }
3685                    else {
3686                            if (getDB().isSupportsInlineDistinct()) {
3687                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3688                            }
3689                            else {
3690                                    query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
3691                            }
3692                    }
3693    
3694                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3695                                    LayoutSetPrototype.class.getName(),
3696                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3697    
3698                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3699    
3700                    q.setFirstResult(0);
3701                    q.setMaxResults(2);
3702    
3703                    if (getDB().isSupportsInlineDistinct()) {
3704                            q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
3705                    }
3706                    else {
3707                            q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
3708                    }
3709    
3710                    QueryPos qPos = QueryPos.getInstance(q);
3711    
3712                    qPos.add(companyId);
3713    
3714                    qPos.add(active);
3715    
3716                    if (orderByComparator != null) {
3717                            Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
3718    
3719                            for (Object value : values) {
3720                                    qPos.add(value);
3721                            }
3722                    }
3723    
3724                    List<LayoutSetPrototype> list = q.list();
3725    
3726                    if (list.size() == 2) {
3727                            return list.get(1);
3728                    }
3729                    else {
3730                            return null;
3731                    }
3732            }
3733    
3734            /**
3735             * Removes all the layout set prototypes where companyId = &#63; and active = &#63; from the database.
3736             *
3737             * @param companyId the company ID
3738             * @param active the active
3739             */
3740            @Override
3741            public void removeByC_A(long companyId, boolean active) {
3742                    for (LayoutSetPrototype layoutSetPrototype : findByC_A(companyId,
3743                                    active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3744                            remove(layoutSetPrototype);
3745                    }
3746            }
3747    
3748            /**
3749             * Returns the number of layout set prototypes where companyId = &#63; and active = &#63;.
3750             *
3751             * @param companyId the company ID
3752             * @param active the active
3753             * @return the number of matching layout set prototypes
3754             */
3755            @Override
3756            public int countByC_A(long companyId, boolean active) {
3757                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_A;
3758    
3759                    Object[] finderArgs = new Object[] { companyId, active };
3760    
3761                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3762    
3763                    if (count == null) {
3764                            StringBundler query = new StringBundler(3);
3765    
3766                            query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
3767    
3768                            query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3769    
3770                            query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3771    
3772                            String sql = query.toString();
3773    
3774                            Session session = null;
3775    
3776                            try {
3777                                    session = openSession();
3778    
3779                                    Query q = session.createQuery(sql);
3780    
3781                                    QueryPos qPos = QueryPos.getInstance(q);
3782    
3783                                    qPos.add(companyId);
3784    
3785                                    qPos.add(active);
3786    
3787                                    count = (Long)q.uniqueResult();
3788    
3789                                    finderCache.putResult(finderPath, finderArgs, count);
3790                            }
3791                            catch (Exception e) {
3792                                    finderCache.removeResult(finderPath, finderArgs);
3793    
3794                                    throw processException(e);
3795                            }
3796                            finally {
3797                                    closeSession(session);
3798                            }
3799                    }
3800    
3801                    return count.intValue();
3802            }
3803    
3804            /**
3805             * Returns the number of layout set prototypes that the user has permission to view where companyId = &#63; and active = &#63;.
3806             *
3807             * @param companyId the company ID
3808             * @param active the active
3809             * @return the number of matching layout set prototypes that the user has permission to view
3810             */
3811            @Override
3812            public int filterCountByC_A(long companyId, boolean active) {
3813                    if (!InlineSQLHelperUtil.isEnabled()) {
3814                            return countByC_A(companyId, active);
3815                    }
3816    
3817                    StringBundler query = new StringBundler(3);
3818    
3819                    query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
3820    
3821                    query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3822    
3823                    query.append(_FINDER_COLUMN_C_A_ACTIVE_2_SQL);
3824    
3825                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3826                                    LayoutSetPrototype.class.getName(),
3827                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3828    
3829                    Session session = null;
3830    
3831                    try {
3832                            session = openSession();
3833    
3834                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3835    
3836                            q.addScalar(COUNT_COLUMN_NAME,
3837                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3838    
3839                            QueryPos qPos = QueryPos.getInstance(q);
3840    
3841                            qPos.add(companyId);
3842    
3843                            qPos.add(active);
3844    
3845                            Long count = (Long)q.uniqueResult();
3846    
3847                            return count.intValue();
3848                    }
3849                    catch (Exception e) {
3850                            throw processException(e);
3851                    }
3852                    finally {
3853                            closeSession(session);
3854                    }
3855            }
3856    
3857            private static final String _FINDER_COLUMN_C_A_COMPANYID_2 = "layoutSetPrototype.companyId = ? AND ";
3858            private static final String _FINDER_COLUMN_C_A_ACTIVE_2 = "layoutSetPrototype.active = ?";
3859            private static final String _FINDER_COLUMN_C_A_ACTIVE_2_SQL = "layoutSetPrototype.active_ = ?";
3860    
3861            public LayoutSetPrototypePersistenceImpl() {
3862                    setModelClass(LayoutSetPrototype.class);
3863            }
3864    
3865            /**
3866             * Caches the layout set prototype in the entity cache if it is enabled.
3867             *
3868             * @param layoutSetPrototype the layout set prototype
3869             */
3870            @Override
3871            public void cacheResult(LayoutSetPrototype layoutSetPrototype) {
3872                    entityCache.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3873                            LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
3874                            layoutSetPrototype);
3875    
3876                    layoutSetPrototype.resetOriginalValues();
3877            }
3878    
3879            /**
3880             * Caches the layout set prototypes in the entity cache if it is enabled.
3881             *
3882             * @param layoutSetPrototypes the layout set prototypes
3883             */
3884            @Override
3885            public void cacheResult(List<LayoutSetPrototype> layoutSetPrototypes) {
3886                    for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
3887                            if (entityCache.getResult(
3888                                                    LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3889                                                    LayoutSetPrototypeImpl.class,
3890                                                    layoutSetPrototype.getPrimaryKey()) == null) {
3891                                    cacheResult(layoutSetPrototype);
3892                            }
3893                            else {
3894                                    layoutSetPrototype.resetOriginalValues();
3895                            }
3896                    }
3897            }
3898    
3899            /**
3900             * Clears the cache for all layout set prototypes.
3901             *
3902             * <p>
3903             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
3904             * </p>
3905             */
3906            @Override
3907            public void clearCache() {
3908                    entityCache.clearCache(LayoutSetPrototypeImpl.class);
3909    
3910                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
3911                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3912                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3913            }
3914    
3915            /**
3916             * Clears the cache for the layout set prototype.
3917             *
3918             * <p>
3919             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
3920             * </p>
3921             */
3922            @Override
3923            public void clearCache(LayoutSetPrototype layoutSetPrototype) {
3924                    entityCache.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3925                            LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
3926    
3927                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3928                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3929            }
3930    
3931            @Override
3932            public void clearCache(List<LayoutSetPrototype> layoutSetPrototypes) {
3933                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3934                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3935    
3936                    for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
3937                            entityCache.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3938                                    LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
3939                    }
3940            }
3941    
3942            /**
3943             * Creates a new layout set prototype with the primary key. Does not add the layout set prototype to the database.
3944             *
3945             * @param layoutSetPrototypeId the primary key for the new layout set prototype
3946             * @return the new layout set prototype
3947             */
3948            @Override
3949            public LayoutSetPrototype create(long layoutSetPrototypeId) {
3950                    LayoutSetPrototype layoutSetPrototype = new LayoutSetPrototypeImpl();
3951    
3952                    layoutSetPrototype.setNew(true);
3953                    layoutSetPrototype.setPrimaryKey(layoutSetPrototypeId);
3954    
3955                    String uuid = PortalUUIDUtil.generate();
3956    
3957                    layoutSetPrototype.setUuid(uuid);
3958    
3959                    return layoutSetPrototype;
3960            }
3961    
3962            /**
3963             * Removes the layout set prototype with the primary key from the database. Also notifies the appropriate model listeners.
3964             *
3965             * @param layoutSetPrototypeId the primary key of the layout set prototype
3966             * @return the layout set prototype that was removed
3967             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
3968             */
3969            @Override
3970            public LayoutSetPrototype remove(long layoutSetPrototypeId)
3971                    throws NoSuchLayoutSetPrototypeException {
3972                    return remove((Serializable)layoutSetPrototypeId);
3973            }
3974    
3975            /**
3976             * Removes the layout set prototype with the primary key from the database. Also notifies the appropriate model listeners.
3977             *
3978             * @param primaryKey the primary key of the layout set prototype
3979             * @return the layout set prototype that was removed
3980             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
3981             */
3982            @Override
3983            public LayoutSetPrototype remove(Serializable primaryKey)
3984                    throws NoSuchLayoutSetPrototypeException {
3985                    Session session = null;
3986    
3987                    try {
3988                            session = openSession();
3989    
3990                            LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
3991                                            primaryKey);
3992    
3993                            if (layoutSetPrototype == null) {
3994                                    if (_log.isWarnEnabled()) {
3995                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3996                                    }
3997    
3998                                    throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3999                                            primaryKey);
4000                            }
4001    
4002                            return remove(layoutSetPrototype);
4003                    }
4004                    catch (NoSuchLayoutSetPrototypeException nsee) {
4005                            throw nsee;
4006                    }
4007                    catch (Exception e) {
4008                            throw processException(e);
4009                    }
4010                    finally {
4011                            closeSession(session);
4012                    }
4013            }
4014    
4015            @Override
4016            protected LayoutSetPrototype removeImpl(
4017                    LayoutSetPrototype layoutSetPrototype) {
4018                    layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
4019    
4020                    Session session = null;
4021    
4022                    try {
4023                            session = openSession();
4024    
4025                            if (!session.contains(layoutSetPrototype)) {
4026                                    layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
4027                                                    layoutSetPrototype.getPrimaryKeyObj());
4028                            }
4029    
4030                            if (layoutSetPrototype != null) {
4031                                    session.delete(layoutSetPrototype);
4032                            }
4033                    }
4034                    catch (Exception e) {
4035                            throw processException(e);
4036                    }
4037                    finally {
4038                            closeSession(session);
4039                    }
4040    
4041                    if (layoutSetPrototype != null) {
4042                            clearCache(layoutSetPrototype);
4043                    }
4044    
4045                    return layoutSetPrototype;
4046            }
4047    
4048            @Override
4049            public LayoutSetPrototype updateImpl(LayoutSetPrototype layoutSetPrototype) {
4050                    layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
4051    
4052                    boolean isNew = layoutSetPrototype.isNew();
4053    
4054                    LayoutSetPrototypeModelImpl layoutSetPrototypeModelImpl = (LayoutSetPrototypeModelImpl)layoutSetPrototype;
4055    
4056                    if (Validator.isNull(layoutSetPrototype.getUuid())) {
4057                            String uuid = PortalUUIDUtil.generate();
4058    
4059                            layoutSetPrototype.setUuid(uuid);
4060                    }
4061    
4062                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
4063    
4064                    Date now = new Date();
4065    
4066                    if (isNew && (layoutSetPrototype.getCreateDate() == null)) {
4067                            if (serviceContext == null) {
4068                                    layoutSetPrototype.setCreateDate(now);
4069                            }
4070                            else {
4071                                    layoutSetPrototype.setCreateDate(serviceContext.getCreateDate(
4072                                                    now));
4073                            }
4074                    }
4075    
4076                    if (!layoutSetPrototypeModelImpl.hasSetModifiedDate()) {
4077                            if (serviceContext == null) {
4078                                    layoutSetPrototype.setModifiedDate(now);
4079                            }
4080                            else {
4081                                    layoutSetPrototype.setModifiedDate(serviceContext.getModifiedDate(
4082                                                    now));
4083                            }
4084                    }
4085    
4086                    Session session = null;
4087    
4088                    try {
4089                            session = openSession();
4090    
4091                            if (layoutSetPrototype.isNew()) {
4092                                    session.save(layoutSetPrototype);
4093    
4094                                    layoutSetPrototype.setNew(false);
4095                            }
4096                            else {
4097                                    layoutSetPrototype = (LayoutSetPrototype)session.merge(layoutSetPrototype);
4098                            }
4099                    }
4100                    catch (Exception e) {
4101                            throw processException(e);
4102                    }
4103                    finally {
4104                            closeSession(session);
4105                    }
4106    
4107                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4108    
4109                    if (isNew || !LayoutSetPrototypeModelImpl.COLUMN_BITMASK_ENABLED) {
4110                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4111                    }
4112    
4113                    else {
4114                            if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
4115                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
4116                                    Object[] args = new Object[] {
4117                                                    layoutSetPrototypeModelImpl.getOriginalUuid()
4118                                            };
4119    
4120                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4121                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4122                                            args);
4123    
4124                                    args = new Object[] { layoutSetPrototypeModelImpl.getUuid() };
4125    
4126                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4127                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4128                                            args);
4129                            }
4130    
4131                            if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
4132                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
4133                                    Object[] args = new Object[] {
4134                                                    layoutSetPrototypeModelImpl.getOriginalUuid(),
4135                                                    layoutSetPrototypeModelImpl.getOriginalCompanyId()
4136                                            };
4137    
4138                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4139                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4140                                            args);
4141    
4142                                    args = new Object[] {
4143                                                    layoutSetPrototypeModelImpl.getUuid(),
4144                                                    layoutSetPrototypeModelImpl.getCompanyId()
4145                                            };
4146    
4147                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4148                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4149                                            args);
4150                            }
4151    
4152                            if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
4153                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
4154                                    Object[] args = new Object[] {
4155                                                    layoutSetPrototypeModelImpl.getOriginalCompanyId()
4156                                            };
4157    
4158                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
4159                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4160                                            args);
4161    
4162                                    args = new Object[] { layoutSetPrototypeModelImpl.getCompanyId() };
4163    
4164                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
4165                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4166                                            args);
4167                            }
4168    
4169                            if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
4170                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A.getColumnBitmask()) != 0) {
4171                                    Object[] args = new Object[] {
4172                                                    layoutSetPrototypeModelImpl.getOriginalCompanyId(),
4173                                                    layoutSetPrototypeModelImpl.getOriginalActive()
4174                                            };
4175    
4176                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_A, args);
4177                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A,
4178                                            args);
4179    
4180                                    args = new Object[] {
4181                                                    layoutSetPrototypeModelImpl.getCompanyId(),
4182                                                    layoutSetPrototypeModelImpl.getActive()
4183                                            };
4184    
4185                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_A, args);
4186                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A,
4187                                            args);
4188                            }
4189                    }
4190    
4191                    entityCache.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4192                            LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
4193                            layoutSetPrototype, false);
4194    
4195                    layoutSetPrototype.resetOriginalValues();
4196    
4197                    return layoutSetPrototype;
4198            }
4199    
4200            protected LayoutSetPrototype toUnwrappedModel(
4201                    LayoutSetPrototype layoutSetPrototype) {
4202                    if (layoutSetPrototype instanceof LayoutSetPrototypeImpl) {
4203                            return layoutSetPrototype;
4204                    }
4205    
4206                    LayoutSetPrototypeImpl layoutSetPrototypeImpl = new LayoutSetPrototypeImpl();
4207    
4208                    layoutSetPrototypeImpl.setNew(layoutSetPrototype.isNew());
4209                    layoutSetPrototypeImpl.setPrimaryKey(layoutSetPrototype.getPrimaryKey());
4210    
4211                    layoutSetPrototypeImpl.setMvccVersion(layoutSetPrototype.getMvccVersion());
4212                    layoutSetPrototypeImpl.setUuid(layoutSetPrototype.getUuid());
4213                    layoutSetPrototypeImpl.setLayoutSetPrototypeId(layoutSetPrototype.getLayoutSetPrototypeId());
4214                    layoutSetPrototypeImpl.setCompanyId(layoutSetPrototype.getCompanyId());
4215                    layoutSetPrototypeImpl.setUserId(layoutSetPrototype.getUserId());
4216                    layoutSetPrototypeImpl.setUserName(layoutSetPrototype.getUserName());
4217                    layoutSetPrototypeImpl.setCreateDate(layoutSetPrototype.getCreateDate());
4218                    layoutSetPrototypeImpl.setModifiedDate(layoutSetPrototype.getModifiedDate());
4219                    layoutSetPrototypeImpl.setName(layoutSetPrototype.getName());
4220                    layoutSetPrototypeImpl.setDescription(layoutSetPrototype.getDescription());
4221                    layoutSetPrototypeImpl.setSettings(layoutSetPrototype.getSettings());
4222                    layoutSetPrototypeImpl.setActive(layoutSetPrototype.isActive());
4223    
4224                    return layoutSetPrototypeImpl;
4225            }
4226    
4227            /**
4228             * Returns the layout set prototype with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
4229             *
4230             * @param primaryKey the primary key of the layout set prototype
4231             * @return the layout set prototype
4232             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
4233             */
4234            @Override
4235            public LayoutSetPrototype findByPrimaryKey(Serializable primaryKey)
4236                    throws NoSuchLayoutSetPrototypeException {
4237                    LayoutSetPrototype layoutSetPrototype = fetchByPrimaryKey(primaryKey);
4238    
4239                    if (layoutSetPrototype == null) {
4240                            if (_log.isWarnEnabled()) {
4241                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4242                            }
4243    
4244                            throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4245                                    primaryKey);
4246                    }
4247    
4248                    return layoutSetPrototype;
4249            }
4250    
4251            /**
4252             * Returns the layout set prototype with the primary key or throws a {@link NoSuchLayoutSetPrototypeException} if it could not be found.
4253             *
4254             * @param layoutSetPrototypeId the primary key of the layout set prototype
4255             * @return the layout set prototype
4256             * @throws NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
4257             */
4258            @Override
4259            public LayoutSetPrototype findByPrimaryKey(long layoutSetPrototypeId)
4260                    throws NoSuchLayoutSetPrototypeException {
4261                    return findByPrimaryKey((Serializable)layoutSetPrototypeId);
4262            }
4263    
4264            /**
4265             * Returns the layout set prototype with the primary key or returns <code>null</code> if it could not be found.
4266             *
4267             * @param primaryKey the primary key of the layout set prototype
4268             * @return the layout set prototype, or <code>null</code> if a layout set prototype with the primary key could not be found
4269             */
4270            @Override
4271            public LayoutSetPrototype fetchByPrimaryKey(Serializable primaryKey) {
4272                    LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)entityCache.getResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4273                                    LayoutSetPrototypeImpl.class, primaryKey);
4274    
4275                    if (layoutSetPrototype == _nullLayoutSetPrototype) {
4276                            return null;
4277                    }
4278    
4279                    if (layoutSetPrototype == null) {
4280                            Session session = null;
4281    
4282                            try {
4283                                    session = openSession();
4284    
4285                                    layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
4286                                                    primaryKey);
4287    
4288                                    if (layoutSetPrototype != null) {
4289                                            cacheResult(layoutSetPrototype);
4290                                    }
4291                                    else {
4292                                            entityCache.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4293                                                    LayoutSetPrototypeImpl.class, primaryKey,
4294                                                    _nullLayoutSetPrototype);
4295                                    }
4296                            }
4297                            catch (Exception e) {
4298                                    entityCache.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4299                                            LayoutSetPrototypeImpl.class, primaryKey);
4300    
4301                                    throw processException(e);
4302                            }
4303                            finally {
4304                                    closeSession(session);
4305                            }
4306                    }
4307    
4308                    return layoutSetPrototype;
4309            }
4310    
4311            /**
4312             * Returns the layout set prototype with the primary key or returns <code>null</code> if it could not be found.
4313             *
4314             * @param layoutSetPrototypeId the primary key of the layout set prototype
4315             * @return the layout set prototype, or <code>null</code> if a layout set prototype with the primary key could not be found
4316             */
4317            @Override
4318            public LayoutSetPrototype fetchByPrimaryKey(long layoutSetPrototypeId) {
4319                    return fetchByPrimaryKey((Serializable)layoutSetPrototypeId);
4320            }
4321    
4322            @Override
4323            public Map<Serializable, LayoutSetPrototype> fetchByPrimaryKeys(
4324                    Set<Serializable> primaryKeys) {
4325                    if (primaryKeys.isEmpty()) {
4326                            return Collections.emptyMap();
4327                    }
4328    
4329                    Map<Serializable, LayoutSetPrototype> map = new HashMap<Serializable, LayoutSetPrototype>();
4330    
4331                    if (primaryKeys.size() == 1) {
4332                            Iterator<Serializable> iterator = primaryKeys.iterator();
4333    
4334                            Serializable primaryKey = iterator.next();
4335    
4336                            LayoutSetPrototype layoutSetPrototype = fetchByPrimaryKey(primaryKey);
4337    
4338                            if (layoutSetPrototype != null) {
4339                                    map.put(primaryKey, layoutSetPrototype);
4340                            }
4341    
4342                            return map;
4343                    }
4344    
4345                    Set<Serializable> uncachedPrimaryKeys = null;
4346    
4347                    for (Serializable primaryKey : primaryKeys) {
4348                            LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)entityCache.getResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4349                                            LayoutSetPrototypeImpl.class, primaryKey);
4350    
4351                            if (layoutSetPrototype == null) {
4352                                    if (uncachedPrimaryKeys == null) {
4353                                            uncachedPrimaryKeys = new HashSet<Serializable>();
4354                                    }
4355    
4356                                    uncachedPrimaryKeys.add(primaryKey);
4357                            }
4358                            else {
4359                                    map.put(primaryKey, layoutSetPrototype);
4360                            }
4361                    }
4362    
4363                    if (uncachedPrimaryKeys == null) {
4364                            return map;
4365                    }
4366    
4367                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
4368                                    1);
4369    
4370                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE_PKS_IN);
4371    
4372                    for (Serializable primaryKey : uncachedPrimaryKeys) {
4373                            query.append(String.valueOf(primaryKey));
4374    
4375                            query.append(StringPool.COMMA);
4376                    }
4377    
4378                    query.setIndex(query.index() - 1);
4379    
4380                    query.append(StringPool.CLOSE_PARENTHESIS);
4381    
4382                    String sql = query.toString();
4383    
4384                    Session session = null;
4385    
4386                    try {
4387                            session = openSession();
4388    
4389                            Query q = session.createQuery(sql);
4390    
4391                            for (LayoutSetPrototype layoutSetPrototype : (List<LayoutSetPrototype>)q.list()) {
4392                                    map.put(layoutSetPrototype.getPrimaryKeyObj(),
4393                                            layoutSetPrototype);
4394    
4395                                    cacheResult(layoutSetPrototype);
4396    
4397                                    uncachedPrimaryKeys.remove(layoutSetPrototype.getPrimaryKeyObj());
4398                            }
4399    
4400                            for (Serializable primaryKey : uncachedPrimaryKeys) {
4401                                    entityCache.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4402                                            LayoutSetPrototypeImpl.class, primaryKey,
4403                                            _nullLayoutSetPrototype);
4404                            }
4405                    }
4406                    catch (Exception e) {
4407                            throw processException(e);
4408                    }
4409                    finally {
4410                            closeSession(session);
4411                    }
4412    
4413                    return map;
4414            }
4415    
4416            /**
4417             * Returns all the layout set prototypes.
4418             *
4419             * @return the layout set prototypes
4420             */
4421            @Override
4422            public List<LayoutSetPrototype> findAll() {
4423                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4424            }
4425    
4426            /**
4427             * Returns a range of all the layout set prototypes.
4428             *
4429             * <p>
4430             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
4431             * </p>
4432             *
4433             * @param start the lower bound of the range of layout set prototypes
4434             * @param end the upper bound of the range of layout set prototypes (not inclusive)
4435             * @return the range of layout set prototypes
4436             */
4437            @Override
4438            public List<LayoutSetPrototype> findAll(int start, int end) {
4439                    return findAll(start, end, null);
4440            }
4441    
4442            /**
4443             * Returns an ordered range of all the layout set prototypes.
4444             *
4445             * <p>
4446             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
4447             * </p>
4448             *
4449             * @param start the lower bound of the range of layout set prototypes
4450             * @param end the upper bound of the range of layout set prototypes (not inclusive)
4451             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4452             * @return the ordered range of layout set prototypes
4453             */
4454            @Override
4455            public List<LayoutSetPrototype> findAll(int start, int end,
4456                    OrderByComparator<LayoutSetPrototype> orderByComparator) {
4457                    return findAll(start, end, orderByComparator, true);
4458            }
4459    
4460            /**
4461             * Returns an ordered range of all the layout set prototypes.
4462             *
4463             * <p>
4464             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link LayoutSetPrototypeModelImpl}. 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.
4465             * </p>
4466             *
4467             * @param start the lower bound of the range of layout set prototypes
4468             * @param end the upper bound of the range of layout set prototypes (not inclusive)
4469             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4470             * @param retrieveFromCache whether to retrieve from the finder cache
4471             * @return the ordered range of layout set prototypes
4472             */
4473            @Override
4474            public List<LayoutSetPrototype> findAll(int start, int end,
4475                    OrderByComparator<LayoutSetPrototype> orderByComparator,
4476                    boolean retrieveFromCache) {
4477                    boolean pagination = true;
4478                    FinderPath finderPath = null;
4479                    Object[] finderArgs = null;
4480    
4481                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4482                                    (orderByComparator == null)) {
4483                            pagination = false;
4484                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4485                            finderArgs = FINDER_ARGS_EMPTY;
4486                    }
4487                    else {
4488                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4489                            finderArgs = new Object[] { start, end, orderByComparator };
4490                    }
4491    
4492                    List<LayoutSetPrototype> list = null;
4493    
4494                    if (retrieveFromCache) {
4495                            list = (List<LayoutSetPrototype>)finderCache.getResult(finderPath,
4496                                            finderArgs, this);
4497                    }
4498    
4499                    if (list == null) {
4500                            StringBundler query = null;
4501                            String sql = null;
4502    
4503                            if (orderByComparator != null) {
4504                                    query = new StringBundler(2 +
4505                                                    (orderByComparator.getOrderByFields().length * 3));
4506    
4507                                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE);
4508    
4509                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4510                                            orderByComparator);
4511    
4512                                    sql = query.toString();
4513                            }
4514                            else {
4515                                    sql = _SQL_SELECT_LAYOUTSETPROTOTYPE;
4516    
4517                                    if (pagination) {
4518                                            sql = sql.concat(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
4519                                    }
4520                            }
4521    
4522                            Session session = null;
4523    
4524                            try {
4525                                    session = openSession();
4526    
4527                                    Query q = session.createQuery(sql);
4528    
4529                                    if (!pagination) {
4530                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
4531                                                            getDialect(), start, end, false);
4532    
4533                                            Collections.sort(list);
4534    
4535                                            list = Collections.unmodifiableList(list);
4536                                    }
4537                                    else {
4538                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
4539                                                            getDialect(), start, end);
4540                                    }
4541    
4542                                    cacheResult(list);
4543    
4544                                    finderCache.putResult(finderPath, finderArgs, list);
4545                            }
4546                            catch (Exception e) {
4547                                    finderCache.removeResult(finderPath, finderArgs);
4548    
4549                                    throw processException(e);
4550                            }
4551                            finally {
4552                                    closeSession(session);
4553                            }
4554                    }
4555    
4556                    return list;
4557            }
4558    
4559            /**
4560             * Removes all the layout set prototypes from the database.
4561             *
4562             */
4563            @Override
4564            public void removeAll() {
4565                    for (LayoutSetPrototype layoutSetPrototype : findAll()) {
4566                            remove(layoutSetPrototype);
4567                    }
4568            }
4569    
4570            /**
4571             * Returns the number of layout set prototypes.
4572             *
4573             * @return the number of layout set prototypes
4574             */
4575            @Override
4576            public int countAll() {
4577                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
4578                                    FINDER_ARGS_EMPTY, this);
4579    
4580                    if (count == null) {
4581                            Session session = null;
4582    
4583                            try {
4584                                    session = openSession();
4585    
4586                                    Query q = session.createQuery(_SQL_COUNT_LAYOUTSETPROTOTYPE);
4587    
4588                                    count = (Long)q.uniqueResult();
4589    
4590                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
4591                                            count);
4592                            }
4593                            catch (Exception e) {
4594                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
4595                                            FINDER_ARGS_EMPTY);
4596    
4597                                    throw processException(e);
4598                            }
4599                            finally {
4600                                    closeSession(session);
4601                            }
4602                    }
4603    
4604                    return count.intValue();
4605            }
4606    
4607            @Override
4608            public Set<String> getBadColumnNames() {
4609                    return _badColumnNames;
4610            }
4611    
4612            @Override
4613            protected Map<String, Integer> getTableColumnsMap() {
4614                    return LayoutSetPrototypeModelImpl.TABLE_COLUMNS_MAP;
4615            }
4616    
4617            /**
4618             * Initializes the layout set prototype persistence.
4619             */
4620            public void afterPropertiesSet() {
4621            }
4622    
4623            public void destroy() {
4624                    entityCache.removeCache(LayoutSetPrototypeImpl.class.getName());
4625                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
4626                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4627                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4628            }
4629    
4630            @BeanReference(type = CompanyProvider.class)
4631            protected CompanyProvider companyProvider;
4632            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
4633            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
4634            private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype";
4635            private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE_PKS_IN = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype WHERE layoutSetPrototypeId IN (";
4636            private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4637            private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype";
4638            private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4639            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "layoutSetPrototype.layoutSetPrototypeId";
4640            private static final String _FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE = "SELECT DISTINCT {layoutSetPrototype.*} FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4641            private static final String _FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1 =
4642                    "SELECT {LayoutSetPrototype.*} FROM (SELECT DISTINCT layoutSetPrototype.layoutSetPrototypeId FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4643            private static final String _FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2 =
4644                    ") TEMP_TABLE INNER JOIN LayoutSetPrototype ON TEMP_TABLE.layoutSetPrototypeId = LayoutSetPrototype.layoutSetPrototypeId";
4645            private static final String _FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE = "SELECT COUNT(DISTINCT layoutSetPrototype.layoutSetPrototypeId) AS COUNT_VALUE FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4646            private static final String _FILTER_ENTITY_ALIAS = "layoutSetPrototype";
4647            private static final String _FILTER_ENTITY_TABLE = "LayoutSetPrototype";
4648            private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetPrototype.";
4649            private static final String _ORDER_BY_ENTITY_TABLE = "LayoutSetPrototype.";
4650            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetPrototype exists with the primary key ";
4651            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetPrototype exists with the key {";
4652            private static final Log _log = LogFactoryUtil.getLog(LayoutSetPrototypePersistenceImpl.class);
4653            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
4654                                    "uuid", "settings", "active"
4655                            });
4656            private static final LayoutSetPrototype _nullLayoutSetPrototype = new LayoutSetPrototypeImpl() {
4657                            @Override
4658                            public Object clone() {
4659                                    return this;
4660                            }
4661    
4662                            @Override
4663                            public CacheModel<LayoutSetPrototype> toCacheModel() {
4664                                    return _nullLayoutSetPrototypeCacheModel;
4665                            }
4666                    };
4667    
4668            private static final CacheModel<LayoutSetPrototype> _nullLayoutSetPrototypeCacheModel =
4669                    new NullCacheModel();
4670    
4671            private static class NullCacheModel implements CacheModel<LayoutSetPrototype>,
4672                    MVCCModel {
4673                    @Override
4674                    public long getMvccVersion() {
4675                            return -1;
4676                    }
4677    
4678                    @Override
4679                    public void setMvccVersion(long mvccVersion) {
4680                    }
4681    
4682                    @Override
4683                    public LayoutSetPrototype toEntityModel() {
4684                            return _nullLayoutSetPrototype;
4685                    }
4686            }
4687    }