001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.getOriginalCompanyId()),
270                                    
271                            pluginSettingModelImpl.getOriginalPluginId(),
272                                    
273                            pluginSettingModelImpl.getOriginalPluginType()
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                            Session session = null;
512    
513                            try {
514                                    session = openSession();
515    
516                                    StringBundler query = null;
517    
518                                    if (orderByComparator != null) {
519                                            query = new StringBundler(3 +
520                                                            (orderByComparator.getOrderByFields().length * 3));
521                                    }
522                                    else {
523                                            query = new StringBundler(2);
524                                    }
525    
526                                    query.append(_SQL_SELECT_PLUGINSETTING_WHERE);
527    
528                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
529    
530                                    if (orderByComparator != null) {
531                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
532                                                    orderByComparator);
533                                    }
534    
535                                    String sql = query.toString();
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                                            list = new ArrayList<PluginSetting>();
552                                    }
553    
554                                    cacheResult(list);
555    
556                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
557                                            finderArgs, list);
558    
559                                    closeSession(session);
560                            }
561                    }
562    
563                    return list;
564            }
565    
566            /**
567             * Finds the first plugin setting in the ordered set where companyId = &#63;.
568             *
569             * <p>
570             * 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.
571             * </p>
572             *
573             * @param companyId the company id to search with
574             * @param orderByComparator the comparator to order the set by
575             * @return the first matching plugin setting
576             * @throws com.liferay.portal.NoSuchPluginSettingException if a matching plugin setting could not be found
577             * @throws SystemException if a system exception occurred
578             */
579            public PluginSetting findByCompanyId_First(long companyId,
580                    OrderByComparator orderByComparator)
581                    throws NoSuchPluginSettingException, SystemException {
582                    List<PluginSetting> list = findByCompanyId(companyId, 0, 1,
583                                    orderByComparator);
584    
585                    if (list.isEmpty()) {
586                            StringBundler msg = new StringBundler(4);
587    
588                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
589    
590                            msg.append("companyId=");
591                            msg.append(companyId);
592    
593                            msg.append(StringPool.CLOSE_CURLY_BRACE);
594    
595                            throw new NoSuchPluginSettingException(msg.toString());
596                    }
597                    else {
598                            return list.get(0);
599                    }
600            }
601    
602            /**
603             * Finds the last plugin setting in the ordered set where companyId = &#63;.
604             *
605             * <p>
606             * 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.
607             * </p>
608             *
609             * @param companyId the company id to search with
610             * @param orderByComparator the comparator to order the set by
611             * @return the last matching plugin setting
612             * @throws com.liferay.portal.NoSuchPluginSettingException if a matching plugin setting could not be found
613             * @throws SystemException if a system exception occurred
614             */
615            public PluginSetting findByCompanyId_Last(long companyId,
616                    OrderByComparator orderByComparator)
617                    throws NoSuchPluginSettingException, SystemException {
618                    int count = countByCompanyId(companyId);
619    
620                    List<PluginSetting> list = findByCompanyId(companyId, count - 1, count,
621                                    orderByComparator);
622    
623                    if (list.isEmpty()) {
624                            StringBundler msg = new StringBundler(4);
625    
626                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
627    
628                            msg.append("companyId=");
629                            msg.append(companyId);
630    
631                            msg.append(StringPool.CLOSE_CURLY_BRACE);
632    
633                            throw new NoSuchPluginSettingException(msg.toString());
634                    }
635                    else {
636                            return list.get(0);
637                    }
638            }
639    
640            /**
641             * Finds the plugin settings before and after the current plugin setting in the ordered set where companyId = &#63;.
642             *
643             * <p>
644             * 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.
645             * </p>
646             *
647             * @param pluginSettingId the primary key of the current plugin setting
648             * @param companyId the company id to search with
649             * @param orderByComparator the comparator to order the set by
650             * @return the previous, current, and next plugin setting
651             * @throws com.liferay.portal.NoSuchPluginSettingException if a plugin setting with the primary key could not be found
652             * @throws SystemException if a system exception occurred
653             */
654            public PluginSetting[] findByCompanyId_PrevAndNext(long pluginSettingId,
655                    long companyId, OrderByComparator orderByComparator)
656                    throws NoSuchPluginSettingException, SystemException {
657                    PluginSetting pluginSetting = findByPrimaryKey(pluginSettingId);
658    
659                    Session session = null;
660    
661                    try {
662                            session = openSession();
663    
664                            PluginSetting[] array = new PluginSettingImpl[3];
665    
666                            array[0] = getByCompanyId_PrevAndNext(session, pluginSetting,
667                                            companyId, orderByComparator, true);
668    
669                            array[1] = pluginSetting;
670    
671                            array[2] = getByCompanyId_PrevAndNext(session, pluginSetting,
672                                            companyId, orderByComparator, false);
673    
674                            return array;
675                    }
676                    catch (Exception e) {
677                            throw processException(e);
678                    }
679                    finally {
680                            closeSession(session);
681                    }
682            }
683    
684            protected PluginSetting getByCompanyId_PrevAndNext(Session session,
685                    PluginSetting pluginSetting, long companyId,
686                    OrderByComparator orderByComparator, boolean previous) {
687                    StringBundler query = null;
688    
689                    if (orderByComparator != null) {
690                            query = new StringBundler(6 +
691                                            (orderByComparator.getOrderByFields().length * 6));
692                    }
693                    else {
694                            query = new StringBundler(3);
695                    }
696    
697                    query.append(_SQL_SELECT_PLUGINSETTING_WHERE);
698    
699                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
700    
701                    if (orderByComparator != null) {
702                            String[] orderByFields = orderByComparator.getOrderByFields();
703    
704                            if (orderByFields.length > 0) {
705                                    query.append(WHERE_AND);
706                            }
707    
708                            for (int i = 0; i < orderByFields.length; i++) {
709                                    query.append(_ORDER_BY_ENTITY_ALIAS);
710                                    query.append(orderByFields[i]);
711    
712                                    if ((i + 1) < orderByFields.length) {
713                                            if (orderByComparator.isAscending() ^ previous) {
714                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
715                                            }
716                                            else {
717                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
718                                            }
719                                    }
720                                    else {
721                                            if (orderByComparator.isAscending() ^ previous) {
722                                                    query.append(WHERE_GREATER_THAN);
723                                            }
724                                            else {
725                                                    query.append(WHERE_LESSER_THAN);
726                                            }
727                                    }
728                            }
729    
730                            query.append(ORDER_BY_CLAUSE);
731    
732                            for (int i = 0; i < orderByFields.length; i++) {
733                                    query.append(_ORDER_BY_ENTITY_ALIAS);
734                                    query.append(orderByFields[i]);
735    
736                                    if ((i + 1) < orderByFields.length) {
737                                            if (orderByComparator.isAscending() ^ previous) {
738                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
739                                            }
740                                            else {
741                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
742                                            }
743                                    }
744                                    else {
745                                            if (orderByComparator.isAscending() ^ previous) {
746                                                    query.append(ORDER_BY_ASC);
747                                            }
748                                            else {
749                                                    query.append(ORDER_BY_DESC);
750                                            }
751                                    }
752                            }
753                    }
754    
755                    String sql = query.toString();
756    
757                    Query q = session.createQuery(sql);
758    
759                    q.setFirstResult(0);
760                    q.setMaxResults(2);
761    
762                    QueryPos qPos = QueryPos.getInstance(q);
763    
764                    qPos.add(companyId);
765    
766                    if (orderByComparator != null) {
767                            Object[] values = orderByComparator.getOrderByValues(pluginSetting);
768    
769                            for (Object value : values) {
770                                    qPos.add(value);
771                            }
772                    }
773    
774                    List<PluginSetting> list = q.list();
775    
776                    if (list.size() == 2) {
777                            return list.get(1);
778                    }
779                    else {
780                            return null;
781                    }
782            }
783    
784            /**
785             * 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.
786             *
787             * @param companyId the company id to search with
788             * @param pluginId the plugin id to search with
789             * @param pluginType the plugin type to search with
790             * @return the matching plugin setting
791             * @throws com.liferay.portal.NoSuchPluginSettingException if a matching plugin setting could not be found
792             * @throws SystemException if a system exception occurred
793             */
794            public PluginSetting findByC_I_T(long companyId, String pluginId,
795                    String pluginType) throws NoSuchPluginSettingException, SystemException {
796                    PluginSetting pluginSetting = fetchByC_I_T(companyId, pluginId,
797                                    pluginType);
798    
799                    if (pluginSetting == null) {
800                            StringBundler msg = new StringBundler(8);
801    
802                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
803    
804                            msg.append("companyId=");
805                            msg.append(companyId);
806    
807                            msg.append(", pluginId=");
808                            msg.append(pluginId);
809    
810                            msg.append(", pluginType=");
811                            msg.append(pluginType);
812    
813                            msg.append(StringPool.CLOSE_CURLY_BRACE);
814    
815                            if (_log.isWarnEnabled()) {
816                                    _log.warn(msg.toString());
817                            }
818    
819                            throw new NoSuchPluginSettingException(msg.toString());
820                    }
821    
822                    return pluginSetting;
823            }
824    
825            /**
826             * 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.
827             *
828             * @param companyId the company id to search with
829             * @param pluginId the plugin id to search with
830             * @param pluginType the plugin type to search with
831             * @return the matching plugin setting, or <code>null</code> if a matching plugin setting could not be found
832             * @throws SystemException if a system exception occurred
833             */
834            public PluginSetting fetchByC_I_T(long companyId, String pluginId,
835                    String pluginType) throws SystemException {
836                    return fetchByC_I_T(companyId, pluginId, pluginType, true);
837            }
838    
839            /**
840             * 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.
841             *
842             * @param companyId the company id to search with
843             * @param pluginId the plugin id to search with
844             * @param pluginType the plugin type to search with
845             * @return the matching plugin setting, or <code>null</code> if a matching plugin setting could not be found
846             * @throws SystemException if a system exception occurred
847             */
848            public PluginSetting fetchByC_I_T(long companyId, String pluginId,
849                    String pluginType, boolean retrieveFromCache) throws SystemException {
850                    Object[] finderArgs = new Object[] { companyId, pluginId, pluginType };
851    
852                    Object result = null;
853    
854                    if (retrieveFromCache) {
855                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_I_T,
856                                            finderArgs, this);
857                    }
858    
859                    if (result == null) {
860                            Session session = null;
861    
862                            try {
863                                    session = openSession();
864    
865                                    StringBundler query = new StringBundler(4);
866    
867                                    query.append(_SQL_SELECT_PLUGINSETTING_WHERE);
868    
869                                    query.append(_FINDER_COLUMN_C_I_T_COMPANYID_2);
870    
871                                    if (pluginId == null) {
872                                            query.append(_FINDER_COLUMN_C_I_T_PLUGINID_1);
873                                    }
874                                    else {
875                                            if (pluginId.equals(StringPool.BLANK)) {
876                                                    query.append(_FINDER_COLUMN_C_I_T_PLUGINID_3);
877                                            }
878                                            else {
879                                                    query.append(_FINDER_COLUMN_C_I_T_PLUGINID_2);
880                                            }
881                                    }
882    
883                                    if (pluginType == null) {
884                                            query.append(_FINDER_COLUMN_C_I_T_PLUGINTYPE_1);
885                                    }
886                                    else {
887                                            if (pluginType.equals(StringPool.BLANK)) {
888                                                    query.append(_FINDER_COLUMN_C_I_T_PLUGINTYPE_3);
889                                            }
890                                            else {
891                                                    query.append(_FINDER_COLUMN_C_I_T_PLUGINTYPE_2);
892                                            }
893                                    }
894    
895                                    String sql = query.toString();
896    
897                                    Query q = session.createQuery(sql);
898    
899                                    QueryPos qPos = QueryPos.getInstance(q);
900    
901                                    qPos.add(companyId);
902    
903                                    if (pluginId != null) {
904                                            qPos.add(pluginId);
905                                    }
906    
907                                    if (pluginType != null) {
908                                            qPos.add(pluginType);
909                                    }
910    
911                                    List<PluginSetting> list = q.list();
912    
913                                    result = list;
914    
915                                    PluginSetting pluginSetting = null;
916    
917                                    if (list.isEmpty()) {
918                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
919                                                    finderArgs, list);
920                                    }
921                                    else {
922                                            pluginSetting = list.get(0);
923    
924                                            cacheResult(pluginSetting);
925    
926                                            if ((pluginSetting.getCompanyId() != companyId) ||
927                                                            (pluginSetting.getPluginId() == null) ||
928                                                            !pluginSetting.getPluginId().equals(pluginId) ||
929                                                            (pluginSetting.getPluginType() == null) ||
930                                                            !pluginSetting.getPluginType().equals(pluginType)) {
931                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
932                                                            finderArgs, pluginSetting);
933                                            }
934                                    }
935    
936                                    return pluginSetting;
937                            }
938                            catch (Exception e) {
939                                    throw processException(e);
940                            }
941                            finally {
942                                    if (result == null) {
943                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
944                                                    finderArgs, new ArrayList<PluginSetting>());
945                                    }
946    
947                                    closeSession(session);
948                            }
949                    }
950                    else {
951                            if (result instanceof List<?>) {
952                                    return null;
953                            }
954                            else {
955                                    return (PluginSetting)result;
956                            }
957                    }
958            }
959    
960            /**
961             * Finds all the plugin settings.
962             *
963             * @return the plugin settings
964             * @throws SystemException if a system exception occurred
965             */
966            public List<PluginSetting> findAll() throws SystemException {
967                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
968            }
969    
970            /**
971             * Finds a range of all the plugin settings.
972             *
973             * <p>
974             * 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.
975             * </p>
976             *
977             * @param start the lower bound of the range of plugin settings to return
978             * @param end the upper bound of the range of plugin settings to return (not inclusive)
979             * @return the range of plugin settings
980             * @throws SystemException if a system exception occurred
981             */
982            public List<PluginSetting> findAll(int start, int end)
983                    throws SystemException {
984                    return findAll(start, end, null);
985            }
986    
987            /**
988             * Finds an ordered range of all the plugin settings.
989             *
990             * <p>
991             * 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.
992             * </p>
993             *
994             * @param start the lower bound of the range of plugin settings to return
995             * @param end the upper bound of the range of plugin settings to return (not inclusive)
996             * @param orderByComparator the comparator to order the results by
997             * @return the ordered range of plugin settings
998             * @throws SystemException if a system exception occurred
999             */
1000            public List<PluginSetting> findAll(int start, int end,
1001                    OrderByComparator orderByComparator) throws SystemException {
1002                    Object[] finderArgs = new Object[] {
1003                                    String.valueOf(start), String.valueOf(end),
1004                                    String.valueOf(orderByComparator)
1005                            };
1006    
1007                    List<PluginSetting> list = (List<PluginSetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1008                                    finderArgs, this);
1009    
1010                    if (list == null) {
1011                            Session session = null;
1012    
1013                            try {
1014                                    session = openSession();
1015    
1016                                    StringBundler query = null;
1017                                    String sql = null;
1018    
1019                                    if (orderByComparator != null) {
1020                                            query = new StringBundler(2 +
1021                                                            (orderByComparator.getOrderByFields().length * 3));
1022    
1023                                            query.append(_SQL_SELECT_PLUGINSETTING);
1024    
1025                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1026                                                    orderByComparator);
1027    
1028                                            sql = query.toString();
1029                                    }
1030                                    else {
1031                                            sql = _SQL_SELECT_PLUGINSETTING;
1032                                    }
1033    
1034                                    Query q = session.createQuery(sql);
1035    
1036                                    if (orderByComparator == null) {
1037                                            list = (List<PluginSetting>)QueryUtil.list(q, getDialect(),
1038                                                            start, end, false);
1039    
1040                                            Collections.sort(list);
1041                                    }
1042                                    else {
1043                                            list = (List<PluginSetting>)QueryUtil.list(q, getDialect(),
1044                                                            start, end);
1045                                    }
1046                            }
1047                            catch (Exception e) {
1048                                    throw processException(e);
1049                            }
1050                            finally {
1051                                    if (list == null) {
1052                                            list = new ArrayList<PluginSetting>();
1053                                    }
1054    
1055                                    cacheResult(list);
1056    
1057                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1058    
1059                                    closeSession(session);
1060                            }
1061                    }
1062    
1063                    return list;
1064            }
1065    
1066            /**
1067             * Removes all the plugin settings where companyId = &#63; from the database.
1068             *
1069             * @param companyId the company id to search with
1070             * @throws SystemException if a system exception occurred
1071             */
1072            public void removeByCompanyId(long companyId) throws SystemException {
1073                    for (PluginSetting pluginSetting : findByCompanyId(companyId)) {
1074                            remove(pluginSetting);
1075                    }
1076            }
1077    
1078            /**
1079             * Removes the plugin setting where companyId = &#63; and pluginId = &#63; and pluginType = &#63; from the database.
1080             *
1081             * @param companyId the company id to search with
1082             * @param pluginId the plugin id to search with
1083             * @param pluginType the plugin type to search with
1084             * @throws SystemException if a system exception occurred
1085             */
1086            public void removeByC_I_T(long companyId, String pluginId, String pluginType)
1087                    throws NoSuchPluginSettingException, SystemException {
1088                    PluginSetting pluginSetting = findByC_I_T(companyId, pluginId,
1089                                    pluginType);
1090    
1091                    remove(pluginSetting);
1092            }
1093    
1094            /**
1095             * Removes all the plugin settings from the database.
1096             *
1097             * @throws SystemException if a system exception occurred
1098             */
1099            public void removeAll() throws SystemException {
1100                    for (PluginSetting pluginSetting : findAll()) {
1101                            remove(pluginSetting);
1102                    }
1103            }
1104    
1105            /**
1106             * Counts all the plugin settings where companyId = &#63;.
1107             *
1108             * @param companyId the company id to search with
1109             * @return the number of matching plugin settings
1110             * @throws SystemException if a system exception occurred
1111             */
1112            public int countByCompanyId(long companyId) throws SystemException {
1113                    Object[] finderArgs = new Object[] { companyId };
1114    
1115                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1116                                    finderArgs, this);
1117    
1118                    if (count == null) {
1119                            Session session = null;
1120    
1121                            try {
1122                                    session = openSession();
1123    
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                                    Query q = session.createQuery(sql);
1133    
1134                                    QueryPos qPos = QueryPos.getInstance(q);
1135    
1136                                    qPos.add(companyId);
1137    
1138                                    count = (Long)q.uniqueResult();
1139                            }
1140                            catch (Exception e) {
1141                                    throw processException(e);
1142                            }
1143                            finally {
1144                                    if (count == null) {
1145                                            count = Long.valueOf(0);
1146                                    }
1147    
1148                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1149                                            finderArgs, count);
1150    
1151                                    closeSession(session);
1152                            }
1153                    }
1154    
1155                    return count.intValue();
1156            }
1157    
1158            /**
1159             * Counts all the plugin settings where companyId = &#63; and pluginId = &#63; and pluginType = &#63;.
1160             *
1161             * @param companyId the company id to search with
1162             * @param pluginId the plugin id to search with
1163             * @param pluginType the plugin type to search with
1164             * @return the number of matching plugin settings
1165             * @throws SystemException if a system exception occurred
1166             */
1167            public int countByC_I_T(long companyId, String pluginId, String pluginType)
1168                    throws SystemException {
1169                    Object[] finderArgs = new Object[] { companyId, pluginId, pluginType };
1170    
1171                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_I_T,
1172                                    finderArgs, this);
1173    
1174                    if (count == null) {
1175                            Session session = null;
1176    
1177                            try {
1178                                    session = openSession();
1179    
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                                    Query q = session.createQuery(sql);
1213    
1214                                    QueryPos qPos = QueryPos.getInstance(q);
1215    
1216                                    qPos.add(companyId);
1217    
1218                                    if (pluginId != null) {
1219                                            qPos.add(pluginId);
1220                                    }
1221    
1222                                    if (pluginType != null) {
1223                                            qPos.add(pluginType);
1224                                    }
1225    
1226                                    count = (Long)q.uniqueResult();
1227                            }
1228                            catch (Exception e) {
1229                                    throw processException(e);
1230                            }
1231                            finally {
1232                                    if (count == null) {
1233                                            count = Long.valueOf(0);
1234                                    }
1235    
1236                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_I_T,
1237                                            finderArgs, count);
1238    
1239                                    closeSession(session);
1240                            }
1241                    }
1242    
1243                    return count.intValue();
1244            }
1245    
1246            /**
1247             * Counts all the plugin settings.
1248             *
1249             * @return the number of plugin settings
1250             * @throws SystemException if a system exception occurred
1251             */
1252            public int countAll() throws SystemException {
1253                    Object[] finderArgs = new Object[0];
1254    
1255                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1256                                    finderArgs, this);
1257    
1258                    if (count == null) {
1259                            Session session = null;
1260    
1261                            try {
1262                                    session = openSession();
1263    
1264                                    Query q = session.createQuery(_SQL_COUNT_PLUGINSETTING);
1265    
1266                                    count = (Long)q.uniqueResult();
1267                            }
1268                            catch (Exception e) {
1269                                    throw processException(e);
1270                            }
1271                            finally {
1272                                    if (count == null) {
1273                                            count = Long.valueOf(0);
1274                                    }
1275    
1276                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1277                                            count);
1278    
1279                                    closeSession(session);
1280                            }
1281                    }
1282    
1283                    return count.intValue();
1284            }
1285    
1286            /**
1287             * Initializes the plugin setting persistence.
1288             */
1289            public void afterPropertiesSet() {
1290                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1291                                            com.liferay.portal.util.PropsUtil.get(
1292                                                    "value.object.listener.com.liferay.portal.model.PluginSetting")));
1293    
1294                    if (listenerClassNames.length > 0) {
1295                            try {
1296                                    List<ModelListener<PluginSetting>> listenersList = new ArrayList<ModelListener<PluginSetting>>();
1297    
1298                                    for (String listenerClassName : listenerClassNames) {
1299                                            listenersList.add((ModelListener<PluginSetting>)InstanceFactory.newInstance(
1300                                                            listenerClassName));
1301                                    }
1302    
1303                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1304                            }
1305                            catch (Exception e) {
1306                                    _log.error(e);
1307                            }
1308                    }
1309            }
1310    
1311            public void destroy() {
1312                    EntityCacheUtil.removeCache(PluginSettingImpl.class.getName());
1313                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1314                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1315            }
1316    
1317            @BeanReference(type = AccountPersistence.class)
1318            protected AccountPersistence accountPersistence;
1319            @BeanReference(type = AddressPersistence.class)
1320            protected AddressPersistence addressPersistence;
1321            @BeanReference(type = BrowserTrackerPersistence.class)
1322            protected BrowserTrackerPersistence browserTrackerPersistence;
1323            @BeanReference(type = ClassNamePersistence.class)
1324            protected ClassNamePersistence classNamePersistence;
1325            @BeanReference(type = ClusterGroupPersistence.class)
1326            protected ClusterGroupPersistence clusterGroupPersistence;
1327            @BeanReference(type = CompanyPersistence.class)
1328            protected CompanyPersistence companyPersistence;
1329            @BeanReference(type = ContactPersistence.class)
1330            protected ContactPersistence contactPersistence;
1331            @BeanReference(type = CountryPersistence.class)
1332            protected CountryPersistence countryPersistence;
1333            @BeanReference(type = EmailAddressPersistence.class)
1334            protected EmailAddressPersistence emailAddressPersistence;
1335            @BeanReference(type = GroupPersistence.class)
1336            protected GroupPersistence groupPersistence;
1337            @BeanReference(type = ImagePersistence.class)
1338            protected ImagePersistence imagePersistence;
1339            @BeanReference(type = LayoutPersistence.class)
1340            protected LayoutPersistence layoutPersistence;
1341            @BeanReference(type = LayoutPrototypePersistence.class)
1342            protected LayoutPrototypePersistence layoutPrototypePersistence;
1343            @BeanReference(type = LayoutSetPersistence.class)
1344            protected LayoutSetPersistence layoutSetPersistence;
1345            @BeanReference(type = LayoutSetPrototypePersistence.class)
1346            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1347            @BeanReference(type = ListTypePersistence.class)
1348            protected ListTypePersistence listTypePersistence;
1349            @BeanReference(type = LockPersistence.class)
1350            protected LockPersistence lockPersistence;
1351            @BeanReference(type = MembershipRequestPersistence.class)
1352            protected MembershipRequestPersistence membershipRequestPersistence;
1353            @BeanReference(type = OrganizationPersistence.class)
1354            protected OrganizationPersistence organizationPersistence;
1355            @BeanReference(type = OrgGroupPermissionPersistence.class)
1356            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1357            @BeanReference(type = OrgGroupRolePersistence.class)
1358            protected OrgGroupRolePersistence orgGroupRolePersistence;
1359            @BeanReference(type = OrgLaborPersistence.class)
1360            protected OrgLaborPersistence orgLaborPersistence;
1361            @BeanReference(type = PasswordPolicyPersistence.class)
1362            protected PasswordPolicyPersistence passwordPolicyPersistence;
1363            @BeanReference(type = PasswordPolicyRelPersistence.class)
1364            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1365            @BeanReference(type = PasswordTrackerPersistence.class)
1366            protected PasswordTrackerPersistence passwordTrackerPersistence;
1367            @BeanReference(type = PermissionPersistence.class)
1368            protected PermissionPersistence permissionPersistence;
1369            @BeanReference(type = PhonePersistence.class)
1370            protected PhonePersistence phonePersistence;
1371            @BeanReference(type = PluginSettingPersistence.class)
1372            protected PluginSettingPersistence pluginSettingPersistence;
1373            @BeanReference(type = PortletPersistence.class)
1374            protected PortletPersistence portletPersistence;
1375            @BeanReference(type = PortletItemPersistence.class)
1376            protected PortletItemPersistence portletItemPersistence;
1377            @BeanReference(type = PortletPreferencesPersistence.class)
1378            protected PortletPreferencesPersistence portletPreferencesPersistence;
1379            @BeanReference(type = RegionPersistence.class)
1380            protected RegionPersistence regionPersistence;
1381            @BeanReference(type = ReleasePersistence.class)
1382            protected ReleasePersistence releasePersistence;
1383            @BeanReference(type = ResourcePersistence.class)
1384            protected ResourcePersistence resourcePersistence;
1385            @BeanReference(type = ResourceActionPersistence.class)
1386            protected ResourceActionPersistence resourceActionPersistence;
1387            @BeanReference(type = ResourceCodePersistence.class)
1388            protected ResourceCodePersistence resourceCodePersistence;
1389            @BeanReference(type = ResourcePermissionPersistence.class)
1390            protected ResourcePermissionPersistence resourcePermissionPersistence;
1391            @BeanReference(type = RolePersistence.class)
1392            protected RolePersistence rolePersistence;
1393            @BeanReference(type = ServiceComponentPersistence.class)
1394            protected ServiceComponentPersistence serviceComponentPersistence;
1395            @BeanReference(type = ShardPersistence.class)
1396            protected ShardPersistence shardPersistence;
1397            @BeanReference(type = SubscriptionPersistence.class)
1398            protected SubscriptionPersistence subscriptionPersistence;
1399            @BeanReference(type = TicketPersistence.class)
1400            protected TicketPersistence ticketPersistence;
1401            @BeanReference(type = TeamPersistence.class)
1402            protected TeamPersistence teamPersistence;
1403            @BeanReference(type = UserPersistence.class)
1404            protected UserPersistence userPersistence;
1405            @BeanReference(type = UserGroupPersistence.class)
1406            protected UserGroupPersistence userGroupPersistence;
1407            @BeanReference(type = UserGroupGroupRolePersistence.class)
1408            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1409            @BeanReference(type = UserGroupRolePersistence.class)
1410            protected UserGroupRolePersistence userGroupRolePersistence;
1411            @BeanReference(type = UserIdMapperPersistence.class)
1412            protected UserIdMapperPersistence userIdMapperPersistence;
1413            @BeanReference(type = UserTrackerPersistence.class)
1414            protected UserTrackerPersistence userTrackerPersistence;
1415            @BeanReference(type = UserTrackerPathPersistence.class)
1416            protected UserTrackerPathPersistence userTrackerPathPersistence;
1417            @BeanReference(type = WebDAVPropsPersistence.class)
1418            protected WebDAVPropsPersistence webDAVPropsPersistence;
1419            @BeanReference(type = WebsitePersistence.class)
1420            protected WebsitePersistence websitePersistence;
1421            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1422            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1423            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1424            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1425            private static final String _SQL_SELECT_PLUGINSETTING = "SELECT pluginSetting FROM PluginSetting pluginSetting";
1426            private static final String _SQL_SELECT_PLUGINSETTING_WHERE = "SELECT pluginSetting FROM PluginSetting pluginSetting WHERE ";
1427            private static final String _SQL_COUNT_PLUGINSETTING = "SELECT COUNT(pluginSetting) FROM PluginSetting pluginSetting";
1428            private static final String _SQL_COUNT_PLUGINSETTING_WHERE = "SELECT COUNT(pluginSetting) FROM PluginSetting pluginSetting WHERE ";
1429            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "pluginSetting.companyId = ?";
1430            private static final String _FINDER_COLUMN_C_I_T_COMPANYID_2 = "pluginSetting.companyId = ? AND ";
1431            private static final String _FINDER_COLUMN_C_I_T_PLUGINID_1 = "pluginSetting.pluginId IS NULL AND ";
1432            private static final String _FINDER_COLUMN_C_I_T_PLUGINID_2 = "pluginSetting.pluginId = ? AND ";
1433            private static final String _FINDER_COLUMN_C_I_T_PLUGINID_3 = "(pluginSetting.pluginId IS NULL OR pluginSetting.pluginId = ?) AND ";
1434            private static final String _FINDER_COLUMN_C_I_T_PLUGINTYPE_1 = "pluginSetting.pluginType IS NULL";
1435            private static final String _FINDER_COLUMN_C_I_T_PLUGINTYPE_2 = "pluginSetting.pluginType = ?";
1436            private static final String _FINDER_COLUMN_C_I_T_PLUGINTYPE_3 = "(pluginSetting.pluginType IS NULL OR pluginSetting.pluginType = ?)";
1437            private static final String _ORDER_BY_ENTITY_ALIAS = "pluginSetting.";
1438            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PluginSetting exists with the primary key ";
1439            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PluginSetting exists with the key {";
1440            private static Log _log = LogFactoryUtil.getLog(PluginSettingPersistenceImpl.class);
1441    }