001    /**
002     * Copyright (c) 2000-present 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.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.EntityCache;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCache;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.OrderByComparator;
031    import com.liferay.portal.kernel.util.SetUtil;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.Validator;
035    import com.liferay.portal.model.CacheModel;
036    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
037    
038    import com.liferay.portlet.social.NoSuchActivityCounterException;
039    import com.liferay.portlet.social.model.SocialActivityCounter;
040    import com.liferay.portlet.social.model.impl.SocialActivityCounterImpl;
041    import com.liferay.portlet.social.model.impl.SocialActivityCounterModelImpl;
042    import com.liferay.portlet.social.service.persistence.SocialActivityCounterPersistence;
043    
044    import java.io.Serializable;
045    
046    import java.util.Collections;
047    import java.util.HashMap;
048    import java.util.HashSet;
049    import java.util.Iterator;
050    import java.util.List;
051    import java.util.Map;
052    import java.util.Set;
053    
054    /**
055     * The persistence implementation for the social activity counter service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see SocialActivityCounterPersistence
063     * @see com.liferay.portlet.social.service.persistence.SocialActivityCounterUtil
064     * @generated
065     */
066    @ProviderType
067    public class SocialActivityCounterPersistenceImpl extends BasePersistenceImpl<SocialActivityCounter>
068            implements SocialActivityCounterPersistence {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link SocialActivityCounterUtil} to access the social activity counter persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
073             */
074            public static final String FINDER_CLASS_NAME_ENTITY = SocialActivityCounterImpl.class.getName();
075            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List1";
077            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List2";
079            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
080                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
081                            SocialActivityCounterImpl.class,
082                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
083            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
084                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
085                            SocialActivityCounterImpl.class,
086                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
088                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED, Long.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
091                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
092                            SocialActivityCounterImpl.class,
093                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
094                            new String[] {
095                                    Long.class.getName(),
096                                    
097                            Integer.class.getName(), Integer.class.getName(),
098                                    OrderByComparator.class.getName()
099                            });
100            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
101                    new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
102                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
103                            SocialActivityCounterImpl.class,
104                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
105                            new String[] { Long.class.getName() },
106                            SocialActivityCounterModelImpl.GROUPID_COLUMN_BITMASK);
107            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
108                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED, Long.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
110                            new String[] { Long.class.getName() });
111    
112            /**
113             * Returns all the social activity counters where groupId = &#63;.
114             *
115             * @param groupId the group ID
116             * @return the matching social activity counters
117             */
118            @Override
119            public List<SocialActivityCounter> findByGroupId(long groupId) {
120                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121            }
122    
123            /**
124             * Returns a range of all the social activity counters where groupId = &#63;.
125             *
126             * <p>
127             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
128             * </p>
129             *
130             * @param groupId the group ID
131             * @param start the lower bound of the range of social activity counters
132             * @param end the upper bound of the range of social activity counters (not inclusive)
133             * @return the range of matching social activity counters
134             */
135            @Override
136            public List<SocialActivityCounter> findByGroupId(long groupId, int start,
137                    int end) {
138                    return findByGroupId(groupId, start, end, null);
139            }
140    
141            /**
142             * Returns an ordered range of all the social activity counters where groupId = &#63;.
143             *
144             * <p>
145             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
146             * </p>
147             *
148             * @param groupId the group ID
149             * @param start the lower bound of the range of social activity counters
150             * @param end the upper bound of the range of social activity counters (not inclusive)
151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
152             * @return the ordered range of matching social activity counters
153             */
154            @Override
155            public List<SocialActivityCounter> findByGroupId(long groupId, int start,
156                    int end, OrderByComparator<SocialActivityCounter> orderByComparator) {
157                    return findByGroupId(groupId, start, end, orderByComparator, true);
158            }
159    
160            /**
161             * Returns an ordered range of all the social activity counters where groupId = &#63;.
162             *
163             * <p>
164             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
165             * </p>
166             *
167             * @param groupId the group ID
168             * @param start the lower bound of the range of social activity counters
169             * @param end the upper bound of the range of social activity counters (not inclusive)
170             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
171             * @param retrieveFromCache whether to retrieve from the finder cache
172             * @return the ordered range of matching social activity counters
173             */
174            @Override
175            public List<SocialActivityCounter> findByGroupId(long groupId, int start,
176                    int end, OrderByComparator<SocialActivityCounter> orderByComparator,
177                    boolean retrieveFromCache) {
178                    boolean pagination = true;
179                    FinderPath finderPath = null;
180                    Object[] finderArgs = null;
181    
182                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
183                                    (orderByComparator == null)) {
184                            pagination = false;
185                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
186                            finderArgs = new Object[] { groupId };
187                    }
188                    else {
189                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
190                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
191                    }
192    
193                    List<SocialActivityCounter> list = null;
194    
195                    if (retrieveFromCache) {
196                            list = (List<SocialActivityCounter>)finderCache.getResult(finderPath,
197                                            finderArgs, this);
198    
199                            if ((list != null) && !list.isEmpty()) {
200                                    for (SocialActivityCounter socialActivityCounter : list) {
201                                            if ((groupId != socialActivityCounter.getGroupId())) {
202                                                    list = null;
203    
204                                                    break;
205                                            }
206                                    }
207                            }
208                    }
209    
210                    if (list == null) {
211                            StringBundler query = null;
212    
213                            if (orderByComparator != null) {
214                                    query = new StringBundler(3 +
215                                                    (orderByComparator.getOrderByFields().length * 3));
216                            }
217                            else {
218                                    query = new StringBundler(3);
219                            }
220    
221                            query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE);
222    
223                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
224    
225                            if (orderByComparator != null) {
226                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
227                                            orderByComparator);
228                            }
229                            else
230                             if (pagination) {
231                                    query.append(SocialActivityCounterModelImpl.ORDER_BY_JPQL);
232                            }
233    
234                            String sql = query.toString();
235    
236                            Session session = null;
237    
238                            try {
239                                    session = openSession();
240    
241                                    Query q = session.createQuery(sql);
242    
243                                    QueryPos qPos = QueryPos.getInstance(q);
244    
245                                    qPos.add(groupId);
246    
247                                    if (!pagination) {
248                                            list = (List<SocialActivityCounter>)QueryUtil.list(q,
249                                                            getDialect(), start, end, false);
250    
251                                            Collections.sort(list);
252    
253                                            list = Collections.unmodifiableList(list);
254                                    }
255                                    else {
256                                            list = (List<SocialActivityCounter>)QueryUtil.list(q,
257                                                            getDialect(), start, end);
258                                    }
259    
260                                    cacheResult(list);
261    
262                                    finderCache.putResult(finderPath, finderArgs, list);
263                            }
264                            catch (Exception e) {
265                                    finderCache.removeResult(finderPath, finderArgs);
266    
267                                    throw processException(e);
268                            }
269                            finally {
270                                    closeSession(session);
271                            }
272                    }
273    
274                    return list;
275            }
276    
277            /**
278             * Returns the first social activity counter in the ordered set where groupId = &#63;.
279             *
280             * @param groupId the group ID
281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
282             * @return the first matching social activity counter
283             * @throws NoSuchActivityCounterException if a matching social activity counter could not be found
284             */
285            @Override
286            public SocialActivityCounter findByGroupId_First(long groupId,
287                    OrderByComparator<SocialActivityCounter> orderByComparator)
288                    throws NoSuchActivityCounterException {
289                    SocialActivityCounter socialActivityCounter = fetchByGroupId_First(groupId,
290                                    orderByComparator);
291    
292                    if (socialActivityCounter != null) {
293                            return socialActivityCounter;
294                    }
295    
296                    StringBundler msg = new StringBundler(4);
297    
298                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
299    
300                    msg.append("groupId=");
301                    msg.append(groupId);
302    
303                    msg.append(StringPool.CLOSE_CURLY_BRACE);
304    
305                    throw new NoSuchActivityCounterException(msg.toString());
306            }
307    
308            /**
309             * Returns the first social activity counter in the ordered set where groupId = &#63;.
310             *
311             * @param groupId the group ID
312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
313             * @return the first matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
314             */
315            @Override
316            public SocialActivityCounter fetchByGroupId_First(long groupId,
317                    OrderByComparator<SocialActivityCounter> orderByComparator) {
318                    List<SocialActivityCounter> list = findByGroupId(groupId, 0, 1,
319                                    orderByComparator);
320    
321                    if (!list.isEmpty()) {
322                            return list.get(0);
323                    }
324    
325                    return null;
326            }
327    
328            /**
329             * Returns the last social activity counter in the ordered set where groupId = &#63;.
330             *
331             * @param groupId the group ID
332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
333             * @return the last matching social activity counter
334             * @throws NoSuchActivityCounterException if a matching social activity counter could not be found
335             */
336            @Override
337            public SocialActivityCounter findByGroupId_Last(long groupId,
338                    OrderByComparator<SocialActivityCounter> orderByComparator)
339                    throws NoSuchActivityCounterException {
340                    SocialActivityCounter socialActivityCounter = fetchByGroupId_Last(groupId,
341                                    orderByComparator);
342    
343                    if (socialActivityCounter != null) {
344                            return socialActivityCounter;
345                    }
346    
347                    StringBundler msg = new StringBundler(4);
348    
349                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
350    
351                    msg.append("groupId=");
352                    msg.append(groupId);
353    
354                    msg.append(StringPool.CLOSE_CURLY_BRACE);
355    
356                    throw new NoSuchActivityCounterException(msg.toString());
357            }
358    
359            /**
360             * Returns the last social activity counter in the ordered set where groupId = &#63;.
361             *
362             * @param groupId the group ID
363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
364             * @return the last matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
365             */
366            @Override
367            public SocialActivityCounter fetchByGroupId_Last(long groupId,
368                    OrderByComparator<SocialActivityCounter> orderByComparator) {
369                    int count = countByGroupId(groupId);
370    
371                    if (count == 0) {
372                            return null;
373                    }
374    
375                    List<SocialActivityCounter> list = findByGroupId(groupId, count - 1,
376                                    count, orderByComparator);
377    
378                    if (!list.isEmpty()) {
379                            return list.get(0);
380                    }
381    
382                    return null;
383            }
384    
385            /**
386             * Returns the social activity counters before and after the current social activity counter in the ordered set where groupId = &#63;.
387             *
388             * @param activityCounterId the primary key of the current social activity counter
389             * @param groupId the group ID
390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
391             * @return the previous, current, and next social activity counter
392             * @throws NoSuchActivityCounterException if a social activity counter with the primary key could not be found
393             */
394            @Override
395            public SocialActivityCounter[] findByGroupId_PrevAndNext(
396                    long activityCounterId, long groupId,
397                    OrderByComparator<SocialActivityCounter> orderByComparator)
398                    throws NoSuchActivityCounterException {
399                    SocialActivityCounter socialActivityCounter = findByPrimaryKey(activityCounterId);
400    
401                    Session session = null;
402    
403                    try {
404                            session = openSession();
405    
406                            SocialActivityCounter[] array = new SocialActivityCounterImpl[3];
407    
408                            array[0] = getByGroupId_PrevAndNext(session, socialActivityCounter,
409                                            groupId, orderByComparator, true);
410    
411                            array[1] = socialActivityCounter;
412    
413                            array[2] = getByGroupId_PrevAndNext(session, socialActivityCounter,
414                                            groupId, orderByComparator, false);
415    
416                            return array;
417                    }
418                    catch (Exception e) {
419                            throw processException(e);
420                    }
421                    finally {
422                            closeSession(session);
423                    }
424            }
425    
426            protected SocialActivityCounter getByGroupId_PrevAndNext(Session session,
427                    SocialActivityCounter socialActivityCounter, long groupId,
428                    OrderByComparator<SocialActivityCounter> orderByComparator,
429                    boolean previous) {
430                    StringBundler query = null;
431    
432                    if (orderByComparator != null) {
433                            query = new StringBundler(6 +
434                                            (orderByComparator.getOrderByFields().length * 6));
435                    }
436                    else {
437                            query = new StringBundler(3);
438                    }
439    
440                    query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE);
441    
442                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
443    
444                    if (orderByComparator != null) {
445                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
446    
447                            if (orderByConditionFields.length > 0) {
448                                    query.append(WHERE_AND);
449                            }
450    
451                            for (int i = 0; i < orderByConditionFields.length; i++) {
452                                    query.append(_ORDER_BY_ENTITY_ALIAS);
453                                    query.append(orderByConditionFields[i]);
454    
455                                    if ((i + 1) < orderByConditionFields.length) {
456                                            if (orderByComparator.isAscending() ^ previous) {
457                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
458                                            }
459                                            else {
460                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
461                                            }
462                                    }
463                                    else {
464                                            if (orderByComparator.isAscending() ^ previous) {
465                                                    query.append(WHERE_GREATER_THAN);
466                                            }
467                                            else {
468                                                    query.append(WHERE_LESSER_THAN);
469                                            }
470                                    }
471                            }
472    
473                            query.append(ORDER_BY_CLAUSE);
474    
475                            String[] orderByFields = orderByComparator.getOrderByFields();
476    
477                            for (int i = 0; i < orderByFields.length; i++) {
478                                    query.append(_ORDER_BY_ENTITY_ALIAS);
479                                    query.append(orderByFields[i]);
480    
481                                    if ((i + 1) < orderByFields.length) {
482                                            if (orderByComparator.isAscending() ^ previous) {
483                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
484                                            }
485                                            else {
486                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
487                                            }
488                                    }
489                                    else {
490                                            if (orderByComparator.isAscending() ^ previous) {
491                                                    query.append(ORDER_BY_ASC);
492                                            }
493                                            else {
494                                                    query.append(ORDER_BY_DESC);
495                                            }
496                                    }
497                            }
498                    }
499                    else {
500                            query.append(SocialActivityCounterModelImpl.ORDER_BY_JPQL);
501                    }
502    
503                    String sql = query.toString();
504    
505                    Query q = session.createQuery(sql);
506    
507                    q.setFirstResult(0);
508                    q.setMaxResults(2);
509    
510                    QueryPos qPos = QueryPos.getInstance(q);
511    
512                    qPos.add(groupId);
513    
514                    if (orderByComparator != null) {
515                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivityCounter);
516    
517                            for (Object value : values) {
518                                    qPos.add(value);
519                            }
520                    }
521    
522                    List<SocialActivityCounter> list = q.list();
523    
524                    if (list.size() == 2) {
525                            return list.get(1);
526                    }
527                    else {
528                            return null;
529                    }
530            }
531    
532            /**
533             * Removes all the social activity counters where groupId = &#63; from the database.
534             *
535             * @param groupId the group ID
536             */
537            @Override
538            public void removeByGroupId(long groupId) {
539                    for (SocialActivityCounter socialActivityCounter : findByGroupId(
540                                    groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
541                            remove(socialActivityCounter);
542                    }
543            }
544    
545            /**
546             * Returns the number of social activity counters where groupId = &#63;.
547             *
548             * @param groupId the group ID
549             * @return the number of matching social activity counters
550             */
551            @Override
552            public int countByGroupId(long groupId) {
553                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
554    
555                    Object[] finderArgs = new Object[] { groupId };
556    
557                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
558    
559                    if (count == null) {
560                            StringBundler query = new StringBundler(2);
561    
562                            query.append(_SQL_COUNT_SOCIALACTIVITYCOUNTER_WHERE);
563    
564                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
565    
566                            String sql = query.toString();
567    
568                            Session session = null;
569    
570                            try {
571                                    session = openSession();
572    
573                                    Query q = session.createQuery(sql);
574    
575                                    QueryPos qPos = QueryPos.getInstance(q);
576    
577                                    qPos.add(groupId);
578    
579                                    count = (Long)q.uniqueResult();
580    
581                                    finderCache.putResult(finderPath, finderArgs, count);
582                            }
583                            catch (Exception e) {
584                                    finderCache.removeResult(finderPath, finderArgs);
585    
586                                    throw processException(e);
587                            }
588                            finally {
589                                    closeSession(session);
590                            }
591                    }
592    
593                    return count.intValue();
594            }
595    
596            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "socialActivityCounter.groupId = ?";
597            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
598                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
599                            SocialActivityCounterImpl.class,
600                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
601                            new String[] {
602                                    Long.class.getName(), Long.class.getName(),
603                                    
604                            Integer.class.getName(), Integer.class.getName(),
605                                    OrderByComparator.class.getName()
606                            });
607            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
608                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
609                            SocialActivityCounterImpl.class,
610                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
611                            new String[] { Long.class.getName(), Long.class.getName() },
612                            SocialActivityCounterModelImpl.CLASSNAMEID_COLUMN_BITMASK |
613                            SocialActivityCounterModelImpl.CLASSPK_COLUMN_BITMASK);
614            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
615                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED, Long.class,
616                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
617                            new String[] { Long.class.getName(), Long.class.getName() });
618    
619            /**
620             * Returns all the social activity counters where classNameId = &#63; and classPK = &#63;.
621             *
622             * @param classNameId the class name ID
623             * @param classPK the class p k
624             * @return the matching social activity counters
625             */
626            @Override
627            public List<SocialActivityCounter> findByC_C(long classNameId, long classPK) {
628                    return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
629                            QueryUtil.ALL_POS, null);
630            }
631    
632            /**
633             * Returns a range of all the social activity counters where classNameId = &#63; and classPK = &#63;.
634             *
635             * <p>
636             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
637             * </p>
638             *
639             * @param classNameId the class name ID
640             * @param classPK the class p k
641             * @param start the lower bound of the range of social activity counters
642             * @param end the upper bound of the range of social activity counters (not inclusive)
643             * @return the range of matching social activity counters
644             */
645            @Override
646            public List<SocialActivityCounter> findByC_C(long classNameId,
647                    long classPK, int start, int end) {
648                    return findByC_C(classNameId, classPK, start, end, null);
649            }
650    
651            /**
652             * Returns an ordered range of all the social activity counters where classNameId = &#63; and classPK = &#63;.
653             *
654             * <p>
655             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
656             * </p>
657             *
658             * @param classNameId the class name ID
659             * @param classPK the class p k
660             * @param start the lower bound of the range of social activity counters
661             * @param end the upper bound of the range of social activity counters (not inclusive)
662             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
663             * @return the ordered range of matching social activity counters
664             */
665            @Override
666            public List<SocialActivityCounter> findByC_C(long classNameId,
667                    long classPK, int start, int end,
668                    OrderByComparator<SocialActivityCounter> orderByComparator) {
669                    return findByC_C(classNameId, classPK, start, end, orderByComparator,
670                            true);
671            }
672    
673            /**
674             * Returns an ordered range of all the social activity counters where classNameId = &#63; and classPK = &#63;.
675             *
676             * <p>
677             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
678             * </p>
679             *
680             * @param classNameId the class name ID
681             * @param classPK the class p k
682             * @param start the lower bound of the range of social activity counters
683             * @param end the upper bound of the range of social activity counters (not inclusive)
684             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
685             * @param retrieveFromCache whether to retrieve from the finder cache
686             * @return the ordered range of matching social activity counters
687             */
688            @Override
689            public List<SocialActivityCounter> findByC_C(long classNameId,
690                    long classPK, int start, int end,
691                    OrderByComparator<SocialActivityCounter> orderByComparator,
692                    boolean retrieveFromCache) {
693                    boolean pagination = true;
694                    FinderPath finderPath = null;
695                    Object[] finderArgs = null;
696    
697                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
698                                    (orderByComparator == null)) {
699                            pagination = false;
700                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
701                            finderArgs = new Object[] { classNameId, classPK };
702                    }
703                    else {
704                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
705                            finderArgs = new Object[] {
706                                            classNameId, classPK,
707                                            
708                                            start, end, orderByComparator
709                                    };
710                    }
711    
712                    List<SocialActivityCounter> list = null;
713    
714                    if (retrieveFromCache) {
715                            list = (List<SocialActivityCounter>)finderCache.getResult(finderPath,
716                                            finderArgs, this);
717    
718                            if ((list != null) && !list.isEmpty()) {
719                                    for (SocialActivityCounter socialActivityCounter : list) {
720                                            if ((classNameId != socialActivityCounter.getClassNameId()) ||
721                                                            (classPK != socialActivityCounter.getClassPK())) {
722                                                    list = null;
723    
724                                                    break;
725                                            }
726                                    }
727                            }
728                    }
729    
730                    if (list == null) {
731                            StringBundler query = null;
732    
733                            if (orderByComparator != null) {
734                                    query = new StringBundler(4 +
735                                                    (orderByComparator.getOrderByFields().length * 3));
736                            }
737                            else {
738                                    query = new StringBundler(4);
739                            }
740    
741                            query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE);
742    
743                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
744    
745                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
746    
747                            if (orderByComparator != null) {
748                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
749                                            orderByComparator);
750                            }
751                            else
752                             if (pagination) {
753                                    query.append(SocialActivityCounterModelImpl.ORDER_BY_JPQL);
754                            }
755    
756                            String sql = query.toString();
757    
758                            Session session = null;
759    
760                            try {
761                                    session = openSession();
762    
763                                    Query q = session.createQuery(sql);
764    
765                                    QueryPos qPos = QueryPos.getInstance(q);
766    
767                                    qPos.add(classNameId);
768    
769                                    qPos.add(classPK);
770    
771                                    if (!pagination) {
772                                            list = (List<SocialActivityCounter>)QueryUtil.list(q,
773                                                            getDialect(), start, end, false);
774    
775                                            Collections.sort(list);
776    
777                                            list = Collections.unmodifiableList(list);
778                                    }
779                                    else {
780                                            list = (List<SocialActivityCounter>)QueryUtil.list(q,
781                                                            getDialect(), start, end);
782                                    }
783    
784                                    cacheResult(list);
785    
786                                    finderCache.putResult(finderPath, finderArgs, list);
787                            }
788                            catch (Exception e) {
789                                    finderCache.removeResult(finderPath, finderArgs);
790    
791                                    throw processException(e);
792                            }
793                            finally {
794                                    closeSession(session);
795                            }
796                    }
797    
798                    return list;
799            }
800    
801            /**
802             * Returns the first social activity counter in the ordered set where classNameId = &#63; and classPK = &#63;.
803             *
804             * @param classNameId the class name ID
805             * @param classPK the class p k
806             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
807             * @return the first matching social activity counter
808             * @throws NoSuchActivityCounterException if a matching social activity counter could not be found
809             */
810            @Override
811            public SocialActivityCounter findByC_C_First(long classNameId,
812                    long classPK, OrderByComparator<SocialActivityCounter> orderByComparator)
813                    throws NoSuchActivityCounterException {
814                    SocialActivityCounter socialActivityCounter = fetchByC_C_First(classNameId,
815                                    classPK, orderByComparator);
816    
817                    if (socialActivityCounter != null) {
818                            return socialActivityCounter;
819                    }
820    
821                    StringBundler msg = new StringBundler(6);
822    
823                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
824    
825                    msg.append("classNameId=");
826                    msg.append(classNameId);
827    
828                    msg.append(", classPK=");
829                    msg.append(classPK);
830    
831                    msg.append(StringPool.CLOSE_CURLY_BRACE);
832    
833                    throw new NoSuchActivityCounterException(msg.toString());
834            }
835    
836            /**
837             * Returns the first social activity counter in the ordered set where classNameId = &#63; and classPK = &#63;.
838             *
839             * @param classNameId the class name ID
840             * @param classPK the class p k
841             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
842             * @return the first matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
843             */
844            @Override
845            public SocialActivityCounter fetchByC_C_First(long classNameId,
846                    long classPK, OrderByComparator<SocialActivityCounter> orderByComparator) {
847                    List<SocialActivityCounter> list = findByC_C(classNameId, classPK, 0,
848                                    1, orderByComparator);
849    
850                    if (!list.isEmpty()) {
851                            return list.get(0);
852                    }
853    
854                    return null;
855            }
856    
857            /**
858             * Returns the last social activity counter in the ordered set where classNameId = &#63; and classPK = &#63;.
859             *
860             * @param classNameId the class name ID
861             * @param classPK the class p k
862             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
863             * @return the last matching social activity counter
864             * @throws NoSuchActivityCounterException if a matching social activity counter could not be found
865             */
866            @Override
867            public SocialActivityCounter findByC_C_Last(long classNameId, long classPK,
868                    OrderByComparator<SocialActivityCounter> orderByComparator)
869                    throws NoSuchActivityCounterException {
870                    SocialActivityCounter socialActivityCounter = fetchByC_C_Last(classNameId,
871                                    classPK, orderByComparator);
872    
873                    if (socialActivityCounter != null) {
874                            return socialActivityCounter;
875                    }
876    
877                    StringBundler msg = new StringBundler(6);
878    
879                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
880    
881                    msg.append("classNameId=");
882                    msg.append(classNameId);
883    
884                    msg.append(", classPK=");
885                    msg.append(classPK);
886    
887                    msg.append(StringPool.CLOSE_CURLY_BRACE);
888    
889                    throw new NoSuchActivityCounterException(msg.toString());
890            }
891    
892            /**
893             * Returns the last social activity counter in the ordered set where classNameId = &#63; and classPK = &#63;.
894             *
895             * @param classNameId the class name ID
896             * @param classPK the class p k
897             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
898             * @return the last matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
899             */
900            @Override
901            public SocialActivityCounter fetchByC_C_Last(long classNameId,
902                    long classPK, OrderByComparator<SocialActivityCounter> orderByComparator) {
903                    int count = countByC_C(classNameId, classPK);
904    
905                    if (count == 0) {
906                            return null;
907                    }
908    
909                    List<SocialActivityCounter> list = findByC_C(classNameId, classPK,
910                                    count - 1, count, orderByComparator);
911    
912                    if (!list.isEmpty()) {
913                            return list.get(0);
914                    }
915    
916                    return null;
917            }
918    
919            /**
920             * Returns the social activity counters before and after the current social activity counter in the ordered set where classNameId = &#63; and classPK = &#63;.
921             *
922             * @param activityCounterId the primary key of the current social activity counter
923             * @param classNameId the class name ID
924             * @param classPK the class p k
925             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
926             * @return the previous, current, and next social activity counter
927             * @throws NoSuchActivityCounterException if a social activity counter with the primary key could not be found
928             */
929            @Override
930            public SocialActivityCounter[] findByC_C_PrevAndNext(
931                    long activityCounterId, long classNameId, long classPK,
932                    OrderByComparator<SocialActivityCounter> orderByComparator)
933                    throws NoSuchActivityCounterException {
934                    SocialActivityCounter socialActivityCounter = findByPrimaryKey(activityCounterId);
935    
936                    Session session = null;
937    
938                    try {
939                            session = openSession();
940    
941                            SocialActivityCounter[] array = new SocialActivityCounterImpl[3];
942    
943                            array[0] = getByC_C_PrevAndNext(session, socialActivityCounter,
944                                            classNameId, classPK, orderByComparator, true);
945    
946                            array[1] = socialActivityCounter;
947    
948                            array[2] = getByC_C_PrevAndNext(session, socialActivityCounter,
949                                            classNameId, classPK, orderByComparator, false);
950    
951                            return array;
952                    }
953                    catch (Exception e) {
954                            throw processException(e);
955                    }
956                    finally {
957                            closeSession(session);
958                    }
959            }
960    
961            protected SocialActivityCounter getByC_C_PrevAndNext(Session session,
962                    SocialActivityCounter socialActivityCounter, long classNameId,
963                    long classPK,
964                    OrderByComparator<SocialActivityCounter> orderByComparator,
965                    boolean previous) {
966                    StringBundler query = null;
967    
968                    if (orderByComparator != null) {
969                            query = new StringBundler(6 +
970                                            (orderByComparator.getOrderByFields().length * 6));
971                    }
972                    else {
973                            query = new StringBundler(3);
974                    }
975    
976                    query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE);
977    
978                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
979    
980                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
981    
982                    if (orderByComparator != null) {
983                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
984    
985                            if (orderByConditionFields.length > 0) {
986                                    query.append(WHERE_AND);
987                            }
988    
989                            for (int i = 0; i < orderByConditionFields.length; i++) {
990                                    query.append(_ORDER_BY_ENTITY_ALIAS);
991                                    query.append(orderByConditionFields[i]);
992    
993                                    if ((i + 1) < orderByConditionFields.length) {
994                                            if (orderByComparator.isAscending() ^ previous) {
995                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
996                                            }
997                                            else {
998                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
999                                            }
1000                                    }
1001                                    else {
1002                                            if (orderByComparator.isAscending() ^ previous) {
1003                                                    query.append(WHERE_GREATER_THAN);
1004                                            }
1005                                            else {
1006                                                    query.append(WHERE_LESSER_THAN);
1007                                            }
1008                                    }
1009                            }
1010    
1011                            query.append(ORDER_BY_CLAUSE);
1012    
1013                            String[] orderByFields = orderByComparator.getOrderByFields();
1014    
1015                            for (int i = 0; i < orderByFields.length; i++) {
1016                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1017                                    query.append(orderByFields[i]);
1018    
1019                                    if ((i + 1) < orderByFields.length) {
1020                                            if (orderByComparator.isAscending() ^ previous) {
1021                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1022                                            }
1023                                            else {
1024                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1025                                            }
1026                                    }
1027                                    else {
1028                                            if (orderByComparator.isAscending() ^ previous) {
1029                                                    query.append(ORDER_BY_ASC);
1030                                            }
1031                                            else {
1032                                                    query.append(ORDER_BY_DESC);
1033                                            }
1034                                    }
1035                            }
1036                    }
1037                    else {
1038                            query.append(SocialActivityCounterModelImpl.ORDER_BY_JPQL);
1039                    }
1040    
1041                    String sql = query.toString();
1042    
1043                    Query q = session.createQuery(sql);
1044    
1045                    q.setFirstResult(0);
1046                    q.setMaxResults(2);
1047    
1048                    QueryPos qPos = QueryPos.getInstance(q);
1049    
1050                    qPos.add(classNameId);
1051    
1052                    qPos.add(classPK);
1053    
1054                    if (orderByComparator != null) {
1055                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivityCounter);
1056    
1057                            for (Object value : values) {
1058                                    qPos.add(value);
1059                            }
1060                    }
1061    
1062                    List<SocialActivityCounter> list = q.list();
1063    
1064                    if (list.size() == 2) {
1065                            return list.get(1);
1066                    }
1067                    else {
1068                            return null;
1069                    }
1070            }
1071    
1072            /**
1073             * Removes all the social activity counters where classNameId = &#63; and classPK = &#63; from the database.
1074             *
1075             * @param classNameId the class name ID
1076             * @param classPK the class p k
1077             */
1078            @Override
1079            public void removeByC_C(long classNameId, long classPK) {
1080                    for (SocialActivityCounter socialActivityCounter : findByC_C(
1081                                    classNameId, classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1082                            remove(socialActivityCounter);
1083                    }
1084            }
1085    
1086            /**
1087             * Returns the number of social activity counters where classNameId = &#63; and classPK = &#63;.
1088             *
1089             * @param classNameId the class name ID
1090             * @param classPK the class p k
1091             * @return the number of matching social activity counters
1092             */
1093            @Override
1094            public int countByC_C(long classNameId, long classPK) {
1095                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
1096    
1097                    Object[] finderArgs = new Object[] { classNameId, classPK };
1098    
1099                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1100    
1101                    if (count == null) {
1102                            StringBundler query = new StringBundler(3);
1103    
1104                            query.append(_SQL_COUNT_SOCIALACTIVITYCOUNTER_WHERE);
1105    
1106                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1107    
1108                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1109    
1110                            String sql = query.toString();
1111    
1112                            Session session = null;
1113    
1114                            try {
1115                                    session = openSession();
1116    
1117                                    Query q = session.createQuery(sql);
1118    
1119                                    QueryPos qPos = QueryPos.getInstance(q);
1120    
1121                                    qPos.add(classNameId);
1122    
1123                                    qPos.add(classPK);
1124    
1125                                    count = (Long)q.uniqueResult();
1126    
1127                                    finderCache.putResult(finderPath, finderArgs, count);
1128                            }
1129                            catch (Exception e) {
1130                                    finderCache.removeResult(finderPath, finderArgs);
1131    
1132                                    throw processException(e);
1133                            }
1134                            finally {
1135                                    closeSession(session);
1136                            }
1137                    }
1138    
1139                    return count.intValue();
1140            }
1141    
1142            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "socialActivityCounter.classNameId = ? AND ";
1143            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "socialActivityCounter.classPK = ?";
1144            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C_O = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
1145                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
1146                            SocialActivityCounterImpl.class,
1147                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_C_O",
1148                            new String[] {
1149                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
1150                                    Integer.class.getName(),
1151                                    
1152                            Integer.class.getName(), Integer.class.getName(),
1153                                    OrderByComparator.class.getName()
1154                            });
1155            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_O =
1156                    new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
1157                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
1158                            SocialActivityCounterImpl.class,
1159                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C_O",
1160                            new String[] {
1161                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
1162                                    Integer.class.getName()
1163                            },
1164                            SocialActivityCounterModelImpl.GROUPID_COLUMN_BITMASK |
1165                            SocialActivityCounterModelImpl.CLASSNAMEID_COLUMN_BITMASK |
1166                            SocialActivityCounterModelImpl.CLASSPK_COLUMN_BITMASK |
1167                            SocialActivityCounterModelImpl.OWNERTYPE_COLUMN_BITMASK);
1168            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_O = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
1169                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED, Long.class,
1170                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C_O",
1171                            new String[] {
1172                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
1173                                    Integer.class.getName()
1174                            });
1175    
1176            /**
1177             * Returns all the social activity counters where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1178             *
1179             * @param groupId the group ID
1180             * @param classNameId the class name ID
1181             * @param classPK the class p k
1182             * @param ownerType the owner type
1183             * @return the matching social activity counters
1184             */
1185            @Override
1186            public List<SocialActivityCounter> findByG_C_C_O(long groupId,
1187                    long classNameId, long classPK, int ownerType) {
1188                    return findByG_C_C_O(groupId, classNameId, classPK, ownerType,
1189                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1190            }
1191    
1192            /**
1193             * Returns a range of all the social activity counters where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1194             *
1195             * <p>
1196             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1197             * </p>
1198             *
1199             * @param groupId the group ID
1200             * @param classNameId the class name ID
1201             * @param classPK the class p k
1202             * @param ownerType the owner type
1203             * @param start the lower bound of the range of social activity counters
1204             * @param end the upper bound of the range of social activity counters (not inclusive)
1205             * @return the range of matching social activity counters
1206             */
1207            @Override
1208            public List<SocialActivityCounter> findByG_C_C_O(long groupId,
1209                    long classNameId, long classPK, int ownerType, int start, int end) {
1210                    return findByG_C_C_O(groupId, classNameId, classPK, ownerType, start,
1211                            end, null);
1212            }
1213    
1214            /**
1215             * Returns an ordered range of all the social activity counters where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1216             *
1217             * <p>
1218             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1219             * </p>
1220             *
1221             * @param groupId the group ID
1222             * @param classNameId the class name ID
1223             * @param classPK the class p k
1224             * @param ownerType the owner type
1225             * @param start the lower bound of the range of social activity counters
1226             * @param end the upper bound of the range of social activity counters (not inclusive)
1227             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1228             * @return the ordered range of matching social activity counters
1229             */
1230            @Override
1231            public List<SocialActivityCounter> findByG_C_C_O(long groupId,
1232                    long classNameId, long classPK, int ownerType, int start, int end,
1233                    OrderByComparator<SocialActivityCounter> orderByComparator) {
1234                    return findByG_C_C_O(groupId, classNameId, classPK, ownerType, start,
1235                            end, orderByComparator, true);
1236            }
1237    
1238            /**
1239             * Returns an ordered range of all the social activity counters where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1240             *
1241             * <p>
1242             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1243             * </p>
1244             *
1245             * @param groupId the group ID
1246             * @param classNameId the class name ID
1247             * @param classPK the class p k
1248             * @param ownerType the owner type
1249             * @param start the lower bound of the range of social activity counters
1250             * @param end the upper bound of the range of social activity counters (not inclusive)
1251             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1252             * @param retrieveFromCache whether to retrieve from the finder cache
1253             * @return the ordered range of matching social activity counters
1254             */
1255            @Override
1256            public List<SocialActivityCounter> findByG_C_C_O(long groupId,
1257                    long classNameId, long classPK, int ownerType, int start, int end,
1258                    OrderByComparator<SocialActivityCounter> orderByComparator,
1259                    boolean retrieveFromCache) {
1260                    boolean pagination = true;
1261                    FinderPath finderPath = null;
1262                    Object[] finderArgs = null;
1263    
1264                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1265                                    (orderByComparator == null)) {
1266                            pagination = false;
1267                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_O;
1268                            finderArgs = new Object[] { groupId, classNameId, classPK, ownerType };
1269                    }
1270                    else {
1271                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C_O;
1272                            finderArgs = new Object[] {
1273                                            groupId, classNameId, classPK, ownerType,
1274                                            
1275                                            start, end, orderByComparator
1276                                    };
1277                    }
1278    
1279                    List<SocialActivityCounter> list = null;
1280    
1281                    if (retrieveFromCache) {
1282                            list = (List<SocialActivityCounter>)finderCache.getResult(finderPath,
1283                                            finderArgs, this);
1284    
1285                            if ((list != null) && !list.isEmpty()) {
1286                                    for (SocialActivityCounter socialActivityCounter : list) {
1287                                            if ((groupId != socialActivityCounter.getGroupId()) ||
1288                                                            (classNameId != socialActivityCounter.getClassNameId()) ||
1289                                                            (classPK != socialActivityCounter.getClassPK()) ||
1290                                                            (ownerType != socialActivityCounter.getOwnerType())) {
1291                                                    list = null;
1292    
1293                                                    break;
1294                                            }
1295                                    }
1296                            }
1297                    }
1298    
1299                    if (list == null) {
1300                            StringBundler query = null;
1301    
1302                            if (orderByComparator != null) {
1303                                    query = new StringBundler(6 +
1304                                                    (orderByComparator.getOrderByFields().length * 3));
1305                            }
1306                            else {
1307                                    query = new StringBundler(6);
1308                            }
1309    
1310                            query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE);
1311    
1312                            query.append(_FINDER_COLUMN_G_C_C_O_GROUPID_2);
1313    
1314                            query.append(_FINDER_COLUMN_G_C_C_O_CLASSNAMEID_2);
1315    
1316                            query.append(_FINDER_COLUMN_G_C_C_O_CLASSPK_2);
1317    
1318                            query.append(_FINDER_COLUMN_G_C_C_O_OWNERTYPE_2);
1319    
1320                            if (orderByComparator != null) {
1321                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1322                                            orderByComparator);
1323                            }
1324                            else
1325                             if (pagination) {
1326                                    query.append(SocialActivityCounterModelImpl.ORDER_BY_JPQL);
1327                            }
1328    
1329                            String sql = query.toString();
1330    
1331                            Session session = null;
1332    
1333                            try {
1334                                    session = openSession();
1335    
1336                                    Query q = session.createQuery(sql);
1337    
1338                                    QueryPos qPos = QueryPos.getInstance(q);
1339    
1340                                    qPos.add(groupId);
1341    
1342                                    qPos.add(classNameId);
1343    
1344                                    qPos.add(classPK);
1345    
1346                                    qPos.add(ownerType);
1347    
1348                                    if (!pagination) {
1349                                            list = (List<SocialActivityCounter>)QueryUtil.list(q,
1350                                                            getDialect(), start, end, false);
1351    
1352                                            Collections.sort(list);
1353    
1354                                            list = Collections.unmodifiableList(list);
1355                                    }
1356                                    else {
1357                                            list = (List<SocialActivityCounter>)QueryUtil.list(q,
1358                                                            getDialect(), start, end);
1359                                    }
1360    
1361                                    cacheResult(list);
1362    
1363                                    finderCache.putResult(finderPath, finderArgs, list);
1364                            }
1365                            catch (Exception e) {
1366                                    finderCache.removeResult(finderPath, finderArgs);
1367    
1368                                    throw processException(e);
1369                            }
1370                            finally {
1371                                    closeSession(session);
1372                            }
1373                    }
1374    
1375                    return list;
1376            }
1377    
1378            /**
1379             * Returns the first social activity counter in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1380             *
1381             * @param groupId the group ID
1382             * @param classNameId the class name ID
1383             * @param classPK the class p k
1384             * @param ownerType the owner type
1385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1386             * @return the first matching social activity counter
1387             * @throws NoSuchActivityCounterException if a matching social activity counter could not be found
1388             */
1389            @Override
1390            public SocialActivityCounter findByG_C_C_O_First(long groupId,
1391                    long classNameId, long classPK, int ownerType,
1392                    OrderByComparator<SocialActivityCounter> orderByComparator)
1393                    throws NoSuchActivityCounterException {
1394                    SocialActivityCounter socialActivityCounter = fetchByG_C_C_O_First(groupId,
1395                                    classNameId, classPK, ownerType, orderByComparator);
1396    
1397                    if (socialActivityCounter != null) {
1398                            return socialActivityCounter;
1399                    }
1400    
1401                    StringBundler msg = new StringBundler(10);
1402    
1403                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1404    
1405                    msg.append("groupId=");
1406                    msg.append(groupId);
1407    
1408                    msg.append(", classNameId=");
1409                    msg.append(classNameId);
1410    
1411                    msg.append(", classPK=");
1412                    msg.append(classPK);
1413    
1414                    msg.append(", ownerType=");
1415                    msg.append(ownerType);
1416    
1417                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1418    
1419                    throw new NoSuchActivityCounterException(msg.toString());
1420            }
1421    
1422            /**
1423             * Returns the first social activity counter in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1424             *
1425             * @param groupId the group ID
1426             * @param classNameId the class name ID
1427             * @param classPK the class p k
1428             * @param ownerType the owner type
1429             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1430             * @return the first matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
1431             */
1432            @Override
1433            public SocialActivityCounter fetchByG_C_C_O_First(long groupId,
1434                    long classNameId, long classPK, int ownerType,
1435                    OrderByComparator<SocialActivityCounter> orderByComparator) {
1436                    List<SocialActivityCounter> list = findByG_C_C_O(groupId, classNameId,
1437                                    classPK, ownerType, 0, 1, orderByComparator);
1438    
1439                    if (!list.isEmpty()) {
1440                            return list.get(0);
1441                    }
1442    
1443                    return null;
1444            }
1445    
1446            /**
1447             * Returns the last social activity counter in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1448             *
1449             * @param groupId the group ID
1450             * @param classNameId the class name ID
1451             * @param classPK the class p k
1452             * @param ownerType the owner type
1453             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1454             * @return the last matching social activity counter
1455             * @throws NoSuchActivityCounterException if a matching social activity counter could not be found
1456             */
1457            @Override
1458            public SocialActivityCounter findByG_C_C_O_Last(long groupId,
1459                    long classNameId, long classPK, int ownerType,
1460                    OrderByComparator<SocialActivityCounter> orderByComparator)
1461                    throws NoSuchActivityCounterException {
1462                    SocialActivityCounter socialActivityCounter = fetchByG_C_C_O_Last(groupId,
1463                                    classNameId, classPK, ownerType, orderByComparator);
1464    
1465                    if (socialActivityCounter != null) {
1466                            return socialActivityCounter;
1467                    }
1468    
1469                    StringBundler msg = new StringBundler(10);
1470    
1471                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1472    
1473                    msg.append("groupId=");
1474                    msg.append(groupId);
1475    
1476                    msg.append(", classNameId=");
1477                    msg.append(classNameId);
1478    
1479                    msg.append(", classPK=");
1480                    msg.append(classPK);
1481    
1482                    msg.append(", ownerType=");
1483                    msg.append(ownerType);
1484    
1485                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1486    
1487                    throw new NoSuchActivityCounterException(msg.toString());
1488            }
1489    
1490            /**
1491             * Returns the last social activity counter in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1492             *
1493             * @param groupId the group ID
1494             * @param classNameId the class name ID
1495             * @param classPK the class p k
1496             * @param ownerType the owner type
1497             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1498             * @return the last matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
1499             */
1500            @Override
1501            public SocialActivityCounter fetchByG_C_C_O_Last(long groupId,
1502                    long classNameId, long classPK, int ownerType,
1503                    OrderByComparator<SocialActivityCounter> orderByComparator) {
1504                    int count = countByG_C_C_O(groupId, classNameId, classPK, ownerType);
1505    
1506                    if (count == 0) {
1507                            return null;
1508                    }
1509    
1510                    List<SocialActivityCounter> list = findByG_C_C_O(groupId, classNameId,
1511                                    classPK, ownerType, count - 1, count, orderByComparator);
1512    
1513                    if (!list.isEmpty()) {
1514                            return list.get(0);
1515                    }
1516    
1517                    return null;
1518            }
1519    
1520            /**
1521             * Returns the social activity counters before and after the current social activity counter in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1522             *
1523             * @param activityCounterId the primary key of the current social activity counter
1524             * @param groupId the group ID
1525             * @param classNameId the class name ID
1526             * @param classPK the class p k
1527             * @param ownerType the owner type
1528             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1529             * @return the previous, current, and next social activity counter
1530             * @throws NoSuchActivityCounterException if a social activity counter with the primary key could not be found
1531             */
1532            @Override
1533            public SocialActivityCounter[] findByG_C_C_O_PrevAndNext(
1534                    long activityCounterId, long groupId, long classNameId, long classPK,
1535                    int ownerType,
1536                    OrderByComparator<SocialActivityCounter> orderByComparator)
1537                    throws NoSuchActivityCounterException {
1538                    SocialActivityCounter socialActivityCounter = findByPrimaryKey(activityCounterId);
1539    
1540                    Session session = null;
1541    
1542                    try {
1543                            session = openSession();
1544    
1545                            SocialActivityCounter[] array = new SocialActivityCounterImpl[3];
1546    
1547                            array[0] = getByG_C_C_O_PrevAndNext(session, socialActivityCounter,
1548                                            groupId, classNameId, classPK, ownerType,
1549                                            orderByComparator, true);
1550    
1551                            array[1] = socialActivityCounter;
1552    
1553                            array[2] = getByG_C_C_O_PrevAndNext(session, socialActivityCounter,
1554                                            groupId, classNameId, classPK, ownerType,
1555                                            orderByComparator, false);
1556    
1557                            return array;
1558                    }
1559                    catch (Exception e) {
1560                            throw processException(e);
1561                    }
1562                    finally {
1563                            closeSession(session);
1564                    }
1565            }
1566    
1567            protected SocialActivityCounter getByG_C_C_O_PrevAndNext(Session session,
1568                    SocialActivityCounter socialActivityCounter, long groupId,
1569                    long classNameId, long classPK, int ownerType,
1570                    OrderByComparator<SocialActivityCounter> orderByComparator,
1571                    boolean previous) {
1572                    StringBundler query = null;
1573    
1574                    if (orderByComparator != null) {
1575                            query = new StringBundler(6 +
1576                                            (orderByComparator.getOrderByFields().length * 6));
1577                    }
1578                    else {
1579                            query = new StringBundler(3);
1580                    }
1581    
1582                    query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE);
1583    
1584                    query.append(_FINDER_COLUMN_G_C_C_O_GROUPID_2);
1585    
1586                    query.append(_FINDER_COLUMN_G_C_C_O_CLASSNAMEID_2);
1587    
1588                    query.append(_FINDER_COLUMN_G_C_C_O_CLASSPK_2);
1589    
1590                    query.append(_FINDER_COLUMN_G_C_C_O_OWNERTYPE_2);
1591    
1592                    if (orderByComparator != null) {
1593                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1594    
1595                            if (orderByConditionFields.length > 0) {
1596                                    query.append(WHERE_AND);
1597                            }
1598    
1599                            for (int i = 0; i < orderByConditionFields.length; i++) {
1600                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1601                                    query.append(orderByConditionFields[i]);
1602    
1603                                    if ((i + 1) < orderByConditionFields.length) {
1604                                            if (orderByComparator.isAscending() ^ previous) {
1605                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1606                                            }
1607                                            else {
1608                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1609                                            }
1610                                    }
1611                                    else {
1612                                            if (orderByComparator.isAscending() ^ previous) {
1613                                                    query.append(WHERE_GREATER_THAN);
1614                                            }
1615                                            else {
1616                                                    query.append(WHERE_LESSER_THAN);
1617                                            }
1618                                    }
1619                            }
1620    
1621                            query.append(ORDER_BY_CLAUSE);
1622    
1623                            String[] orderByFields = orderByComparator.getOrderByFields();
1624    
1625                            for (int i = 0; i < orderByFields.length; i++) {
1626                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1627                                    query.append(orderByFields[i]);
1628    
1629                                    if ((i + 1) < orderByFields.length) {
1630                                            if (orderByComparator.isAscending() ^ previous) {
1631                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1632                                            }
1633                                            else {
1634                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1635                                            }
1636                                    }
1637                                    else {
1638                                            if (orderByComparator.isAscending() ^ previous) {
1639                                                    query.append(ORDER_BY_ASC);
1640                                            }
1641                                            else {
1642                                                    query.append(ORDER_BY_DESC);
1643                                            }
1644                                    }
1645                            }
1646                    }
1647                    else {
1648                            query.append(SocialActivityCounterModelImpl.ORDER_BY_JPQL);
1649                    }
1650    
1651                    String sql = query.toString();
1652    
1653                    Query q = session.createQuery(sql);
1654    
1655                    q.setFirstResult(0);
1656                    q.setMaxResults(2);
1657    
1658                    QueryPos qPos = QueryPos.getInstance(q);
1659    
1660                    qPos.add(groupId);
1661    
1662                    qPos.add(classNameId);
1663    
1664                    qPos.add(classPK);
1665    
1666                    qPos.add(ownerType);
1667    
1668                    if (orderByComparator != null) {
1669                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivityCounter);
1670    
1671                            for (Object value : values) {
1672                                    qPos.add(value);
1673                            }
1674                    }
1675    
1676                    List<SocialActivityCounter> list = q.list();
1677    
1678                    if (list.size() == 2) {
1679                            return list.get(1);
1680                    }
1681                    else {
1682                            return null;
1683                    }
1684            }
1685    
1686            /**
1687             * Removes all the social activity counters where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63; from the database.
1688             *
1689             * @param groupId the group ID
1690             * @param classNameId the class name ID
1691             * @param classPK the class p k
1692             * @param ownerType the owner type
1693             */
1694            @Override
1695            public void removeByG_C_C_O(long groupId, long classNameId, long classPK,
1696                    int ownerType) {
1697                    for (SocialActivityCounter socialActivityCounter : findByG_C_C_O(
1698                                    groupId, classNameId, classPK, ownerType, QueryUtil.ALL_POS,
1699                                    QueryUtil.ALL_POS, null)) {
1700                            remove(socialActivityCounter);
1701                    }
1702            }
1703    
1704            /**
1705             * Returns the number of social activity counters where groupId = &#63; and classNameId = &#63; and classPK = &#63; and ownerType = &#63;.
1706             *
1707             * @param groupId the group ID
1708             * @param classNameId the class name ID
1709             * @param classPK the class p k
1710             * @param ownerType the owner type
1711             * @return the number of matching social activity counters
1712             */
1713            @Override
1714            public int countByG_C_C_O(long groupId, long classNameId, long classPK,
1715                    int ownerType) {
1716                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C_O;
1717    
1718                    Object[] finderArgs = new Object[] {
1719                                    groupId, classNameId, classPK, ownerType
1720                            };
1721    
1722                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1723    
1724                    if (count == null) {
1725                            StringBundler query = new StringBundler(5);
1726    
1727                            query.append(_SQL_COUNT_SOCIALACTIVITYCOUNTER_WHERE);
1728    
1729                            query.append(_FINDER_COLUMN_G_C_C_O_GROUPID_2);
1730    
1731                            query.append(_FINDER_COLUMN_G_C_C_O_CLASSNAMEID_2);
1732    
1733                            query.append(_FINDER_COLUMN_G_C_C_O_CLASSPK_2);
1734    
1735                            query.append(_FINDER_COLUMN_G_C_C_O_OWNERTYPE_2);
1736    
1737                            String sql = query.toString();
1738    
1739                            Session session = null;
1740    
1741                            try {
1742                                    session = openSession();
1743    
1744                                    Query q = session.createQuery(sql);
1745    
1746                                    QueryPos qPos = QueryPos.getInstance(q);
1747    
1748                                    qPos.add(groupId);
1749    
1750                                    qPos.add(classNameId);
1751    
1752                                    qPos.add(classPK);
1753    
1754                                    qPos.add(ownerType);
1755    
1756                                    count = (Long)q.uniqueResult();
1757    
1758                                    finderCache.putResult(finderPath, finderArgs, count);
1759                            }
1760                            catch (Exception e) {
1761                                    finderCache.removeResult(finderPath, finderArgs);
1762    
1763                                    throw processException(e);
1764                            }
1765                            finally {
1766                                    closeSession(session);
1767                            }
1768                    }
1769    
1770                    return count.intValue();
1771            }
1772    
1773            private static final String _FINDER_COLUMN_G_C_C_O_GROUPID_2 = "socialActivityCounter.groupId = ? AND ";
1774            private static final String _FINDER_COLUMN_G_C_C_O_CLASSNAMEID_2 = "socialActivityCounter.classNameId = ? AND ";
1775            private static final String _FINDER_COLUMN_G_C_C_O_CLASSPK_2 = "socialActivityCounter.classPK = ? AND ";
1776            private static final String _FINDER_COLUMN_G_C_C_O_OWNERTYPE_2 = "socialActivityCounter.ownerType = ? AND socialActivityCounter.endPeriod = -1";
1777            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_C_N_O_S = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
1778                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
1779                            SocialActivityCounterImpl.class, FINDER_CLASS_NAME_ENTITY,
1780                            "fetchByG_C_C_N_O_S",
1781                            new String[] {
1782                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
1783                                    String.class.getName(), Integer.class.getName(),
1784                                    Integer.class.getName()
1785                            },
1786                            SocialActivityCounterModelImpl.GROUPID_COLUMN_BITMASK |
1787                            SocialActivityCounterModelImpl.CLASSNAMEID_COLUMN_BITMASK |
1788                            SocialActivityCounterModelImpl.CLASSPK_COLUMN_BITMASK |
1789                            SocialActivityCounterModelImpl.NAME_COLUMN_BITMASK |
1790                            SocialActivityCounterModelImpl.OWNERTYPE_COLUMN_BITMASK |
1791                            SocialActivityCounterModelImpl.STARTPERIOD_COLUMN_BITMASK);
1792            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_N_O_S = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
1793                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED, Long.class,
1794                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C_N_O_S",
1795                            new String[] {
1796                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
1797                                    String.class.getName(), Integer.class.getName(),
1798                                    Integer.class.getName()
1799                            });
1800    
1801            /**
1802             * Returns the social activity counter where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and startPeriod = &#63; or throws a {@link NoSuchActivityCounterException} if it could not be found.
1803             *
1804             * @param groupId the group ID
1805             * @param classNameId the class name ID
1806             * @param classPK the class p k
1807             * @param name the name
1808             * @param ownerType the owner type
1809             * @param startPeriod the start period
1810             * @return the matching social activity counter
1811             * @throws NoSuchActivityCounterException if a matching social activity counter could not be found
1812             */
1813            @Override
1814            public SocialActivityCounter findByG_C_C_N_O_S(long groupId,
1815                    long classNameId, long classPK, String name, int ownerType,
1816                    int startPeriod) throws NoSuchActivityCounterException {
1817                    SocialActivityCounter socialActivityCounter = fetchByG_C_C_N_O_S(groupId,
1818                                    classNameId, classPK, name, ownerType, startPeriod);
1819    
1820                    if (socialActivityCounter == null) {
1821                            StringBundler msg = new StringBundler(14);
1822    
1823                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1824    
1825                            msg.append("groupId=");
1826                            msg.append(groupId);
1827    
1828                            msg.append(", classNameId=");
1829                            msg.append(classNameId);
1830    
1831                            msg.append(", classPK=");
1832                            msg.append(classPK);
1833    
1834                            msg.append(", name=");
1835                            msg.append(name);
1836    
1837                            msg.append(", ownerType=");
1838                            msg.append(ownerType);
1839    
1840                            msg.append(", startPeriod=");
1841                            msg.append(startPeriod);
1842    
1843                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1844    
1845                            if (_log.isWarnEnabled()) {
1846                                    _log.warn(msg.toString());
1847                            }
1848    
1849                            throw new NoSuchActivityCounterException(msg.toString());
1850                    }
1851    
1852                    return socialActivityCounter;
1853            }
1854    
1855            /**
1856             * Returns the social activity counter where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and startPeriod = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1857             *
1858             * @param groupId the group ID
1859             * @param classNameId the class name ID
1860             * @param classPK the class p k
1861             * @param name the name
1862             * @param ownerType the owner type
1863             * @param startPeriod the start period
1864             * @return the matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
1865             */
1866            @Override
1867            public SocialActivityCounter fetchByG_C_C_N_O_S(long groupId,
1868                    long classNameId, long classPK, String name, int ownerType,
1869                    int startPeriod) {
1870                    return fetchByG_C_C_N_O_S(groupId, classNameId, classPK, name,
1871                            ownerType, startPeriod, true);
1872            }
1873    
1874            /**
1875             * Returns the social activity counter where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and startPeriod = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1876             *
1877             * @param groupId the group ID
1878             * @param classNameId the class name ID
1879             * @param classPK the class p k
1880             * @param name the name
1881             * @param ownerType the owner type
1882             * @param startPeriod the start period
1883             * @param retrieveFromCache whether to retrieve from the finder cache
1884             * @return the matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
1885             */
1886            @Override
1887            public SocialActivityCounter fetchByG_C_C_N_O_S(long groupId,
1888                    long classNameId, long classPK, String name, int ownerType,
1889                    int startPeriod, boolean retrieveFromCache) {
1890                    Object[] finderArgs = new Object[] {
1891                                    groupId, classNameId, classPK, name, ownerType, startPeriod
1892                            };
1893    
1894                    Object result = null;
1895    
1896                    if (retrieveFromCache) {
1897                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_S,
1898                                            finderArgs, this);
1899                    }
1900    
1901                    if (result instanceof SocialActivityCounter) {
1902                            SocialActivityCounter socialActivityCounter = (SocialActivityCounter)result;
1903    
1904                            if ((groupId != socialActivityCounter.getGroupId()) ||
1905                                            (classNameId != socialActivityCounter.getClassNameId()) ||
1906                                            (classPK != socialActivityCounter.getClassPK()) ||
1907                                            !Validator.equals(name, socialActivityCounter.getName()) ||
1908                                            (ownerType != socialActivityCounter.getOwnerType()) ||
1909                                            (startPeriod != socialActivityCounter.getStartPeriod())) {
1910                                    result = null;
1911                            }
1912                    }
1913    
1914                    if (result == null) {
1915                            StringBundler query = new StringBundler(8);
1916    
1917                            query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE);
1918    
1919                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_GROUPID_2);
1920    
1921                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_CLASSNAMEID_2);
1922    
1923                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_CLASSPK_2);
1924    
1925                            boolean bindName = false;
1926    
1927                            if (name == null) {
1928                                    query.append(_FINDER_COLUMN_G_C_C_N_O_S_NAME_1);
1929                            }
1930                            else if (name.equals(StringPool.BLANK)) {
1931                                    query.append(_FINDER_COLUMN_G_C_C_N_O_S_NAME_3);
1932                            }
1933                            else {
1934                                    bindName = true;
1935    
1936                                    query.append(_FINDER_COLUMN_G_C_C_N_O_S_NAME_2);
1937                            }
1938    
1939                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_OWNERTYPE_2);
1940    
1941                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_STARTPERIOD_2);
1942    
1943                            String sql = query.toString();
1944    
1945                            Session session = null;
1946    
1947                            try {
1948                                    session = openSession();
1949    
1950                                    Query q = session.createQuery(sql);
1951    
1952                                    QueryPos qPos = QueryPos.getInstance(q);
1953    
1954                                    qPos.add(groupId);
1955    
1956                                    qPos.add(classNameId);
1957    
1958                                    qPos.add(classPK);
1959    
1960                                    if (bindName) {
1961                                            qPos.add(name);
1962                                    }
1963    
1964                                    qPos.add(ownerType);
1965    
1966                                    qPos.add(startPeriod);
1967    
1968                                    List<SocialActivityCounter> list = q.list();
1969    
1970                                    if (list.isEmpty()) {
1971                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_S,
1972                                                    finderArgs, list);
1973                                    }
1974                                    else {
1975                                            SocialActivityCounter socialActivityCounter = list.get(0);
1976    
1977                                            result = socialActivityCounter;
1978    
1979                                            cacheResult(socialActivityCounter);
1980    
1981                                            if ((socialActivityCounter.getGroupId() != groupId) ||
1982                                                            (socialActivityCounter.getClassNameId() != classNameId) ||
1983                                                            (socialActivityCounter.getClassPK() != classPK) ||
1984                                                            (socialActivityCounter.getName() == null) ||
1985                                                            !socialActivityCounter.getName().equals(name) ||
1986                                                            (socialActivityCounter.getOwnerType() != ownerType) ||
1987                                                            (socialActivityCounter.getStartPeriod() != startPeriod)) {
1988                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_S,
1989                                                            finderArgs, socialActivityCounter);
1990                                            }
1991                                    }
1992                            }
1993                            catch (Exception e) {
1994                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_S,
1995                                            finderArgs);
1996    
1997                                    throw processException(e);
1998                            }
1999                            finally {
2000                                    closeSession(session);
2001                            }
2002                    }
2003    
2004                    if (result instanceof List<?>) {
2005                            return null;
2006                    }
2007                    else {
2008                            return (SocialActivityCounter)result;
2009                    }
2010            }
2011    
2012            /**
2013             * Removes the social activity counter where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and startPeriod = &#63; from the database.
2014             *
2015             * @param groupId the group ID
2016             * @param classNameId the class name ID
2017             * @param classPK the class p k
2018             * @param name the name
2019             * @param ownerType the owner type
2020             * @param startPeriod the start period
2021             * @return the social activity counter that was removed
2022             */
2023            @Override
2024            public SocialActivityCounter removeByG_C_C_N_O_S(long groupId,
2025                    long classNameId, long classPK, String name, int ownerType,
2026                    int startPeriod) throws NoSuchActivityCounterException {
2027                    SocialActivityCounter socialActivityCounter = findByG_C_C_N_O_S(groupId,
2028                                    classNameId, classPK, name, ownerType, startPeriod);
2029    
2030                    return remove(socialActivityCounter);
2031            }
2032    
2033            /**
2034             * Returns the number of social activity counters where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and startPeriod = &#63;.
2035             *
2036             * @param groupId the group ID
2037             * @param classNameId the class name ID
2038             * @param classPK the class p k
2039             * @param name the name
2040             * @param ownerType the owner type
2041             * @param startPeriod the start period
2042             * @return the number of matching social activity counters
2043             */
2044            @Override
2045            public int countByG_C_C_N_O_S(long groupId, long classNameId, long classPK,
2046                    String name, int ownerType, int startPeriod) {
2047                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C_N_O_S;
2048    
2049                    Object[] finderArgs = new Object[] {
2050                                    groupId, classNameId, classPK, name, ownerType, startPeriod
2051                            };
2052    
2053                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2054    
2055                    if (count == null) {
2056                            StringBundler query = new StringBundler(7);
2057    
2058                            query.append(_SQL_COUNT_SOCIALACTIVITYCOUNTER_WHERE);
2059    
2060                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_GROUPID_2);
2061    
2062                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_CLASSNAMEID_2);
2063    
2064                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_CLASSPK_2);
2065    
2066                            boolean bindName = false;
2067    
2068                            if (name == null) {
2069                                    query.append(_FINDER_COLUMN_G_C_C_N_O_S_NAME_1);
2070                            }
2071                            else if (name.equals(StringPool.BLANK)) {
2072                                    query.append(_FINDER_COLUMN_G_C_C_N_O_S_NAME_3);
2073                            }
2074                            else {
2075                                    bindName = true;
2076    
2077                                    query.append(_FINDER_COLUMN_G_C_C_N_O_S_NAME_2);
2078                            }
2079    
2080                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_OWNERTYPE_2);
2081    
2082                            query.append(_FINDER_COLUMN_G_C_C_N_O_S_STARTPERIOD_2);
2083    
2084                            String sql = query.toString();
2085    
2086                            Session session = null;
2087    
2088                            try {
2089                                    session = openSession();
2090    
2091                                    Query q = session.createQuery(sql);
2092    
2093                                    QueryPos qPos = QueryPos.getInstance(q);
2094    
2095                                    qPos.add(groupId);
2096    
2097                                    qPos.add(classNameId);
2098    
2099                                    qPos.add(classPK);
2100    
2101                                    if (bindName) {
2102                                            qPos.add(name);
2103                                    }
2104    
2105                                    qPos.add(ownerType);
2106    
2107                                    qPos.add(startPeriod);
2108    
2109                                    count = (Long)q.uniqueResult();
2110    
2111                                    finderCache.putResult(finderPath, finderArgs, count);
2112                            }
2113                            catch (Exception e) {
2114                                    finderCache.removeResult(finderPath, finderArgs);
2115    
2116                                    throw processException(e);
2117                            }
2118                            finally {
2119                                    closeSession(session);
2120                            }
2121                    }
2122    
2123                    return count.intValue();
2124            }
2125    
2126            private static final String _FINDER_COLUMN_G_C_C_N_O_S_GROUPID_2 = "socialActivityCounter.groupId = ? AND ";
2127            private static final String _FINDER_COLUMN_G_C_C_N_O_S_CLASSNAMEID_2 = "socialActivityCounter.classNameId = ? AND ";
2128            private static final String _FINDER_COLUMN_G_C_C_N_O_S_CLASSPK_2 = "socialActivityCounter.classPK = ? AND ";
2129            private static final String _FINDER_COLUMN_G_C_C_N_O_S_NAME_1 = "socialActivityCounter.name IS NULL AND ";
2130            private static final String _FINDER_COLUMN_G_C_C_N_O_S_NAME_2 = "socialActivityCounter.name = ? AND ";
2131            private static final String _FINDER_COLUMN_G_C_C_N_O_S_NAME_3 = "(socialActivityCounter.name IS NULL OR socialActivityCounter.name = '') AND ";
2132            private static final String _FINDER_COLUMN_G_C_C_N_O_S_OWNERTYPE_2 = "socialActivityCounter.ownerType = ? AND ";
2133            private static final String _FINDER_COLUMN_G_C_C_N_O_S_STARTPERIOD_2 = "socialActivityCounter.startPeriod = ?";
2134            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_C_N_O_E = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
2135                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED,
2136                            SocialActivityCounterImpl.class, FINDER_CLASS_NAME_ENTITY,
2137                            "fetchByG_C_C_N_O_E",
2138                            new String[] {
2139                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
2140                                    String.class.getName(), Integer.class.getName(),
2141                                    Integer.class.getName()
2142                            },
2143                            SocialActivityCounterModelImpl.GROUPID_COLUMN_BITMASK |
2144                            SocialActivityCounterModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2145                            SocialActivityCounterModelImpl.CLASSPK_COLUMN_BITMASK |
2146                            SocialActivityCounterModelImpl.NAME_COLUMN_BITMASK |
2147                            SocialActivityCounterModelImpl.OWNERTYPE_COLUMN_BITMASK |
2148                            SocialActivityCounterModelImpl.ENDPERIOD_COLUMN_BITMASK);
2149            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_N_O_E = new FinderPath(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
2150                            SocialActivityCounterModelImpl.FINDER_CACHE_ENABLED, Long.class,
2151                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C_N_O_E",
2152                            new String[] {
2153                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
2154                                    String.class.getName(), Integer.class.getName(),
2155                                    Integer.class.getName()
2156                            });
2157    
2158            /**
2159             * Returns the social activity counter where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and endPeriod = &#63; or throws a {@link NoSuchActivityCounterException} if it could not be found.
2160             *
2161             * @param groupId the group ID
2162             * @param classNameId the class name ID
2163             * @param classPK the class p k
2164             * @param name the name
2165             * @param ownerType the owner type
2166             * @param endPeriod the end period
2167             * @return the matching social activity counter
2168             * @throws NoSuchActivityCounterException if a matching social activity counter could not be found
2169             */
2170            @Override
2171            public SocialActivityCounter findByG_C_C_N_O_E(long groupId,
2172                    long classNameId, long classPK, String name, int ownerType,
2173                    int endPeriod) throws NoSuchActivityCounterException {
2174                    SocialActivityCounter socialActivityCounter = fetchByG_C_C_N_O_E(groupId,
2175                                    classNameId, classPK, name, ownerType, endPeriod);
2176    
2177                    if (socialActivityCounter == null) {
2178                            StringBundler msg = new StringBundler(14);
2179    
2180                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2181    
2182                            msg.append("groupId=");
2183                            msg.append(groupId);
2184    
2185                            msg.append(", classNameId=");
2186                            msg.append(classNameId);
2187    
2188                            msg.append(", classPK=");
2189                            msg.append(classPK);
2190    
2191                            msg.append(", name=");
2192                            msg.append(name);
2193    
2194                            msg.append(", ownerType=");
2195                            msg.append(ownerType);
2196    
2197                            msg.append(", endPeriod=");
2198                            msg.append(endPeriod);
2199    
2200                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2201    
2202                            if (_log.isWarnEnabled()) {
2203                                    _log.warn(msg.toString());
2204                            }
2205    
2206                            throw new NoSuchActivityCounterException(msg.toString());
2207                    }
2208    
2209                    return socialActivityCounter;
2210            }
2211    
2212            /**
2213             * Returns the social activity counter where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and endPeriod = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2214             *
2215             * @param groupId the group ID
2216             * @param classNameId the class name ID
2217             * @param classPK the class p k
2218             * @param name the name
2219             * @param ownerType the owner type
2220             * @param endPeriod the end period
2221             * @return the matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
2222             */
2223            @Override
2224            public SocialActivityCounter fetchByG_C_C_N_O_E(long groupId,
2225                    long classNameId, long classPK, String name, int ownerType,
2226                    int endPeriod) {
2227                    return fetchByG_C_C_N_O_E(groupId, classNameId, classPK, name,
2228                            ownerType, endPeriod, true);
2229            }
2230    
2231            /**
2232             * Returns the social activity counter where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and endPeriod = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2233             *
2234             * @param groupId the group ID
2235             * @param classNameId the class name ID
2236             * @param classPK the class p k
2237             * @param name the name
2238             * @param ownerType the owner type
2239             * @param endPeriod the end period
2240             * @param retrieveFromCache whether to retrieve from the finder cache
2241             * @return the matching social activity counter, or <code>null</code> if a matching social activity counter could not be found
2242             */
2243            @Override
2244            public SocialActivityCounter fetchByG_C_C_N_O_E(long groupId,
2245                    long classNameId, long classPK, String name, int ownerType,
2246                    int endPeriod, boolean retrieveFromCache) {
2247                    Object[] finderArgs = new Object[] {
2248                                    groupId, classNameId, classPK, name, ownerType, endPeriod
2249                            };
2250    
2251                    Object result = null;
2252    
2253                    if (retrieveFromCache) {
2254                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_E,
2255                                            finderArgs, this);
2256                    }
2257    
2258                    if (result instanceof SocialActivityCounter) {
2259                            SocialActivityCounter socialActivityCounter = (SocialActivityCounter)result;
2260    
2261                            if ((groupId != socialActivityCounter.getGroupId()) ||
2262                                            (classNameId != socialActivityCounter.getClassNameId()) ||
2263                                            (classPK != socialActivityCounter.getClassPK()) ||
2264                                            !Validator.equals(name, socialActivityCounter.getName()) ||
2265                                            (ownerType != socialActivityCounter.getOwnerType()) ||
2266                                            (endPeriod != socialActivityCounter.getEndPeriod())) {
2267                                    result = null;
2268                            }
2269                    }
2270    
2271                    if (result == null) {
2272                            StringBundler query = new StringBundler(8);
2273    
2274                            query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE);
2275    
2276                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_GROUPID_2);
2277    
2278                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_CLASSNAMEID_2);
2279    
2280                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_CLASSPK_2);
2281    
2282                            boolean bindName = false;
2283    
2284                            if (name == null) {
2285                                    query.append(_FINDER_COLUMN_G_C_C_N_O_E_NAME_1);
2286                            }
2287                            else if (name.equals(StringPool.BLANK)) {
2288                                    query.append(_FINDER_COLUMN_G_C_C_N_O_E_NAME_3);
2289                            }
2290                            else {
2291                                    bindName = true;
2292    
2293                                    query.append(_FINDER_COLUMN_G_C_C_N_O_E_NAME_2);
2294                            }
2295    
2296                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_OWNERTYPE_2);
2297    
2298                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_ENDPERIOD_2);
2299    
2300                            String sql = query.toString();
2301    
2302                            Session session = null;
2303    
2304                            try {
2305                                    session = openSession();
2306    
2307                                    Query q = session.createQuery(sql);
2308    
2309                                    QueryPos qPos = QueryPos.getInstance(q);
2310    
2311                                    qPos.add(groupId);
2312    
2313                                    qPos.add(classNameId);
2314    
2315                                    qPos.add(classPK);
2316    
2317                                    if (bindName) {
2318                                            qPos.add(name);
2319                                    }
2320    
2321                                    qPos.add(ownerType);
2322    
2323                                    qPos.add(endPeriod);
2324    
2325                                    List<SocialActivityCounter> list = q.list();
2326    
2327                                    if (list.isEmpty()) {
2328                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_E,
2329                                                    finderArgs, list);
2330                                    }
2331                                    else {
2332                                            SocialActivityCounter socialActivityCounter = list.get(0);
2333    
2334                                            result = socialActivityCounter;
2335    
2336                                            cacheResult(socialActivityCounter);
2337    
2338                                            if ((socialActivityCounter.getGroupId() != groupId) ||
2339                                                            (socialActivityCounter.getClassNameId() != classNameId) ||
2340                                                            (socialActivityCounter.getClassPK() != classPK) ||
2341                                                            (socialActivityCounter.getName() == null) ||
2342                                                            !socialActivityCounter.getName().equals(name) ||
2343                                                            (socialActivityCounter.getOwnerType() != ownerType) ||
2344                                                            (socialActivityCounter.getEndPeriod() != endPeriod)) {
2345                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_E,
2346                                                            finderArgs, socialActivityCounter);
2347                                            }
2348                                    }
2349                            }
2350                            catch (Exception e) {
2351                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_E,
2352                                            finderArgs);
2353    
2354                                    throw processException(e);
2355                            }
2356                            finally {
2357                                    closeSession(session);
2358                            }
2359                    }
2360    
2361                    if (result instanceof List<?>) {
2362                            return null;
2363                    }
2364                    else {
2365                            return (SocialActivityCounter)result;
2366                    }
2367            }
2368    
2369            /**
2370             * Removes the social activity counter where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and endPeriod = &#63; from the database.
2371             *
2372             * @param groupId the group ID
2373             * @param classNameId the class name ID
2374             * @param classPK the class p k
2375             * @param name the name
2376             * @param ownerType the owner type
2377             * @param endPeriod the end period
2378             * @return the social activity counter that was removed
2379             */
2380            @Override
2381            public SocialActivityCounter removeByG_C_C_N_O_E(long groupId,
2382                    long classNameId, long classPK, String name, int ownerType,
2383                    int endPeriod) throws NoSuchActivityCounterException {
2384                    SocialActivityCounter socialActivityCounter = findByG_C_C_N_O_E(groupId,
2385                                    classNameId, classPK, name, ownerType, endPeriod);
2386    
2387                    return remove(socialActivityCounter);
2388            }
2389    
2390            /**
2391             * Returns the number of social activity counters where groupId = &#63; and classNameId = &#63; and classPK = &#63; and name = &#63; and ownerType = &#63; and endPeriod = &#63;.
2392             *
2393             * @param groupId the group ID
2394             * @param classNameId the class name ID
2395             * @param classPK the class p k
2396             * @param name the name
2397             * @param ownerType the owner type
2398             * @param endPeriod the end period
2399             * @return the number of matching social activity counters
2400             */
2401            @Override
2402            public int countByG_C_C_N_O_E(long groupId, long classNameId, long classPK,
2403                    String name, int ownerType, int endPeriod) {
2404                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C_N_O_E;
2405    
2406                    Object[] finderArgs = new Object[] {
2407                                    groupId, classNameId, classPK, name, ownerType, endPeriod
2408                            };
2409    
2410                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2411    
2412                    if (count == null) {
2413                            StringBundler query = new StringBundler(7);
2414    
2415                            query.append(_SQL_COUNT_SOCIALACTIVITYCOUNTER_WHERE);
2416    
2417                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_GROUPID_2);
2418    
2419                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_CLASSNAMEID_2);
2420    
2421                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_CLASSPK_2);
2422    
2423                            boolean bindName = false;
2424    
2425                            if (name == null) {
2426                                    query.append(_FINDER_COLUMN_G_C_C_N_O_E_NAME_1);
2427                            }
2428                            else if (name.equals(StringPool.BLANK)) {
2429                                    query.append(_FINDER_COLUMN_G_C_C_N_O_E_NAME_3);
2430                            }
2431                            else {
2432                                    bindName = true;
2433    
2434                                    query.append(_FINDER_COLUMN_G_C_C_N_O_E_NAME_2);
2435                            }
2436    
2437                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_OWNERTYPE_2);
2438    
2439                            query.append(_FINDER_COLUMN_G_C_C_N_O_E_ENDPERIOD_2);
2440    
2441                            String sql = query.toString();
2442    
2443                            Session session = null;
2444    
2445                            try {
2446                                    session = openSession();
2447    
2448                                    Query q = session.createQuery(sql);
2449    
2450                                    QueryPos qPos = QueryPos.getInstance(q);
2451    
2452                                    qPos.add(groupId);
2453    
2454                                    qPos.add(classNameId);
2455    
2456                                    qPos.add(classPK);
2457    
2458                                    if (bindName) {
2459                                            qPos.add(name);
2460                                    }
2461    
2462                                    qPos.add(ownerType);
2463    
2464                                    qPos.add(endPeriod);
2465    
2466                                    count = (Long)q.uniqueResult();
2467    
2468                                    finderCache.putResult(finderPath, finderArgs, count);
2469                            }
2470                            catch (Exception e) {
2471                                    finderCache.removeResult(finderPath, finderArgs);
2472    
2473                                    throw processException(e);
2474                            }
2475                            finally {
2476                                    closeSession(session);
2477                            }
2478                    }
2479    
2480                    return count.intValue();
2481            }
2482    
2483            private static final String _FINDER_COLUMN_G_C_C_N_O_E_GROUPID_2 = "socialActivityCounter.groupId = ? AND ";
2484            private static final String _FINDER_COLUMN_G_C_C_N_O_E_CLASSNAMEID_2 = "socialActivityCounter.classNameId = ? AND ";
2485            private static final String _FINDER_COLUMN_G_C_C_N_O_E_CLASSPK_2 = "socialActivityCounter.classPK = ? AND ";
2486            private static final String _FINDER_COLUMN_G_C_C_N_O_E_NAME_1 = "socialActivityCounter.name IS NULL AND ";
2487            private static final String _FINDER_COLUMN_G_C_C_N_O_E_NAME_2 = "socialActivityCounter.name = ? AND ";
2488            private static final String _FINDER_COLUMN_G_C_C_N_O_E_NAME_3 = "(socialActivityCounter.name IS NULL OR socialActivityCounter.name = '') AND ";
2489            private static final String _FINDER_COLUMN_G_C_C_N_O_E_OWNERTYPE_2 = "socialActivityCounter.ownerType = ? AND ";
2490            private static final String _FINDER_COLUMN_G_C_C_N_O_E_ENDPERIOD_2 = "socialActivityCounter.endPeriod = ?";
2491    
2492            public SocialActivityCounterPersistenceImpl() {
2493                    setModelClass(SocialActivityCounter.class);
2494            }
2495    
2496            /**
2497             * Caches the social activity counter in the entity cache if it is enabled.
2498             *
2499             * @param socialActivityCounter the social activity counter
2500             */
2501            @Override
2502            public void cacheResult(SocialActivityCounter socialActivityCounter) {
2503                    entityCache.putResult(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
2504                            SocialActivityCounterImpl.class,
2505                            socialActivityCounter.getPrimaryKey(), socialActivityCounter);
2506    
2507                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_S,
2508                            new Object[] {
2509                                    socialActivityCounter.getGroupId(),
2510                                    socialActivityCounter.getClassNameId(),
2511                                    socialActivityCounter.getClassPK(),
2512                                    socialActivityCounter.getName(),
2513                                    socialActivityCounter.getOwnerType(),
2514                                    socialActivityCounter.getStartPeriod()
2515                            }, socialActivityCounter);
2516    
2517                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_E,
2518                            new Object[] {
2519                                    socialActivityCounter.getGroupId(),
2520                                    socialActivityCounter.getClassNameId(),
2521                                    socialActivityCounter.getClassPK(),
2522                                    socialActivityCounter.getName(),
2523                                    socialActivityCounter.getOwnerType(),
2524                                    socialActivityCounter.getEndPeriod()
2525                            }, socialActivityCounter);
2526    
2527                    socialActivityCounter.resetOriginalValues();
2528            }
2529    
2530            /**
2531             * Caches the social activity counters in the entity cache if it is enabled.
2532             *
2533             * @param socialActivityCounters the social activity counters
2534             */
2535            @Override
2536            public void cacheResult(List<SocialActivityCounter> socialActivityCounters) {
2537                    for (SocialActivityCounter socialActivityCounter : socialActivityCounters) {
2538                            if (entityCache.getResult(
2539                                                    SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
2540                                                    SocialActivityCounterImpl.class,
2541                                                    socialActivityCounter.getPrimaryKey()) == null) {
2542                                    cacheResult(socialActivityCounter);
2543                            }
2544                            else {
2545                                    socialActivityCounter.resetOriginalValues();
2546                            }
2547                    }
2548            }
2549    
2550            /**
2551             * Clears the cache for all social activity counters.
2552             *
2553             * <p>
2554             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
2555             * </p>
2556             */
2557            @Override
2558            public void clearCache() {
2559                    entityCache.clearCache(SocialActivityCounterImpl.class);
2560    
2561                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
2562                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2563                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2564            }
2565    
2566            /**
2567             * Clears the cache for the social activity counter.
2568             *
2569             * <p>
2570             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
2571             * </p>
2572             */
2573            @Override
2574            public void clearCache(SocialActivityCounter socialActivityCounter) {
2575                    entityCache.removeResult(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
2576                            SocialActivityCounterImpl.class,
2577                            socialActivityCounter.getPrimaryKey());
2578    
2579                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2580                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2581    
2582                    clearUniqueFindersCache((SocialActivityCounterModelImpl)socialActivityCounter);
2583            }
2584    
2585            @Override
2586            public void clearCache(List<SocialActivityCounter> socialActivityCounters) {
2587                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2588                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2589    
2590                    for (SocialActivityCounter socialActivityCounter : socialActivityCounters) {
2591                            entityCache.removeResult(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
2592                                    SocialActivityCounterImpl.class,
2593                                    socialActivityCounter.getPrimaryKey());
2594    
2595                            clearUniqueFindersCache((SocialActivityCounterModelImpl)socialActivityCounter);
2596                    }
2597            }
2598    
2599            protected void cacheUniqueFindersCache(
2600                    SocialActivityCounterModelImpl socialActivityCounterModelImpl,
2601                    boolean isNew) {
2602                    if (isNew) {
2603                            Object[] args = new Object[] {
2604                                            socialActivityCounterModelImpl.getGroupId(),
2605                                            socialActivityCounterModelImpl.getClassNameId(),
2606                                            socialActivityCounterModelImpl.getClassPK(),
2607                                            socialActivityCounterModelImpl.getName(),
2608                                            socialActivityCounterModelImpl.getOwnerType(),
2609                                            socialActivityCounterModelImpl.getStartPeriod()
2610                                    };
2611    
2612                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_C_C_N_O_S, args,
2613                                    Long.valueOf(1));
2614                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_S, args,
2615                                    socialActivityCounterModelImpl);
2616    
2617                            args = new Object[] {
2618                                            socialActivityCounterModelImpl.getGroupId(),
2619                                            socialActivityCounterModelImpl.getClassNameId(),
2620                                            socialActivityCounterModelImpl.getClassPK(),
2621                                            socialActivityCounterModelImpl.getName(),
2622                                            socialActivityCounterModelImpl.getOwnerType(),
2623                                            socialActivityCounterModelImpl.getEndPeriod()
2624                                    };
2625    
2626                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_C_C_N_O_E, args,
2627                                    Long.valueOf(1));
2628                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_E, args,
2629                                    socialActivityCounterModelImpl);
2630                    }
2631                    else {
2632                            if ((socialActivityCounterModelImpl.getColumnBitmask() &
2633                                            FINDER_PATH_FETCH_BY_G_C_C_N_O_S.getColumnBitmask()) != 0) {
2634                                    Object[] args = new Object[] {
2635                                                    socialActivityCounterModelImpl.getGroupId(),
2636                                                    socialActivityCounterModelImpl.getClassNameId(),
2637                                                    socialActivityCounterModelImpl.getClassPK(),
2638                                                    socialActivityCounterModelImpl.getName(),
2639                                                    socialActivityCounterModelImpl.getOwnerType(),
2640                                                    socialActivityCounterModelImpl.getStartPeriod()
2641                                            };
2642    
2643                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_C_C_N_O_S, args,
2644                                            Long.valueOf(1));
2645                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_S, args,
2646                                            socialActivityCounterModelImpl);
2647                            }
2648    
2649                            if ((socialActivityCounterModelImpl.getColumnBitmask() &
2650                                            FINDER_PATH_FETCH_BY_G_C_C_N_O_E.getColumnBitmask()) != 0) {
2651                                    Object[] args = new Object[] {
2652                                                    socialActivityCounterModelImpl.getGroupId(),
2653                                                    socialActivityCounterModelImpl.getClassNameId(),
2654                                                    socialActivityCounterModelImpl.getClassPK(),
2655                                                    socialActivityCounterModelImpl.getName(),
2656                                                    socialActivityCounterModelImpl.getOwnerType(),
2657                                                    socialActivityCounterModelImpl.getEndPeriod()
2658                                            };
2659    
2660                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_C_C_N_O_E, args,
2661                                            Long.valueOf(1));
2662                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_E, args,
2663                                            socialActivityCounterModelImpl);
2664                            }
2665                    }
2666            }
2667    
2668            protected void clearUniqueFindersCache(
2669                    SocialActivityCounterModelImpl socialActivityCounterModelImpl) {
2670                    Object[] args = new Object[] {
2671                                    socialActivityCounterModelImpl.getGroupId(),
2672                                    socialActivityCounterModelImpl.getClassNameId(),
2673                                    socialActivityCounterModelImpl.getClassPK(),
2674                                    socialActivityCounterModelImpl.getName(),
2675                                    socialActivityCounterModelImpl.getOwnerType(),
2676                                    socialActivityCounterModelImpl.getStartPeriod()
2677                            };
2678    
2679                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_C_N_O_S, args);
2680                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_S, args);
2681    
2682                    if ((socialActivityCounterModelImpl.getColumnBitmask() &
2683                                    FINDER_PATH_FETCH_BY_G_C_C_N_O_S.getColumnBitmask()) != 0) {
2684                            args = new Object[] {
2685                                            socialActivityCounterModelImpl.getOriginalGroupId(),
2686                                            socialActivityCounterModelImpl.getOriginalClassNameId(),
2687                                            socialActivityCounterModelImpl.getOriginalClassPK(),
2688                                            socialActivityCounterModelImpl.getOriginalName(),
2689                                            socialActivityCounterModelImpl.getOriginalOwnerType(),
2690                                            socialActivityCounterModelImpl.getOriginalStartPeriod()
2691                                    };
2692    
2693                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_C_N_O_S, args);
2694                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_S, args);
2695                    }
2696    
2697                    args = new Object[] {
2698                                    socialActivityCounterModelImpl.getGroupId(),
2699                                    socialActivityCounterModelImpl.getClassNameId(),
2700                                    socialActivityCounterModelImpl.getClassPK(),
2701                                    socialActivityCounterModelImpl.getName(),
2702                                    socialActivityCounterModelImpl.getOwnerType(),
2703                                    socialActivityCounterModelImpl.getEndPeriod()
2704                            };
2705    
2706                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_C_N_O_E, args);
2707                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_E, args);
2708    
2709                    if ((socialActivityCounterModelImpl.getColumnBitmask() &
2710                                    FINDER_PATH_FETCH_BY_G_C_C_N_O_E.getColumnBitmask()) != 0) {
2711                            args = new Object[] {
2712                                            socialActivityCounterModelImpl.getOriginalGroupId(),
2713                                            socialActivityCounterModelImpl.getOriginalClassNameId(),
2714                                            socialActivityCounterModelImpl.getOriginalClassPK(),
2715                                            socialActivityCounterModelImpl.getOriginalName(),
2716                                            socialActivityCounterModelImpl.getOriginalOwnerType(),
2717                                            socialActivityCounterModelImpl.getOriginalEndPeriod()
2718                                    };
2719    
2720                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_C_N_O_E, args);
2721                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_C_C_N_O_E, args);
2722                    }
2723            }
2724    
2725            /**
2726             * Creates a new social activity counter with the primary key. Does not add the social activity counter to the database.
2727             *
2728             * @param activityCounterId the primary key for the new social activity counter
2729             * @return the new social activity counter
2730             */
2731            @Override
2732            public SocialActivityCounter create(long activityCounterId) {
2733                    SocialActivityCounter socialActivityCounter = new SocialActivityCounterImpl();
2734    
2735                    socialActivityCounter.setNew(true);
2736                    socialActivityCounter.setPrimaryKey(activityCounterId);
2737    
2738                    return socialActivityCounter;
2739            }
2740    
2741            /**
2742             * Removes the social activity counter with the primary key from the database. Also notifies the appropriate model listeners.
2743             *
2744             * @param activityCounterId the primary key of the social activity counter
2745             * @return the social activity counter that was removed
2746             * @throws NoSuchActivityCounterException if a social activity counter with the primary key could not be found
2747             */
2748            @Override
2749            public SocialActivityCounter remove(long activityCounterId)
2750                    throws NoSuchActivityCounterException {
2751                    return remove((Serializable)activityCounterId);
2752            }
2753    
2754            /**
2755             * Removes the social activity counter with the primary key from the database. Also notifies the appropriate model listeners.
2756             *
2757             * @param primaryKey the primary key of the social activity counter
2758             * @return the social activity counter that was removed
2759             * @throws NoSuchActivityCounterException if a social activity counter with the primary key could not be found
2760             */
2761            @Override
2762            public SocialActivityCounter remove(Serializable primaryKey)
2763                    throws NoSuchActivityCounterException {
2764                    Session session = null;
2765    
2766                    try {
2767                            session = openSession();
2768    
2769                            SocialActivityCounter socialActivityCounter = (SocialActivityCounter)session.get(SocialActivityCounterImpl.class,
2770                                            primaryKey);
2771    
2772                            if (socialActivityCounter == null) {
2773                                    if (_log.isWarnEnabled()) {
2774                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2775                                    }
2776    
2777                                    throw new NoSuchActivityCounterException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2778                                            primaryKey);
2779                            }
2780    
2781                            return remove(socialActivityCounter);
2782                    }
2783                    catch (NoSuchActivityCounterException nsee) {
2784                            throw nsee;
2785                    }
2786                    catch (Exception e) {
2787                            throw processException(e);
2788                    }
2789                    finally {
2790                            closeSession(session);
2791                    }
2792            }
2793    
2794            @Override
2795            protected SocialActivityCounter removeImpl(
2796                    SocialActivityCounter socialActivityCounter) {
2797                    socialActivityCounter = toUnwrappedModel(socialActivityCounter);
2798    
2799                    Session session = null;
2800    
2801                    try {
2802                            session = openSession();
2803    
2804                            if (!session.contains(socialActivityCounter)) {
2805                                    socialActivityCounter = (SocialActivityCounter)session.get(SocialActivityCounterImpl.class,
2806                                                    socialActivityCounter.getPrimaryKeyObj());
2807                            }
2808    
2809                            if (socialActivityCounter != null) {
2810                                    session.delete(socialActivityCounter);
2811                            }
2812                    }
2813                    catch (Exception e) {
2814                            throw processException(e);
2815                    }
2816                    finally {
2817                            closeSession(session);
2818                    }
2819    
2820                    if (socialActivityCounter != null) {
2821                            clearCache(socialActivityCounter);
2822                    }
2823    
2824                    return socialActivityCounter;
2825            }
2826    
2827            @Override
2828            public SocialActivityCounter updateImpl(
2829                    SocialActivityCounter socialActivityCounter) {
2830                    socialActivityCounter = toUnwrappedModel(socialActivityCounter);
2831    
2832                    boolean isNew = socialActivityCounter.isNew();
2833    
2834                    SocialActivityCounterModelImpl socialActivityCounterModelImpl = (SocialActivityCounterModelImpl)socialActivityCounter;
2835    
2836                    Session session = null;
2837    
2838                    try {
2839                            session = openSession();
2840    
2841                            if (socialActivityCounter.isNew()) {
2842                                    session.save(socialActivityCounter);
2843    
2844                                    socialActivityCounter.setNew(false);
2845                            }
2846                            else {
2847                                    socialActivityCounter = (SocialActivityCounter)session.merge(socialActivityCounter);
2848                            }
2849                    }
2850                    catch (Exception e) {
2851                            throw processException(e);
2852                    }
2853                    finally {
2854                            closeSession(session);
2855                    }
2856    
2857                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2858    
2859                    if (isNew || !SocialActivityCounterModelImpl.COLUMN_BITMASK_ENABLED) {
2860                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2861                    }
2862    
2863                    else {
2864                            if ((socialActivityCounterModelImpl.getColumnBitmask() &
2865                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2866                                    Object[] args = new Object[] {
2867                                                    socialActivityCounterModelImpl.getOriginalGroupId()
2868                                            };
2869    
2870                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2871                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2872                                            args);
2873    
2874                                    args = new Object[] { socialActivityCounterModelImpl.getGroupId() };
2875    
2876                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2877                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2878                                            args);
2879                            }
2880    
2881                            if ((socialActivityCounterModelImpl.getColumnBitmask() &
2882                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
2883                                    Object[] args = new Object[] {
2884                                                    socialActivityCounterModelImpl.getOriginalClassNameId(),
2885                                                    socialActivityCounterModelImpl.getOriginalClassPK()
2886                                            };
2887    
2888                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
2889                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
2890                                            args);
2891    
2892                                    args = new Object[] {
2893                                                    socialActivityCounterModelImpl.getClassNameId(),
2894                                                    socialActivityCounterModelImpl.getClassPK()
2895                                            };
2896    
2897                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
2898                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
2899                                            args);
2900                            }
2901    
2902                            if ((socialActivityCounterModelImpl.getColumnBitmask() &
2903                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_O.getColumnBitmask()) != 0) {
2904                                    Object[] args = new Object[] {
2905                                                    socialActivityCounterModelImpl.getOriginalGroupId(),
2906                                                    socialActivityCounterModelImpl.getOriginalClassNameId(),
2907                                                    socialActivityCounterModelImpl.getOriginalClassPK(),
2908                                                    socialActivityCounterModelImpl.getOriginalOwnerType()
2909                                            };
2910    
2911                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_C_O, args);
2912                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_O,
2913                                            args);
2914    
2915                                    args = new Object[] {
2916                                                    socialActivityCounterModelImpl.getGroupId(),
2917                                                    socialActivityCounterModelImpl.getClassNameId(),
2918                                                    socialActivityCounterModelImpl.getClassPK(),
2919                                                    socialActivityCounterModelImpl.getOwnerType()
2920                                            };
2921    
2922                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_C_O, args);
2923                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_O,
2924                                            args);
2925                            }
2926                    }
2927    
2928                    entityCache.putResult(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
2929                            SocialActivityCounterImpl.class,
2930                            socialActivityCounter.getPrimaryKey(), socialActivityCounter, false);
2931    
2932                    clearUniqueFindersCache(socialActivityCounterModelImpl);
2933                    cacheUniqueFindersCache(socialActivityCounterModelImpl, isNew);
2934    
2935                    socialActivityCounter.resetOriginalValues();
2936    
2937                    return socialActivityCounter;
2938            }
2939    
2940            protected SocialActivityCounter toUnwrappedModel(
2941                    SocialActivityCounter socialActivityCounter) {
2942                    if (socialActivityCounter instanceof SocialActivityCounterImpl) {
2943                            return socialActivityCounter;
2944                    }
2945    
2946                    SocialActivityCounterImpl socialActivityCounterImpl = new SocialActivityCounterImpl();
2947    
2948                    socialActivityCounterImpl.setNew(socialActivityCounter.isNew());
2949                    socialActivityCounterImpl.setPrimaryKey(socialActivityCounter.getPrimaryKey());
2950    
2951                    socialActivityCounterImpl.setActivityCounterId(socialActivityCounter.getActivityCounterId());
2952                    socialActivityCounterImpl.setGroupId(socialActivityCounter.getGroupId());
2953                    socialActivityCounterImpl.setCompanyId(socialActivityCounter.getCompanyId());
2954                    socialActivityCounterImpl.setClassNameId(socialActivityCounter.getClassNameId());
2955                    socialActivityCounterImpl.setClassPK(socialActivityCounter.getClassPK());
2956                    socialActivityCounterImpl.setName(socialActivityCounter.getName());
2957                    socialActivityCounterImpl.setOwnerType(socialActivityCounter.getOwnerType());
2958                    socialActivityCounterImpl.setCurrentValue(socialActivityCounter.getCurrentValue());
2959                    socialActivityCounterImpl.setTotalValue(socialActivityCounter.getTotalValue());
2960                    socialActivityCounterImpl.setGraceValue(socialActivityCounter.getGraceValue());
2961                    socialActivityCounterImpl.setStartPeriod(socialActivityCounter.getStartPeriod());
2962                    socialActivityCounterImpl.setEndPeriod(socialActivityCounter.getEndPeriod());
2963                    socialActivityCounterImpl.setActive(socialActivityCounter.isActive());
2964    
2965                    return socialActivityCounterImpl;
2966            }
2967    
2968            /**
2969             * Returns the social activity counter with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2970             *
2971             * @param primaryKey the primary key of the social activity counter
2972             * @return the social activity counter
2973             * @throws NoSuchActivityCounterException if a social activity counter with the primary key could not be found
2974             */
2975            @Override
2976            public SocialActivityCounter findByPrimaryKey(Serializable primaryKey)
2977                    throws NoSuchActivityCounterException {
2978                    SocialActivityCounter socialActivityCounter = fetchByPrimaryKey(primaryKey);
2979    
2980                    if (socialActivityCounter == null) {
2981                            if (_log.isWarnEnabled()) {
2982                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2983                            }
2984    
2985                            throw new NoSuchActivityCounterException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2986                                    primaryKey);
2987                    }
2988    
2989                    return socialActivityCounter;
2990            }
2991    
2992            /**
2993             * Returns the social activity counter with the primary key or throws a {@link NoSuchActivityCounterException} if it could not be found.
2994             *
2995             * @param activityCounterId the primary key of the social activity counter
2996             * @return the social activity counter
2997             * @throws NoSuchActivityCounterException if a social activity counter with the primary key could not be found
2998             */
2999            @Override
3000            public SocialActivityCounter findByPrimaryKey(long activityCounterId)
3001                    throws NoSuchActivityCounterException {
3002                    return findByPrimaryKey((Serializable)activityCounterId);
3003            }
3004    
3005            /**
3006             * Returns the social activity counter with the primary key or returns <code>null</code> if it could not be found.
3007             *
3008             * @param primaryKey the primary key of the social activity counter
3009             * @return the social activity counter, or <code>null</code> if a social activity counter with the primary key could not be found
3010             */
3011            @Override
3012            public SocialActivityCounter fetchByPrimaryKey(Serializable primaryKey) {
3013                    SocialActivityCounter socialActivityCounter = (SocialActivityCounter)entityCache.getResult(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
3014                                    SocialActivityCounterImpl.class, primaryKey);
3015    
3016                    if (socialActivityCounter == _nullSocialActivityCounter) {
3017                            return null;
3018                    }
3019    
3020                    if (socialActivityCounter == null) {
3021                            Session session = null;
3022    
3023                            try {
3024                                    session = openSession();
3025    
3026                                    socialActivityCounter = (SocialActivityCounter)session.get(SocialActivityCounterImpl.class,
3027                                                    primaryKey);
3028    
3029                                    if (socialActivityCounter != null) {
3030                                            cacheResult(socialActivityCounter);
3031                                    }
3032                                    else {
3033                                            entityCache.putResult(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
3034                                                    SocialActivityCounterImpl.class, primaryKey,
3035                                                    _nullSocialActivityCounter);
3036                                    }
3037                            }
3038                            catch (Exception e) {
3039                                    entityCache.removeResult(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
3040                                            SocialActivityCounterImpl.class, primaryKey);
3041    
3042                                    throw processException(e);
3043                            }
3044                            finally {
3045                                    closeSession(session);
3046                            }
3047                    }
3048    
3049                    return socialActivityCounter;
3050            }
3051    
3052            /**
3053             * Returns the social activity counter with the primary key or returns <code>null</code> if it could not be found.
3054             *
3055             * @param activityCounterId the primary key of the social activity counter
3056             * @return the social activity counter, or <code>null</code> if a social activity counter with the primary key could not be found
3057             */
3058            @Override
3059            public SocialActivityCounter fetchByPrimaryKey(long activityCounterId) {
3060                    return fetchByPrimaryKey((Serializable)activityCounterId);
3061            }
3062    
3063            @Override
3064            public Map<Serializable, SocialActivityCounter> fetchByPrimaryKeys(
3065                    Set<Serializable> primaryKeys) {
3066                    if (primaryKeys.isEmpty()) {
3067                            return Collections.emptyMap();
3068                    }
3069    
3070                    Map<Serializable, SocialActivityCounter> map = new HashMap<Serializable, SocialActivityCounter>();
3071    
3072                    if (primaryKeys.size() == 1) {
3073                            Iterator<Serializable> iterator = primaryKeys.iterator();
3074    
3075                            Serializable primaryKey = iterator.next();
3076    
3077                            SocialActivityCounter socialActivityCounter = fetchByPrimaryKey(primaryKey);
3078    
3079                            if (socialActivityCounter != null) {
3080                                    map.put(primaryKey, socialActivityCounter);
3081                            }
3082    
3083                            return map;
3084                    }
3085    
3086                    Set<Serializable> uncachedPrimaryKeys = null;
3087    
3088                    for (Serializable primaryKey : primaryKeys) {
3089                            SocialActivityCounter socialActivityCounter = (SocialActivityCounter)entityCache.getResult(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
3090                                            SocialActivityCounterImpl.class, primaryKey);
3091    
3092                            if (socialActivityCounter == null) {
3093                                    if (uncachedPrimaryKeys == null) {
3094                                            uncachedPrimaryKeys = new HashSet<Serializable>();
3095                                    }
3096    
3097                                    uncachedPrimaryKeys.add(primaryKey);
3098                            }
3099                            else {
3100                                    map.put(primaryKey, socialActivityCounter);
3101                            }
3102                    }
3103    
3104                    if (uncachedPrimaryKeys == null) {
3105                            return map;
3106                    }
3107    
3108                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
3109                                    1);
3110    
3111                    query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE_PKS_IN);
3112    
3113                    for (Serializable primaryKey : uncachedPrimaryKeys) {
3114                            query.append(String.valueOf(primaryKey));
3115    
3116                            query.append(StringPool.COMMA);
3117                    }
3118    
3119                    query.setIndex(query.index() - 1);
3120    
3121                    query.append(StringPool.CLOSE_PARENTHESIS);
3122    
3123                    String sql = query.toString();
3124    
3125                    Session session = null;
3126    
3127                    try {
3128                            session = openSession();
3129    
3130                            Query q = session.createQuery(sql);
3131    
3132                            for (SocialActivityCounter socialActivityCounter : (List<SocialActivityCounter>)q.list()) {
3133                                    map.put(socialActivityCounter.getPrimaryKeyObj(),
3134                                            socialActivityCounter);
3135    
3136                                    cacheResult(socialActivityCounter);
3137    
3138                                    uncachedPrimaryKeys.remove(socialActivityCounter.getPrimaryKeyObj());
3139                            }
3140    
3141                            for (Serializable primaryKey : uncachedPrimaryKeys) {
3142                                    entityCache.putResult(SocialActivityCounterModelImpl.ENTITY_CACHE_ENABLED,
3143                                            SocialActivityCounterImpl.class, primaryKey,
3144                                            _nullSocialActivityCounter);
3145                            }
3146                    }
3147                    catch (Exception e) {
3148                            throw processException(e);
3149                    }
3150                    finally {
3151                            closeSession(session);
3152                    }
3153    
3154                    return map;
3155            }
3156    
3157            /**
3158             * Returns all the social activity counters.
3159             *
3160             * @return the social activity counters
3161             */
3162            @Override
3163            public List<SocialActivityCounter> findAll() {
3164                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3165            }
3166    
3167            /**
3168             * Returns a range of all the social activity counters.
3169             *
3170             * <p>
3171             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3172             * </p>
3173             *
3174             * @param start the lower bound of the range of social activity counters
3175             * @param end the upper bound of the range of social activity counters (not inclusive)
3176             * @return the range of social activity counters
3177             */
3178            @Override
3179            public List<SocialActivityCounter> findAll(int start, int end) {
3180                    return findAll(start, end, null);
3181            }
3182    
3183            /**
3184             * Returns an ordered range of all the social activity counters.
3185             *
3186             * <p>
3187             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3188             * </p>
3189             *
3190             * @param start the lower bound of the range of social activity counters
3191             * @param end the upper bound of the range of social activity counters (not inclusive)
3192             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3193             * @return the ordered range of social activity counters
3194             */
3195            @Override
3196            public List<SocialActivityCounter> findAll(int start, int end,
3197                    OrderByComparator<SocialActivityCounter> orderByComparator) {
3198                    return findAll(start, end, orderByComparator, true);
3199            }
3200    
3201            /**
3202             * Returns an ordered range of all the social activity counters.
3203             *
3204             * <p>
3205             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityCounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3206             * </p>
3207             *
3208             * @param start the lower bound of the range of social activity counters
3209             * @param end the upper bound of the range of social activity counters (not inclusive)
3210             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3211             * @param retrieveFromCache whether to retrieve from the finder cache
3212             * @return the ordered range of social activity counters
3213             */
3214            @Override
3215            public List<SocialActivityCounter> findAll(int start, int end,
3216                    OrderByComparator<SocialActivityCounter> orderByComparator,
3217                    boolean retrieveFromCache) {
3218                    boolean pagination = true;
3219                    FinderPath finderPath = null;
3220                    Object[] finderArgs = null;
3221    
3222                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3223                                    (orderByComparator == null)) {
3224                            pagination = false;
3225                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3226                            finderArgs = FINDER_ARGS_EMPTY;
3227                    }
3228                    else {
3229                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3230                            finderArgs = new Object[] { start, end, orderByComparator };
3231                    }
3232    
3233                    List<SocialActivityCounter> list = null;
3234    
3235                    if (retrieveFromCache) {
3236                            list = (List<SocialActivityCounter>)finderCache.getResult(finderPath,
3237                                            finderArgs, this);
3238                    }
3239    
3240                    if (list == null) {
3241                            StringBundler query = null;
3242                            String sql = null;
3243    
3244                            if (orderByComparator != null) {
3245                                    query = new StringBundler(2 +
3246                                                    (orderByComparator.getOrderByFields().length * 3));
3247    
3248                                    query.append(_SQL_SELECT_SOCIALACTIVITYCOUNTER);
3249    
3250                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3251                                            orderByComparator);
3252    
3253                                    sql = query.toString();
3254                            }
3255                            else {
3256                                    sql = _SQL_SELECT_SOCIALACTIVITYCOUNTER;
3257    
3258                                    if (pagination) {
3259                                            sql = sql.concat(SocialActivityCounterModelImpl.ORDER_BY_JPQL);
3260                                    }
3261                            }
3262    
3263                            Session session = null;
3264    
3265                            try {
3266                                    session = openSession();
3267    
3268                                    Query q = session.createQuery(sql);
3269    
3270                                    if (!pagination) {
3271                                            list = (List<SocialActivityCounter>)QueryUtil.list(q,
3272                                                            getDialect(), start, end, false);
3273    
3274                                            Collections.sort(list);
3275    
3276                                            list = Collections.unmodifiableList(list);
3277                                    }
3278                                    else {
3279                                            list = (List<SocialActivityCounter>)QueryUtil.list(q,
3280                                                            getDialect(), start, end);
3281                                    }
3282    
3283                                    cacheResult(list);
3284    
3285                                    finderCache.putResult(finderPath, finderArgs, list);
3286                            }
3287                            catch (Exception e) {
3288                                    finderCache.removeResult(finderPath, finderArgs);
3289    
3290                                    throw processException(e);
3291                            }
3292                            finally {
3293                                    closeSession(session);
3294                            }
3295                    }
3296    
3297                    return list;
3298            }
3299    
3300            /**
3301             * Removes all the social activity counters from the database.
3302             *
3303             */
3304            @Override
3305            public void removeAll() {
3306                    for (SocialActivityCounter socialActivityCounter : findAll()) {
3307                            remove(socialActivityCounter);
3308                    }
3309            }
3310    
3311            /**
3312             * Returns the number of social activity counters.
3313             *
3314             * @return the number of social activity counters
3315             */
3316            @Override
3317            public int countAll() {
3318                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
3319                                    FINDER_ARGS_EMPTY, this);
3320    
3321                    if (count == null) {
3322                            Session session = null;
3323    
3324                            try {
3325                                    session = openSession();
3326    
3327                                    Query q = session.createQuery(_SQL_COUNT_SOCIALACTIVITYCOUNTER);
3328    
3329                                    count = (Long)q.uniqueResult();
3330    
3331                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
3332                                            count);
3333                            }
3334                            catch (Exception e) {
3335                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
3336                                            FINDER_ARGS_EMPTY);
3337    
3338                                    throw processException(e);
3339                            }
3340                            finally {
3341                                    closeSession(session);
3342                            }
3343                    }
3344    
3345                    return count.intValue();
3346            }
3347    
3348            @Override
3349            public Set<String> getBadColumnNames() {
3350                    return _badColumnNames;
3351            }
3352    
3353            @Override
3354            protected Map<String, Integer> getTableColumnsMap() {
3355                    return SocialActivityCounterModelImpl.TABLE_COLUMNS_MAP;
3356            }
3357    
3358            /**
3359             * Initializes the social activity counter persistence.
3360             */
3361            public void afterPropertiesSet() {
3362            }
3363    
3364            public void destroy() {
3365                    entityCache.removeCache(SocialActivityCounterImpl.class.getName());
3366                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
3367                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3368                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3369            }
3370    
3371            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
3372            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
3373            private static final String _SQL_SELECT_SOCIALACTIVITYCOUNTER = "SELECT socialActivityCounter FROM SocialActivityCounter socialActivityCounter";
3374            private static final String _SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE_PKS_IN = "SELECT socialActivityCounter FROM SocialActivityCounter socialActivityCounter WHERE activityCounterId IN (";
3375            private static final String _SQL_SELECT_SOCIALACTIVITYCOUNTER_WHERE = "SELECT socialActivityCounter FROM SocialActivityCounter socialActivityCounter WHERE ";
3376            private static final String _SQL_COUNT_SOCIALACTIVITYCOUNTER = "SELECT COUNT(socialActivityCounter) FROM SocialActivityCounter socialActivityCounter";
3377            private static final String _SQL_COUNT_SOCIALACTIVITYCOUNTER_WHERE = "SELECT COUNT(socialActivityCounter) FROM SocialActivityCounter socialActivityCounter WHERE ";
3378            private static final String _ORDER_BY_ENTITY_ALIAS = "socialActivityCounter.";
3379            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialActivityCounter exists with the primary key ";
3380            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialActivityCounter exists with the key {";
3381            private static final Log _log = LogFactoryUtil.getLog(SocialActivityCounterPersistenceImpl.class);
3382            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3383                                    "active"
3384                            });
3385            private static final SocialActivityCounter _nullSocialActivityCounter = new SocialActivityCounterImpl() {
3386                            @Override
3387                            public Object clone() {
3388                                    return this;
3389                            }
3390    
3391                            @Override
3392                            public CacheModel<SocialActivityCounter> toCacheModel() {
3393                                    return _nullSocialActivityCounterCacheModel;
3394                            }
3395                    };
3396    
3397            private static final CacheModel<SocialActivityCounter> _nullSocialActivityCounterCacheModel =
3398                    new CacheModel<SocialActivityCounter>() {
3399                            @Override
3400                            public SocialActivityCounter toEntityModel() {
3401                                    return _nullSocialActivityCounter;
3402                            }
3403                    };
3404    }