001    /**
002     * Copyright (c) 2000-2012 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.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchSubscriptionException;
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.model.Subscription;
040    import com.liferay.portal.model.impl.SubscriptionImpl;
041    import com.liferay.portal.model.impl.SubscriptionModelImpl;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
045    import com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence;
046    import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
047    
048    import java.io.Serializable;
049    
050    import java.util.ArrayList;
051    import java.util.Collections;
052    import java.util.List;
053    
054    /**
055     * The persistence implementation for the subscription service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see SubscriptionPersistence
063     * @see SubscriptionUtil
064     * @generated
065     */
066    public class SubscriptionPersistenceImpl extends BasePersistenceImpl<Subscription>
067            implements SubscriptionPersistence {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link SubscriptionUtil} to access the subscription persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
072             */
073            public static final String FINDER_CLASS_NAME_ENTITY = SubscriptionImpl.class.getName();
074            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List1";
076            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List2";
078            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
079                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
081                            new String[] {
082                                    Long.class.getName(),
083                                    
084                            "java.lang.Integer", "java.lang.Integer",
085                                    "com.liferay.portal.kernel.util.OrderByComparator"
086                            });
087            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
088                    new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
089                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
091                            new String[] { Long.class.getName() },
092                            SubscriptionModelImpl.USERID_COLUMN_BITMASK);
093            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
094                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
095                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
096                            new String[] { Long.class.getName() });
097            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
098                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C",
100                            new String[] {
101                                    Long.class.getName(), Long.class.getName(),
102                                    
103                            "java.lang.Integer", "java.lang.Integer",
104                                    "com.liferay.portal.kernel.util.OrderByComparator"
105                            });
106            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
107                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C",
109                            new String[] { Long.class.getName(), Long.class.getName() },
110                            SubscriptionModelImpl.USERID_COLUMN_BITMASK |
111                            SubscriptionModelImpl.CLASSNAMEID_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_U_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
113                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C",
115                            new String[] { Long.class.getName(), Long.class.getName() });
116            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
117                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
118                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_C",
119                            new String[] {
120                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
121                                    
122                            "java.lang.Integer", "java.lang.Integer",
123                                    "com.liferay.portal.kernel.util.OrderByComparator"
124                            });
125            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
126                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
127                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_C",
128                            new String[] {
129                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
130                            },
131                            SubscriptionModelImpl.COMPANYID_COLUMN_BITMASK |
132                            SubscriptionModelImpl.CLASSNAMEID_COLUMN_BITMASK |
133                            SubscriptionModelImpl.CLASSPK_COLUMN_BITMASK);
134            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
135                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
136                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
137                            new String[] {
138                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
139                            });
140            public static final FinderPath FINDER_PATH_FETCH_BY_C_U_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
141                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
142                            FINDER_CLASS_NAME_ENTITY, "fetchByC_U_C_C",
143                            new String[] {
144                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
145                                    Long.class.getName()
146                            },
147                            SubscriptionModelImpl.COMPANYID_COLUMN_BITMASK |
148                            SubscriptionModelImpl.USERID_COLUMN_BITMASK |
149                            SubscriptionModelImpl.CLASSNAMEID_COLUMN_BITMASK |
150                            SubscriptionModelImpl.CLASSPK_COLUMN_BITMASK);
151            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
152                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_C_C",
154                            new String[] {
155                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
156                                    Long.class.getName()
157                            });
158            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
159                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
160                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
161            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
162                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
164            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
165                            SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
166                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
167    
168            /**
169             * Caches the subscription in the entity cache if it is enabled.
170             *
171             * @param subscription the subscription
172             */
173            public void cacheResult(Subscription subscription) {
174                    EntityCacheUtil.putResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
175                            SubscriptionImpl.class, subscription.getPrimaryKey(), subscription);
176    
177                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
178                            new Object[] {
179                                    Long.valueOf(subscription.getCompanyId()),
180                                    Long.valueOf(subscription.getUserId()),
181                                    Long.valueOf(subscription.getClassNameId()),
182                                    Long.valueOf(subscription.getClassPK())
183                            }, subscription);
184    
185                    subscription.resetOriginalValues();
186            }
187    
188            /**
189             * Caches the subscriptions in the entity cache if it is enabled.
190             *
191             * @param subscriptions the subscriptions
192             */
193            public void cacheResult(List<Subscription> subscriptions) {
194                    for (Subscription subscription : subscriptions) {
195                            if (EntityCacheUtil.getResult(
196                                                    SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
197                                                    SubscriptionImpl.class, subscription.getPrimaryKey()) == null) {
198                                    cacheResult(subscription);
199                            }
200                            else {
201                                    subscription.resetOriginalValues();
202                            }
203                    }
204            }
205    
206            /**
207             * Clears the cache for all subscriptions.
208             *
209             * <p>
210             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
211             * </p>
212             */
213            @Override
214            public void clearCache() {
215                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
216                            CacheRegistryUtil.clear(SubscriptionImpl.class.getName());
217                    }
218    
219                    EntityCacheUtil.clearCache(SubscriptionImpl.class.getName());
220    
221                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
222                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
223                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
224            }
225    
226            /**
227             * Clears the cache for the subscription.
228             *
229             * <p>
230             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
231             * </p>
232             */
233            @Override
234            public void clearCache(Subscription subscription) {
235                    EntityCacheUtil.removeResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
236                            SubscriptionImpl.class, subscription.getPrimaryKey());
237    
238                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
239                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
240    
241                    clearUniqueFindersCache(subscription);
242            }
243    
244            @Override
245            public void clearCache(List<Subscription> subscriptions) {
246                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
247                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
248    
249                    for (Subscription subscription : subscriptions) {
250                            EntityCacheUtil.removeResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
251                                    SubscriptionImpl.class, subscription.getPrimaryKey());
252    
253                            clearUniqueFindersCache(subscription);
254                    }
255            }
256    
257            protected void clearUniqueFindersCache(Subscription subscription) {
258                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_C_C,
259                            new Object[] {
260                                    Long.valueOf(subscription.getCompanyId()),
261                                    Long.valueOf(subscription.getUserId()),
262                                    Long.valueOf(subscription.getClassNameId()),
263                                    Long.valueOf(subscription.getClassPK())
264                            });
265            }
266    
267            /**
268             * Creates a new subscription with the primary key. Does not add the subscription to the database.
269             *
270             * @param subscriptionId the primary key for the new subscription
271             * @return the new subscription
272             */
273            public Subscription create(long subscriptionId) {
274                    Subscription subscription = new SubscriptionImpl();
275    
276                    subscription.setNew(true);
277                    subscription.setPrimaryKey(subscriptionId);
278    
279                    return subscription;
280            }
281    
282            /**
283             * Removes the subscription with the primary key from the database. Also notifies the appropriate model listeners.
284             *
285             * @param subscriptionId the primary key of the subscription
286             * @return the subscription that was removed
287             * @throws com.liferay.portal.NoSuchSubscriptionException if a subscription with the primary key could not be found
288             * @throws SystemException if a system exception occurred
289             */
290            public Subscription remove(long subscriptionId)
291                    throws NoSuchSubscriptionException, SystemException {
292                    return remove(Long.valueOf(subscriptionId));
293            }
294    
295            /**
296             * Removes the subscription with the primary key from the database. Also notifies the appropriate model listeners.
297             *
298             * @param primaryKey the primary key of the subscription
299             * @return the subscription that was removed
300             * @throws com.liferay.portal.NoSuchSubscriptionException if a subscription with the primary key could not be found
301             * @throws SystemException if a system exception occurred
302             */
303            @Override
304            public Subscription remove(Serializable primaryKey)
305                    throws NoSuchSubscriptionException, SystemException {
306                    Session session = null;
307    
308                    try {
309                            session = openSession();
310    
311                            Subscription subscription = (Subscription)session.get(SubscriptionImpl.class,
312                                            primaryKey);
313    
314                            if (subscription == null) {
315                                    if (_log.isWarnEnabled()) {
316                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
317                                    }
318    
319                                    throw new NoSuchSubscriptionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
320                                            primaryKey);
321                            }
322    
323                            return remove(subscription);
324                    }
325                    catch (NoSuchSubscriptionException nsee) {
326                            throw nsee;
327                    }
328                    catch (Exception e) {
329                            throw processException(e);
330                    }
331                    finally {
332                            closeSession(session);
333                    }
334            }
335    
336            @Override
337            protected Subscription removeImpl(Subscription subscription)
338                    throws SystemException {
339                    subscription = toUnwrappedModel(subscription);
340    
341                    Session session = null;
342    
343                    try {
344                            session = openSession();
345    
346                            if (subscription.isCachedModel()) {
347                                    subscription = (Subscription)session.get(SubscriptionImpl.class,
348                                                    subscription.getPrimaryKeyObj());
349                            }
350    
351                            session.delete(subscription);
352                    }
353                    catch (Exception e) {
354                            throw processException(e);
355                    }
356                    finally {
357                            closeSession(session);
358                    }
359    
360                    clearCache(subscription);
361    
362                    return subscription;
363            }
364    
365            @Override
366            public Subscription updateImpl(
367                    com.liferay.portal.model.Subscription subscription)
368                    throws SystemException {
369                    subscription = toUnwrappedModel(subscription);
370    
371                    boolean isNew = subscription.isNew();
372    
373                    SubscriptionModelImpl subscriptionModelImpl = (SubscriptionModelImpl)subscription;
374    
375                    Session session = null;
376    
377                    try {
378                            session = openSession();
379    
380                            if (subscription.isNew()) {
381                                    session.save(subscription);
382    
383                                    subscription.setNew(false);
384                            }
385                            else {
386                                    session.merge(subscription);
387                            }
388                    }
389                    catch (Exception e) {
390                            throw processException(e);
391                    }
392                    finally {
393                            closeSession(session);
394                    }
395    
396                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
397    
398                    if (isNew || !SubscriptionModelImpl.COLUMN_BITMASK_ENABLED) {
399                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
400                    }
401    
402                    else {
403                            if ((subscriptionModelImpl.getColumnBitmask() &
404                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
405                                    Object[] args = new Object[] {
406                                                    Long.valueOf(subscriptionModelImpl.getOriginalUserId())
407                                            };
408    
409                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
410                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
411                                            args);
412    
413                                    args = new Object[] {
414                                                    Long.valueOf(subscriptionModelImpl.getUserId())
415                                            };
416    
417                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
418                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
419                                            args);
420                            }
421    
422                            if ((subscriptionModelImpl.getColumnBitmask() &
423                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C.getColumnBitmask()) != 0) {
424                                    Object[] args = new Object[] {
425                                                    Long.valueOf(subscriptionModelImpl.getOriginalUserId()),
426                                                    Long.valueOf(subscriptionModelImpl.getOriginalClassNameId())
427                                            };
428    
429                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C, args);
430                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C,
431                                            args);
432    
433                                    args = new Object[] {
434                                                    Long.valueOf(subscriptionModelImpl.getUserId()),
435                                                    Long.valueOf(subscriptionModelImpl.getClassNameId())
436                                            };
437    
438                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C, args);
439                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C,
440                                            args);
441                            }
442    
443                            if ((subscriptionModelImpl.getColumnBitmask() &
444                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C.getColumnBitmask()) != 0) {
445                                    Object[] args = new Object[] {
446                                                    Long.valueOf(subscriptionModelImpl.getOriginalCompanyId()),
447                                                    Long.valueOf(subscriptionModelImpl.getOriginalClassNameId()),
448                                                    Long.valueOf(subscriptionModelImpl.getOriginalClassPK())
449                                            };
450    
451                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
452                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
453                                            args);
454    
455                                    args = new Object[] {
456                                                    Long.valueOf(subscriptionModelImpl.getCompanyId()),
457                                                    Long.valueOf(subscriptionModelImpl.getClassNameId()),
458                                                    Long.valueOf(subscriptionModelImpl.getClassPK())
459                                            };
460    
461                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
462                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
463                                            args);
464                            }
465                    }
466    
467                    EntityCacheUtil.putResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
468                            SubscriptionImpl.class, subscription.getPrimaryKey(), subscription);
469    
470                    if (isNew) {
471                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
472                                    new Object[] {
473                                            Long.valueOf(subscription.getCompanyId()),
474                                            Long.valueOf(subscription.getUserId()),
475                                            Long.valueOf(subscription.getClassNameId()),
476                                            Long.valueOf(subscription.getClassPK())
477                                    }, subscription);
478                    }
479                    else {
480                            if ((subscriptionModelImpl.getColumnBitmask() &
481                                            FINDER_PATH_FETCH_BY_C_U_C_C.getColumnBitmask()) != 0) {
482                                    Object[] args = new Object[] {
483                                                    Long.valueOf(subscriptionModelImpl.getOriginalCompanyId()),
484                                                    Long.valueOf(subscriptionModelImpl.getOriginalUserId()),
485                                                    Long.valueOf(subscriptionModelImpl.getOriginalClassNameId()),
486                                                    Long.valueOf(subscriptionModelImpl.getOriginalClassPK())
487                                            };
488    
489                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_C_C, args);
490    
491                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_C_C, args);
492    
493                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
494                                            new Object[] {
495                                                    Long.valueOf(subscription.getCompanyId()),
496                                                    Long.valueOf(subscription.getUserId()),
497                                                    Long.valueOf(subscription.getClassNameId()),
498                                                    Long.valueOf(subscription.getClassPK())
499                                            }, subscription);
500                            }
501                    }
502    
503                    return subscription;
504            }
505    
506            protected Subscription toUnwrappedModel(Subscription subscription) {
507                    if (subscription instanceof SubscriptionImpl) {
508                            return subscription;
509                    }
510    
511                    SubscriptionImpl subscriptionImpl = new SubscriptionImpl();
512    
513                    subscriptionImpl.setNew(subscription.isNew());
514                    subscriptionImpl.setPrimaryKey(subscription.getPrimaryKey());
515    
516                    subscriptionImpl.setSubscriptionId(subscription.getSubscriptionId());
517                    subscriptionImpl.setCompanyId(subscription.getCompanyId());
518                    subscriptionImpl.setUserId(subscription.getUserId());
519                    subscriptionImpl.setUserName(subscription.getUserName());
520                    subscriptionImpl.setCreateDate(subscription.getCreateDate());
521                    subscriptionImpl.setModifiedDate(subscription.getModifiedDate());
522                    subscriptionImpl.setClassNameId(subscription.getClassNameId());
523                    subscriptionImpl.setClassPK(subscription.getClassPK());
524                    subscriptionImpl.setFrequency(subscription.getFrequency());
525    
526                    return subscriptionImpl;
527            }
528    
529            /**
530             * Returns the subscription with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
531             *
532             * @param primaryKey the primary key of the subscription
533             * @return the subscription
534             * @throws com.liferay.portal.NoSuchModelException if a subscription with the primary key could not be found
535             * @throws SystemException if a system exception occurred
536             */
537            @Override
538            public Subscription findByPrimaryKey(Serializable primaryKey)
539                    throws NoSuchModelException, SystemException {
540                    return findByPrimaryKey(((Long)primaryKey).longValue());
541            }
542    
543            /**
544             * Returns the subscription with the primary key or throws a {@link com.liferay.portal.NoSuchSubscriptionException} if it could not be found.
545             *
546             * @param subscriptionId the primary key of the subscription
547             * @return the subscription
548             * @throws com.liferay.portal.NoSuchSubscriptionException if a subscription with the primary key could not be found
549             * @throws SystemException if a system exception occurred
550             */
551            public Subscription findByPrimaryKey(long subscriptionId)
552                    throws NoSuchSubscriptionException, SystemException {
553                    Subscription subscription = fetchByPrimaryKey(subscriptionId);
554    
555                    if (subscription == null) {
556                            if (_log.isWarnEnabled()) {
557                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + subscriptionId);
558                            }
559    
560                            throw new NoSuchSubscriptionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
561                                    subscriptionId);
562                    }
563    
564                    return subscription;
565            }
566    
567            /**
568             * Returns the subscription with the primary key or returns <code>null</code> if it could not be found.
569             *
570             * @param primaryKey the primary key of the subscription
571             * @return the subscription, or <code>null</code> if a subscription with the primary key could not be found
572             * @throws SystemException if a system exception occurred
573             */
574            @Override
575            public Subscription fetchByPrimaryKey(Serializable primaryKey)
576                    throws SystemException {
577                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
578            }
579    
580            /**
581             * Returns the subscription with the primary key or returns <code>null</code> if it could not be found.
582             *
583             * @param subscriptionId the primary key of the subscription
584             * @return the subscription, or <code>null</code> if a subscription with the primary key could not be found
585             * @throws SystemException if a system exception occurred
586             */
587            public Subscription fetchByPrimaryKey(long subscriptionId)
588                    throws SystemException {
589                    Subscription subscription = (Subscription)EntityCacheUtil.getResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
590                                    SubscriptionImpl.class, subscriptionId);
591    
592                    if (subscription == _nullSubscription) {
593                            return null;
594                    }
595    
596                    if (subscription == null) {
597                            Session session = null;
598    
599                            boolean hasException = false;
600    
601                            try {
602                                    session = openSession();
603    
604                                    subscription = (Subscription)session.get(SubscriptionImpl.class,
605                                                    Long.valueOf(subscriptionId));
606                            }
607                            catch (Exception e) {
608                                    hasException = true;
609    
610                                    throw processException(e);
611                            }
612                            finally {
613                                    if (subscription != null) {
614                                            cacheResult(subscription);
615                                    }
616                                    else if (!hasException) {
617                                            EntityCacheUtil.putResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
618                                                    SubscriptionImpl.class, subscriptionId,
619                                                    _nullSubscription);
620                                    }
621    
622                                    closeSession(session);
623                            }
624                    }
625    
626                    return subscription;
627            }
628    
629            /**
630             * Returns all the subscriptions where userId = &#63;.
631             *
632             * @param userId the user ID
633             * @return the matching subscriptions
634             * @throws SystemException if a system exception occurred
635             */
636            public List<Subscription> findByUserId(long userId)
637                    throws SystemException {
638                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
639            }
640    
641            /**
642             * Returns a range of all the subscriptions where userId = &#63;.
643             *
644             * <p>
645             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
646             * </p>
647             *
648             * @param userId the user ID
649             * @param start the lower bound of the range of subscriptions
650             * @param end the upper bound of the range of subscriptions (not inclusive)
651             * @return the range of matching subscriptions
652             * @throws SystemException if a system exception occurred
653             */
654            public List<Subscription> findByUserId(long userId, int start, int end)
655                    throws SystemException {
656                    return findByUserId(userId, start, end, null);
657            }
658    
659            /**
660             * Returns an ordered range of all the subscriptions where userId = &#63;.
661             *
662             * <p>
663             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
664             * </p>
665             *
666             * @param userId the user ID
667             * @param start the lower bound of the range of subscriptions
668             * @param end the upper bound of the range of subscriptions (not inclusive)
669             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
670             * @return the ordered range of matching subscriptions
671             * @throws SystemException if a system exception occurred
672             */
673            public List<Subscription> findByUserId(long userId, int start, int end,
674                    OrderByComparator orderByComparator) throws SystemException {
675                    FinderPath finderPath = null;
676                    Object[] finderArgs = null;
677    
678                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
679                                    (orderByComparator == null)) {
680                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
681                            finderArgs = new Object[] { userId };
682                    }
683                    else {
684                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
685                            finderArgs = new Object[] { userId, start, end, orderByComparator };
686                    }
687    
688                    List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
689                                    finderArgs, this);
690    
691                    if ((list != null) && !list.isEmpty()) {
692                            for (Subscription subscription : list) {
693                                    if ((userId != subscription.getUserId())) {
694                                            list = null;
695    
696                                            break;
697                                    }
698                            }
699                    }
700    
701                    if (list == null) {
702                            StringBundler query = null;
703    
704                            if (orderByComparator != null) {
705                                    query = new StringBundler(3 +
706                                                    (orderByComparator.getOrderByFields().length * 3));
707                            }
708                            else {
709                                    query = new StringBundler(2);
710                            }
711    
712                            query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
713    
714                            query.append(_FINDER_COLUMN_USERID_USERID_2);
715    
716                            if (orderByComparator != null) {
717                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
718                                            orderByComparator);
719                            }
720    
721                            String sql = query.toString();
722    
723                            Session session = null;
724    
725                            try {
726                                    session = openSession();
727    
728                                    Query q = session.createQuery(sql);
729    
730                                    QueryPos qPos = QueryPos.getInstance(q);
731    
732                                    qPos.add(userId);
733    
734                                    list = (List<Subscription>)QueryUtil.list(q, getDialect(),
735                                                    start, end);
736                            }
737                            catch (Exception e) {
738                                    throw processException(e);
739                            }
740                            finally {
741                                    if (list == null) {
742                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
743                                    }
744                                    else {
745                                            cacheResult(list);
746    
747                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
748                                    }
749    
750                                    closeSession(session);
751                            }
752                    }
753    
754                    return list;
755            }
756    
757            /**
758             * Returns the first subscription in the ordered set where userId = &#63;.
759             *
760             * @param userId the user ID
761             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
762             * @return the first matching subscription
763             * @throws com.liferay.portal.NoSuchSubscriptionException if a matching subscription could not be found
764             * @throws SystemException if a system exception occurred
765             */
766            public Subscription findByUserId_First(long userId,
767                    OrderByComparator orderByComparator)
768                    throws NoSuchSubscriptionException, SystemException {
769                    Subscription subscription = fetchByUserId_First(userId,
770                                    orderByComparator);
771    
772                    if (subscription != null) {
773                            return subscription;
774                    }
775    
776                    StringBundler msg = new StringBundler(4);
777    
778                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
779    
780                    msg.append("userId=");
781                    msg.append(userId);
782    
783                    msg.append(StringPool.CLOSE_CURLY_BRACE);
784    
785                    throw new NoSuchSubscriptionException(msg.toString());
786            }
787    
788            /**
789             * Returns the first subscription in the ordered set where userId = &#63;.
790             *
791             * @param userId the user ID
792             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
793             * @return the first matching subscription, or <code>null</code> if a matching subscription could not be found
794             * @throws SystemException if a system exception occurred
795             */
796            public Subscription fetchByUserId_First(long userId,
797                    OrderByComparator orderByComparator) throws SystemException {
798                    List<Subscription> list = findByUserId(userId, 0, 1, orderByComparator);
799    
800                    if (!list.isEmpty()) {
801                            return list.get(0);
802                    }
803    
804                    return null;
805            }
806    
807            /**
808             * Returns the last subscription in the ordered set where userId = &#63;.
809             *
810             * @param userId the user ID
811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
812             * @return the last matching subscription
813             * @throws com.liferay.portal.NoSuchSubscriptionException if a matching subscription could not be found
814             * @throws SystemException if a system exception occurred
815             */
816            public Subscription findByUserId_Last(long userId,
817                    OrderByComparator orderByComparator)
818                    throws NoSuchSubscriptionException, SystemException {
819                    Subscription subscription = fetchByUserId_Last(userId, orderByComparator);
820    
821                    if (subscription != null) {
822                            return subscription;
823                    }
824    
825                    StringBundler msg = new StringBundler(4);
826    
827                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
828    
829                    msg.append("userId=");
830                    msg.append(userId);
831    
832                    msg.append(StringPool.CLOSE_CURLY_BRACE);
833    
834                    throw new NoSuchSubscriptionException(msg.toString());
835            }
836    
837            /**
838             * Returns the last subscription in the ordered set where userId = &#63;.
839             *
840             * @param userId the user ID
841             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
842             * @return the last matching subscription, or <code>null</code> if a matching subscription could not be found
843             * @throws SystemException if a system exception occurred
844             */
845            public Subscription fetchByUserId_Last(long userId,
846                    OrderByComparator orderByComparator) throws SystemException {
847                    int count = countByUserId(userId);
848    
849                    List<Subscription> list = findByUserId(userId, count - 1, count,
850                                    orderByComparator);
851    
852                    if (!list.isEmpty()) {
853                            return list.get(0);
854                    }
855    
856                    return null;
857            }
858    
859            /**
860             * Returns the subscriptions before and after the current subscription in the ordered set where userId = &#63;.
861             *
862             * @param subscriptionId the primary key of the current subscription
863             * @param userId the user ID
864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
865             * @return the previous, current, and next subscription
866             * @throws com.liferay.portal.NoSuchSubscriptionException if a subscription with the primary key could not be found
867             * @throws SystemException if a system exception occurred
868             */
869            public Subscription[] findByUserId_PrevAndNext(long subscriptionId,
870                    long userId, OrderByComparator orderByComparator)
871                    throws NoSuchSubscriptionException, SystemException {
872                    Subscription subscription = findByPrimaryKey(subscriptionId);
873    
874                    Session session = null;
875    
876                    try {
877                            session = openSession();
878    
879                            Subscription[] array = new SubscriptionImpl[3];
880    
881                            array[0] = getByUserId_PrevAndNext(session, subscription, userId,
882                                            orderByComparator, true);
883    
884                            array[1] = subscription;
885    
886                            array[2] = getByUserId_PrevAndNext(session, subscription, userId,
887                                            orderByComparator, false);
888    
889                            return array;
890                    }
891                    catch (Exception e) {
892                            throw processException(e);
893                    }
894                    finally {
895                            closeSession(session);
896                    }
897            }
898    
899            protected Subscription getByUserId_PrevAndNext(Session session,
900                    Subscription subscription, long userId,
901                    OrderByComparator orderByComparator, boolean previous) {
902                    StringBundler query = null;
903    
904                    if (orderByComparator != null) {
905                            query = new StringBundler(6 +
906                                            (orderByComparator.getOrderByFields().length * 6));
907                    }
908                    else {
909                            query = new StringBundler(3);
910                    }
911    
912                    query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
913    
914                    query.append(_FINDER_COLUMN_USERID_USERID_2);
915    
916                    if (orderByComparator != null) {
917                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
918    
919                            if (orderByConditionFields.length > 0) {
920                                    query.append(WHERE_AND);
921                            }
922    
923                            for (int i = 0; i < orderByConditionFields.length; i++) {
924                                    query.append(_ORDER_BY_ENTITY_ALIAS);
925                                    query.append(orderByConditionFields[i]);
926    
927                                    if ((i + 1) < orderByConditionFields.length) {
928                                            if (orderByComparator.isAscending() ^ previous) {
929                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
930                                            }
931                                            else {
932                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
933                                            }
934                                    }
935                                    else {
936                                            if (orderByComparator.isAscending() ^ previous) {
937                                                    query.append(WHERE_GREATER_THAN);
938                                            }
939                                            else {
940                                                    query.append(WHERE_LESSER_THAN);
941                                            }
942                                    }
943                            }
944    
945                            query.append(ORDER_BY_CLAUSE);
946    
947                            String[] orderByFields = orderByComparator.getOrderByFields();
948    
949                            for (int i = 0; i < orderByFields.length; i++) {
950                                    query.append(_ORDER_BY_ENTITY_ALIAS);
951                                    query.append(orderByFields[i]);
952    
953                                    if ((i + 1) < orderByFields.length) {
954                                            if (orderByComparator.isAscending() ^ previous) {
955                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
956                                            }
957                                            else {
958                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
959                                            }
960                                    }
961                                    else {
962                                            if (orderByComparator.isAscending() ^ previous) {
963                                                    query.append(ORDER_BY_ASC);
964                                            }
965                                            else {
966                                                    query.append(ORDER_BY_DESC);
967                                            }
968                                    }
969                            }
970                    }
971    
972                    String sql = query.toString();
973    
974                    Query q = session.createQuery(sql);
975    
976                    q.setFirstResult(0);
977                    q.setMaxResults(2);
978    
979                    QueryPos qPos = QueryPos.getInstance(q);
980    
981                    qPos.add(userId);
982    
983                    if (orderByComparator != null) {
984                            Object[] values = orderByComparator.getOrderByConditionValues(subscription);
985    
986                            for (Object value : values) {
987                                    qPos.add(value);
988                            }
989                    }
990    
991                    List<Subscription> list = q.list();
992    
993                    if (list.size() == 2) {
994                            return list.get(1);
995                    }
996                    else {
997                            return null;
998                    }
999            }
1000    
1001            /**
1002             * Returns all the subscriptions where userId = &#63; and classNameId = &#63;.
1003             *
1004             * @param userId the user ID
1005             * @param classNameId the class name ID
1006             * @return the matching subscriptions
1007             * @throws SystemException if a system exception occurred
1008             */
1009            public List<Subscription> findByU_C(long userId, long classNameId)
1010                    throws SystemException {
1011                    return findByU_C(userId, classNameId, QueryUtil.ALL_POS,
1012                            QueryUtil.ALL_POS, null);
1013            }
1014    
1015            /**
1016             * Returns a range of all the subscriptions where userId = &#63; and classNameId = &#63;.
1017             *
1018             * <p>
1019             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1020             * </p>
1021             *
1022             * @param userId the user ID
1023             * @param classNameId the class name ID
1024             * @param start the lower bound of the range of subscriptions
1025             * @param end the upper bound of the range of subscriptions (not inclusive)
1026             * @return the range of matching subscriptions
1027             * @throws SystemException if a system exception occurred
1028             */
1029            public List<Subscription> findByU_C(long userId, long classNameId,
1030                    int start, int end) throws SystemException {
1031                    return findByU_C(userId, classNameId, start, end, null);
1032            }
1033    
1034            /**
1035             * Returns an ordered range of all the subscriptions where userId = &#63; and classNameId = &#63;.
1036             *
1037             * <p>
1038             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1039             * </p>
1040             *
1041             * @param userId the user ID
1042             * @param classNameId the class name ID
1043             * @param start the lower bound of the range of subscriptions
1044             * @param end the upper bound of the range of subscriptions (not inclusive)
1045             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1046             * @return the ordered range of matching subscriptions
1047             * @throws SystemException if a system exception occurred
1048             */
1049            public List<Subscription> findByU_C(long userId, long classNameId,
1050                    int start, int end, OrderByComparator orderByComparator)
1051                    throws SystemException {
1052                    FinderPath finderPath = null;
1053                    Object[] finderArgs = null;
1054    
1055                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1056                                    (orderByComparator == null)) {
1057                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C;
1058                            finderArgs = new Object[] { userId, classNameId };
1059                    }
1060                    else {
1061                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C;
1062                            finderArgs = new Object[] {
1063                                            userId, classNameId,
1064                                            
1065                                            start, end, orderByComparator
1066                                    };
1067                    }
1068    
1069                    List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
1070                                    finderArgs, this);
1071    
1072                    if ((list != null) && !list.isEmpty()) {
1073                            for (Subscription subscription : list) {
1074                                    if ((userId != subscription.getUserId()) ||
1075                                                    (classNameId != subscription.getClassNameId())) {
1076                                            list = null;
1077    
1078                                            break;
1079                                    }
1080                            }
1081                    }
1082    
1083                    if (list == null) {
1084                            StringBundler query = null;
1085    
1086                            if (orderByComparator != null) {
1087                                    query = new StringBundler(4 +
1088                                                    (orderByComparator.getOrderByFields().length * 3));
1089                            }
1090                            else {
1091                                    query = new StringBundler(3);
1092                            }
1093    
1094                            query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1095    
1096                            query.append(_FINDER_COLUMN_U_C_USERID_2);
1097    
1098                            query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
1099    
1100                            if (orderByComparator != null) {
1101                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1102                                            orderByComparator);
1103                            }
1104    
1105                            String sql = query.toString();
1106    
1107                            Session session = null;
1108    
1109                            try {
1110                                    session = openSession();
1111    
1112                                    Query q = session.createQuery(sql);
1113    
1114                                    QueryPos qPos = QueryPos.getInstance(q);
1115    
1116                                    qPos.add(userId);
1117    
1118                                    qPos.add(classNameId);
1119    
1120                                    list = (List<Subscription>)QueryUtil.list(q, getDialect(),
1121                                                    start, end);
1122                            }
1123                            catch (Exception e) {
1124                                    throw processException(e);
1125                            }
1126                            finally {
1127                                    if (list == null) {
1128                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1129                                    }
1130                                    else {
1131                                            cacheResult(list);
1132    
1133                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1134                                    }
1135    
1136                                    closeSession(session);
1137                            }
1138                    }
1139    
1140                    return list;
1141            }
1142    
1143            /**
1144             * Returns the first subscription in the ordered set where userId = &#63; and classNameId = &#63;.
1145             *
1146             * @param userId the user ID
1147             * @param classNameId the class name ID
1148             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1149             * @return the first matching subscription
1150             * @throws com.liferay.portal.NoSuchSubscriptionException if a matching subscription could not be found
1151             * @throws SystemException if a system exception occurred
1152             */
1153            public Subscription findByU_C_First(long userId, long classNameId,
1154                    OrderByComparator orderByComparator)
1155                    throws NoSuchSubscriptionException, SystemException {
1156                    Subscription subscription = fetchByU_C_First(userId, classNameId,
1157                                    orderByComparator);
1158    
1159                    if (subscription != null) {
1160                            return subscription;
1161                    }
1162    
1163                    StringBundler msg = new StringBundler(6);
1164    
1165                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1166    
1167                    msg.append("userId=");
1168                    msg.append(userId);
1169    
1170                    msg.append(", classNameId=");
1171                    msg.append(classNameId);
1172    
1173                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1174    
1175                    throw new NoSuchSubscriptionException(msg.toString());
1176            }
1177    
1178            /**
1179             * Returns the first subscription in the ordered set where userId = &#63; and classNameId = &#63;.
1180             *
1181             * @param userId the user ID
1182             * @param classNameId the class name ID
1183             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1184             * @return the first matching subscription, or <code>null</code> if a matching subscription could not be found
1185             * @throws SystemException if a system exception occurred
1186             */
1187            public Subscription fetchByU_C_First(long userId, long classNameId,
1188                    OrderByComparator orderByComparator) throws SystemException {
1189                    List<Subscription> list = findByU_C(userId, classNameId, 0, 1,
1190                                    orderByComparator);
1191    
1192                    if (!list.isEmpty()) {
1193                            return list.get(0);
1194                    }
1195    
1196                    return null;
1197            }
1198    
1199            /**
1200             * Returns the last subscription in the ordered set where userId = &#63; and classNameId = &#63;.
1201             *
1202             * @param userId the user ID
1203             * @param classNameId the class name ID
1204             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1205             * @return the last matching subscription
1206             * @throws com.liferay.portal.NoSuchSubscriptionException if a matching subscription could not be found
1207             * @throws SystemException if a system exception occurred
1208             */
1209            public Subscription findByU_C_Last(long userId, long classNameId,
1210                    OrderByComparator orderByComparator)
1211                    throws NoSuchSubscriptionException, SystemException {
1212                    Subscription subscription = fetchByU_C_Last(userId, classNameId,
1213                                    orderByComparator);
1214    
1215                    if (subscription != null) {
1216                            return subscription;
1217                    }
1218    
1219                    StringBundler msg = new StringBundler(6);
1220    
1221                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1222    
1223                    msg.append("userId=");
1224                    msg.append(userId);
1225    
1226                    msg.append(", classNameId=");
1227                    msg.append(classNameId);
1228    
1229                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1230    
1231                    throw new NoSuchSubscriptionException(msg.toString());
1232            }
1233    
1234            /**
1235             * Returns the last subscription in the ordered set where userId = &#63; and classNameId = &#63;.
1236             *
1237             * @param userId the user ID
1238             * @param classNameId the class name ID
1239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1240             * @return the last matching subscription, or <code>null</code> if a matching subscription could not be found
1241             * @throws SystemException if a system exception occurred
1242             */
1243            public Subscription fetchByU_C_Last(long userId, long classNameId,
1244                    OrderByComparator orderByComparator) throws SystemException {
1245                    int count = countByU_C(userId, classNameId);
1246    
1247                    List<Subscription> list = findByU_C(userId, classNameId, count - 1,
1248                                    count, orderByComparator);
1249    
1250                    if (!list.isEmpty()) {
1251                            return list.get(0);
1252                    }
1253    
1254                    return null;
1255            }
1256    
1257            /**
1258             * Returns the subscriptions before and after the current subscription in the ordered set where userId = &#63; and classNameId = &#63;.
1259             *
1260             * @param subscriptionId the primary key of the current subscription
1261             * @param userId the user ID
1262             * @param classNameId the class name ID
1263             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1264             * @return the previous, current, and next subscription
1265             * @throws com.liferay.portal.NoSuchSubscriptionException if a subscription with the primary key could not be found
1266             * @throws SystemException if a system exception occurred
1267             */
1268            public Subscription[] findByU_C_PrevAndNext(long subscriptionId,
1269                    long userId, long classNameId, OrderByComparator orderByComparator)
1270                    throws NoSuchSubscriptionException, SystemException {
1271                    Subscription subscription = findByPrimaryKey(subscriptionId);
1272    
1273                    Session session = null;
1274    
1275                    try {
1276                            session = openSession();
1277    
1278                            Subscription[] array = new SubscriptionImpl[3];
1279    
1280                            array[0] = getByU_C_PrevAndNext(session, subscription, userId,
1281                                            classNameId, orderByComparator, true);
1282    
1283                            array[1] = subscription;
1284    
1285                            array[2] = getByU_C_PrevAndNext(session, subscription, userId,
1286                                            classNameId, orderByComparator, false);
1287    
1288                            return array;
1289                    }
1290                    catch (Exception e) {
1291                            throw processException(e);
1292                    }
1293                    finally {
1294                            closeSession(session);
1295                    }
1296            }
1297    
1298            protected Subscription getByU_C_PrevAndNext(Session session,
1299                    Subscription subscription, long userId, long classNameId,
1300                    OrderByComparator orderByComparator, boolean previous) {
1301                    StringBundler query = null;
1302    
1303                    if (orderByComparator != null) {
1304                            query = new StringBundler(6 +
1305                                            (orderByComparator.getOrderByFields().length * 6));
1306                    }
1307                    else {
1308                            query = new StringBundler(3);
1309                    }
1310    
1311                    query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1312    
1313                    query.append(_FINDER_COLUMN_U_C_USERID_2);
1314    
1315                    query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
1316    
1317                    if (orderByComparator != null) {
1318                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1319    
1320                            if (orderByConditionFields.length > 0) {
1321                                    query.append(WHERE_AND);
1322                            }
1323    
1324                            for (int i = 0; i < orderByConditionFields.length; i++) {
1325                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1326                                    query.append(orderByConditionFields[i]);
1327    
1328                                    if ((i + 1) < orderByConditionFields.length) {
1329                                            if (orderByComparator.isAscending() ^ previous) {
1330                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1331                                            }
1332                                            else {
1333                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1334                                            }
1335                                    }
1336                                    else {
1337                                            if (orderByComparator.isAscending() ^ previous) {
1338                                                    query.append(WHERE_GREATER_THAN);
1339                                            }
1340                                            else {
1341                                                    query.append(WHERE_LESSER_THAN);
1342                                            }
1343                                    }
1344                            }
1345    
1346                            query.append(ORDER_BY_CLAUSE);
1347    
1348                            String[] orderByFields = orderByComparator.getOrderByFields();
1349    
1350                            for (int i = 0; i < orderByFields.length; i++) {
1351                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1352                                    query.append(orderByFields[i]);
1353    
1354                                    if ((i + 1) < orderByFields.length) {
1355                                            if (orderByComparator.isAscending() ^ previous) {
1356                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1357                                            }
1358                                            else {
1359                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1360                                            }
1361                                    }
1362                                    else {
1363                                            if (orderByComparator.isAscending() ^ previous) {
1364                                                    query.append(ORDER_BY_ASC);
1365                                            }
1366                                            else {
1367                                                    query.append(ORDER_BY_DESC);
1368                                            }
1369                                    }
1370                            }
1371                    }
1372    
1373                    String sql = query.toString();
1374    
1375                    Query q = session.createQuery(sql);
1376    
1377                    q.setFirstResult(0);
1378                    q.setMaxResults(2);
1379    
1380                    QueryPos qPos = QueryPos.getInstance(q);
1381    
1382                    qPos.add(userId);
1383    
1384                    qPos.add(classNameId);
1385    
1386                    if (orderByComparator != null) {
1387                            Object[] values = orderByComparator.getOrderByConditionValues(subscription);
1388    
1389                            for (Object value : values) {
1390                                    qPos.add(value);
1391                            }
1392                    }
1393    
1394                    List<Subscription> list = q.list();
1395    
1396                    if (list.size() == 2) {
1397                            return list.get(1);
1398                    }
1399                    else {
1400                            return null;
1401                    }
1402            }
1403    
1404            /**
1405             * Returns all the subscriptions where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1406             *
1407             * @param companyId the company ID
1408             * @param classNameId the class name ID
1409             * @param classPK the class p k
1410             * @return the matching subscriptions
1411             * @throws SystemException if a system exception occurred
1412             */
1413            public List<Subscription> findByC_C_C(long companyId, long classNameId,
1414                    long classPK) throws SystemException {
1415                    return findByC_C_C(companyId, classNameId, classPK, QueryUtil.ALL_POS,
1416                            QueryUtil.ALL_POS, null);
1417            }
1418    
1419            /**
1420             * Returns a range of all the subscriptions where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1421             *
1422             * <p>
1423             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1424             * </p>
1425             *
1426             * @param companyId the company ID
1427             * @param classNameId the class name ID
1428             * @param classPK the class p k
1429             * @param start the lower bound of the range of subscriptions
1430             * @param end the upper bound of the range of subscriptions (not inclusive)
1431             * @return the range of matching subscriptions
1432             * @throws SystemException if a system exception occurred
1433             */
1434            public List<Subscription> findByC_C_C(long companyId, long classNameId,
1435                    long classPK, int start, int end) throws SystemException {
1436                    return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1437            }
1438    
1439            /**
1440             * Returns an ordered range of all the subscriptions where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1441             *
1442             * <p>
1443             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1444             * </p>
1445             *
1446             * @param companyId the company ID
1447             * @param classNameId the class name ID
1448             * @param classPK the class p k
1449             * @param start the lower bound of the range of subscriptions
1450             * @param end the upper bound of the range of subscriptions (not inclusive)
1451             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1452             * @return the ordered range of matching subscriptions
1453             * @throws SystemException if a system exception occurred
1454             */
1455            public List<Subscription> findByC_C_C(long companyId, long classNameId,
1456                    long classPK, int start, int end, OrderByComparator orderByComparator)
1457                    throws SystemException {
1458                    FinderPath finderPath = null;
1459                    Object[] finderArgs = null;
1460    
1461                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1462                                    (orderByComparator == null)) {
1463                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C;
1464                            finderArgs = new Object[] { companyId, classNameId, classPK };
1465                    }
1466                    else {
1467                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C;
1468                            finderArgs = new Object[] {
1469                                            companyId, classNameId, classPK,
1470                                            
1471                                            start, end, orderByComparator
1472                                    };
1473                    }
1474    
1475                    List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
1476                                    finderArgs, this);
1477    
1478                    if ((list != null) && !list.isEmpty()) {
1479                            for (Subscription subscription : list) {
1480                                    if ((companyId != subscription.getCompanyId()) ||
1481                                                    (classNameId != subscription.getClassNameId()) ||
1482                                                    (classPK != subscription.getClassPK())) {
1483                                            list = null;
1484    
1485                                            break;
1486                                    }
1487                            }
1488                    }
1489    
1490                    if (list == null) {
1491                            StringBundler query = null;
1492    
1493                            if (orderByComparator != null) {
1494                                    query = new StringBundler(5 +
1495                                                    (orderByComparator.getOrderByFields().length * 3));
1496                            }
1497                            else {
1498                                    query = new StringBundler(4);
1499                            }
1500    
1501                            query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1502    
1503                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1504    
1505                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1506    
1507                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1508    
1509                            if (orderByComparator != null) {
1510                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1511                                            orderByComparator);
1512                            }
1513    
1514                            String sql = query.toString();
1515    
1516                            Session session = null;
1517    
1518                            try {
1519                                    session = openSession();
1520    
1521                                    Query q = session.createQuery(sql);
1522    
1523                                    QueryPos qPos = QueryPos.getInstance(q);
1524    
1525                                    qPos.add(companyId);
1526    
1527                                    qPos.add(classNameId);
1528    
1529                                    qPos.add(classPK);
1530    
1531                                    list = (List<Subscription>)QueryUtil.list(q, getDialect(),
1532                                                    start, end);
1533                            }
1534                            catch (Exception e) {
1535                                    throw processException(e);
1536                            }
1537                            finally {
1538                                    if (list == null) {
1539                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1540                                    }
1541                                    else {
1542                                            cacheResult(list);
1543    
1544                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1545                                    }
1546    
1547                                    closeSession(session);
1548                            }
1549                    }
1550    
1551                    return list;
1552            }
1553    
1554            /**
1555             * Returns the first subscription in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1556             *
1557             * @param companyId the company ID
1558             * @param classNameId the class name ID
1559             * @param classPK the class p k
1560             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1561             * @return the first matching subscription
1562             * @throws com.liferay.portal.NoSuchSubscriptionException if a matching subscription could not be found
1563             * @throws SystemException if a system exception occurred
1564             */
1565            public Subscription findByC_C_C_First(long companyId, long classNameId,
1566                    long classPK, OrderByComparator orderByComparator)
1567                    throws NoSuchSubscriptionException, SystemException {
1568                    Subscription subscription = fetchByC_C_C_First(companyId, classNameId,
1569                                    classPK, orderByComparator);
1570    
1571                    if (subscription != null) {
1572                            return subscription;
1573                    }
1574    
1575                    StringBundler msg = new StringBundler(8);
1576    
1577                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1578    
1579                    msg.append("companyId=");
1580                    msg.append(companyId);
1581    
1582                    msg.append(", classNameId=");
1583                    msg.append(classNameId);
1584    
1585                    msg.append(", classPK=");
1586                    msg.append(classPK);
1587    
1588                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1589    
1590                    throw new NoSuchSubscriptionException(msg.toString());
1591            }
1592    
1593            /**
1594             * Returns the first subscription in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1595             *
1596             * @param companyId the company ID
1597             * @param classNameId the class name ID
1598             * @param classPK the class p k
1599             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1600             * @return the first matching subscription, or <code>null</code> if a matching subscription could not be found
1601             * @throws SystemException if a system exception occurred
1602             */
1603            public Subscription fetchByC_C_C_First(long companyId, long classNameId,
1604                    long classPK, OrderByComparator orderByComparator)
1605                    throws SystemException {
1606                    List<Subscription> list = findByC_C_C(companyId, classNameId, classPK,
1607                                    0, 1, orderByComparator);
1608    
1609                    if (!list.isEmpty()) {
1610                            return list.get(0);
1611                    }
1612    
1613                    return null;
1614            }
1615    
1616            /**
1617             * Returns the last subscription in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1618             *
1619             * @param companyId the company ID
1620             * @param classNameId the class name ID
1621             * @param classPK the class p k
1622             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1623             * @return the last matching subscription
1624             * @throws com.liferay.portal.NoSuchSubscriptionException if a matching subscription could not be found
1625             * @throws SystemException if a system exception occurred
1626             */
1627            public Subscription findByC_C_C_Last(long companyId, long classNameId,
1628                    long classPK, OrderByComparator orderByComparator)
1629                    throws NoSuchSubscriptionException, SystemException {
1630                    Subscription subscription = fetchByC_C_C_Last(companyId, classNameId,
1631                                    classPK, orderByComparator);
1632    
1633                    if (subscription != null) {
1634                            return subscription;
1635                    }
1636    
1637                    StringBundler msg = new StringBundler(8);
1638    
1639                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1640    
1641                    msg.append("companyId=");
1642                    msg.append(companyId);
1643    
1644                    msg.append(", classNameId=");
1645                    msg.append(classNameId);
1646    
1647                    msg.append(", classPK=");
1648                    msg.append(classPK);
1649    
1650                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1651    
1652                    throw new NoSuchSubscriptionException(msg.toString());
1653            }
1654    
1655            /**
1656             * Returns the last subscription in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1657             *
1658             * @param companyId the company ID
1659             * @param classNameId the class name ID
1660             * @param classPK the class p k
1661             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1662             * @return the last matching subscription, or <code>null</code> if a matching subscription could not be found
1663             * @throws SystemException if a system exception occurred
1664             */
1665            public Subscription fetchByC_C_C_Last(long companyId, long classNameId,
1666                    long classPK, OrderByComparator orderByComparator)
1667                    throws SystemException {
1668                    int count = countByC_C_C(companyId, classNameId, classPK);
1669    
1670                    List<Subscription> list = findByC_C_C(companyId, classNameId, classPK,
1671                                    count - 1, count, orderByComparator);
1672    
1673                    if (!list.isEmpty()) {
1674                            return list.get(0);
1675                    }
1676    
1677                    return null;
1678            }
1679    
1680            /**
1681             * Returns the subscriptions before and after the current subscription in the ordered set where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1682             *
1683             * @param subscriptionId the primary key of the current subscription
1684             * @param companyId the company ID
1685             * @param classNameId the class name ID
1686             * @param classPK the class p k
1687             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1688             * @return the previous, current, and next subscription
1689             * @throws com.liferay.portal.NoSuchSubscriptionException if a subscription with the primary key could not be found
1690             * @throws SystemException if a system exception occurred
1691             */
1692            public Subscription[] findByC_C_C_PrevAndNext(long subscriptionId,
1693                    long companyId, long classNameId, long classPK,
1694                    OrderByComparator orderByComparator)
1695                    throws NoSuchSubscriptionException, SystemException {
1696                    Subscription subscription = findByPrimaryKey(subscriptionId);
1697    
1698                    Session session = null;
1699    
1700                    try {
1701                            session = openSession();
1702    
1703                            Subscription[] array = new SubscriptionImpl[3];
1704    
1705                            array[0] = getByC_C_C_PrevAndNext(session, subscription, companyId,
1706                                            classNameId, classPK, orderByComparator, true);
1707    
1708                            array[1] = subscription;
1709    
1710                            array[2] = getByC_C_C_PrevAndNext(session, subscription, companyId,
1711                                            classNameId, classPK, orderByComparator, false);
1712    
1713                            return array;
1714                    }
1715                    catch (Exception e) {
1716                            throw processException(e);
1717                    }
1718                    finally {
1719                            closeSession(session);
1720                    }
1721            }
1722    
1723            protected Subscription getByC_C_C_PrevAndNext(Session session,
1724                    Subscription subscription, long companyId, long classNameId,
1725                    long classPK, OrderByComparator orderByComparator, boolean previous) {
1726                    StringBundler query = null;
1727    
1728                    if (orderByComparator != null) {
1729                            query = new StringBundler(6 +
1730                                            (orderByComparator.getOrderByFields().length * 6));
1731                    }
1732                    else {
1733                            query = new StringBundler(3);
1734                    }
1735    
1736                    query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1737    
1738                    query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1739    
1740                    query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1741    
1742                    query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1743    
1744                    if (orderByComparator != null) {
1745                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1746    
1747                            if (orderByConditionFields.length > 0) {
1748                                    query.append(WHERE_AND);
1749                            }
1750    
1751                            for (int i = 0; i < orderByConditionFields.length; i++) {
1752                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1753                                    query.append(orderByConditionFields[i]);
1754    
1755                                    if ((i + 1) < orderByConditionFields.length) {
1756                                            if (orderByComparator.isAscending() ^ previous) {
1757                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1758                                            }
1759                                            else {
1760                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1761                                            }
1762                                    }
1763                                    else {
1764                                            if (orderByComparator.isAscending() ^ previous) {
1765                                                    query.append(WHERE_GREATER_THAN);
1766                                            }
1767                                            else {
1768                                                    query.append(WHERE_LESSER_THAN);
1769                                            }
1770                                    }
1771                            }
1772    
1773                            query.append(ORDER_BY_CLAUSE);
1774    
1775                            String[] orderByFields = orderByComparator.getOrderByFields();
1776    
1777                            for (int i = 0; i < orderByFields.length; i++) {
1778                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1779                                    query.append(orderByFields[i]);
1780    
1781                                    if ((i + 1) < orderByFields.length) {
1782                                            if (orderByComparator.isAscending() ^ previous) {
1783                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1784                                            }
1785                                            else {
1786                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1787                                            }
1788                                    }
1789                                    else {
1790                                            if (orderByComparator.isAscending() ^ previous) {
1791                                                    query.append(ORDER_BY_ASC);
1792                                            }
1793                                            else {
1794                                                    query.append(ORDER_BY_DESC);
1795                                            }
1796                                    }
1797                            }
1798                    }
1799    
1800                    String sql = query.toString();
1801    
1802                    Query q = session.createQuery(sql);
1803    
1804                    q.setFirstResult(0);
1805                    q.setMaxResults(2);
1806    
1807                    QueryPos qPos = QueryPos.getInstance(q);
1808    
1809                    qPos.add(companyId);
1810    
1811                    qPos.add(classNameId);
1812    
1813                    qPos.add(classPK);
1814    
1815                    if (orderByComparator != null) {
1816                            Object[] values = orderByComparator.getOrderByConditionValues(subscription);
1817    
1818                            for (Object value : values) {
1819                                    qPos.add(value);
1820                            }
1821                    }
1822    
1823                    List<Subscription> list = q.list();
1824    
1825                    if (list.size() == 2) {
1826                            return list.get(1);
1827                    }
1828                    else {
1829                            return null;
1830                    }
1831            }
1832    
1833            /**
1834             * Returns the subscription where companyId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portal.NoSuchSubscriptionException} if it could not be found.
1835             *
1836             * @param companyId the company ID
1837             * @param userId the user ID
1838             * @param classNameId the class name ID
1839             * @param classPK the class p k
1840             * @return the matching subscription
1841             * @throws com.liferay.portal.NoSuchSubscriptionException if a matching subscription could not be found
1842             * @throws SystemException if a system exception occurred
1843             */
1844            public Subscription findByC_U_C_C(long companyId, long userId,
1845                    long classNameId, long classPK)
1846                    throws NoSuchSubscriptionException, SystemException {
1847                    Subscription subscription = fetchByC_U_C_C(companyId, userId,
1848                                    classNameId, classPK);
1849    
1850                    if (subscription == null) {
1851                            StringBundler msg = new StringBundler(10);
1852    
1853                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1854    
1855                            msg.append("companyId=");
1856                            msg.append(companyId);
1857    
1858                            msg.append(", userId=");
1859                            msg.append(userId);
1860    
1861                            msg.append(", classNameId=");
1862                            msg.append(classNameId);
1863    
1864                            msg.append(", classPK=");
1865                            msg.append(classPK);
1866    
1867                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1868    
1869                            if (_log.isWarnEnabled()) {
1870                                    _log.warn(msg.toString());
1871                            }
1872    
1873                            throw new NoSuchSubscriptionException(msg.toString());
1874                    }
1875    
1876                    return subscription;
1877            }
1878    
1879            /**
1880             * Returns the subscription where companyId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1881             *
1882             * @param companyId the company ID
1883             * @param userId the user ID
1884             * @param classNameId the class name ID
1885             * @param classPK the class p k
1886             * @return the matching subscription, or <code>null</code> if a matching subscription could not be found
1887             * @throws SystemException if a system exception occurred
1888             */
1889            public Subscription fetchByC_U_C_C(long companyId, long userId,
1890                    long classNameId, long classPK) throws SystemException {
1891                    return fetchByC_U_C_C(companyId, userId, classNameId, classPK, true);
1892            }
1893    
1894            /**
1895             * Returns the subscription where companyId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1896             *
1897             * @param companyId the company ID
1898             * @param userId the user ID
1899             * @param classNameId the class name ID
1900             * @param classPK the class p k
1901             * @param retrieveFromCache whether to use the finder cache
1902             * @return the matching subscription, or <code>null</code> if a matching subscription could not be found
1903             * @throws SystemException if a system exception occurred
1904             */
1905            public Subscription fetchByC_U_C_C(long companyId, long userId,
1906                    long classNameId, long classPK, boolean retrieveFromCache)
1907                    throws SystemException {
1908                    Object[] finderArgs = new Object[] {
1909                                    companyId, userId, classNameId, classPK
1910                            };
1911    
1912                    Object result = null;
1913    
1914                    if (retrieveFromCache) {
1915                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1916                                            finderArgs, this);
1917                    }
1918    
1919                    if (result instanceof Subscription) {
1920                            Subscription subscription = (Subscription)result;
1921    
1922                            if ((companyId != subscription.getCompanyId()) ||
1923                                            (userId != subscription.getUserId()) ||
1924                                            (classNameId != subscription.getClassNameId()) ||
1925                                            (classPK != subscription.getClassPK())) {
1926                                    result = null;
1927                            }
1928                    }
1929    
1930                    if (result == null) {
1931                            StringBundler query = new StringBundler(5);
1932    
1933                            query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1934    
1935                            query.append(_FINDER_COLUMN_C_U_C_C_COMPANYID_2);
1936    
1937                            query.append(_FINDER_COLUMN_C_U_C_C_USERID_2);
1938    
1939                            query.append(_FINDER_COLUMN_C_U_C_C_CLASSNAMEID_2);
1940    
1941                            query.append(_FINDER_COLUMN_C_U_C_C_CLASSPK_2);
1942    
1943                            String sql = query.toString();
1944    
1945                            Session session = null;
1946    
1947                            try {
1948                                    session = openSession();
1949    
1950                                    Query q = session.createQuery(sql);
1951    
1952                                    QueryPos qPos = QueryPos.getInstance(q);
1953    
1954                                    qPos.add(companyId);
1955    
1956                                    qPos.add(userId);
1957    
1958                                    qPos.add(classNameId);
1959    
1960                                    qPos.add(classPK);
1961    
1962                                    List<Subscription> list = q.list();
1963    
1964                                    result = list;
1965    
1966                                    Subscription subscription = null;
1967    
1968                                    if (list.isEmpty()) {
1969                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1970                                                    finderArgs, list);
1971                                    }
1972                                    else {
1973                                            subscription = list.get(0);
1974    
1975                                            cacheResult(subscription);
1976    
1977                                            if ((subscription.getCompanyId() != companyId) ||
1978                                                            (subscription.getUserId() != userId) ||
1979                                                            (subscription.getClassNameId() != classNameId) ||
1980                                                            (subscription.getClassPK() != classPK)) {
1981                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1982                                                            finderArgs, subscription);
1983                                            }
1984                                    }
1985    
1986                                    return subscription;
1987                            }
1988                            catch (Exception e) {
1989                                    throw processException(e);
1990                            }
1991                            finally {
1992                                    if (result == null) {
1993                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1994                                                    finderArgs);
1995                                    }
1996    
1997                                    closeSession(session);
1998                            }
1999                    }
2000                    else {
2001                            if (result instanceof List<?>) {
2002                                    return null;
2003                            }
2004                            else {
2005                                    return (Subscription)result;
2006                            }
2007                    }
2008            }
2009    
2010            /**
2011             * Returns all the subscriptions.
2012             *
2013             * @return the subscriptions
2014             * @throws SystemException if a system exception occurred
2015             */
2016            public List<Subscription> findAll() throws SystemException {
2017                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2018            }
2019    
2020            /**
2021             * Returns a range of all the subscriptions.
2022             *
2023             * <p>
2024             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2025             * </p>
2026             *
2027             * @param start the lower bound of the range of subscriptions
2028             * @param end the upper bound of the range of subscriptions (not inclusive)
2029             * @return the range of subscriptions
2030             * @throws SystemException if a system exception occurred
2031             */
2032            public List<Subscription> findAll(int start, int end)
2033                    throws SystemException {
2034                    return findAll(start, end, null);
2035            }
2036    
2037            /**
2038             * Returns an ordered range of all the subscriptions.
2039             *
2040             * <p>
2041             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2042             * </p>
2043             *
2044             * @param start the lower bound of the range of subscriptions
2045             * @param end the upper bound of the range of subscriptions (not inclusive)
2046             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2047             * @return the ordered range of subscriptions
2048             * @throws SystemException if a system exception occurred
2049             */
2050            public List<Subscription> findAll(int start, int end,
2051                    OrderByComparator orderByComparator) throws SystemException {
2052                    FinderPath finderPath = null;
2053                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2054    
2055                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2056                                    (orderByComparator == null)) {
2057                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2058                            finderArgs = FINDER_ARGS_EMPTY;
2059                    }
2060                    else {
2061                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2062                            finderArgs = new Object[] { start, end, orderByComparator };
2063                    }
2064    
2065                    List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
2066                                    finderArgs, this);
2067    
2068                    if (list == null) {
2069                            StringBundler query = null;
2070                            String sql = null;
2071    
2072                            if (orderByComparator != null) {
2073                                    query = new StringBundler(2 +
2074                                                    (orderByComparator.getOrderByFields().length * 3));
2075    
2076                                    query.append(_SQL_SELECT_SUBSCRIPTION);
2077    
2078                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2079                                            orderByComparator);
2080    
2081                                    sql = query.toString();
2082                            }
2083                            else {
2084                                    sql = _SQL_SELECT_SUBSCRIPTION;
2085                            }
2086    
2087                            Session session = null;
2088    
2089                            try {
2090                                    session = openSession();
2091    
2092                                    Query q = session.createQuery(sql);
2093    
2094                                    if (orderByComparator == null) {
2095                                            list = (List<Subscription>)QueryUtil.list(q, getDialect(),
2096                                                            start, end, false);
2097    
2098                                            Collections.sort(list);
2099                                    }
2100                                    else {
2101                                            list = (List<Subscription>)QueryUtil.list(q, getDialect(),
2102                                                            start, end);
2103                                    }
2104                            }
2105                            catch (Exception e) {
2106                                    throw processException(e);
2107                            }
2108                            finally {
2109                                    if (list == null) {
2110                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2111                                    }
2112                                    else {
2113                                            cacheResult(list);
2114    
2115                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2116                                    }
2117    
2118                                    closeSession(session);
2119                            }
2120                    }
2121    
2122                    return list;
2123            }
2124    
2125            /**
2126             * Removes all the subscriptions where userId = &#63; from the database.
2127             *
2128             * @param userId the user ID
2129             * @throws SystemException if a system exception occurred
2130             */
2131            public void removeByUserId(long userId) throws SystemException {
2132                    for (Subscription subscription : findByUserId(userId)) {
2133                            remove(subscription);
2134                    }
2135            }
2136    
2137            /**
2138             * Removes all the subscriptions where userId = &#63; and classNameId = &#63; from the database.
2139             *
2140             * @param userId the user ID
2141             * @param classNameId the class name ID
2142             * @throws SystemException if a system exception occurred
2143             */
2144            public void removeByU_C(long userId, long classNameId)
2145                    throws SystemException {
2146                    for (Subscription subscription : findByU_C(userId, classNameId)) {
2147                            remove(subscription);
2148                    }
2149            }
2150    
2151            /**
2152             * Removes all the subscriptions where companyId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
2153             *
2154             * @param companyId the company ID
2155             * @param classNameId the class name ID
2156             * @param classPK the class p k
2157             * @throws SystemException if a system exception occurred
2158             */
2159            public void removeByC_C_C(long companyId, long classNameId, long classPK)
2160                    throws SystemException {
2161                    for (Subscription subscription : findByC_C_C(companyId, classNameId,
2162                                    classPK)) {
2163                            remove(subscription);
2164                    }
2165            }
2166    
2167            /**
2168             * Removes the subscription where companyId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
2169             *
2170             * @param companyId the company ID
2171             * @param userId the user ID
2172             * @param classNameId the class name ID
2173             * @param classPK the class p k
2174             * @return the subscription that was removed
2175             * @throws SystemException if a system exception occurred
2176             */
2177            public Subscription removeByC_U_C_C(long companyId, long userId,
2178                    long classNameId, long classPK)
2179                    throws NoSuchSubscriptionException, SystemException {
2180                    Subscription subscription = findByC_U_C_C(companyId, userId,
2181                                    classNameId, classPK);
2182    
2183                    return remove(subscription);
2184            }
2185    
2186            /**
2187             * Removes all the subscriptions from the database.
2188             *
2189             * @throws SystemException if a system exception occurred
2190             */
2191            public void removeAll() throws SystemException {
2192                    for (Subscription subscription : findAll()) {
2193                            remove(subscription);
2194                    }
2195            }
2196    
2197            /**
2198             * Returns the number of subscriptions where userId = &#63;.
2199             *
2200             * @param userId the user ID
2201             * @return the number of matching subscriptions
2202             * @throws SystemException if a system exception occurred
2203             */
2204            public int countByUserId(long userId) throws SystemException {
2205                    Object[] finderArgs = new Object[] { userId };
2206    
2207                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2208                                    finderArgs, this);
2209    
2210                    if (count == null) {
2211                            StringBundler query = new StringBundler(2);
2212    
2213                            query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
2214    
2215                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2216    
2217                            String sql = query.toString();
2218    
2219                            Session session = null;
2220    
2221                            try {
2222                                    session = openSession();
2223    
2224                                    Query q = session.createQuery(sql);
2225    
2226                                    QueryPos qPos = QueryPos.getInstance(q);
2227    
2228                                    qPos.add(userId);
2229    
2230                                    count = (Long)q.uniqueResult();
2231                            }
2232                            catch (Exception e) {
2233                                    throw processException(e);
2234                            }
2235                            finally {
2236                                    if (count == null) {
2237                                            count = Long.valueOf(0);
2238                                    }
2239    
2240                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2241                                            finderArgs, count);
2242    
2243                                    closeSession(session);
2244                            }
2245                    }
2246    
2247                    return count.intValue();
2248            }
2249    
2250            /**
2251             * Returns the number of subscriptions where userId = &#63; and classNameId = &#63;.
2252             *
2253             * @param userId the user ID
2254             * @param classNameId the class name ID
2255             * @return the number of matching subscriptions
2256             * @throws SystemException if a system exception occurred
2257             */
2258            public int countByU_C(long userId, long classNameId)
2259                    throws SystemException {
2260                    Object[] finderArgs = new Object[] { userId, classNameId };
2261    
2262                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C,
2263                                    finderArgs, this);
2264    
2265                    if (count == null) {
2266                            StringBundler query = new StringBundler(3);
2267    
2268                            query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
2269    
2270                            query.append(_FINDER_COLUMN_U_C_USERID_2);
2271    
2272                            query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
2273    
2274                            String sql = query.toString();
2275    
2276                            Session session = null;
2277    
2278                            try {
2279                                    session = openSession();
2280    
2281                                    Query q = session.createQuery(sql);
2282    
2283                                    QueryPos qPos = QueryPos.getInstance(q);
2284    
2285                                    qPos.add(userId);
2286    
2287                                    qPos.add(classNameId);
2288    
2289                                    count = (Long)q.uniqueResult();
2290                            }
2291                            catch (Exception e) {
2292                                    throw processException(e);
2293                            }
2294                            finally {
2295                                    if (count == null) {
2296                                            count = Long.valueOf(0);
2297                                    }
2298    
2299                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C, finderArgs,
2300                                            count);
2301    
2302                                    closeSession(session);
2303                            }
2304                    }
2305    
2306                    return count.intValue();
2307            }
2308    
2309            /**
2310             * Returns the number of subscriptions where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
2311             *
2312             * @param companyId the company ID
2313             * @param classNameId the class name ID
2314             * @param classPK the class p k
2315             * @return the number of matching subscriptions
2316             * @throws SystemException if a system exception occurred
2317             */
2318            public int countByC_C_C(long companyId, long classNameId, long classPK)
2319                    throws SystemException {
2320                    Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2321    
2322                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
2323                                    finderArgs, this);
2324    
2325                    if (count == null) {
2326                            StringBundler query = new StringBundler(4);
2327    
2328                            query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
2329    
2330                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2331    
2332                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2333    
2334                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2335    
2336                            String sql = query.toString();
2337    
2338                            Session session = null;
2339    
2340                            try {
2341                                    session = openSession();
2342    
2343                                    Query q = session.createQuery(sql);
2344    
2345                                    QueryPos qPos = QueryPos.getInstance(q);
2346    
2347                                    qPos.add(companyId);
2348    
2349                                    qPos.add(classNameId);
2350    
2351                                    qPos.add(classPK);
2352    
2353                                    count = (Long)q.uniqueResult();
2354                            }
2355                            catch (Exception e) {
2356                                    throw processException(e);
2357                            }
2358                            finally {
2359                                    if (count == null) {
2360                                            count = Long.valueOf(0);
2361                                    }
2362    
2363                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
2364                                            finderArgs, count);
2365    
2366                                    closeSession(session);
2367                            }
2368                    }
2369    
2370                    return count.intValue();
2371            }
2372    
2373            /**
2374             * Returns the number of subscriptions where companyId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63;.
2375             *
2376             * @param companyId the company ID
2377             * @param userId the user ID
2378             * @param classNameId the class name ID
2379             * @param classPK the class p k
2380             * @return the number of matching subscriptions
2381             * @throws SystemException if a system exception occurred
2382             */
2383            public int countByC_U_C_C(long companyId, long userId, long classNameId,
2384                    long classPK) throws SystemException {
2385                    Object[] finderArgs = new Object[] {
2386                                    companyId, userId, classNameId, classPK
2387                            };
2388    
2389                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U_C_C,
2390                                    finderArgs, this);
2391    
2392                    if (count == null) {
2393                            StringBundler query = new StringBundler(5);
2394    
2395                            query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
2396    
2397                            query.append(_FINDER_COLUMN_C_U_C_C_COMPANYID_2);
2398    
2399                            query.append(_FINDER_COLUMN_C_U_C_C_USERID_2);
2400    
2401                            query.append(_FINDER_COLUMN_C_U_C_C_CLASSNAMEID_2);
2402    
2403                            query.append(_FINDER_COLUMN_C_U_C_C_CLASSPK_2);
2404    
2405                            String sql = query.toString();
2406    
2407                            Session session = null;
2408    
2409                            try {
2410                                    session = openSession();
2411    
2412                                    Query q = session.createQuery(sql);
2413    
2414                                    QueryPos qPos = QueryPos.getInstance(q);
2415    
2416                                    qPos.add(companyId);
2417    
2418                                    qPos.add(userId);
2419    
2420                                    qPos.add(classNameId);
2421    
2422                                    qPos.add(classPK);
2423    
2424                                    count = (Long)q.uniqueResult();
2425                            }
2426                            catch (Exception e) {
2427                                    throw processException(e);
2428                            }
2429                            finally {
2430                                    if (count == null) {
2431                                            count = Long.valueOf(0);
2432                                    }
2433    
2434                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_C_C,
2435                                            finderArgs, count);
2436    
2437                                    closeSession(session);
2438                            }
2439                    }
2440    
2441                    return count.intValue();
2442            }
2443    
2444            /**
2445             * Returns the number of subscriptions.
2446             *
2447             * @return the number of subscriptions
2448             * @throws SystemException if a system exception occurred
2449             */
2450            public int countAll() throws SystemException {
2451                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2452                                    FINDER_ARGS_EMPTY, this);
2453    
2454                    if (count == null) {
2455                            Session session = null;
2456    
2457                            try {
2458                                    session = openSession();
2459    
2460                                    Query q = session.createQuery(_SQL_COUNT_SUBSCRIPTION);
2461    
2462                                    count = (Long)q.uniqueResult();
2463                            }
2464                            catch (Exception e) {
2465                                    throw processException(e);
2466                            }
2467                            finally {
2468                                    if (count == null) {
2469                                            count = Long.valueOf(0);
2470                                    }
2471    
2472                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2473                                            FINDER_ARGS_EMPTY, count);
2474    
2475                                    closeSession(session);
2476                            }
2477                    }
2478    
2479                    return count.intValue();
2480            }
2481    
2482            /**
2483             * Initializes the subscription persistence.
2484             */
2485            public void afterPropertiesSet() {
2486                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2487                                            com.liferay.portal.util.PropsUtil.get(
2488                                                    "value.object.listener.com.liferay.portal.model.Subscription")));
2489    
2490                    if (listenerClassNames.length > 0) {
2491                            try {
2492                                    List<ModelListener<Subscription>> listenersList = new ArrayList<ModelListener<Subscription>>();
2493    
2494                                    for (String listenerClassName : listenerClassNames) {
2495                                            listenersList.add((ModelListener<Subscription>)InstanceFactory.newInstance(
2496                                                            listenerClassName));
2497                                    }
2498    
2499                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2500                            }
2501                            catch (Exception e) {
2502                                    _log.error(e);
2503                            }
2504                    }
2505            }
2506    
2507            public void destroy() {
2508                    EntityCacheUtil.removeCache(SubscriptionImpl.class.getName());
2509                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2510                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2511            }
2512    
2513            @BeanReference(type = AccountPersistence.class)
2514            protected AccountPersistence accountPersistence;
2515            @BeanReference(type = AddressPersistence.class)
2516            protected AddressPersistence addressPersistence;
2517            @BeanReference(type = BrowserTrackerPersistence.class)
2518            protected BrowserTrackerPersistence browserTrackerPersistence;
2519            @BeanReference(type = ClassNamePersistence.class)
2520            protected ClassNamePersistence classNamePersistence;
2521            @BeanReference(type = ClusterGroupPersistence.class)
2522            protected ClusterGroupPersistence clusterGroupPersistence;
2523            @BeanReference(type = CompanyPersistence.class)
2524            protected CompanyPersistence companyPersistence;
2525            @BeanReference(type = ContactPersistence.class)
2526            protected ContactPersistence contactPersistence;
2527            @BeanReference(type = CountryPersistence.class)
2528            protected CountryPersistence countryPersistence;
2529            @BeanReference(type = EmailAddressPersistence.class)
2530            protected EmailAddressPersistence emailAddressPersistence;
2531            @BeanReference(type = GroupPersistence.class)
2532            protected GroupPersistence groupPersistence;
2533            @BeanReference(type = ImagePersistence.class)
2534            protected ImagePersistence imagePersistence;
2535            @BeanReference(type = LayoutPersistence.class)
2536            protected LayoutPersistence layoutPersistence;
2537            @BeanReference(type = LayoutBranchPersistence.class)
2538            protected LayoutBranchPersistence layoutBranchPersistence;
2539            @BeanReference(type = LayoutPrototypePersistence.class)
2540            protected LayoutPrototypePersistence layoutPrototypePersistence;
2541            @BeanReference(type = LayoutRevisionPersistence.class)
2542            protected LayoutRevisionPersistence layoutRevisionPersistence;
2543            @BeanReference(type = LayoutSetPersistence.class)
2544            protected LayoutSetPersistence layoutSetPersistence;
2545            @BeanReference(type = LayoutSetBranchPersistence.class)
2546            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2547            @BeanReference(type = LayoutSetPrototypePersistence.class)
2548            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2549            @BeanReference(type = ListTypePersistence.class)
2550            protected ListTypePersistence listTypePersistence;
2551            @BeanReference(type = LockPersistence.class)
2552            protected LockPersistence lockPersistence;
2553            @BeanReference(type = MembershipRequestPersistence.class)
2554            protected MembershipRequestPersistence membershipRequestPersistence;
2555            @BeanReference(type = OrganizationPersistence.class)
2556            protected OrganizationPersistence organizationPersistence;
2557            @BeanReference(type = OrgGroupRolePersistence.class)
2558            protected OrgGroupRolePersistence orgGroupRolePersistence;
2559            @BeanReference(type = OrgLaborPersistence.class)
2560            protected OrgLaborPersistence orgLaborPersistence;
2561            @BeanReference(type = PasswordPolicyPersistence.class)
2562            protected PasswordPolicyPersistence passwordPolicyPersistence;
2563            @BeanReference(type = PasswordPolicyRelPersistence.class)
2564            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2565            @BeanReference(type = PasswordTrackerPersistence.class)
2566            protected PasswordTrackerPersistence passwordTrackerPersistence;
2567            @BeanReference(type = PhonePersistence.class)
2568            protected PhonePersistence phonePersistence;
2569            @BeanReference(type = PluginSettingPersistence.class)
2570            protected PluginSettingPersistence pluginSettingPersistence;
2571            @BeanReference(type = PortalPreferencesPersistence.class)
2572            protected PortalPreferencesPersistence portalPreferencesPersistence;
2573            @BeanReference(type = PortletPersistence.class)
2574            protected PortletPersistence portletPersistence;
2575            @BeanReference(type = PortletItemPersistence.class)
2576            protected PortletItemPersistence portletItemPersistence;
2577            @BeanReference(type = PortletPreferencesPersistence.class)
2578            protected PortletPreferencesPersistence portletPreferencesPersistence;
2579            @BeanReference(type = RegionPersistence.class)
2580            protected RegionPersistence regionPersistence;
2581            @BeanReference(type = ReleasePersistence.class)
2582            protected ReleasePersistence releasePersistence;
2583            @BeanReference(type = RepositoryPersistence.class)
2584            protected RepositoryPersistence repositoryPersistence;
2585            @BeanReference(type = RepositoryEntryPersistence.class)
2586            protected RepositoryEntryPersistence repositoryEntryPersistence;
2587            @BeanReference(type = ResourceActionPersistence.class)
2588            protected ResourceActionPersistence resourceActionPersistence;
2589            @BeanReference(type = ResourceBlockPersistence.class)
2590            protected ResourceBlockPersistence resourceBlockPersistence;
2591            @BeanReference(type = ResourceBlockPermissionPersistence.class)
2592            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2593            @BeanReference(type = ResourcePermissionPersistence.class)
2594            protected ResourcePermissionPersistence resourcePermissionPersistence;
2595            @BeanReference(type = ResourceTypePermissionPersistence.class)
2596            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2597            @BeanReference(type = RolePersistence.class)
2598            protected RolePersistence rolePersistence;
2599            @BeanReference(type = ServiceComponentPersistence.class)
2600            protected ServiceComponentPersistence serviceComponentPersistence;
2601            @BeanReference(type = ShardPersistence.class)
2602            protected ShardPersistence shardPersistence;
2603            @BeanReference(type = SubscriptionPersistence.class)
2604            protected SubscriptionPersistence subscriptionPersistence;
2605            @BeanReference(type = TeamPersistence.class)
2606            protected TeamPersistence teamPersistence;
2607            @BeanReference(type = TicketPersistence.class)
2608            protected TicketPersistence ticketPersistence;
2609            @BeanReference(type = UserPersistence.class)
2610            protected UserPersistence userPersistence;
2611            @BeanReference(type = UserGroupPersistence.class)
2612            protected UserGroupPersistence userGroupPersistence;
2613            @BeanReference(type = UserGroupGroupRolePersistence.class)
2614            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2615            @BeanReference(type = UserGroupRolePersistence.class)
2616            protected UserGroupRolePersistence userGroupRolePersistence;
2617            @BeanReference(type = UserIdMapperPersistence.class)
2618            protected UserIdMapperPersistence userIdMapperPersistence;
2619            @BeanReference(type = UserNotificationEventPersistence.class)
2620            protected UserNotificationEventPersistence userNotificationEventPersistence;
2621            @BeanReference(type = UserTrackerPersistence.class)
2622            protected UserTrackerPersistence userTrackerPersistence;
2623            @BeanReference(type = UserTrackerPathPersistence.class)
2624            protected UserTrackerPathPersistence userTrackerPathPersistence;
2625            @BeanReference(type = VirtualHostPersistence.class)
2626            protected VirtualHostPersistence virtualHostPersistence;
2627            @BeanReference(type = WebDAVPropsPersistence.class)
2628            protected WebDAVPropsPersistence webDAVPropsPersistence;
2629            @BeanReference(type = WebsitePersistence.class)
2630            protected WebsitePersistence websitePersistence;
2631            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2632            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2633            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2634            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2635            @BeanReference(type = AssetEntryPersistence.class)
2636            protected AssetEntryPersistence assetEntryPersistence;
2637            @BeanReference(type = MBThreadPersistence.class)
2638            protected MBThreadPersistence mbThreadPersistence;
2639            @BeanReference(type = SocialActivityPersistence.class)
2640            protected SocialActivityPersistence socialActivityPersistence;
2641            private static final String _SQL_SELECT_SUBSCRIPTION = "SELECT subscription FROM Subscription subscription";
2642            private static final String _SQL_SELECT_SUBSCRIPTION_WHERE = "SELECT subscription FROM Subscription subscription WHERE ";
2643            private static final String _SQL_COUNT_SUBSCRIPTION = "SELECT COUNT(subscription) FROM Subscription subscription";
2644            private static final String _SQL_COUNT_SUBSCRIPTION_WHERE = "SELECT COUNT(subscription) FROM Subscription subscription WHERE ";
2645            private static final String _FINDER_COLUMN_USERID_USERID_2 = "subscription.userId = ?";
2646            private static final String _FINDER_COLUMN_U_C_USERID_2 = "subscription.userId = ? AND ";
2647            private static final String _FINDER_COLUMN_U_C_CLASSNAMEID_2 = "subscription.classNameId = ?";
2648            private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "subscription.companyId = ? AND ";
2649            private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "subscription.classNameId = ? AND ";
2650            private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "subscription.classPK = ?";
2651            private static final String _FINDER_COLUMN_C_U_C_C_COMPANYID_2 = "subscription.companyId = ? AND ";
2652            private static final String _FINDER_COLUMN_C_U_C_C_USERID_2 = "subscription.userId = ? AND ";
2653            private static final String _FINDER_COLUMN_C_U_C_C_CLASSNAMEID_2 = "subscription.classNameId = ? AND ";
2654            private static final String _FINDER_COLUMN_C_U_C_C_CLASSPK_2 = "subscription.classPK = ?";
2655            private static final String _ORDER_BY_ENTITY_ALIAS = "subscription.";
2656            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Subscription exists with the primary key ";
2657            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Subscription exists with the key {";
2658            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2659            private static Log _log = LogFactoryUtil.getLog(SubscriptionPersistenceImpl.class);
2660            private static Subscription _nullSubscription = new SubscriptionImpl() {
2661                            @Override
2662                            public Object clone() {
2663                                    return this;
2664                            }
2665    
2666                            @Override
2667                            public CacheModel<Subscription> toCacheModel() {
2668                                    return _nullSubscriptionCacheModel;
2669                            }
2670                    };
2671    
2672            private static CacheModel<Subscription> _nullSubscriptionCacheModel = new CacheModel<Subscription>() {
2673                            public Subscription toEntityModel() {
2674                                    return _nullSubscription;
2675                            }
2676                    };
2677    }