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