001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.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.getOriginalGroupId()),
279                                    new Long(socialEquitySettingModelImpl.getOriginalClassNameId()),
280                                    
281                            socialEquitySettingModelImpl.getOriginalActionId(),
282                                    new Integer(socialEquitySettingModelImpl.getOriginalType())
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                            Session session = null;
534    
535                            try {
536                                    session = openSession();
537    
538                                    StringBundler query = null;
539    
540                                    if (orderByComparator != null) {
541                                            query = new StringBundler(5 +
542                                                            (orderByComparator.getOrderByFields().length * 3));
543                                    }
544                                    else {
545                                            query = new StringBundler(4);
546                                    }
547    
548                                    query.append(_SQL_SELECT_SOCIALEQUITYSETTING_WHERE);
549    
550                                    query.append(_FINDER_COLUMN_G_C_A_GROUPID_2);
551    
552                                    query.append(_FINDER_COLUMN_G_C_A_CLASSNAMEID_2);
553    
554                                    if (actionId == null) {
555                                            query.append(_FINDER_COLUMN_G_C_A_ACTIONID_1);
556                                    }
557                                    else {
558                                            if (actionId.equals(StringPool.BLANK)) {
559                                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_3);
560                                            }
561                                            else {
562                                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_2);
563                                            }
564                                    }
565    
566                                    if (orderByComparator != null) {
567                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
568                                                    orderByComparator);
569                                    }
570    
571                                    String sql = query.toString();
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                                            list = new ArrayList<SocialEquitySetting>();
594                                    }
595    
596                                    cacheResult(list);
597    
598                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_A,
599                                            finderArgs, list);
600    
601                                    closeSession(session);
602                            }
603                    }
604    
605                    return list;
606            }
607    
608            /**
609             * Finds the first social equity setting in the ordered set where groupId = &#63; and classNameId = &#63; and actionId = &#63;.
610             *
611             * <p>
612             * 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.
613             * </p>
614             *
615             * @param groupId the group id to search with
616             * @param classNameId the class name id to search with
617             * @param actionId the action id to search with
618             * @param orderByComparator the comparator to order the set by
619             * @return the first matching social equity setting
620             * @throws com.liferay.portlet.social.NoSuchEquitySettingException if a matching social equity setting could not be found
621             * @throws SystemException if a system exception occurred
622             */
623            public SocialEquitySetting findByG_C_A_First(long groupId,
624                    long classNameId, String actionId, OrderByComparator orderByComparator)
625                    throws NoSuchEquitySettingException, SystemException {
626                    List<SocialEquitySetting> list = findByG_C_A(groupId, classNameId,
627                                    actionId, 0, 1, orderByComparator);
628    
629                    if (list.isEmpty()) {
630                            StringBundler msg = new StringBundler(8);
631    
632                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
633    
634                            msg.append("groupId=");
635                            msg.append(groupId);
636    
637                            msg.append(", classNameId=");
638                            msg.append(classNameId);
639    
640                            msg.append(", actionId=");
641                            msg.append(actionId);
642    
643                            msg.append(StringPool.CLOSE_CURLY_BRACE);
644    
645                            throw new NoSuchEquitySettingException(msg.toString());
646                    }
647                    else {
648                            return list.get(0);
649                    }
650            }
651    
652            /**
653             * Finds the last social equity setting in the ordered set where groupId = &#63; and classNameId = &#63; and actionId = &#63;.
654             *
655             * <p>
656             * 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.
657             * </p>
658             *
659             * @param groupId the group id to search with
660             * @param classNameId the class name id to search with
661             * @param actionId the action id to search with
662             * @param orderByComparator the comparator to order the set by
663             * @return the last matching social equity setting
664             * @throws com.liferay.portlet.social.NoSuchEquitySettingException if a matching social equity setting could not be found
665             * @throws SystemException if a system exception occurred
666             */
667            public SocialEquitySetting findByG_C_A_Last(long groupId, long classNameId,
668                    String actionId, OrderByComparator orderByComparator)
669                    throws NoSuchEquitySettingException, SystemException {
670                    int count = countByG_C_A(groupId, classNameId, actionId);
671    
672                    List<SocialEquitySetting> list = findByG_C_A(groupId, classNameId,
673                                    actionId, count - 1, count, orderByComparator);
674    
675                    if (list.isEmpty()) {
676                            StringBundler msg = new StringBundler(8);
677    
678                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
679    
680                            msg.append("groupId=");
681                            msg.append(groupId);
682    
683                            msg.append(", classNameId=");
684                            msg.append(classNameId);
685    
686                            msg.append(", actionId=");
687                            msg.append(actionId);
688    
689                            msg.append(StringPool.CLOSE_CURLY_BRACE);
690    
691                            throw new NoSuchEquitySettingException(msg.toString());
692                    }
693                    else {
694                            return list.get(0);
695                    }
696            }
697    
698            /**
699             * 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;.
700             *
701             * <p>
702             * 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.
703             * </p>
704             *
705             * @param equitySettingId the primary key of the current social equity setting
706             * @param groupId the group id to search with
707             * @param classNameId the class name id to search with
708             * @param actionId the action id to search with
709             * @param orderByComparator the comparator to order the set by
710             * @return the previous, current, and next social equity setting
711             * @throws com.liferay.portlet.social.NoSuchEquitySettingException if a social equity setting with the primary key could not be found
712             * @throws SystemException if a system exception occurred
713             */
714            public SocialEquitySetting[] findByG_C_A_PrevAndNext(long equitySettingId,
715                    long groupId, long classNameId, String actionId,
716                    OrderByComparator orderByComparator)
717                    throws NoSuchEquitySettingException, SystemException {
718                    SocialEquitySetting socialEquitySetting = findByPrimaryKey(equitySettingId);
719    
720                    Session session = null;
721    
722                    try {
723                            session = openSession();
724    
725                            SocialEquitySetting[] array = new SocialEquitySettingImpl[3];
726    
727                            array[0] = getByG_C_A_PrevAndNext(session, socialEquitySetting,
728                                            groupId, classNameId, actionId, orderByComparator, true);
729    
730                            array[1] = socialEquitySetting;
731    
732                            array[2] = getByG_C_A_PrevAndNext(session, socialEquitySetting,
733                                            groupId, classNameId, actionId, orderByComparator, false);
734    
735                            return array;
736                    }
737                    catch (Exception e) {
738                            throw processException(e);
739                    }
740                    finally {
741                            closeSession(session);
742                    }
743            }
744    
745            protected SocialEquitySetting getByG_C_A_PrevAndNext(Session session,
746                    SocialEquitySetting socialEquitySetting, long groupId,
747                    long classNameId, String actionId, OrderByComparator orderByComparator,
748                    boolean previous) {
749                    StringBundler query = null;
750    
751                    if (orderByComparator != null) {
752                            query = new StringBundler(6 +
753                                            (orderByComparator.getOrderByFields().length * 6));
754                    }
755                    else {
756                            query = new StringBundler(3);
757                    }
758    
759                    query.append(_SQL_SELECT_SOCIALEQUITYSETTING_WHERE);
760    
761                    query.append(_FINDER_COLUMN_G_C_A_GROUPID_2);
762    
763                    query.append(_FINDER_COLUMN_G_C_A_CLASSNAMEID_2);
764    
765                    if (actionId == null) {
766                            query.append(_FINDER_COLUMN_G_C_A_ACTIONID_1);
767                    }
768                    else {
769                            if (actionId.equals(StringPool.BLANK)) {
770                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_3);
771                            }
772                            else {
773                                    query.append(_FINDER_COLUMN_G_C_A_ACTIONID_2);
774                            }
775                    }
776    
777                    if (orderByComparator != null) {
778                            String[] orderByFields = orderByComparator.getOrderByFields();
779    
780                            if (orderByFields.length > 0) {
781                                    query.append(WHERE_AND);
782                            }
783    
784                            for (int i = 0; i < orderByFields.length; i++) {
785                                    query.append(_ORDER_BY_ENTITY_ALIAS);
786                                    query.append(orderByFields[i]);
787    
788                                    if ((i + 1) < orderByFields.length) {
789                                            if (orderByComparator.isAscending() ^ previous) {
790                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
791                                            }
792                                            else {
793                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
794                                            }
795                                    }
796                                    else {
797                                            if (orderByComparator.isAscending() ^ previous) {
798                                                    query.append(WHERE_GREATER_THAN);
799                                            }
800                                            else {
801                                                    query.append(WHERE_LESSER_THAN);
802                                            }
803                                    }
804                            }
805    
806                            query.append(ORDER_BY_CLAUSE);
807    
808                            for (int i = 0; i < orderByFields.length; i++) {
809                                    query.append(_ORDER_BY_ENTITY_ALIAS);
810                                    query.append(orderByFields[i]);
811    
812                                    if ((i + 1) < orderByFields.length) {
813                                            if (orderByComparator.isAscending() ^ previous) {
814                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
815                                            }
816                                            else {
817                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
818                                            }
819                                    }
820                                    else {
821                                            if (orderByComparator.isAscending() ^ previous) {
822                                                    query.append(ORDER_BY_ASC);
823                                            }
824                                            else {
825                                                    query.append(ORDER_BY_DESC);
826                                            }
827                                    }
828                            }
829                    }
830    
831                    String sql = query.toString();
832    
833                    Query q = session.createQuery(sql);
834    
835                    q.setFirstResult(0);
836                    q.setMaxResults(2);
837    
838                    QueryPos qPos = QueryPos.getInstance(q);
839    
840                    qPos.add(groupId);
841    
842                    qPos.add(classNameId);
843    
844                    if (actionId != null) {
845                            qPos.add(actionId);
846                    }
847    
848                    if (orderByComparator != null) {
849                            Object[] values = orderByComparator.getOrderByValues(socialEquitySetting);
850    
851                            for (Object value : values) {
852                                    qPos.add(value);
853                            }
854                    }
855    
856                    List<SocialEquitySetting> list = q.list();
857    
858                    if (list.size() == 2) {
859                            return list.get(1);
860                    }
861                    else {
862                            return null;
863                    }
864            }
865    
866            /**
867             * 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.
868             *
869             * @param groupId the group id to search with
870             * @param classNameId the class name id to search with
871             * @param actionId the action id to search with
872             * @param type the type to search with
873             * @return the matching social equity setting
874             * @throws com.liferay.portlet.social.NoSuchEquitySettingException if a matching social equity setting could not be found
875             * @throws SystemException if a system exception occurred
876             */
877            public SocialEquitySetting findByG_C_A_T(long groupId, long classNameId,
878                    String actionId, int type)
879                    throws NoSuchEquitySettingException, SystemException {
880                    SocialEquitySetting socialEquitySetting = fetchByG_C_A_T(groupId,
881                                    classNameId, actionId, type);
882    
883                    if (socialEquitySetting == null) {
884                            StringBundler msg = new StringBundler(10);
885    
886                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
887    
888                            msg.append("groupId=");
889                            msg.append(groupId);
890    
891                            msg.append(", classNameId=");
892                            msg.append(classNameId);
893    
894                            msg.append(", actionId=");
895                            msg.append(actionId);
896    
897                            msg.append(", type=");
898                            msg.append(type);
899    
900                            msg.append(StringPool.CLOSE_CURLY_BRACE);
901    
902                            if (_log.isWarnEnabled()) {
903                                    _log.warn(msg.toString());
904                            }
905    
906                            throw new NoSuchEquitySettingException(msg.toString());
907                    }
908    
909                    return socialEquitySetting;
910            }
911    
912            /**
913             * 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.
914             *
915             * @param groupId the group id to search with
916             * @param classNameId the class name id to search with
917             * @param actionId the action id to search with
918             * @param type the type to search with
919             * @return the matching social equity setting, or <code>null</code> if a matching social equity setting could not be found
920             * @throws SystemException if a system exception occurred
921             */
922            public SocialEquitySetting fetchByG_C_A_T(long groupId, long classNameId,
923                    String actionId, int type) throws SystemException {
924                    return fetchByG_C_A_T(groupId, classNameId, actionId, type, true);
925            }
926    
927            /**
928             * 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.
929             *
930             * @param groupId the group id to search with
931             * @param classNameId the class name id to search with
932             * @param actionId the action id to search with
933             * @param type the type to search with
934             * @return the matching social equity setting, or <code>null</code> if a matching social equity setting could not be found
935             * @throws SystemException if a system exception occurred
936             */
937            public SocialEquitySetting fetchByG_C_A_T(long groupId, long classNameId,
938                    String actionId, int type, boolean retrieveFromCache)
939                    throws SystemException {
940                    Object[] finderArgs = new Object[] { groupId, classNameId, actionId, type };
941    
942                    Object result = null;
943    
944                    if (retrieveFromCache) {
945                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_A_T,
946                                            finderArgs, this);
947                    }
948    
949                    if (result == null) {
950                            Session session = null;
951    
952                            try {
953                                    session = openSession();
954    
955                                    StringBundler query = new StringBundler(5);
956    
957                                    query.append(_SQL_SELECT_SOCIALEQUITYSETTING_WHERE);
958    
959                                    query.append(_FINDER_COLUMN_G_C_A_T_GROUPID_2);
960    
961                                    query.append(_FINDER_COLUMN_G_C_A_T_CLASSNAMEID_2);
962    
963                                    if (actionId == null) {
964                                            query.append(_FINDER_COLUMN_G_C_A_T_ACTIONID_1);
965                                    }
966                                    else {
967                                            if (actionId.equals(StringPool.BLANK)) {
968                                                    query.append(_FINDER_COLUMN_G_C_A_T_ACTIONID_3);
969                                            }
970                                            else {
971                                                    query.append(_FINDER_COLUMN_G_C_A_T_ACTIONID_2);
972                                            }
973                                    }
974    
975                                    query.append(_FINDER_COLUMN_G_C_A_T_TYPE_2);
976    
977                                    String sql = query.toString();
978    
979                                    Query q = session.createQuery(sql);
980    
981                                    QueryPos qPos = QueryPos.getInstance(q);
982    
983                                    qPos.add(groupId);
984    
985                                    qPos.add(classNameId);
986    
987                                    if (actionId != null) {
988                                            qPos.add(actionId);
989                                    }
990    
991                                    qPos.add(type);
992    
993                                    List<SocialEquitySetting> list = q.list();
994    
995                                    result = list;
996    
997                                    SocialEquitySetting socialEquitySetting = null;
998    
999                                    if (list.isEmpty()) {
1000                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_A_T,
1001                                                    finderArgs, list);
1002                                    }
1003                                    else {
1004                                            socialEquitySetting = list.get(0);
1005    
1006                                            cacheResult(socialEquitySetting);
1007    
1008                                            if ((socialEquitySetting.getGroupId() != groupId) ||
1009                                                            (socialEquitySetting.getClassNameId() != classNameId) ||
1010                                                            (socialEquitySetting.getActionId() == null) ||
1011                                                            !socialEquitySetting.getActionId().equals(actionId) ||
1012                                                            (socialEquitySetting.getType() != type)) {
1013                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_A_T,
1014                                                            finderArgs, socialEquitySetting);
1015                                            }
1016                                    }
1017    
1018                                    return socialEquitySetting;
1019                            }
1020                            catch (Exception e) {
1021                                    throw processException(e);
1022                            }
1023                            finally {
1024                                    if (result == null) {
1025                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_A_T,
1026                                                    finderArgs, new ArrayList<SocialEquitySetting>());
1027                                    }
1028    
1029                                    closeSession(session);
1030                            }
1031                    }
1032                    else {
1033                            if (result instanceof List<?>) {
1034                                    return null;
1035                            }
1036                            else {
1037                                    return (SocialEquitySetting)result;
1038                            }
1039                    }
1040            }
1041    
1042            /**
1043             * Finds all the social equity settings.
1044             *
1045             * @return the social equity settings
1046             * @throws SystemException if a system exception occurred
1047             */
1048            public List<SocialEquitySetting> findAll() throws SystemException {
1049                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1050            }
1051    
1052            /**
1053             * Finds a range of all the social equity settings.
1054             *
1055             * <p>
1056             * 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.
1057             * </p>
1058             *
1059             * @param start the lower bound of the range of social equity settings to return
1060             * @param end the upper bound of the range of social equity settings to return (not inclusive)
1061             * @return the range of social equity settings
1062             * @throws SystemException if a system exception occurred
1063             */
1064            public List<SocialEquitySetting> findAll(int start, int end)
1065                    throws SystemException {
1066                    return findAll(start, end, null);
1067            }
1068    
1069            /**
1070             * Finds an ordered range of all the social equity settings.
1071             *
1072             * <p>
1073             * 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.
1074             * </p>
1075             *
1076             * @param start the lower bound of the range of social equity settings to return
1077             * @param end the upper bound of the range of social equity settings to return (not inclusive)
1078             * @param orderByComparator the comparator to order the results by
1079             * @return the ordered range of social equity settings
1080             * @throws SystemException if a system exception occurred
1081             */
1082            public List<SocialEquitySetting> findAll(int start, int end,
1083                    OrderByComparator orderByComparator) throws SystemException {
1084                    Object[] finderArgs = new Object[] {
1085                                    String.valueOf(start), String.valueOf(end),
1086                                    String.valueOf(orderByComparator)
1087                            };
1088    
1089                    List<SocialEquitySetting> list = (List<SocialEquitySetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1090                                    finderArgs, this);
1091    
1092                    if (list == null) {
1093                            Session session = null;
1094    
1095                            try {
1096                                    session = openSession();
1097    
1098                                    StringBundler query = null;
1099                                    String sql = null;
1100    
1101                                    if (orderByComparator != null) {
1102                                            query = new StringBundler(2 +
1103                                                            (orderByComparator.getOrderByFields().length * 3));
1104    
1105                                            query.append(_SQL_SELECT_SOCIALEQUITYSETTING);
1106    
1107                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1108                                                    orderByComparator);
1109    
1110                                            sql = query.toString();
1111                                    }
1112                                    else {
1113                                            sql = _SQL_SELECT_SOCIALEQUITYSETTING;
1114                                    }
1115    
1116                                    Query q = session.createQuery(sql);
1117    
1118                                    if (orderByComparator == null) {
1119                                            list = (List<SocialEquitySetting>)QueryUtil.list(q,
1120                                                            getDialect(), start, end, false);
1121    
1122                                            Collections.sort(list);
1123                                    }
1124                                    else {
1125                                            list = (List<SocialEquitySetting>)QueryUtil.list(q,
1126                                                            getDialect(), start, end);
1127                                    }
1128                            }
1129                            catch (Exception e) {
1130                                    throw processException(e);
1131                            }
1132                            finally {
1133                                    if (list == null) {
1134                                            list = new ArrayList<SocialEquitySetting>();
1135                                    }
1136    
1137                                    cacheResult(list);
1138    
1139                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1140    
1141                                    closeSession(session);
1142                            }
1143                    }
1144    
1145                    return list;
1146            }
1147    
1148            /**
1149             * Removes all the social equity settings where groupId = &#63; and classNameId = &#63; and actionId = &#63; from the database.
1150             *
1151             * @param groupId the group id to search with
1152             * @param classNameId the class name id to search with
1153             * @param actionId the action id to search with
1154             * @throws SystemException if a system exception occurred
1155             */
1156            public void removeByG_C_A(long groupId, long classNameId, String actionId)
1157                    throws SystemException {
1158                    for (SocialEquitySetting socialEquitySetting : findByG_C_A(groupId,
1159                                    classNameId, actionId)) {
1160                            remove(socialEquitySetting);
1161                    }
1162            }
1163    
1164            /**
1165             * Removes the social equity setting where groupId = &#63; and classNameId = &#63; and actionId = &#63; and type = &#63; from the database.
1166             *
1167             * @param groupId the group id to search with
1168             * @param classNameId the class name id to search with
1169             * @param actionId the action id to search with
1170             * @param type the type to search with
1171             * @throws SystemException if a system exception occurred
1172             */
1173            public void removeByG_C_A_T(long groupId, long classNameId,
1174                    String actionId, int type)
1175                    throws NoSuchEquitySettingException, SystemException {
1176                    SocialEquitySetting socialEquitySetting = findByG_C_A_T(groupId,
1177                                    classNameId, actionId, type);
1178    
1179                    remove(socialEquitySetting);
1180            }
1181    
1182            /**
1183             * Removes all the social equity settings from the database.
1184             *
1185             * @throws SystemException if a system exception occurred
1186             */
1187            public void removeAll() throws SystemException {
1188                    for (SocialEquitySetting socialEquitySetting : findAll()) {
1189                            remove(socialEquitySetting);
1190                    }
1191            }
1192    
1193            /**
1194             * Counts all the social equity settings where groupId = &#63; and classNameId = &#63; and actionId = &#63;.
1195             *
1196             * @param groupId the group id to search with
1197             * @param classNameId the class name id to search with
1198             * @param actionId the action id to search with
1199             * @return the number of matching social equity settings
1200             * @throws SystemException if a system exception occurred
1201             */
1202            public int countByG_C_A(long groupId, long classNameId, String actionId)
1203                    throws SystemException {
1204                    Object[] finderArgs = new Object[] { groupId, classNameId, actionId };
1205    
1206                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_A,
1207                                    finderArgs, this);
1208    
1209                    if (count == null) {
1210                            Session session = null;
1211    
1212                            try {
1213                                    session = openSession();
1214    
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                                    Query q = session.createQuery(sql);
1238    
1239                                    QueryPos qPos = QueryPos.getInstance(q);
1240    
1241                                    qPos.add(groupId);
1242    
1243                                    qPos.add(classNameId);
1244    
1245                                    if (actionId != null) {
1246                                            qPos.add(actionId);
1247                                    }
1248    
1249                                    count = (Long)q.uniqueResult();
1250                            }
1251                            catch (Exception e) {
1252                                    throw processException(e);
1253                            }
1254                            finally {
1255                                    if (count == null) {
1256                                            count = Long.valueOf(0);
1257                                    }
1258    
1259                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_A,
1260                                            finderArgs, count);
1261    
1262                                    closeSession(session);
1263                            }
1264                    }
1265    
1266                    return count.intValue();
1267            }
1268    
1269            /**
1270             * Counts all the social equity settings where groupId = &#63; and classNameId = &#63; and actionId = &#63; and type = &#63;.
1271             *
1272             * @param groupId the group id to search with
1273             * @param classNameId the class name id to search with
1274             * @param actionId the action id to search with
1275             * @param type the type to search with
1276             * @return the number of matching social equity settings
1277             * @throws SystemException if a system exception occurred
1278             */
1279            public int countByG_C_A_T(long groupId, long classNameId, String actionId,
1280                    int type) throws SystemException {
1281                    Object[] finderArgs = new Object[] { groupId, classNameId, actionId, type };
1282    
1283                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_A_T,
1284                                    finderArgs, this);
1285    
1286                    if (count == null) {
1287                            Session session = null;
1288    
1289                            try {
1290                                    session = openSession();
1291    
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                                    Query q = session.createQuery(sql);
1317    
1318                                    QueryPos qPos = QueryPos.getInstance(q);
1319    
1320                                    qPos.add(groupId);
1321    
1322                                    qPos.add(classNameId);
1323    
1324                                    if (actionId != null) {
1325                                            qPos.add(actionId);
1326                                    }
1327    
1328                                    qPos.add(type);
1329    
1330                                    count = (Long)q.uniqueResult();
1331                            }
1332                            catch (Exception e) {
1333                                    throw processException(e);
1334                            }
1335                            finally {
1336                                    if (count == null) {
1337                                            count = Long.valueOf(0);
1338                                    }
1339    
1340                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_A_T,
1341                                            finderArgs, count);
1342    
1343                                    closeSession(session);
1344                            }
1345                    }
1346    
1347                    return count.intValue();
1348            }
1349    
1350            /**
1351             * Counts all the social equity settings.
1352             *
1353             * @return the number of social equity settings
1354             * @throws SystemException if a system exception occurred
1355             */
1356            public int countAll() throws SystemException {
1357                    Object[] finderArgs = new Object[0];
1358    
1359                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1360                                    finderArgs, this);
1361    
1362                    if (count == null) {
1363                            Session session = null;
1364    
1365                            try {
1366                                    session = openSession();
1367    
1368                                    Query q = session.createQuery(_SQL_COUNT_SOCIALEQUITYSETTING);
1369    
1370                                    count = (Long)q.uniqueResult();
1371                            }
1372                            catch (Exception e) {
1373                                    throw processException(e);
1374                            }
1375                            finally {
1376                                    if (count == null) {
1377                                            count = Long.valueOf(0);
1378                                    }
1379    
1380                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1381                                            count);
1382    
1383                                    closeSession(session);
1384                            }
1385                    }
1386    
1387                    return count.intValue();
1388            }
1389    
1390            /**
1391             * Initializes the social equity setting persistence.
1392             */
1393            public void afterPropertiesSet() {
1394                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1395                                            com.liferay.portal.util.PropsUtil.get(
1396                                                    "value.object.listener.com.liferay.portlet.social.model.SocialEquitySetting")));
1397    
1398                    if (listenerClassNames.length > 0) {
1399                            try {
1400                                    List<ModelListener<SocialEquitySetting>> listenersList = new ArrayList<ModelListener<SocialEquitySetting>>();
1401    
1402                                    for (String listenerClassName : listenerClassNames) {
1403                                            listenersList.add((ModelListener<SocialEquitySetting>)InstanceFactory.newInstance(
1404                                                            listenerClassName));
1405                                    }
1406    
1407                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1408                            }
1409                            catch (Exception e) {
1410                                    _log.error(e);
1411                            }
1412                    }
1413            }
1414    
1415            public void destroy() {
1416                    EntityCacheUtil.removeCache(SocialEquitySettingImpl.class.getName());
1417                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1418                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1419            }
1420    
1421            @BeanReference(type = SocialActivityPersistence.class)
1422            protected SocialActivityPersistence socialActivityPersistence;
1423            @BeanReference(type = SocialEquityAssetEntryPersistence.class)
1424            protected SocialEquityAssetEntryPersistence socialEquityAssetEntryPersistence;
1425            @BeanReference(type = SocialEquityGroupSettingPersistence.class)
1426            protected SocialEquityGroupSettingPersistence socialEquityGroupSettingPersistence;
1427            @BeanReference(type = SocialEquityHistoryPersistence.class)
1428            protected SocialEquityHistoryPersistence socialEquityHistoryPersistence;
1429            @BeanReference(type = SocialEquityLogPersistence.class)
1430            protected SocialEquityLogPersistence socialEquityLogPersistence;
1431            @BeanReference(type = SocialEquitySettingPersistence.class)
1432            protected SocialEquitySettingPersistence socialEquitySettingPersistence;
1433            @BeanReference(type = SocialEquityUserPersistence.class)
1434            protected SocialEquityUserPersistence socialEquityUserPersistence;
1435            @BeanReference(type = SocialRelationPersistence.class)
1436            protected SocialRelationPersistence socialRelationPersistence;
1437            @BeanReference(type = SocialRequestPersistence.class)
1438            protected SocialRequestPersistence socialRequestPersistence;
1439            @BeanReference(type = GroupPersistence.class)
1440            protected GroupPersistence groupPersistence;
1441            @BeanReference(type = ResourcePersistence.class)
1442            protected ResourcePersistence resourcePersistence;
1443            @BeanReference(type = UserPersistence.class)
1444            protected UserPersistence userPersistence;
1445            private static final String _SQL_SELECT_SOCIALEQUITYSETTING = "SELECT socialEquitySetting FROM SocialEquitySetting socialEquitySetting";
1446            private static final String _SQL_SELECT_SOCIALEQUITYSETTING_WHERE = "SELECT socialEquitySetting FROM SocialEquitySetting socialEquitySetting WHERE ";
1447            private static final String _SQL_COUNT_SOCIALEQUITYSETTING = "SELECT COUNT(socialEquitySetting) FROM SocialEquitySetting socialEquitySetting";
1448            private static final String _SQL_COUNT_SOCIALEQUITYSETTING_WHERE = "SELECT COUNT(socialEquitySetting) FROM SocialEquitySetting socialEquitySetting WHERE ";
1449            private static final String _FINDER_COLUMN_G_C_A_GROUPID_2 = "socialEquitySetting.groupId = ? AND ";
1450            private static final String _FINDER_COLUMN_G_C_A_CLASSNAMEID_2 = "socialEquitySetting.classNameId = ? AND ";
1451            private static final String _FINDER_COLUMN_G_C_A_ACTIONID_1 = "socialEquitySetting.actionId IS NULL";
1452            private static final String _FINDER_COLUMN_G_C_A_ACTIONID_2 = "socialEquitySetting.actionId = ?";
1453            private static final String _FINDER_COLUMN_G_C_A_ACTIONID_3 = "(socialEquitySetting.actionId IS NULL OR socialEquitySetting.actionId = ?)";
1454            private static final String _FINDER_COLUMN_G_C_A_T_GROUPID_2 = "socialEquitySetting.groupId = ? AND ";
1455            private static final String _FINDER_COLUMN_G_C_A_T_CLASSNAMEID_2 = "socialEquitySetting.classNameId = ? AND ";
1456            private static final String _FINDER_COLUMN_G_C_A_T_ACTIONID_1 = "socialEquitySetting.actionId IS NULL AND ";
1457            private static final String _FINDER_COLUMN_G_C_A_T_ACTIONID_2 = "socialEquitySetting.actionId = ? AND ";
1458            private static final String _FINDER_COLUMN_G_C_A_T_ACTIONID_3 = "(socialEquitySetting.actionId IS NULL OR socialEquitySetting.actionId = ?) AND ";
1459            private static final String _FINDER_COLUMN_G_C_A_T_TYPE_2 = "socialEquitySetting.type = ?";
1460            private static final String _ORDER_BY_ENTITY_ALIAS = "socialEquitySetting.";
1461            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialEquitySetting exists with the primary key ";
1462            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialEquitySetting exists with the key {";
1463            private static Log _log = LogFactoryUtil.getLog(SocialEquitySettingPersistenceImpl.class);
1464    }