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