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