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