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