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