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