001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.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                            if (socialEquitySetting.isCachedModel() ||
264                                            BatchSessionUtil.isEnabled()) {
265                                    Object staleObject = session.get(SocialEquitySettingImpl.class,
266                                                    socialEquitySetting.getPrimaryKeyObj());
267    
268                                    if (staleObject != null) {
269                                            session.evict(staleObject);
270                                    }
271                            }
272    
273                            session.delete(socialEquitySetting);
274    
275                            session.flush();
276                    }
277                    catch (Exception e) {
278                            throw processException(e);
279                    }
280                    finally {
281                            closeSession(session);
282                    }
283    
284                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
285    
286                    SocialEquitySettingModelImpl socialEquitySettingModelImpl = (SocialEquitySettingModelImpl)socialEquitySetting;
287    
288                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_A_T,
289                            new Object[] {
290                                    new Long(socialEquitySettingModelImpl.getOriginalGroupId()),
291                                    new Long(socialEquitySettingModelImpl.getOriginalClassNameId()),
292                                    
293                            socialEquitySettingModelImpl.getOriginalActionId(),
294                                    new Integer(socialEquitySettingModelImpl.getOriginalType())
295                            });
296    
297                    EntityCacheUtil.removeResult(SocialEquitySettingModelImpl.ENTITY_CACHE_ENABLED,
298                            SocialEquitySettingImpl.class, socialEquitySetting.getPrimaryKey());
299    
300                    return socialEquitySetting;
301            }
302    
303            public SocialEquitySetting updateImpl(
304                    com.liferay.portlet.social.model.SocialEquitySetting socialEquitySetting,
305                    boolean merge) throws SystemException {
306                    socialEquitySetting = toUnwrappedModel(socialEquitySetting);
307    
308                    boolean isNew = socialEquitySetting.isNew();
309    
310                    SocialEquitySettingModelImpl socialEquitySettingModelImpl = (SocialEquitySettingModelImpl)socialEquitySetting;
311    
312                    Session session = null;
313    
314                    try {
315                            session = openSession();
316    
317                            BatchSessionUtil.update(session, socialEquitySetting, merge);
318    
319                            socialEquitySetting.setNew(false);
320                    }
321                    catch (Exception e) {
322                            throw processException(e);
323                    }
324                    finally {
325                            closeSession(session);
326                    }
327    
328                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
329    
330                    EntityCacheUtil.putResult(SocialEquitySettingModelImpl.ENTITY_CACHE_ENABLED,
331                            SocialEquitySettingImpl.class, socialEquitySetting.getPrimaryKey(),
332                            socialEquitySetting);
333    
334                    if (!isNew &&
335                                    ((socialEquitySetting.getGroupId() != socialEquitySettingModelImpl.getOriginalGroupId()) ||
336                                    (socialEquitySetting.getClassNameId() != socialEquitySettingModelImpl.getOriginalClassNameId()) ||
337                                    !Validator.equals(socialEquitySetting.getActionId(),
338                                            socialEquitySettingModelImpl.getOriginalActionId()) ||
339                                    (socialEquitySetting.getType() != socialEquitySettingModelImpl.getOriginalType()))) {
340                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_A_T,
341                                    new Object[] {
342                                            new Long(socialEquitySettingModelImpl.getOriginalGroupId()),
343                                            new Long(socialEquitySettingModelImpl.getOriginalClassNameId()),
344                                            
345                                    socialEquitySettingModelImpl.getOriginalActionId(),
346                                            new Integer(socialEquitySettingModelImpl.getOriginalType())
347                                    });
348                    }
349    
350                    if (isNew ||
351                                    ((socialEquitySetting.getGroupId() != socialEquitySettingModelImpl.getOriginalGroupId()) ||
352                                    (socialEquitySetting.getClassNameId() != socialEquitySettingModelImpl.getOriginalClassNameId()) ||
353                                    !Validator.equals(socialEquitySetting.getActionId(),
354                                            socialEquitySettingModelImpl.getOriginalActionId()) ||
355                                    (socialEquitySetting.getType() != socialEquitySettingModelImpl.getOriginalType()))) {
356                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_A_T,
357                                    new Object[] {
358                                            new Long(socialEquitySetting.getGroupId()),
359                                            new Long(socialEquitySetting.getClassNameId()),
360                                            
361                                    socialEquitySetting.getActionId(),
362                                            new Integer(socialEquitySetting.getType())
363                                    }, socialEquitySetting);
364                    }
365    
366                    return socialEquitySetting;
367            }
368    
369            protected SocialEquitySetting toUnwrappedModel(
370                    SocialEquitySetting socialEquitySetting) {
371                    if (socialEquitySetting instanceof SocialEquitySettingImpl) {
372                            return socialEquitySetting;
373                    }
374    
375                    SocialEquitySettingImpl socialEquitySettingImpl = new SocialEquitySettingImpl();
376    
377                    socialEquitySettingImpl.setNew(socialEquitySetting.isNew());
378                    socialEquitySettingImpl.setPrimaryKey(socialEquitySetting.getPrimaryKey());
379    
380                    socialEquitySettingImpl.setEquitySettingId(socialEquitySetting.getEquitySettingId());
381                    socialEquitySettingImpl.setGroupId(socialEquitySetting.getGroupId());
382                    socialEquitySettingImpl.setCompanyId(socialEquitySetting.getCompanyId());
383                    socialEquitySettingImpl.setClassNameId(socialEquitySetting.getClassNameId());
384                    socialEquitySettingImpl.setActionId(socialEquitySetting.getActionId());
385                    socialEquitySettingImpl.setDailyLimit(socialEquitySetting.getDailyLimit());
386                    socialEquitySettingImpl.setLifespan(socialEquitySetting.getLifespan());
387                    socialEquitySettingImpl.setType(socialEquitySetting.getType());
388                    socialEquitySettingImpl.setUniqueEntry(socialEquitySetting.isUniqueEntry());
389                    socialEquitySettingImpl.setValue(socialEquitySetting.getValue());
390    
391                    return socialEquitySettingImpl;
392            }
393    
394            /**
395             * Finds the social equity setting with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
396             *
397             * @param primaryKey the primary key of the social equity setting to find
398             * @return the social equity setting
399             * @throws com.liferay.portal.NoSuchModelException if a social equity setting with the primary key could not be found
400             * @throws SystemException if a system exception occurred
401             */
402            public SocialEquitySetting findByPrimaryKey(Serializable primaryKey)
403                    throws NoSuchModelException, SystemException {
404                    return findByPrimaryKey(((Long)primaryKey).longValue());
405            }
406    
407            /**
408             * Finds the social equity setting with the primary key or throws a {@link com.liferay.portlet.social.NoSuchEquitySettingException} if it could not be found.
409             *
410             * @param equitySettingId the primary key of the social equity setting to find
411             * @return the social equity setting
412             * @throws com.liferay.portlet.social.NoSuchEquitySettingException if a social equity setting with the primary key could not be found
413             * @throws SystemException if a system exception occurred
414             */
415            public SocialEquitySetting findByPrimaryKey(long equitySettingId)
416                    throws NoSuchEquitySettingException, SystemException {
417                    SocialEquitySetting socialEquitySetting = fetchByPrimaryKey(equitySettingId);
418    
419                    if (socialEquitySetting == null) {
420                            if (_log.isWarnEnabled()) {
421                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + equitySettingId);
422                            }
423    
424                            throw new NoSuchEquitySettingException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
425                                    equitySettingId);
426                    }
427    
428                    return socialEquitySetting;
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 primaryKey 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(Serializable primaryKey)
439                    throws SystemException {
440                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
441            }
442    
443            /**
444             * Finds the social equity setting with the primary key or returns <code>null</code> if it could not be found.
445             *
446             * @param equitySettingId the primary key of the social equity setting to find
447             * @return the social equity setting, or <code>null</code> if a social equity setting with the primary key could not be found
448             * @throws SystemException if a system exception occurred
449             */
450            public SocialEquitySetting fetchByPrimaryKey(long equitySettingId)
451                    throws SystemException {
452                    SocialEquitySetting socialEquitySetting = (SocialEquitySetting)EntityCacheUtil.getResult(SocialEquitySettingModelImpl.ENTITY_CACHE_ENABLED,
453                                    SocialEquitySettingImpl.class, equitySettingId, this);
454    
455                    if (socialEquitySetting == null) {
456                            Session session = null;
457    
458                            try {
459                                    session = openSession();
460    
461                                    socialEquitySetting = (SocialEquitySetting)session.get(SocialEquitySettingImpl.class,
462                                                    new Long(equitySettingId));
463                            }
464                            catch (Exception e) {
465                                    throw processException(e);
466                            }
467                            finally {
468                                    if (socialEquitySetting != null) {
469                                            cacheResult(socialEquitySetting);
470                                    }
471    
472                                    closeSession(session);
473                            }
474                    }
475    
476                    return socialEquitySetting;
477            }
478    
479            /**
480             * Finds all the social equity settings where groupId = &#63; and classNameId = &#63; and actionId = &#63;.
481             *
482             * @param groupId the group id to search with
483             * @param classNameId the class name id to search with
484             * @param actionId the action id to search with
485             * @return the matching social equity settings
486             * @throws SystemException if a system exception occurred
487             */
488            public List<SocialEquitySetting> findByG_C_A(long groupId,
489                    long classNameId, String actionId) throws SystemException {
490                    return findByG_C_A(groupId, classNameId, actionId, QueryUtil.ALL_POS,
491                            QueryUtil.ALL_POS, null);
492            }
493    
494            /**
495             * Finds a range of all the social equity settings where groupId = &#63; and classNameId = &#63; and actionId = &#63;.
496             *
497             * <p>
498             * 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.
499             * </p>
500             *
501             * @param groupId the group id to search with
502             * @param classNameId the class name id to search with
503             * @param actionId the action id to search with
504             * @param start the lower bound of the range of social equity settings to return
505             * @param end the upper bound of the range of social equity settings to return (not inclusive)
506             * @return the range of matching social equity settings
507             * @throws SystemException if a system exception occurred
508             */
509            public List<SocialEquitySetting> findByG_C_A(long groupId,
510                    long classNameId, String actionId, int start, int end)
511                    throws SystemException {
512                    return findByG_C_A(groupId, classNameId, actionId, start, end, null);
513            }
514    
515            /**
516             * Finds an ordered range of all the social equity settings where groupId = &#63; and classNameId = &#63; and actionId = &#63;.
517             *
518             * <p>
519             * 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.
520             * </p>
521             *
522             * @param groupId the group id to search with
523             * @param classNameId the class name id to search with
524             * @param actionId the action id to search with
525             * @param start the lower bound of the range of social equity settings to return
526             * @param end the upper bound of the range of social equity settings to return (not inclusive)
527             * @param orderByComparator the comparator to order the results by
528             * @return the ordered range of matching social equity settings
529             * @throws SystemException if a system exception occurred
530             */
531            public List<SocialEquitySetting> findByG_C_A(long groupId,
532                    long classNameId, String actionId, int start, int end,
533                    OrderByComparator orderByComparator) throws SystemException {
534                    Object[] finderArgs = new Object[] {
535                                    groupId, classNameId, actionId,
536                                    
537                                    String.valueOf(start), String.valueOf(end),
538                                    String.valueOf(orderByComparator)
539                            };
540    
541                    List<SocialEquitySetting> list = (List<SocialEquitySetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_A,
542                                    finderArgs, this);
543    
544                    if (list == null) {
545                            Session session = null;
546    
547                            try {
548                                    session = openSession();
549    
550                                    StringBundler query = null;
551    
552                                    if (orderByComparator != null) {
553                                            query = new StringBundler(5 +
554                                                            (orderByComparator.getOrderByFields().length * 3));
555                                    }
556                                    else {
557                                            query = new StringBundler(4);
558                                    }
559    
560                                    query.append(_SQL_SELECT_SOCIALEQUITYSETTING_WHERE);
561    
562                                    query.append(_FINDER_COLUMN_G_C_A_GROUPID_2);
563    
564                                    query.append(_FINDER_COLUMN_G_C_A_CLASSNAMEID_2);
565    
566                                    if (actionId == null) {
567                                            query.append(_FINDER_COLUMN_G_C_A_ACTIONID_1);
568                                    }
569                                    else {
570                                            if (actionId.equals(StringPool.BLANK)) {
571                                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_3);
572                                            }
573                                            else {
574                                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_2);
575                                            }
576                                    }
577    
578                                    if (orderByComparator != null) {
579                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
580                                                    orderByComparator);
581                                    }
582    
583                                    String sql = query.toString();
584    
585                                    Query q = session.createQuery(sql);
586    
587                                    QueryPos qPos = QueryPos.getInstance(q);
588    
589                                    qPos.add(groupId);
590    
591                                    qPos.add(classNameId);
592    
593                                    if (actionId != null) {
594                                            qPos.add(actionId);
595                                    }
596    
597                                    list = (List<SocialEquitySetting>)QueryUtil.list(q,
598                                                    getDialect(), start, end);
599                            }
600                            catch (Exception e) {
601                                    throw processException(e);
602                            }
603                            finally {
604                                    if (list == null) {
605                                            list = new ArrayList<SocialEquitySetting>();
606                                    }
607    
608                                    cacheResult(list);
609    
610                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_A,
611                                            finderArgs, list);
612    
613                                    closeSession(session);
614                            }
615                    }
616    
617                    return list;
618            }
619    
620            /**
621             * Finds the first social equity setting in the ordered set where groupId = &#63; and classNameId = &#63; and actionId = &#63;.
622             *
623             * <p>
624             * 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.
625             * </p>
626             *
627             * @param groupId the group id to search with
628             * @param classNameId the class name id to search with
629             * @param actionId the action id to search with
630             * @param orderByComparator the comparator to order the set by
631             * @return the first matching social equity setting
632             * @throws com.liferay.portlet.social.NoSuchEquitySettingException if a matching social equity setting could not be found
633             * @throws SystemException if a system exception occurred
634             */
635            public SocialEquitySetting findByG_C_A_First(long groupId,
636                    long classNameId, String actionId, OrderByComparator orderByComparator)
637                    throws NoSuchEquitySettingException, SystemException {
638                    List<SocialEquitySetting> list = findByG_C_A(groupId, classNameId,
639                                    actionId, 0, 1, orderByComparator);
640    
641                    if (list.isEmpty()) {
642                            StringBundler msg = new StringBundler(8);
643    
644                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
645    
646                            msg.append("groupId=");
647                            msg.append(groupId);
648    
649                            msg.append(", classNameId=");
650                            msg.append(classNameId);
651    
652                            msg.append(", actionId=");
653                            msg.append(actionId);
654    
655                            msg.append(StringPool.CLOSE_CURLY_BRACE);
656    
657                            throw new NoSuchEquitySettingException(msg.toString());
658                    }
659                    else {
660                            return list.get(0);
661                    }
662            }
663    
664            /**
665             * Finds the last social equity setting in the ordered set where groupId = &#63; and classNameId = &#63; and actionId = &#63;.
666             *
667             * <p>
668             * 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.
669             * </p>
670             *
671             * @param groupId the group id to search with
672             * @param classNameId the class name id to search with
673             * @param actionId the action id to search with
674             * @param orderByComparator the comparator to order the set by
675             * @return the last matching social equity setting
676             * @throws com.liferay.portlet.social.NoSuchEquitySettingException if a matching social equity setting could not be found
677             * @throws SystemException if a system exception occurred
678             */
679            public SocialEquitySetting findByG_C_A_Last(long groupId, long classNameId,
680                    String actionId, OrderByComparator orderByComparator)
681                    throws NoSuchEquitySettingException, SystemException {
682                    int count = countByG_C_A(groupId, classNameId, actionId);
683    
684                    List<SocialEquitySetting> list = findByG_C_A(groupId, classNameId,
685                                    actionId, count - 1, count, orderByComparator);
686    
687                    if (list.isEmpty()) {
688                            StringBundler msg = new StringBundler(8);
689    
690                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
691    
692                            msg.append("groupId=");
693                            msg.append(groupId);
694    
695                            msg.append(", classNameId=");
696                            msg.append(classNameId);
697    
698                            msg.append(", actionId=");
699                            msg.append(actionId);
700    
701                            msg.append(StringPool.CLOSE_CURLY_BRACE);
702    
703                            throw new NoSuchEquitySettingException(msg.toString());
704                    }
705                    else {
706                            return list.get(0);
707                    }
708            }
709    
710            /**
711             * 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;.
712             *
713             * <p>
714             * 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.
715             * </p>
716             *
717             * @param equitySettingId the primary key of the current social equity setting
718             * @param groupId the group id to search with
719             * @param classNameId the class name id to search with
720             * @param actionId the action id to search with
721             * @param orderByComparator the comparator to order the set by
722             * @return the previous, current, and next social equity setting
723             * @throws com.liferay.portlet.social.NoSuchEquitySettingException if a social equity setting with the primary key could not be found
724             * @throws SystemException if a system exception occurred
725             */
726            public SocialEquitySetting[] findByG_C_A_PrevAndNext(long equitySettingId,
727                    long groupId, long classNameId, String actionId,
728                    OrderByComparator orderByComparator)
729                    throws NoSuchEquitySettingException, SystemException {
730                    SocialEquitySetting socialEquitySetting = findByPrimaryKey(equitySettingId);
731    
732                    Session session = null;
733    
734                    try {
735                            session = openSession();
736    
737                            SocialEquitySetting[] array = new SocialEquitySettingImpl[3];
738    
739                            array[0] = getByG_C_A_PrevAndNext(session, socialEquitySetting,
740                                            groupId, classNameId, actionId, orderByComparator, true);
741    
742                            array[1] = socialEquitySetting;
743    
744                            array[2] = getByG_C_A_PrevAndNext(session, socialEquitySetting,
745                                            groupId, classNameId, actionId, orderByComparator, false);
746    
747                            return array;
748                    }
749                    catch (Exception e) {
750                            throw processException(e);
751                    }
752                    finally {
753                            closeSession(session);
754                    }
755            }
756    
757            protected SocialEquitySetting getByG_C_A_PrevAndNext(Session session,
758                    SocialEquitySetting socialEquitySetting, long groupId,
759                    long classNameId, String actionId, OrderByComparator orderByComparator,
760                    boolean previous) {
761                    StringBundler query = null;
762    
763                    if (orderByComparator != null) {
764                            query = new StringBundler(6 +
765                                            (orderByComparator.getOrderByFields().length * 6));
766                    }
767                    else {
768                            query = new StringBundler(3);
769                    }
770    
771                    query.append(_SQL_SELECT_SOCIALEQUITYSETTING_WHERE);
772    
773                    query.append(_FINDER_COLUMN_G_C_A_GROUPID_2);
774    
775                    query.append(_FINDER_COLUMN_G_C_A_CLASSNAMEID_2);
776    
777                    if (actionId == null) {
778                            query.append(_FINDER_COLUMN_G_C_A_ACTIONID_1);
779                    }
780                    else {
781                            if (actionId.equals(StringPool.BLANK)) {
782                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_3);
783                            }
784                            else {
785                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_2);
786                            }
787                    }
788    
789                    if (orderByComparator != null) {
790                            String[] orderByFields = orderByComparator.getOrderByFields();
791    
792                            if (orderByFields.length > 0) {
793                                    query.append(WHERE_AND);
794                            }
795    
796                            for (int i = 0; i < orderByFields.length; i++) {
797                                    query.append(_ORDER_BY_ENTITY_ALIAS);
798                                    query.append(orderByFields[i]);
799    
800                                    if ((i + 1) < orderByFields.length) {
801                                            if (orderByComparator.isAscending() ^ previous) {
802                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
803                                            }
804                                            else {
805                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
806                                            }
807                                    }
808                                    else {
809                                            if (orderByComparator.isAscending() ^ previous) {
810                                                    query.append(WHERE_GREATER_THAN);
811                                            }
812                                            else {
813                                                    query.append(WHERE_LESSER_THAN);
814                                            }
815                                    }
816                            }
817    
818                            query.append(ORDER_BY_CLAUSE);
819    
820                            for (int i = 0; i < orderByFields.length; i++) {
821                                    query.append(_ORDER_BY_ENTITY_ALIAS);
822                                    query.append(orderByFields[i]);
823    
824                                    if ((i + 1) < orderByFields.length) {
825                                            if (orderByComparator.isAscending() ^ previous) {
826                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
827                                            }
828                                            else {
829                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
830                                            }
831                                    }
832                                    else {
833                                            if (orderByComparator.isAscending() ^ previous) {
834                                                    query.append(ORDER_BY_ASC);
835                                            }
836                                            else {
837                                                    query.append(ORDER_BY_DESC);
838                                            }
839                                    }
840                            }
841                    }
842    
843                    String sql = query.toString();
844    
845                    Query q = session.createQuery(sql);
846    
847                    q.setFirstResult(0);
848                    q.setMaxResults(2);
849    
850                    QueryPos qPos = QueryPos.getInstance(q);
851    
852                    qPos.add(groupId);
853    
854                    qPos.add(classNameId);
855    
856                    if (actionId != null) {
857                            qPos.add(actionId);
858                    }
859    
860                    if (orderByComparator != null) {
861                            Object[] values = orderByComparator.getOrderByValues(socialEquitySetting);
862    
863                            for (Object value : values) {
864                                    qPos.add(value);
865                            }
866                    }
867    
868                    List<SocialEquitySetting> list = q.list();
869    
870                    if (list.size() == 2) {
871                            return list.get(1);
872                    }
873                    else {
874                            return null;
875                    }
876            }
877    
878            /**
879             * 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.
880             *
881             * @param groupId the group id to search with
882             * @param classNameId the class name id to search with
883             * @param actionId the action id to search with
884             * @param type the type to search with
885             * @return the matching social equity setting
886             * @throws com.liferay.portlet.social.NoSuchEquitySettingException if a matching social equity setting could not be found
887             * @throws SystemException if a system exception occurred
888             */
889            public SocialEquitySetting findByG_C_A_T(long groupId, long classNameId,
890                    String actionId, int type)
891                    throws NoSuchEquitySettingException, SystemException {
892                    SocialEquitySetting socialEquitySetting = fetchByG_C_A_T(groupId,
893                                    classNameId, actionId, type);
894    
895                    if (socialEquitySetting == null) {
896                            StringBundler msg = new StringBundler(10);
897    
898                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
899    
900                            msg.append("groupId=");
901                            msg.append(groupId);
902    
903                            msg.append(", classNameId=");
904                            msg.append(classNameId);
905    
906                            msg.append(", actionId=");
907                            msg.append(actionId);
908    
909                            msg.append(", type=");
910                            msg.append(type);
911    
912                            msg.append(StringPool.CLOSE_CURLY_BRACE);
913    
914                            if (_log.isWarnEnabled()) {
915                                    _log.warn(msg.toString());
916                            }
917    
918                            throw new NoSuchEquitySettingException(msg.toString());
919                    }
920    
921                    return socialEquitySetting;
922            }
923    
924            /**
925             * 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.
926             *
927             * @param groupId the group id to search with
928             * @param classNameId the class name id to search with
929             * @param actionId the action id to search with
930             * @param type the type to search with
931             * @return the matching social equity setting, or <code>null</code> if a matching social equity setting could not be found
932             * @throws SystemException if a system exception occurred
933             */
934            public SocialEquitySetting fetchByG_C_A_T(long groupId, long classNameId,
935                    String actionId, int type) throws SystemException {
936                    return fetchByG_C_A_T(groupId, classNameId, actionId, type, true);
937            }
938    
939            /**
940             * 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.
941             *
942             * @param groupId the group id to search with
943             * @param classNameId the class name id to search with
944             * @param actionId the action id to search with
945             * @param type the type to search with
946             * @return the matching social equity setting, or <code>null</code> if a matching social equity setting could not be found
947             * @throws SystemException if a system exception occurred
948             */
949            public SocialEquitySetting fetchByG_C_A_T(long groupId, long classNameId,
950                    String actionId, int type, boolean retrieveFromCache)
951                    throws SystemException {
952                    Object[] finderArgs = new Object[] { groupId, classNameId, actionId, type };
953    
954                    Object result = null;
955    
956                    if (retrieveFromCache) {
957                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_A_T,
958                                            finderArgs, this);
959                    }
960    
961                    if (result == null) {
962                            Session session = null;
963    
964                            try {
965                                    session = openSession();
966    
967                                    StringBundler query = new StringBundler(5);
968    
969                                    query.append(_SQL_SELECT_SOCIALEQUITYSETTING_WHERE);
970    
971                                    query.append(_FINDER_COLUMN_G_C_A_T_GROUPID_2);
972    
973                                    query.append(_FINDER_COLUMN_G_C_A_T_CLASSNAMEID_2);
974    
975                                    if (actionId == null) {
976                                            query.append(_FINDER_COLUMN_G_C_A_T_ACTIONID_1);
977                                    }
978                                    else {
979                                            if (actionId.equals(StringPool.BLANK)) {
980                                                    query.append(_FINDER_COLUMN_G_C_A_T_ACTIONID_3);
981                                            }
982                                            else {
983                                                    query.append(_FINDER_COLUMN_G_C_A_T_ACTIONID_2);
984                                            }
985                                    }
986    
987                                    query.append(_FINDER_COLUMN_G_C_A_T_TYPE_2);
988    
989                                    String sql = query.toString();
990    
991                                    Query q = session.createQuery(sql);
992    
993                                    QueryPos qPos = QueryPos.getInstance(q);
994    
995                                    qPos.add(groupId);
996    
997                                    qPos.add(classNameId);
998    
999                                    if (actionId != null) {
1000                                            qPos.add(actionId);
1001                                    }
1002    
1003                                    qPos.add(type);
1004    
1005                                    List<SocialEquitySetting> list = q.list();
1006    
1007                                    result = list;
1008    
1009                                    SocialEquitySetting socialEquitySetting = null;
1010    
1011                                    if (list.isEmpty()) {
1012                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_A_T,
1013                                                    finderArgs, list);
1014                                    }
1015                                    else {
1016                                            socialEquitySetting = list.get(0);
1017    
1018                                            cacheResult(socialEquitySetting);
1019    
1020                                            if ((socialEquitySetting.getGroupId() != groupId) ||
1021                                                            (socialEquitySetting.getClassNameId() != classNameId) ||
1022                                                            (socialEquitySetting.getActionId() == null) ||
1023                                                            !socialEquitySetting.getActionId().equals(actionId) ||
1024                                                            (socialEquitySetting.getType() != type)) {
1025                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_A_T,
1026                                                            finderArgs, socialEquitySetting);
1027                                            }
1028                                    }
1029    
1030                                    return socialEquitySetting;
1031                            }
1032                            catch (Exception e) {
1033                                    throw processException(e);
1034                            }
1035                            finally {
1036                                    if (result == null) {
1037                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_A_T,
1038                                                    finderArgs, new ArrayList<SocialEquitySetting>());
1039                                    }
1040    
1041                                    closeSession(session);
1042                            }
1043                    }
1044                    else {
1045                            if (result instanceof List<?>) {
1046                                    return null;
1047                            }
1048                            else {
1049                                    return (SocialEquitySetting)result;
1050                            }
1051                    }
1052            }
1053    
1054            /**
1055             * Finds all the social equity settings.
1056             *
1057             * @return the social equity settings
1058             * @throws SystemException if a system exception occurred
1059             */
1060            public List<SocialEquitySetting> findAll() throws SystemException {
1061                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1062            }
1063    
1064            /**
1065             * Finds a range of all the social equity settings.
1066             *
1067             * <p>
1068             * 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.
1069             * </p>
1070             *
1071             * @param start the lower bound of the range of social equity settings to return
1072             * @param end the upper bound of the range of social equity settings to return (not inclusive)
1073             * @return the range of social equity settings
1074             * @throws SystemException if a system exception occurred
1075             */
1076            public List<SocialEquitySetting> findAll(int start, int end)
1077                    throws SystemException {
1078                    return findAll(start, end, null);
1079            }
1080    
1081            /**
1082             * Finds an ordered range of all the social equity settings.
1083             *
1084             * <p>
1085             * 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.
1086             * </p>
1087             *
1088             * @param start the lower bound of the range of social equity settings to return
1089             * @param end the upper bound of the range of social equity settings to return (not inclusive)
1090             * @param orderByComparator the comparator to order the results by
1091             * @return the ordered range of social equity settings
1092             * @throws SystemException if a system exception occurred
1093             */
1094            public List<SocialEquitySetting> findAll(int start, int end,
1095                    OrderByComparator orderByComparator) throws SystemException {
1096                    Object[] finderArgs = new Object[] {
1097                                    String.valueOf(start), String.valueOf(end),
1098                                    String.valueOf(orderByComparator)
1099                            };
1100    
1101                    List<SocialEquitySetting> list = (List<SocialEquitySetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1102                                    finderArgs, this);
1103    
1104                    if (list == null) {
1105                            Session session = null;
1106    
1107                            try {
1108                                    session = openSession();
1109    
1110                                    StringBundler query = null;
1111                                    String sql = null;
1112    
1113                                    if (orderByComparator != null) {
1114                                            query = new StringBundler(2 +
1115                                                            (orderByComparator.getOrderByFields().length * 3));
1116    
1117                                            query.append(_SQL_SELECT_SOCIALEQUITYSETTING);
1118    
1119                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1120                                                    orderByComparator);
1121    
1122                                            sql = query.toString();
1123                                    }
1124                                    else {
1125                                            sql = _SQL_SELECT_SOCIALEQUITYSETTING;
1126                                    }
1127    
1128                                    Query q = session.createQuery(sql);
1129    
1130                                    if (orderByComparator == null) {
1131                                            list = (List<SocialEquitySetting>)QueryUtil.list(q,
1132                                                            getDialect(), start, end, false);
1133    
1134                                            Collections.sort(list);
1135                                    }
1136                                    else {
1137                                            list = (List<SocialEquitySetting>)QueryUtil.list(q,
1138                                                            getDialect(), start, end);
1139                                    }
1140                            }
1141                            catch (Exception e) {
1142                                    throw processException(e);
1143                            }
1144                            finally {
1145                                    if (list == null) {
1146                                            list = new ArrayList<SocialEquitySetting>();
1147                                    }
1148    
1149                                    cacheResult(list);
1150    
1151                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1152    
1153                                    closeSession(session);
1154                            }
1155                    }
1156    
1157                    return list;
1158            }
1159    
1160            /**
1161             * Removes all the social equity settings where groupId = &#63; and classNameId = &#63; and actionId = &#63; from the database.
1162             *
1163             * @param groupId the group id to search with
1164             * @param classNameId the class name id to search with
1165             * @param actionId the action id to search with
1166             * @throws SystemException if a system exception occurred
1167             */
1168            public void removeByG_C_A(long groupId, long classNameId, String actionId)
1169                    throws SystemException {
1170                    for (SocialEquitySetting socialEquitySetting : findByG_C_A(groupId,
1171                                    classNameId, actionId)) {
1172                            remove(socialEquitySetting);
1173                    }
1174            }
1175    
1176            /**
1177             * Removes the social equity setting where groupId = &#63; and classNameId = &#63; and actionId = &#63; and type = &#63; from the database.
1178             *
1179             * @param groupId the group id to search with
1180             * @param classNameId the class name id to search with
1181             * @param actionId the action id to search with
1182             * @param type the type to search with
1183             * @throws SystemException if a system exception occurred
1184             */
1185            public void removeByG_C_A_T(long groupId, long classNameId,
1186                    String actionId, int type)
1187                    throws NoSuchEquitySettingException, SystemException {
1188                    SocialEquitySetting socialEquitySetting = findByG_C_A_T(groupId,
1189                                    classNameId, actionId, type);
1190    
1191                    remove(socialEquitySetting);
1192            }
1193    
1194            /**
1195             * Removes all the social equity settings from the database.
1196             *
1197             * @throws SystemException if a system exception occurred
1198             */
1199            public void removeAll() throws SystemException {
1200                    for (SocialEquitySetting socialEquitySetting : findAll()) {
1201                            remove(socialEquitySetting);
1202                    }
1203            }
1204    
1205            /**
1206             * Counts all the social equity settings where groupId = &#63; and classNameId = &#63; and actionId = &#63;.
1207             *
1208             * @param groupId the group id to search with
1209             * @param classNameId the class name id to search with
1210             * @param actionId the action id to search with
1211             * @return the number of matching social equity settings
1212             * @throws SystemException if a system exception occurred
1213             */
1214            public int countByG_C_A(long groupId, long classNameId, String actionId)
1215                    throws SystemException {
1216                    Object[] finderArgs = new Object[] { groupId, classNameId, actionId };
1217    
1218                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_A,
1219                                    finderArgs, this);
1220    
1221                    if (count == null) {
1222                            Session session = null;
1223    
1224                            try {
1225                                    session = openSession();
1226    
1227                                    StringBundler query = new StringBundler(4);
1228    
1229                                    query.append(_SQL_COUNT_SOCIALEQUITYSETTING_WHERE);
1230    
1231                                    query.append(_FINDER_COLUMN_G_C_A_GROUPID_2);
1232    
1233                                    query.append(_FINDER_COLUMN_G_C_A_CLASSNAMEID_2);
1234    
1235                                    if (actionId == null) {
1236                                            query.append(_FINDER_COLUMN_G_C_A_ACTIONID_1);
1237                                    }
1238                                    else {
1239                                            if (actionId.equals(StringPool.BLANK)) {
1240                                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_3);
1241                                            }
1242                                            else {
1243                                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_2);
1244                                            }
1245                                    }
1246    
1247                                    String sql = query.toString();
1248    
1249                                    Query q = session.createQuery(sql);
1250    
1251                                    QueryPos qPos = QueryPos.getInstance(q);
1252    
1253                                    qPos.add(groupId);
1254    
1255                                    qPos.add(classNameId);
1256    
1257                                    if (actionId != null) {
1258                                            qPos.add(actionId);
1259                                    }
1260    
1261                                    count = (Long)q.uniqueResult();
1262                            }
1263                            catch (Exception e) {
1264                                    throw processException(e);
1265                            }
1266                            finally {
1267                                    if (count == null) {
1268                                            count = Long.valueOf(0);
1269                                    }
1270    
1271                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_A,
1272                                            finderArgs, count);
1273    
1274                                    closeSession(session);
1275                            }
1276                    }
1277    
1278                    return count.intValue();
1279            }
1280    
1281            /**
1282             * Counts all the social equity settings where groupId = &#63; and classNameId = &#63; and actionId = &#63; and type = &#63;.
1283             *
1284             * @param groupId the group id to search with
1285             * @param classNameId the class name id to search with
1286             * @param actionId the action id to search with
1287             * @param type the type to search with
1288             * @return the number of matching social equity settings
1289             * @throws SystemException if a system exception occurred
1290             */
1291            public int countByG_C_A_T(long groupId, long classNameId, String actionId,
1292                    int type) throws SystemException {
1293                    Object[] finderArgs = new Object[] { groupId, classNameId, actionId, type };
1294    
1295                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_A_T,
1296                                    finderArgs, this);
1297    
1298                    if (count == null) {
1299                            Session session = null;
1300    
1301                            try {
1302                                    session = openSession();
1303    
1304                                    StringBundler query = new StringBundler(5);
1305    
1306                                    query.append(_SQL_COUNT_SOCIALEQUITYSETTING_WHERE);
1307    
1308                                    query.append(_FINDER_COLUMN_G_C_A_T_GROUPID_2);
1309    
1310                                    query.append(_FINDER_COLUMN_G_C_A_T_CLASSNAMEID_2);
1311    
1312                                    if (actionId == null) {
1313                                            query.append(_FINDER_COLUMN_G_C_A_T_ACTIONID_1);
1314                                    }
1315                                    else {
1316                                            if (actionId.equals(StringPool.BLANK)) {
1317                                                    query.append(_FINDER_COLUMN_G_C_A_T_ACTIONID_3);
1318                                            }
1319                                            else {
1320                                                    query.append(_FINDER_COLUMN_G_C_A_T_ACTIONID_2);
1321                                            }
1322                                    }
1323    
1324                                    query.append(_FINDER_COLUMN_G_C_A_T_TYPE_2);
1325    
1326                                    String sql = query.toString();
1327    
1328                                    Query q = session.createQuery(sql);
1329    
1330                                    QueryPos qPos = QueryPos.getInstance(q);
1331    
1332                                    qPos.add(groupId);
1333    
1334                                    qPos.add(classNameId);
1335    
1336                                    if (actionId != null) {
1337                                            qPos.add(actionId);
1338                                    }
1339    
1340                                    qPos.add(type);
1341    
1342                                    count = (Long)q.uniqueResult();
1343                            }
1344                            catch (Exception e) {
1345                                    throw processException(e);
1346                            }
1347                            finally {
1348                                    if (count == null) {
1349                                            count = Long.valueOf(0);
1350                                    }
1351    
1352                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_A_T,
1353                                            finderArgs, count);
1354    
1355                                    closeSession(session);
1356                            }
1357                    }
1358    
1359                    return count.intValue();
1360            }
1361    
1362            /**
1363             * Counts all the social equity settings.
1364             *
1365             * @return the number of social equity settings
1366             * @throws SystemException if a system exception occurred
1367             */
1368            public int countAll() throws SystemException {
1369                    Object[] finderArgs = new Object[0];
1370    
1371                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1372                                    finderArgs, this);
1373    
1374                    if (count == null) {
1375                            Session session = null;
1376    
1377                            try {
1378                                    session = openSession();
1379    
1380                                    Query q = session.createQuery(_SQL_COUNT_SOCIALEQUITYSETTING);
1381    
1382                                    count = (Long)q.uniqueResult();
1383                            }
1384                            catch (Exception e) {
1385                                    throw processException(e);
1386                            }
1387                            finally {
1388                                    if (count == null) {
1389                                            count = Long.valueOf(0);
1390                                    }
1391    
1392                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1393                                            count);
1394    
1395                                    closeSession(session);
1396                            }
1397                    }
1398    
1399                    return count.intValue();
1400            }
1401    
1402            /**
1403             * Initializes the social equity setting persistence.
1404             */
1405            public void afterPropertiesSet() {
1406                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1407                                            com.liferay.portal.util.PropsUtil.get(
1408                                                    "value.object.listener.com.liferay.portlet.social.model.SocialEquitySetting")));
1409    
1410                    if (listenerClassNames.length > 0) {
1411                            try {
1412                                    List<ModelListener<SocialEquitySetting>> listenersList = new ArrayList<ModelListener<SocialEquitySetting>>();
1413    
1414                                    for (String listenerClassName : listenerClassNames) {
1415                                            listenersList.add((ModelListener<SocialEquitySetting>)InstanceFactory.newInstance(
1416                                                            listenerClassName));
1417                                    }
1418    
1419                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1420                            }
1421                            catch (Exception e) {
1422                                    _log.error(e);
1423                            }
1424                    }
1425            }
1426    
1427            @BeanReference(type = SocialActivityPersistence.class)
1428            protected SocialActivityPersistence socialActivityPersistence;
1429            @BeanReference(type = SocialEquityAssetEntryPersistence.class)
1430            protected SocialEquityAssetEntryPersistence socialEquityAssetEntryPersistence;
1431            @BeanReference(type = SocialEquityHistoryPersistence.class)
1432            protected SocialEquityHistoryPersistence socialEquityHistoryPersistence;
1433            @BeanReference(type = SocialEquityLogPersistence.class)
1434            protected SocialEquityLogPersistence socialEquityLogPersistence;
1435            @BeanReference(type = SocialEquitySettingPersistence.class)
1436            protected SocialEquitySettingPersistence socialEquitySettingPersistence;
1437            @BeanReference(type = SocialEquityUserPersistence.class)
1438            protected SocialEquityUserPersistence socialEquityUserPersistence;
1439            @BeanReference(type = SocialRelationPersistence.class)
1440            protected SocialRelationPersistence socialRelationPersistence;
1441            @BeanReference(type = SocialRequestPersistence.class)
1442            protected SocialRequestPersistence socialRequestPersistence;
1443            @BeanReference(type = GroupPersistence.class)
1444            protected GroupPersistence groupPersistence;
1445            @BeanReference(type = ResourcePersistence.class)
1446            protected ResourcePersistence resourcePersistence;
1447            @BeanReference(type = UserPersistence.class)
1448            protected UserPersistence userPersistence;
1449            private static final String _SQL_SELECT_SOCIALEQUITYSETTING = "SELECT socialEquitySetting FROM SocialEquitySetting socialEquitySetting";
1450            private static final String _SQL_SELECT_SOCIALEQUITYSETTING_WHERE = "SELECT socialEquitySetting FROM SocialEquitySetting socialEquitySetting WHERE ";
1451            private static final String _SQL_COUNT_SOCIALEQUITYSETTING = "SELECT COUNT(socialEquitySetting) FROM SocialEquitySetting socialEquitySetting";
1452            private static final String _SQL_COUNT_SOCIALEQUITYSETTING_WHERE = "SELECT COUNT(socialEquitySetting) FROM SocialEquitySetting socialEquitySetting WHERE ";
1453            private static final String _FINDER_COLUMN_G_C_A_GROUPID_2 = "socialEquitySetting.groupId = ? AND ";
1454            private static final String _FINDER_COLUMN_G_C_A_CLASSNAMEID_2 = "socialEquitySetting.classNameId = ? AND ";
1455            private static final String _FINDER_COLUMN_G_C_A_ACTIONID_1 = "socialEquitySetting.actionId IS NULL";
1456            private static final String _FINDER_COLUMN_G_C_A_ACTIONID_2 = "socialEquitySetting.actionId = ?";
1457            private static final String _FINDER_COLUMN_G_C_A_ACTIONID_3 = "(socialEquitySetting.actionId IS NULL OR socialEquitySetting.actionId = ?)";
1458            private static final String _FINDER_COLUMN_G_C_A_T_GROUPID_2 = "socialEquitySetting.groupId = ? AND ";
1459            private static final String _FINDER_COLUMN_G_C_A_T_CLASSNAMEID_2 = "socialEquitySetting.classNameId = ? AND ";
1460            private static final String _FINDER_COLUMN_G_C_A_T_ACTIONID_1 = "socialEquitySetting.actionId IS NULL AND ";
1461            private static final String _FINDER_COLUMN_G_C_A_T_ACTIONID_2 = "socialEquitySetting.actionId = ? AND ";
1462            private static final String _FINDER_COLUMN_G_C_A_T_ACTIONID_3 = "(socialEquitySetting.actionId IS NULL OR socialEquitySetting.actionId = ?) AND ";
1463            private static final String _FINDER_COLUMN_G_C_A_T_TYPE_2 = "socialEquitySetting.type = ?";
1464            private static final String _ORDER_BY_ENTITY_ALIAS = "socialEquitySetting.";
1465            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialEquitySetting exists with the primary key ";
1466            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialEquitySetting exists with the key {";
1467            private static Log _log = LogFactoryUtil.getLog(SocialEquitySettingPersistenceImpl.class);
1468    }