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