001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchLayoutSetPrototypeException;
018    import com.liferay.portal.NoSuchModelException;
019    import com.liferay.portal.kernel.annotation.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.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.model.LayoutSetPrototype;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.model.impl.LayoutSetPrototypeImpl;
040    import com.liferay.portal.model.impl.LayoutSetPrototypeModelImpl;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import java.io.Serializable;
044    
045    import java.util.ArrayList;
046    import java.util.Collections;
047    import java.util.List;
048    
049    /**
050     * The persistence implementation for the layout set prototype service.
051     *
052     * <p>
053     * Never modify or reference this class directly. Always use {@link LayoutSetPrototypeUtil} to access the layout set prototype persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
054     * </p>
055     *
056     * <p>
057     * Caching information and settings can be found in <code>portal.properties</code>
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see LayoutSetPrototypePersistence
062     * @see LayoutSetPrototypeUtil
063     * @generated
064     */
065    public class LayoutSetPrototypePersistenceImpl extends BasePersistenceImpl<LayoutSetPrototype>
066            implements LayoutSetPrototypePersistence {
067            public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetPrototypeImpl.class.getName();
068            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
069                    ".List";
070            public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
071                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
072                            FINDER_CLASS_NAME_LIST, "findByCompanyId",
073                            new String[] {
074                                    Long.class.getName(),
075                                    
076                            "java.lang.Integer", "java.lang.Integer",
077                                    "com.liferay.portal.kernel.util.OrderByComparator"
078                            });
079            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
080                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
081                            FINDER_CLASS_NAME_LIST, "countByCompanyId",
082                            new String[] { Long.class.getName() });
083            public static final FinderPath FINDER_PATH_FIND_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
084                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
085                            FINDER_CLASS_NAME_LIST, "findByC_A",
086                            new String[] {
087                                    Long.class.getName(), Boolean.class.getName(),
088                                    
089                            "java.lang.Integer", "java.lang.Integer",
090                                    "com.liferay.portal.kernel.util.OrderByComparator"
091                            });
092            public static final FinderPath FINDER_PATH_COUNT_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
093                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
094                            FINDER_CLASS_NAME_LIST, "countByC_A",
095                            new String[] { Long.class.getName(), Boolean.class.getName() });
096            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
097                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
098                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
099            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
100                            LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
101                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
102    
103            /**
104             * Caches the layout set prototype in the entity cache if it is enabled.
105             *
106             * @param layoutSetPrototype the layout set prototype to cache
107             */
108            public void cacheResult(LayoutSetPrototype layoutSetPrototype) {
109                    EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
110                            LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
111                            layoutSetPrototype);
112            }
113    
114            /**
115             * Caches the layout set prototypes in the entity cache if it is enabled.
116             *
117             * @param layoutSetPrototypes the layout set prototypes to cache
118             */
119            public void cacheResult(List<LayoutSetPrototype> layoutSetPrototypes) {
120                    for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
121                            if (EntityCacheUtil.getResult(
122                                                    LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
123                                                    LayoutSetPrototypeImpl.class,
124                                                    layoutSetPrototype.getPrimaryKey(), this) == null) {
125                                    cacheResult(layoutSetPrototype);
126                            }
127                    }
128            }
129    
130            /**
131             * Clears the cache for all layout set prototypes.
132             *
133             * <p>
134             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
135             * </p>
136             */
137            public void clearCache() {
138                    CacheRegistryUtil.clear(LayoutSetPrototypeImpl.class.getName());
139                    EntityCacheUtil.clearCache(LayoutSetPrototypeImpl.class.getName());
140                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
141                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
142            }
143    
144            /**
145             * Clears the cache for the layout set prototype.
146             *
147             * <p>
148             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
149             * </p>
150             */
151            public void clearCache(LayoutSetPrototype layoutSetPrototype) {
152                    EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
153                            LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
154            }
155    
156            /**
157             * Creates a new layout set prototype with the primary key. Does not add the layout set prototype to the database.
158             *
159             * @param layoutSetPrototypeId the primary key for the new layout set prototype
160             * @return the new layout set prototype
161             */
162            public LayoutSetPrototype create(long layoutSetPrototypeId) {
163                    LayoutSetPrototype layoutSetPrototype = new LayoutSetPrototypeImpl();
164    
165                    layoutSetPrototype.setNew(true);
166                    layoutSetPrototype.setPrimaryKey(layoutSetPrototypeId);
167    
168                    return layoutSetPrototype;
169            }
170    
171            /**
172             * Removes the layout set prototype with the primary key from the database. Also notifies the appropriate model listeners.
173             *
174             * @param primaryKey the primary key of the layout set prototype to remove
175             * @return the layout set prototype that was removed
176             * @throws com.liferay.portal.NoSuchModelException if a layout set prototype with the primary key could not be found
177             * @throws SystemException if a system exception occurred
178             */
179            public LayoutSetPrototype remove(Serializable primaryKey)
180                    throws NoSuchModelException, SystemException {
181                    return remove(((Long)primaryKey).longValue());
182            }
183    
184            /**
185             * Removes the layout set prototype with the primary key from the database. Also notifies the appropriate model listeners.
186             *
187             * @param layoutSetPrototypeId the primary key of the layout set prototype to remove
188             * @return the layout set prototype that was removed
189             * @throws com.liferay.portal.NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
190             * @throws SystemException if a system exception occurred
191             */
192            public LayoutSetPrototype remove(long layoutSetPrototypeId)
193                    throws NoSuchLayoutSetPrototypeException, SystemException {
194                    Session session = null;
195    
196                    try {
197                            session = openSession();
198    
199                            LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
200                                            new Long(layoutSetPrototypeId));
201    
202                            if (layoutSetPrototype == null) {
203                                    if (_log.isWarnEnabled()) {
204                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
205                                                    layoutSetPrototypeId);
206                                    }
207    
208                                    throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
209                                            layoutSetPrototypeId);
210                            }
211    
212                            return remove(layoutSetPrototype);
213                    }
214                    catch (NoSuchLayoutSetPrototypeException nsee) {
215                            throw nsee;
216                    }
217                    catch (Exception e) {
218                            throw processException(e);
219                    }
220                    finally {
221                            closeSession(session);
222                    }
223            }
224    
225            protected LayoutSetPrototype removeImpl(
226                    LayoutSetPrototype layoutSetPrototype) throws SystemException {
227                    layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
228    
229                    Session session = null;
230    
231                    try {
232                            session = openSession();
233    
234                            if (layoutSetPrototype.isCachedModel() ||
235                                            BatchSessionUtil.isEnabled()) {
236                                    Object staleObject = session.get(LayoutSetPrototypeImpl.class,
237                                                    layoutSetPrototype.getPrimaryKeyObj());
238    
239                                    if (staleObject != null) {
240                                            session.evict(staleObject);
241                                    }
242                            }
243    
244                            session.delete(layoutSetPrototype);
245    
246                            session.flush();
247                    }
248                    catch (Exception e) {
249                            throw processException(e);
250                    }
251                    finally {
252                            closeSession(session);
253                    }
254    
255                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
256    
257                    EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
258                            LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
259    
260                    return layoutSetPrototype;
261            }
262    
263            public LayoutSetPrototype updateImpl(
264                    com.liferay.portal.model.LayoutSetPrototype layoutSetPrototype,
265                    boolean merge) throws SystemException {
266                    layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
267    
268                    Session session = null;
269    
270                    try {
271                            session = openSession();
272    
273                            BatchSessionUtil.update(session, layoutSetPrototype, merge);
274    
275                            layoutSetPrototype.setNew(false);
276                    }
277                    catch (Exception e) {
278                            throw processException(e);
279                    }
280                    finally {
281                            closeSession(session);
282                    }
283    
284                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
285    
286                    EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
287                            LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
288                            layoutSetPrototype);
289    
290                    return layoutSetPrototype;
291            }
292    
293            protected LayoutSetPrototype toUnwrappedModel(
294                    LayoutSetPrototype layoutSetPrototype) {
295                    if (layoutSetPrototype instanceof LayoutSetPrototypeImpl) {
296                            return layoutSetPrototype;
297                    }
298    
299                    LayoutSetPrototypeImpl layoutSetPrototypeImpl = new LayoutSetPrototypeImpl();
300    
301                    layoutSetPrototypeImpl.setNew(layoutSetPrototype.isNew());
302                    layoutSetPrototypeImpl.setPrimaryKey(layoutSetPrototype.getPrimaryKey());
303    
304                    layoutSetPrototypeImpl.setLayoutSetPrototypeId(layoutSetPrototype.getLayoutSetPrototypeId());
305                    layoutSetPrototypeImpl.setCompanyId(layoutSetPrototype.getCompanyId());
306                    layoutSetPrototypeImpl.setName(layoutSetPrototype.getName());
307                    layoutSetPrototypeImpl.setDescription(layoutSetPrototype.getDescription());
308                    layoutSetPrototypeImpl.setSettings(layoutSetPrototype.getSettings());
309                    layoutSetPrototypeImpl.setActive(layoutSetPrototype.isActive());
310    
311                    return layoutSetPrototypeImpl;
312            }
313    
314            /**
315             * Finds the layout set prototype with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
316             *
317             * @param primaryKey the primary key of the layout set prototype to find
318             * @return the layout set prototype
319             * @throws com.liferay.portal.NoSuchModelException if a layout set prototype with the primary key could not be found
320             * @throws SystemException if a system exception occurred
321             */
322            public LayoutSetPrototype findByPrimaryKey(Serializable primaryKey)
323                    throws NoSuchModelException, SystemException {
324                    return findByPrimaryKey(((Long)primaryKey).longValue());
325            }
326    
327            /**
328             * Finds the layout set prototype with the primary key or throws a {@link com.liferay.portal.NoSuchLayoutSetPrototypeException} if it could not be found.
329             *
330             * @param layoutSetPrototypeId the primary key of the layout set prototype to find
331             * @return the layout set prototype
332             * @throws com.liferay.portal.NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
333             * @throws SystemException if a system exception occurred
334             */
335            public LayoutSetPrototype findByPrimaryKey(long layoutSetPrototypeId)
336                    throws NoSuchLayoutSetPrototypeException, SystemException {
337                    LayoutSetPrototype layoutSetPrototype = fetchByPrimaryKey(layoutSetPrototypeId);
338    
339                    if (layoutSetPrototype == null) {
340                            if (_log.isWarnEnabled()) {
341                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
342                                            layoutSetPrototypeId);
343                            }
344    
345                            throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
346                                    layoutSetPrototypeId);
347                    }
348    
349                    return layoutSetPrototype;
350            }
351    
352            /**
353             * Finds the layout set prototype with the primary key or returns <code>null</code> if it could not be found.
354             *
355             * @param primaryKey the primary key of the layout set prototype to find
356             * @return the layout set prototype, or <code>null</code> if a layout set prototype with the primary key could not be found
357             * @throws SystemException if a system exception occurred
358             */
359            public LayoutSetPrototype fetchByPrimaryKey(Serializable primaryKey)
360                    throws SystemException {
361                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
362            }
363    
364            /**
365             * Finds the layout set prototype with the primary key or returns <code>null</code> if it could not be found.
366             *
367             * @param layoutSetPrototypeId the primary key of the layout set prototype to find
368             * @return the layout set prototype, or <code>null</code> if a layout set prototype with the primary key could not be found
369             * @throws SystemException if a system exception occurred
370             */
371            public LayoutSetPrototype fetchByPrimaryKey(long layoutSetPrototypeId)
372                    throws SystemException {
373                    LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)EntityCacheUtil.getResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
374                                    LayoutSetPrototypeImpl.class, layoutSetPrototypeId, this);
375    
376                    if (layoutSetPrototype == null) {
377                            Session session = null;
378    
379                            try {
380                                    session = openSession();
381    
382                                    layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
383                                                    new Long(layoutSetPrototypeId));
384                            }
385                            catch (Exception e) {
386                                    throw processException(e);
387                            }
388                            finally {
389                                    if (layoutSetPrototype != null) {
390                                            cacheResult(layoutSetPrototype);
391                                    }
392    
393                                    closeSession(session);
394                            }
395                    }
396    
397                    return layoutSetPrototype;
398            }
399    
400            /**
401             * Finds all the layout set prototypes where companyId = &#63;.
402             *
403             * @param companyId the company id to search with
404             * @return the matching layout set prototypes
405             * @throws SystemException if a system exception occurred
406             */
407            public List<LayoutSetPrototype> findByCompanyId(long companyId)
408                    throws SystemException {
409                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
410                            null);
411            }
412    
413            /**
414             * Finds a range of all the layout set prototypes where companyId = &#63;.
415             *
416             * <p>
417             * 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.
418             * </p>
419             *
420             * @param companyId the company id to search with
421             * @param start the lower bound of the range of layout set prototypes to return
422             * @param end the upper bound of the range of layout set prototypes to return (not inclusive)
423             * @return the range of matching layout set prototypes
424             * @throws SystemException if a system exception occurred
425             */
426            public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
427                    int end) throws SystemException {
428                    return findByCompanyId(companyId, start, end, null);
429            }
430    
431            /**
432             * Finds an ordered range of all the layout set prototypes where companyId = &#63;.
433             *
434             * <p>
435             * 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.
436             * </p>
437             *
438             * @param companyId the company id to search with
439             * @param start the lower bound of the range of layout set prototypes to return
440             * @param end the upper bound of the range of layout set prototypes to return (not inclusive)
441             * @param orderByComparator the comparator to order the results by
442             * @return the ordered range of matching layout set prototypes
443             * @throws SystemException if a system exception occurred
444             */
445            public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
446                    int end, OrderByComparator orderByComparator) throws SystemException {
447                    Object[] finderArgs = new Object[] {
448                                    companyId,
449                                    
450                                    String.valueOf(start), String.valueOf(end),
451                                    String.valueOf(orderByComparator)
452                            };
453    
454                    List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
455                                    finderArgs, this);
456    
457                    if (list == null) {
458                            Session session = null;
459    
460                            try {
461                                    session = openSession();
462    
463                                    StringBundler query = null;
464    
465                                    if (orderByComparator != null) {
466                                            query = new StringBundler(3 +
467                                                            (orderByComparator.getOrderByFields().length * 3));
468                                    }
469                                    else {
470                                            query = new StringBundler(2);
471                                    }
472    
473                                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
474    
475                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
476    
477                                    if (orderByComparator != null) {
478                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
479                                                    orderByComparator);
480                                    }
481    
482                                    String sql = query.toString();
483    
484                                    Query q = session.createQuery(sql);
485    
486                                    QueryPos qPos = QueryPos.getInstance(q);
487    
488                                    qPos.add(companyId);
489    
490                                    list = (List<LayoutSetPrototype>)QueryUtil.list(q,
491                                                    getDialect(), start, end);
492                            }
493                            catch (Exception e) {
494                                    throw processException(e);
495                            }
496                            finally {
497                                    if (list == null) {
498                                            list = new ArrayList<LayoutSetPrototype>();
499                                    }
500    
501                                    cacheResult(list);
502    
503                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
504                                            finderArgs, list);
505    
506                                    closeSession(session);
507                            }
508                    }
509    
510                    return list;
511            }
512    
513            /**
514             * Finds the first layout set prototype in the ordered set where companyId = &#63;.
515             *
516             * <p>
517             * 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.
518             * </p>
519             *
520             * @param companyId the company id to search with
521             * @param orderByComparator the comparator to order the set by
522             * @return the first matching layout set prototype
523             * @throws com.liferay.portal.NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
524             * @throws SystemException if a system exception occurred
525             */
526            public LayoutSetPrototype findByCompanyId_First(long companyId,
527                    OrderByComparator orderByComparator)
528                    throws NoSuchLayoutSetPrototypeException, SystemException {
529                    List<LayoutSetPrototype> list = findByCompanyId(companyId, 0, 1,
530                                    orderByComparator);
531    
532                    if (list.isEmpty()) {
533                            StringBundler msg = new StringBundler(4);
534    
535                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
536    
537                            msg.append("companyId=");
538                            msg.append(companyId);
539    
540                            msg.append(StringPool.CLOSE_CURLY_BRACE);
541    
542                            throw new NoSuchLayoutSetPrototypeException(msg.toString());
543                    }
544                    else {
545                            return list.get(0);
546                    }
547            }
548    
549            /**
550             * Finds the last layout set prototype in the ordered set where companyId = &#63;.
551             *
552             * <p>
553             * 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.
554             * </p>
555             *
556             * @param companyId the company id to search with
557             * @param orderByComparator the comparator to order the set by
558             * @return the last matching layout set prototype
559             * @throws com.liferay.portal.NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
560             * @throws SystemException if a system exception occurred
561             */
562            public LayoutSetPrototype findByCompanyId_Last(long companyId,
563                    OrderByComparator orderByComparator)
564                    throws NoSuchLayoutSetPrototypeException, SystemException {
565                    int count = countByCompanyId(companyId);
566    
567                    List<LayoutSetPrototype> list = findByCompanyId(companyId, count - 1,
568                                    count, orderByComparator);
569    
570                    if (list.isEmpty()) {
571                            StringBundler msg = new StringBundler(4);
572    
573                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
574    
575                            msg.append("companyId=");
576                            msg.append(companyId);
577    
578                            msg.append(StringPool.CLOSE_CURLY_BRACE);
579    
580                            throw new NoSuchLayoutSetPrototypeException(msg.toString());
581                    }
582                    else {
583                            return list.get(0);
584                    }
585            }
586    
587            /**
588             * Finds the layout set prototypes before and after the current layout set prototype in the ordered set where companyId = &#63;.
589             *
590             * <p>
591             * 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.
592             * </p>
593             *
594             * @param layoutSetPrototypeId the primary key of the current layout set prototype
595             * @param companyId the company id to search with
596             * @param orderByComparator the comparator to order the set by
597             * @return the previous, current, and next layout set prototype
598             * @throws com.liferay.portal.NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
599             * @throws SystemException if a system exception occurred
600             */
601            public LayoutSetPrototype[] findByCompanyId_PrevAndNext(
602                    long layoutSetPrototypeId, long companyId,
603                    OrderByComparator orderByComparator)
604                    throws NoSuchLayoutSetPrototypeException, SystemException {
605                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
606    
607                    Session session = null;
608    
609                    try {
610                            session = openSession();
611    
612                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
613    
614                            array[0] = getByCompanyId_PrevAndNext(session, layoutSetPrototype,
615                                            companyId, orderByComparator, true);
616    
617                            array[1] = layoutSetPrototype;
618    
619                            array[2] = getByCompanyId_PrevAndNext(session, layoutSetPrototype,
620                                            companyId, orderByComparator, false);
621    
622                            return array;
623                    }
624                    catch (Exception e) {
625                            throw processException(e);
626                    }
627                    finally {
628                            closeSession(session);
629                    }
630            }
631    
632            protected LayoutSetPrototype getByCompanyId_PrevAndNext(Session session,
633                    LayoutSetPrototype layoutSetPrototype, long companyId,
634                    OrderByComparator orderByComparator, boolean previous) {
635                    StringBundler query = null;
636    
637                    if (orderByComparator != null) {
638                            query = new StringBundler(6 +
639                                            (orderByComparator.getOrderByFields().length * 6));
640                    }
641                    else {
642                            query = new StringBundler(3);
643                    }
644    
645                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
646    
647                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
648    
649                    if (orderByComparator != null) {
650                            String[] orderByFields = orderByComparator.getOrderByFields();
651    
652                            if (orderByFields.length > 0) {
653                                    query.append(WHERE_AND);
654                            }
655    
656                            for (int i = 0; i < orderByFields.length; i++) {
657                                    query.append(_ORDER_BY_ENTITY_ALIAS);
658                                    query.append(orderByFields[i]);
659    
660                                    if ((i + 1) < orderByFields.length) {
661                                            if (orderByComparator.isAscending() ^ previous) {
662                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
663                                            }
664                                            else {
665                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
666                                            }
667                                    }
668                                    else {
669                                            if (orderByComparator.isAscending() ^ previous) {
670                                                    query.append(WHERE_GREATER_THAN);
671                                            }
672                                            else {
673                                                    query.append(WHERE_LESSER_THAN);
674                                            }
675                                    }
676                            }
677    
678                            query.append(ORDER_BY_CLAUSE);
679    
680                            for (int i = 0; i < orderByFields.length; i++) {
681                                    query.append(_ORDER_BY_ENTITY_ALIAS);
682                                    query.append(orderByFields[i]);
683    
684                                    if ((i + 1) < orderByFields.length) {
685                                            if (orderByComparator.isAscending() ^ previous) {
686                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
687                                            }
688                                            else {
689                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
690                                            }
691                                    }
692                                    else {
693                                            if (orderByComparator.isAscending() ^ previous) {
694                                                    query.append(ORDER_BY_ASC);
695                                            }
696                                            else {
697                                                    query.append(ORDER_BY_DESC);
698                                            }
699                                    }
700                            }
701                    }
702    
703                    String sql = query.toString();
704    
705                    Query q = session.createQuery(sql);
706    
707                    q.setFirstResult(0);
708                    q.setMaxResults(2);
709    
710                    QueryPos qPos = QueryPos.getInstance(q);
711    
712                    qPos.add(companyId);
713    
714                    if (orderByComparator != null) {
715                            Object[] values = orderByComparator.getOrderByValues(layoutSetPrototype);
716    
717                            for (Object value : values) {
718                                    qPos.add(value);
719                            }
720                    }
721    
722                    List<LayoutSetPrototype> list = q.list();
723    
724                    if (list.size() == 2) {
725                            return list.get(1);
726                    }
727                    else {
728                            return null;
729                    }
730            }
731    
732            /**
733             * Finds all the layout set prototypes where companyId = &#63; and active = &#63;.
734             *
735             * @param companyId the company id to search with
736             * @param active the active to search with
737             * @return the matching layout set prototypes
738             * @throws SystemException if a system exception occurred
739             */
740            public List<LayoutSetPrototype> findByC_A(long companyId, boolean active)
741                    throws SystemException {
742                    return findByC_A(companyId, active, QueryUtil.ALL_POS,
743                            QueryUtil.ALL_POS, null);
744            }
745    
746            /**
747             * Finds a range of all the layout set prototypes where companyId = &#63; and active = &#63;.
748             *
749             * <p>
750             * 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.
751             * </p>
752             *
753             * @param companyId the company id to search with
754             * @param active the active to search with
755             * @param start the lower bound of the range of layout set prototypes to return
756             * @param end the upper bound of the range of layout set prototypes to return (not inclusive)
757             * @return the range of matching layout set prototypes
758             * @throws SystemException if a system exception occurred
759             */
760            public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
761                    int start, int end) throws SystemException {
762                    return findByC_A(companyId, active, start, end, null);
763            }
764    
765            /**
766             * Finds an ordered range of all the layout set prototypes where companyId = &#63; and active = &#63;.
767             *
768             * <p>
769             * 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.
770             * </p>
771             *
772             * @param companyId the company id to search with
773             * @param active the active to search with
774             * @param start the lower bound of the range of layout set prototypes to return
775             * @param end the upper bound of the range of layout set prototypes to return (not inclusive)
776             * @param orderByComparator the comparator to order the results by
777             * @return the ordered range of matching layout set prototypes
778             * @throws SystemException if a system exception occurred
779             */
780            public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
781                    int start, int end, OrderByComparator orderByComparator)
782                    throws SystemException {
783                    Object[] finderArgs = new Object[] {
784                                    companyId, active,
785                                    
786                                    String.valueOf(start), String.valueOf(end),
787                                    String.valueOf(orderByComparator)
788                            };
789    
790                    List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_A,
791                                    finderArgs, this);
792    
793                    if (list == null) {
794                            Session session = null;
795    
796                            try {
797                                    session = openSession();
798    
799                                    StringBundler query = null;
800    
801                                    if (orderByComparator != null) {
802                                            query = new StringBundler(4 +
803                                                            (orderByComparator.getOrderByFields().length * 3));
804                                    }
805                                    else {
806                                            query = new StringBundler(3);
807                                    }
808    
809                                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
810    
811                                    query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
812    
813                                    query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
814    
815                                    if (orderByComparator != null) {
816                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
817                                                    orderByComparator);
818                                    }
819    
820                                    String sql = query.toString();
821    
822                                    Query q = session.createQuery(sql);
823    
824                                    QueryPos qPos = QueryPos.getInstance(q);
825    
826                                    qPos.add(companyId);
827    
828                                    qPos.add(active);
829    
830                                    list = (List<LayoutSetPrototype>)QueryUtil.list(q,
831                                                    getDialect(), start, end);
832                            }
833                            catch (Exception e) {
834                                    throw processException(e);
835                            }
836                            finally {
837                                    if (list == null) {
838                                            list = new ArrayList<LayoutSetPrototype>();
839                                    }
840    
841                                    cacheResult(list);
842    
843                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_A, finderArgs,
844                                            list);
845    
846                                    closeSession(session);
847                            }
848                    }
849    
850                    return list;
851            }
852    
853            /**
854             * Finds the first layout set prototype in the ordered set where companyId = &#63; and active = &#63;.
855             *
856             * <p>
857             * 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.
858             * </p>
859             *
860             * @param companyId the company id to search with
861             * @param active the active to search with
862             * @param orderByComparator the comparator to order the set by
863             * @return the first matching layout set prototype
864             * @throws com.liferay.portal.NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
865             * @throws SystemException if a system exception occurred
866             */
867            public LayoutSetPrototype findByC_A_First(long companyId, boolean active,
868                    OrderByComparator orderByComparator)
869                    throws NoSuchLayoutSetPrototypeException, SystemException {
870                    List<LayoutSetPrototype> list = findByC_A(companyId, active, 0, 1,
871                                    orderByComparator);
872    
873                    if (list.isEmpty()) {
874                            StringBundler msg = new StringBundler(6);
875    
876                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
877    
878                            msg.append("companyId=");
879                            msg.append(companyId);
880    
881                            msg.append(", active=");
882                            msg.append(active);
883    
884                            msg.append(StringPool.CLOSE_CURLY_BRACE);
885    
886                            throw new NoSuchLayoutSetPrototypeException(msg.toString());
887                    }
888                    else {
889                            return list.get(0);
890                    }
891            }
892    
893            /**
894             * Finds the last layout set prototype in the ordered set where companyId = &#63; and active = &#63;.
895             *
896             * <p>
897             * 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.
898             * </p>
899             *
900             * @param companyId the company id to search with
901             * @param active the active to search with
902             * @param orderByComparator the comparator to order the set by
903             * @return the last matching layout set prototype
904             * @throws com.liferay.portal.NoSuchLayoutSetPrototypeException if a matching layout set prototype could not be found
905             * @throws SystemException if a system exception occurred
906             */
907            public LayoutSetPrototype findByC_A_Last(long companyId, boolean active,
908                    OrderByComparator orderByComparator)
909                    throws NoSuchLayoutSetPrototypeException, SystemException {
910                    int count = countByC_A(companyId, active);
911    
912                    List<LayoutSetPrototype> list = findByC_A(companyId, active, count - 1,
913                                    count, orderByComparator);
914    
915                    if (list.isEmpty()) {
916                            StringBundler msg = new StringBundler(6);
917    
918                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
919    
920                            msg.append("companyId=");
921                            msg.append(companyId);
922    
923                            msg.append(", active=");
924                            msg.append(active);
925    
926                            msg.append(StringPool.CLOSE_CURLY_BRACE);
927    
928                            throw new NoSuchLayoutSetPrototypeException(msg.toString());
929                    }
930                    else {
931                            return list.get(0);
932                    }
933            }
934    
935            /**
936             * Finds the layout set prototypes before and after the current layout set prototype in the ordered set where companyId = &#63; and active = &#63;.
937             *
938             * <p>
939             * 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.
940             * </p>
941             *
942             * @param layoutSetPrototypeId the primary key of the current layout set prototype
943             * @param companyId the company id to search with
944             * @param active the active to search with
945             * @param orderByComparator the comparator to order the set by
946             * @return the previous, current, and next layout set prototype
947             * @throws com.liferay.portal.NoSuchLayoutSetPrototypeException if a layout set prototype with the primary key could not be found
948             * @throws SystemException if a system exception occurred
949             */
950            public LayoutSetPrototype[] findByC_A_PrevAndNext(
951                    long layoutSetPrototypeId, long companyId, boolean active,
952                    OrderByComparator orderByComparator)
953                    throws NoSuchLayoutSetPrototypeException, SystemException {
954                    LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
955    
956                    Session session = null;
957    
958                    try {
959                            session = openSession();
960    
961                            LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
962    
963                            array[0] = getByC_A_PrevAndNext(session, layoutSetPrototype,
964                                            companyId, active, orderByComparator, true);
965    
966                            array[1] = layoutSetPrototype;
967    
968                            array[2] = getByC_A_PrevAndNext(session, layoutSetPrototype,
969                                            companyId, active, orderByComparator, false);
970    
971                            return array;
972                    }
973                    catch (Exception e) {
974                            throw processException(e);
975                    }
976                    finally {
977                            closeSession(session);
978                    }
979            }
980    
981            protected LayoutSetPrototype getByC_A_PrevAndNext(Session session,
982                    LayoutSetPrototype layoutSetPrototype, long companyId, boolean active,
983                    OrderByComparator orderByComparator, boolean previous) {
984                    StringBundler query = null;
985    
986                    if (orderByComparator != null) {
987                            query = new StringBundler(6 +
988                                            (orderByComparator.getOrderByFields().length * 6));
989                    }
990                    else {
991                            query = new StringBundler(3);
992                    }
993    
994                    query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
995    
996                    query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
997    
998                    query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
999    
1000                    if (orderByComparator != null) {
1001                            String[] orderByFields = orderByComparator.getOrderByFields();
1002    
1003                            if (orderByFields.length > 0) {
1004                                    query.append(WHERE_AND);
1005                            }
1006    
1007                            for (int i = 0; i < orderByFields.length; i++) {
1008                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1009                                    query.append(orderByFields[i]);
1010    
1011                                    if ((i + 1) < orderByFields.length) {
1012                                            if (orderByComparator.isAscending() ^ previous) {
1013                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1014                                            }
1015                                            else {
1016                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1017                                            }
1018                                    }
1019                                    else {
1020                                            if (orderByComparator.isAscending() ^ previous) {
1021                                                    query.append(WHERE_GREATER_THAN);
1022                                            }
1023                                            else {
1024                                                    query.append(WHERE_LESSER_THAN);
1025                                            }
1026                                    }
1027                            }
1028    
1029                            query.append(ORDER_BY_CLAUSE);
1030    
1031                            for (int i = 0; i < orderByFields.length; i++) {
1032                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1033                                    query.append(orderByFields[i]);
1034    
1035                                    if ((i + 1) < orderByFields.length) {
1036                                            if (orderByComparator.isAscending() ^ previous) {
1037                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1038                                            }
1039                                            else {
1040                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1041                                            }
1042                                    }
1043                                    else {
1044                                            if (orderByComparator.isAscending() ^ previous) {
1045                                                    query.append(ORDER_BY_ASC);
1046                                            }
1047                                            else {
1048                                                    query.append(ORDER_BY_DESC);
1049                                            }
1050                                    }
1051                            }
1052                    }
1053    
1054                    String sql = query.toString();
1055    
1056                    Query q = session.createQuery(sql);
1057    
1058                    q.setFirstResult(0);
1059                    q.setMaxResults(2);
1060    
1061                    QueryPos qPos = QueryPos.getInstance(q);
1062    
1063                    qPos.add(companyId);
1064    
1065                    qPos.add(active);
1066    
1067                    if (orderByComparator != null) {
1068                            Object[] values = orderByComparator.getOrderByValues(layoutSetPrototype);
1069    
1070                            for (Object value : values) {
1071                                    qPos.add(value);
1072                            }
1073                    }
1074    
1075                    List<LayoutSetPrototype> list = q.list();
1076    
1077                    if (list.size() == 2) {
1078                            return list.get(1);
1079                    }
1080                    else {
1081                            return null;
1082                    }
1083            }
1084    
1085            /**
1086             * Finds all the layout set prototypes.
1087             *
1088             * @return the layout set prototypes
1089             * @throws SystemException if a system exception occurred
1090             */
1091            public List<LayoutSetPrototype> findAll() throws SystemException {
1092                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1093            }
1094    
1095            /**
1096             * Finds a range of all the layout set prototypes.
1097             *
1098             * <p>
1099             * 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.
1100             * </p>
1101             *
1102             * @param start the lower bound of the range of layout set prototypes to return
1103             * @param end the upper bound of the range of layout set prototypes to return (not inclusive)
1104             * @return the range of layout set prototypes
1105             * @throws SystemException if a system exception occurred
1106             */
1107            public List<LayoutSetPrototype> findAll(int start, int end)
1108                    throws SystemException {
1109                    return findAll(start, end, null);
1110            }
1111    
1112            /**
1113             * Finds an ordered range of all the layout set prototypes.
1114             *
1115             * <p>
1116             * 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.
1117             * </p>
1118             *
1119             * @param start the lower bound of the range of layout set prototypes to return
1120             * @param end the upper bound of the range of layout set prototypes to return (not inclusive)
1121             * @param orderByComparator the comparator to order the results by
1122             * @return the ordered range of layout set prototypes
1123             * @throws SystemException if a system exception occurred
1124             */
1125            public List<LayoutSetPrototype> findAll(int start, int end,
1126                    OrderByComparator orderByComparator) throws SystemException {
1127                    Object[] finderArgs = new Object[] {
1128                                    String.valueOf(start), String.valueOf(end),
1129                                    String.valueOf(orderByComparator)
1130                            };
1131    
1132                    List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1133                                    finderArgs, this);
1134    
1135                    if (list == null) {
1136                            Session session = null;
1137    
1138                            try {
1139                                    session = openSession();
1140    
1141                                    StringBundler query = null;
1142                                    String sql = null;
1143    
1144                                    if (orderByComparator != null) {
1145                                            query = new StringBundler(2 +
1146                                                            (orderByComparator.getOrderByFields().length * 3));
1147    
1148                                            query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE);
1149    
1150                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1151                                                    orderByComparator);
1152    
1153                                            sql = query.toString();
1154                                    }
1155                                    else {
1156                                            sql = _SQL_SELECT_LAYOUTSETPROTOTYPE;
1157                                    }
1158    
1159                                    Query q = session.createQuery(sql);
1160    
1161                                    if (orderByComparator == null) {
1162                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
1163                                                            getDialect(), start, end, false);
1164    
1165                                            Collections.sort(list);
1166                                    }
1167                                    else {
1168                                            list = (List<LayoutSetPrototype>)QueryUtil.list(q,
1169                                                            getDialect(), start, end);
1170                                    }
1171                            }
1172                            catch (Exception e) {
1173                                    throw processException(e);
1174                            }
1175                            finally {
1176                                    if (list == null) {
1177                                            list = new ArrayList<LayoutSetPrototype>();
1178                                    }
1179    
1180                                    cacheResult(list);
1181    
1182                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1183    
1184                                    closeSession(session);
1185                            }
1186                    }
1187    
1188                    return list;
1189            }
1190    
1191            /**
1192             * Removes all the layout set prototypes where companyId = &#63; from the database.
1193             *
1194             * @param companyId the company id to search with
1195             * @throws SystemException if a system exception occurred
1196             */
1197            public void removeByCompanyId(long companyId) throws SystemException {
1198                    for (LayoutSetPrototype layoutSetPrototype : findByCompanyId(companyId)) {
1199                            remove(layoutSetPrototype);
1200                    }
1201            }
1202    
1203            /**
1204             * Removes all the layout set prototypes where companyId = &#63; and active = &#63; from the database.
1205             *
1206             * @param companyId the company id to search with
1207             * @param active the active to search with
1208             * @throws SystemException if a system exception occurred
1209             */
1210            public void removeByC_A(long companyId, boolean active)
1211                    throws SystemException {
1212                    for (LayoutSetPrototype layoutSetPrototype : findByC_A(companyId, active)) {
1213                            remove(layoutSetPrototype);
1214                    }
1215            }
1216    
1217            /**
1218             * Removes all the layout set prototypes from the database.
1219             *
1220             * @throws SystemException if a system exception occurred
1221             */
1222            public void removeAll() throws SystemException {
1223                    for (LayoutSetPrototype layoutSetPrototype : findAll()) {
1224                            remove(layoutSetPrototype);
1225                    }
1226            }
1227    
1228            /**
1229             * Counts all the layout set prototypes where companyId = &#63;.
1230             *
1231             * @param companyId the company id to search with
1232             * @return the number of matching layout set prototypes
1233             * @throws SystemException if a system exception occurred
1234             */
1235            public int countByCompanyId(long companyId) throws SystemException {
1236                    Object[] finderArgs = new Object[] { companyId };
1237    
1238                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1239                                    finderArgs, this);
1240    
1241                    if (count == null) {
1242                            Session session = null;
1243    
1244                            try {
1245                                    session = openSession();
1246    
1247                                    StringBundler query = new StringBundler(2);
1248    
1249                                    query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
1250    
1251                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1252    
1253                                    String sql = query.toString();
1254    
1255                                    Query q = session.createQuery(sql);
1256    
1257                                    QueryPos qPos = QueryPos.getInstance(q);
1258    
1259                                    qPos.add(companyId);
1260    
1261                                    count = (Long)q.uniqueResult();
1262                            }
1263                            catch (Exception e) {
1264                                    throw processException(e);
1265                            }
1266                            finally {
1267                                    if (count == null) {
1268                                            count = Long.valueOf(0);
1269                                    }
1270    
1271                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1272                                            finderArgs, count);
1273    
1274                                    closeSession(session);
1275                            }
1276                    }
1277    
1278                    return count.intValue();
1279            }
1280    
1281            /**
1282             * Counts all the layout set prototypes where companyId = &#63; and active = &#63;.
1283             *
1284             * @param companyId the company id to search with
1285             * @param active the active to search with
1286             * @return the number of matching layout set prototypes
1287             * @throws SystemException if a system exception occurred
1288             */
1289            public int countByC_A(long companyId, boolean active)
1290                    throws SystemException {
1291                    Object[] finderArgs = new Object[] { companyId, active };
1292    
1293                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_A,
1294                                    finderArgs, this);
1295    
1296                    if (count == null) {
1297                            Session session = null;
1298    
1299                            try {
1300                                    session = openSession();
1301    
1302                                    StringBundler query = new StringBundler(3);
1303    
1304                                    query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
1305    
1306                                    query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
1307    
1308                                    query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
1309    
1310                                    String sql = query.toString();
1311    
1312                                    Query q = session.createQuery(sql);
1313    
1314                                    QueryPos qPos = QueryPos.getInstance(q);
1315    
1316                                    qPos.add(companyId);
1317    
1318                                    qPos.add(active);
1319    
1320                                    count = (Long)q.uniqueResult();
1321                            }
1322                            catch (Exception e) {
1323                                    throw processException(e);
1324                            }
1325                            finally {
1326                                    if (count == null) {
1327                                            count = Long.valueOf(0);
1328                                    }
1329    
1330                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_A, finderArgs,
1331                                            count);
1332    
1333                                    closeSession(session);
1334                            }
1335                    }
1336    
1337                    return count.intValue();
1338            }
1339    
1340            /**
1341             * Counts all the layout set prototypes.
1342             *
1343             * @return the number of layout set prototypes
1344             * @throws SystemException if a system exception occurred
1345             */
1346            public int countAll() throws SystemException {
1347                    Object[] finderArgs = new Object[0];
1348    
1349                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1350                                    finderArgs, this);
1351    
1352                    if (count == null) {
1353                            Session session = null;
1354    
1355                            try {
1356                                    session = openSession();
1357    
1358                                    Query q = session.createQuery(_SQL_COUNT_LAYOUTSETPROTOTYPE);
1359    
1360                                    count = (Long)q.uniqueResult();
1361                            }
1362                            catch (Exception e) {
1363                                    throw processException(e);
1364                            }
1365                            finally {
1366                                    if (count == null) {
1367                                            count = Long.valueOf(0);
1368                                    }
1369    
1370                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1371                                            count);
1372    
1373                                    closeSession(session);
1374                            }
1375                    }
1376    
1377                    return count.intValue();
1378            }
1379    
1380            /**
1381             * Initializes the layout set prototype persistence.
1382             */
1383            public void afterPropertiesSet() {
1384                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1385                                            com.liferay.portal.util.PropsUtil.get(
1386                                                    "value.object.listener.com.liferay.portal.model.LayoutSetPrototype")));
1387    
1388                    if (listenerClassNames.length > 0) {
1389                            try {
1390                                    List<ModelListener<LayoutSetPrototype>> listenersList = new ArrayList<ModelListener<LayoutSetPrototype>>();
1391    
1392                                    for (String listenerClassName : listenerClassNames) {
1393                                            listenersList.add((ModelListener<LayoutSetPrototype>)InstanceFactory.newInstance(
1394                                                            listenerClassName));
1395                                    }
1396    
1397                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1398                            }
1399                            catch (Exception e) {
1400                                    _log.error(e);
1401                            }
1402                    }
1403            }
1404    
1405            @BeanReference(type = AccountPersistence.class)
1406            protected AccountPersistence accountPersistence;
1407            @BeanReference(type = AddressPersistence.class)
1408            protected AddressPersistence addressPersistence;
1409            @BeanReference(type = BrowserTrackerPersistence.class)
1410            protected BrowserTrackerPersistence browserTrackerPersistence;
1411            @BeanReference(type = ClassNamePersistence.class)
1412            protected ClassNamePersistence classNamePersistence;
1413            @BeanReference(type = ClusterGroupPersistence.class)
1414            protected ClusterGroupPersistence clusterGroupPersistence;
1415            @BeanReference(type = CompanyPersistence.class)
1416            protected CompanyPersistence companyPersistence;
1417            @BeanReference(type = ContactPersistence.class)
1418            protected ContactPersistence contactPersistence;
1419            @BeanReference(type = CountryPersistence.class)
1420            protected CountryPersistence countryPersistence;
1421            @BeanReference(type = EmailAddressPersistence.class)
1422            protected EmailAddressPersistence emailAddressPersistence;
1423            @BeanReference(type = GroupPersistence.class)
1424            protected GroupPersistence groupPersistence;
1425            @BeanReference(type = ImagePersistence.class)
1426            protected ImagePersistence imagePersistence;
1427            @BeanReference(type = LayoutPersistence.class)
1428            protected LayoutPersistence layoutPersistence;
1429            @BeanReference(type = LayoutPrototypePersistence.class)
1430            protected LayoutPrototypePersistence layoutPrototypePersistence;
1431            @BeanReference(type = LayoutSetPersistence.class)
1432            protected LayoutSetPersistence layoutSetPersistence;
1433            @BeanReference(type = LayoutSetPrototypePersistence.class)
1434            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1435            @BeanReference(type = ListTypePersistence.class)
1436            protected ListTypePersistence listTypePersistence;
1437            @BeanReference(type = LockPersistence.class)
1438            protected LockPersistence lockPersistence;
1439            @BeanReference(type = MembershipRequestPersistence.class)
1440            protected MembershipRequestPersistence membershipRequestPersistence;
1441            @BeanReference(type = OrganizationPersistence.class)
1442            protected OrganizationPersistence organizationPersistence;
1443            @BeanReference(type = OrgGroupPermissionPersistence.class)
1444            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1445            @BeanReference(type = OrgGroupRolePersistence.class)
1446            protected OrgGroupRolePersistence orgGroupRolePersistence;
1447            @BeanReference(type = OrgLaborPersistence.class)
1448            protected OrgLaborPersistence orgLaborPersistence;
1449            @BeanReference(type = PasswordPolicyPersistence.class)
1450            protected PasswordPolicyPersistence passwordPolicyPersistence;
1451            @BeanReference(type = PasswordPolicyRelPersistence.class)
1452            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1453            @BeanReference(type = PasswordTrackerPersistence.class)
1454            protected PasswordTrackerPersistence passwordTrackerPersistence;
1455            @BeanReference(type = PermissionPersistence.class)
1456            protected PermissionPersistence permissionPersistence;
1457            @BeanReference(type = PhonePersistence.class)
1458            protected PhonePersistence phonePersistence;
1459            @BeanReference(type = PluginSettingPersistence.class)
1460            protected PluginSettingPersistence pluginSettingPersistence;
1461            @BeanReference(type = PortletPersistence.class)
1462            protected PortletPersistence portletPersistence;
1463            @BeanReference(type = PortletItemPersistence.class)
1464            protected PortletItemPersistence portletItemPersistence;
1465            @BeanReference(type = PortletPreferencesPersistence.class)
1466            protected PortletPreferencesPersistence portletPreferencesPersistence;
1467            @BeanReference(type = RegionPersistence.class)
1468            protected RegionPersistence regionPersistence;
1469            @BeanReference(type = ReleasePersistence.class)
1470            protected ReleasePersistence releasePersistence;
1471            @BeanReference(type = ResourcePersistence.class)
1472            protected ResourcePersistence resourcePersistence;
1473            @BeanReference(type = ResourceActionPersistence.class)
1474            protected ResourceActionPersistence resourceActionPersistence;
1475            @BeanReference(type = ResourceCodePersistence.class)
1476            protected ResourceCodePersistence resourceCodePersistence;
1477            @BeanReference(type = ResourcePermissionPersistence.class)
1478            protected ResourcePermissionPersistence resourcePermissionPersistence;
1479            @BeanReference(type = RolePersistence.class)
1480            protected RolePersistence rolePersistence;
1481            @BeanReference(type = ServiceComponentPersistence.class)
1482            protected ServiceComponentPersistence serviceComponentPersistence;
1483            @BeanReference(type = ShardPersistence.class)
1484            protected ShardPersistence shardPersistence;
1485            @BeanReference(type = SubscriptionPersistence.class)
1486            protected SubscriptionPersistence subscriptionPersistence;
1487            @BeanReference(type = TicketPersistence.class)
1488            protected TicketPersistence ticketPersistence;
1489            @BeanReference(type = TeamPersistence.class)
1490            protected TeamPersistence teamPersistence;
1491            @BeanReference(type = UserPersistence.class)
1492            protected UserPersistence userPersistence;
1493            @BeanReference(type = UserGroupPersistence.class)
1494            protected UserGroupPersistence userGroupPersistence;
1495            @BeanReference(type = UserGroupGroupRolePersistence.class)
1496            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1497            @BeanReference(type = UserGroupRolePersistence.class)
1498            protected UserGroupRolePersistence userGroupRolePersistence;
1499            @BeanReference(type = UserIdMapperPersistence.class)
1500            protected UserIdMapperPersistence userIdMapperPersistence;
1501            @BeanReference(type = UserTrackerPersistence.class)
1502            protected UserTrackerPersistence userTrackerPersistence;
1503            @BeanReference(type = UserTrackerPathPersistence.class)
1504            protected UserTrackerPathPersistence userTrackerPathPersistence;
1505            @BeanReference(type = WebDAVPropsPersistence.class)
1506            protected WebDAVPropsPersistence webDAVPropsPersistence;
1507            @BeanReference(type = WebsitePersistence.class)
1508            protected WebsitePersistence websitePersistence;
1509            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1510            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1511            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1512            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1513            private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype";
1514            private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype WHERE ";
1515            private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype";
1516            private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype WHERE ";
1517            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "layoutSetPrototype.companyId = ?";
1518            private static final String _FINDER_COLUMN_C_A_COMPANYID_2 = "layoutSetPrototype.companyId = ? AND ";
1519            private static final String _FINDER_COLUMN_C_A_ACTIVE_2 = "layoutSetPrototype.active = ?";
1520            private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetPrototype.";
1521            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetPrototype exists with the primary key ";
1522            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetPrototype exists with the key {";
1523            private static Log _log = LogFactoryUtil.getLog(LayoutSetPrototypePersistenceImpl.class);
1524    }