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