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