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