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