001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.NoSuchUserNotificationDeliveryException;
020    import com.liferay.portal.kernel.dao.orm.EntityCache;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCache;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.Session;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.Validator;
035    import com.liferay.portal.model.CacheModel;
036    import com.liferay.portal.model.MVCCModel;
037    import com.liferay.portal.model.UserNotificationDelivery;
038    import com.liferay.portal.model.impl.UserNotificationDeliveryImpl;
039    import com.liferay.portal.model.impl.UserNotificationDeliveryModelImpl;
040    import com.liferay.portal.service.persistence.UserNotificationDeliveryPersistence;
041    
042    import java.io.Serializable;
043    
044    import java.util.Collections;
045    import java.util.HashMap;
046    import java.util.HashSet;
047    import java.util.Iterator;
048    import java.util.List;
049    import java.util.Map;
050    import java.util.Set;
051    
052    /**
053     * The persistence implementation for the user notification delivery service.
054     *
055     * <p>
056     * Caching information and settings can be found in <code>portal.properties</code>
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see UserNotificationDeliveryPersistence
061     * @see com.liferay.portal.service.persistence.UserNotificationDeliveryUtil
062     * @generated
063     */
064    @ProviderType
065    public class UserNotificationDeliveryPersistenceImpl extends BasePersistenceImpl<UserNotificationDelivery>
066            implements UserNotificationDeliveryPersistence {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link UserNotificationDeliveryUtil} to access the user notification delivery persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
071             */
072            public static final String FINDER_CLASS_NAME_ENTITY = UserNotificationDeliveryImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List1";
075            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List2";
077            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
078                            UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
079                            UserNotificationDeliveryImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
082                            UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
083                            UserNotificationDeliveryImpl.class,
084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
086                            UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED, Long.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
089                            UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
090                            UserNotificationDeliveryImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
092                            new String[] {
093                                    Long.class.getName(),
094                                    
095                            Integer.class.getName(), Integer.class.getName(),
096                                    OrderByComparator.class.getName()
097                            });
098            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
099                    new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
100                            UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
101                            UserNotificationDeliveryImpl.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
103                            new String[] { Long.class.getName() },
104                            UserNotificationDeliveryModelImpl.USERID_COLUMN_BITMASK);
105            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
106                            UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED, Long.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
108                            new String[] { Long.class.getName() });
109    
110            /**
111             * Returns all the user notification deliveries where userId = &#63;.
112             *
113             * @param userId the user ID
114             * @return the matching user notification deliveries
115             */
116            @Override
117            public List<UserNotificationDelivery> findByUserId(long userId) {
118                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
119            }
120    
121            /**
122             * Returns a range of all the user notification deliveries where userId = &#63;.
123             *
124             * <p>
125             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserNotificationDeliveryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
126             * </p>
127             *
128             * @param userId the user ID
129             * @param start the lower bound of the range of user notification deliveries
130             * @param end the upper bound of the range of user notification deliveries (not inclusive)
131             * @return the range of matching user notification deliveries
132             */
133            @Override
134            public List<UserNotificationDelivery> findByUserId(long userId, int start,
135                    int end) {
136                    return findByUserId(userId, start, end, null);
137            }
138    
139            /**
140             * Returns an ordered range of all the user notification deliveries where userId = &#63;.
141             *
142             * <p>
143             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserNotificationDeliveryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
144             * </p>
145             *
146             * @param userId the user ID
147             * @param start the lower bound of the range of user notification deliveries
148             * @param end the upper bound of the range of user notification deliveries (not inclusive)
149             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
150             * @return the ordered range of matching user notification deliveries
151             */
152            @Override
153            public List<UserNotificationDelivery> findByUserId(long userId, int start,
154                    int end, OrderByComparator<UserNotificationDelivery> orderByComparator) {
155                    return findByUserId(userId, start, end, orderByComparator, true);
156            }
157    
158            /**
159             * Returns an ordered range of all the user notification deliveries where userId = &#63;.
160             *
161             * <p>
162             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserNotificationDeliveryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
163             * </p>
164             *
165             * @param userId the user ID
166             * @param start the lower bound of the range of user notification deliveries
167             * @param end the upper bound of the range of user notification deliveries (not inclusive)
168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
169             * @param retrieveFromCache whether to retrieve from the finder cache
170             * @return the ordered range of matching user notification deliveries
171             */
172            @Override
173            public List<UserNotificationDelivery> findByUserId(long userId, int start,
174                    int end, OrderByComparator<UserNotificationDelivery> orderByComparator,
175                    boolean retrieveFromCache) {
176                    boolean pagination = true;
177                    FinderPath finderPath = null;
178                    Object[] finderArgs = null;
179    
180                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
181                                    (orderByComparator == null)) {
182                            pagination = false;
183                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
184                            finderArgs = new Object[] { userId };
185                    }
186                    else {
187                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
188                            finderArgs = new Object[] { userId, start, end, orderByComparator };
189                    }
190    
191                    List<UserNotificationDelivery> list = null;
192    
193                    if (retrieveFromCache) {
194                            list = (List<UserNotificationDelivery>)finderCache.getResult(finderPath,
195                                            finderArgs, this);
196    
197                            if ((list != null) && !list.isEmpty()) {
198                                    for (UserNotificationDelivery userNotificationDelivery : list) {
199                                            if ((userId != userNotificationDelivery.getUserId())) {
200                                                    list = null;
201    
202                                                    break;
203                                            }
204                                    }
205                            }
206                    }
207    
208                    if (list == null) {
209                            StringBundler query = null;
210    
211                            if (orderByComparator != null) {
212                                    query = new StringBundler(3 +
213                                                    (orderByComparator.getOrderByFields().length * 3));
214                            }
215                            else {
216                                    query = new StringBundler(3);
217                            }
218    
219                            query.append(_SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE);
220    
221                            query.append(_FINDER_COLUMN_USERID_USERID_2);
222    
223                            if (orderByComparator != null) {
224                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
225                                            orderByComparator);
226                            }
227                            else
228                             if (pagination) {
229                                    query.append(UserNotificationDeliveryModelImpl.ORDER_BY_JPQL);
230                            }
231    
232                            String sql = query.toString();
233    
234                            Session session = null;
235    
236                            try {
237                                    session = openSession();
238    
239                                    Query q = session.createQuery(sql);
240    
241                                    QueryPos qPos = QueryPos.getInstance(q);
242    
243                                    qPos.add(userId);
244    
245                                    if (!pagination) {
246                                            list = (List<UserNotificationDelivery>)QueryUtil.list(q,
247                                                            getDialect(), start, end, false);
248    
249                                            Collections.sort(list);
250    
251                                            list = Collections.unmodifiableList(list);
252                                    }
253                                    else {
254                                            list = (List<UserNotificationDelivery>)QueryUtil.list(q,
255                                                            getDialect(), start, end);
256                                    }
257    
258                                    cacheResult(list);
259    
260                                    finderCache.putResult(finderPath, finderArgs, list);
261                            }
262                            catch (Exception e) {
263                                    finderCache.removeResult(finderPath, finderArgs);
264    
265                                    throw processException(e);
266                            }
267                            finally {
268                                    closeSession(session);
269                            }
270                    }
271    
272                    return list;
273            }
274    
275            /**
276             * Returns the first user notification delivery in the ordered set where userId = &#63;.
277             *
278             * @param userId the user ID
279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
280             * @return the first matching user notification delivery
281             * @throws NoSuchUserNotificationDeliveryException if a matching user notification delivery could not be found
282             */
283            @Override
284            public UserNotificationDelivery findByUserId_First(long userId,
285                    OrderByComparator<UserNotificationDelivery> orderByComparator)
286                    throws NoSuchUserNotificationDeliveryException {
287                    UserNotificationDelivery userNotificationDelivery = fetchByUserId_First(userId,
288                                    orderByComparator);
289    
290                    if (userNotificationDelivery != null) {
291                            return userNotificationDelivery;
292                    }
293    
294                    StringBundler msg = new StringBundler(4);
295    
296                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
297    
298                    msg.append("userId=");
299                    msg.append(userId);
300    
301                    msg.append(StringPool.CLOSE_CURLY_BRACE);
302    
303                    throw new NoSuchUserNotificationDeliveryException(msg.toString());
304            }
305    
306            /**
307             * Returns the first user notification delivery in the ordered set where userId = &#63;.
308             *
309             * @param userId the user ID
310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
311             * @return the first matching user notification delivery, or <code>null</code> if a matching user notification delivery could not be found
312             */
313            @Override
314            public UserNotificationDelivery fetchByUserId_First(long userId,
315                    OrderByComparator<UserNotificationDelivery> orderByComparator) {
316                    List<UserNotificationDelivery> list = findByUserId(userId, 0, 1,
317                                    orderByComparator);
318    
319                    if (!list.isEmpty()) {
320                            return list.get(0);
321                    }
322    
323                    return null;
324            }
325    
326            /**
327             * Returns the last user notification delivery in the ordered set where userId = &#63;.
328             *
329             * @param userId the user ID
330             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
331             * @return the last matching user notification delivery
332             * @throws NoSuchUserNotificationDeliveryException if a matching user notification delivery could not be found
333             */
334            @Override
335            public UserNotificationDelivery findByUserId_Last(long userId,
336                    OrderByComparator<UserNotificationDelivery> orderByComparator)
337                    throws NoSuchUserNotificationDeliveryException {
338                    UserNotificationDelivery userNotificationDelivery = fetchByUserId_Last(userId,
339                                    orderByComparator);
340    
341                    if (userNotificationDelivery != null) {
342                            return userNotificationDelivery;
343                    }
344    
345                    StringBundler msg = new StringBundler(4);
346    
347                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
348    
349                    msg.append("userId=");
350                    msg.append(userId);
351    
352                    msg.append(StringPool.CLOSE_CURLY_BRACE);
353    
354                    throw new NoSuchUserNotificationDeliveryException(msg.toString());
355            }
356    
357            /**
358             * Returns the last user notification delivery in the ordered set where userId = &#63;.
359             *
360             * @param userId the user ID
361             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
362             * @return the last matching user notification delivery, or <code>null</code> if a matching user notification delivery could not be found
363             */
364            @Override
365            public UserNotificationDelivery fetchByUserId_Last(long userId,
366                    OrderByComparator<UserNotificationDelivery> orderByComparator) {
367                    int count = countByUserId(userId);
368    
369                    if (count == 0) {
370                            return null;
371                    }
372    
373                    List<UserNotificationDelivery> list = findByUserId(userId, count - 1,
374                                    count, orderByComparator);
375    
376                    if (!list.isEmpty()) {
377                            return list.get(0);
378                    }
379    
380                    return null;
381            }
382    
383            /**
384             * Returns the user notification deliveries before and after the current user notification delivery in the ordered set where userId = &#63;.
385             *
386             * @param userNotificationDeliveryId the primary key of the current user notification delivery
387             * @param userId the user ID
388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
389             * @return the previous, current, and next user notification delivery
390             * @throws NoSuchUserNotificationDeliveryException if a user notification delivery with the primary key could not be found
391             */
392            @Override
393            public UserNotificationDelivery[] findByUserId_PrevAndNext(
394                    long userNotificationDeliveryId, long userId,
395                    OrderByComparator<UserNotificationDelivery> orderByComparator)
396                    throws NoSuchUserNotificationDeliveryException {
397                    UserNotificationDelivery userNotificationDelivery = findByPrimaryKey(userNotificationDeliveryId);
398    
399                    Session session = null;
400    
401                    try {
402                            session = openSession();
403    
404                            UserNotificationDelivery[] array = new UserNotificationDeliveryImpl[3];
405    
406                            array[0] = getByUserId_PrevAndNext(session,
407                                            userNotificationDelivery, userId, orderByComparator, true);
408    
409                            array[1] = userNotificationDelivery;
410    
411                            array[2] = getByUserId_PrevAndNext(session,
412                                            userNotificationDelivery, userId, orderByComparator, false);
413    
414                            return array;
415                    }
416                    catch (Exception e) {
417                            throw processException(e);
418                    }
419                    finally {
420                            closeSession(session);
421                    }
422            }
423    
424            protected UserNotificationDelivery getByUserId_PrevAndNext(
425                    Session session, UserNotificationDelivery userNotificationDelivery,
426                    long userId,
427                    OrderByComparator<UserNotificationDelivery> orderByComparator,
428                    boolean previous) {
429                    StringBundler query = null;
430    
431                    if (orderByComparator != null) {
432                            query = new StringBundler(6 +
433                                            (orderByComparator.getOrderByFields().length * 6));
434                    }
435                    else {
436                            query = new StringBundler(3);
437                    }
438    
439                    query.append(_SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE);
440    
441                    query.append(_FINDER_COLUMN_USERID_USERID_2);
442    
443                    if (orderByComparator != null) {
444                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
445    
446                            if (orderByConditionFields.length > 0) {
447                                    query.append(WHERE_AND);
448                            }
449    
450                            for (int i = 0; i < orderByConditionFields.length; i++) {
451                                    query.append(_ORDER_BY_ENTITY_ALIAS);
452                                    query.append(orderByConditionFields[i]);
453    
454                                    if ((i + 1) < orderByConditionFields.length) {
455                                            if (orderByComparator.isAscending() ^ previous) {
456                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
457                                            }
458                                            else {
459                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
460                                            }
461                                    }
462                                    else {
463                                            if (orderByComparator.isAscending() ^ previous) {
464                                                    query.append(WHERE_GREATER_THAN);
465                                            }
466                                            else {
467                                                    query.append(WHERE_LESSER_THAN);
468                                            }
469                                    }
470                            }
471    
472                            query.append(ORDER_BY_CLAUSE);
473    
474                            String[] orderByFields = orderByComparator.getOrderByFields();
475    
476                            for (int i = 0; i < orderByFields.length; i++) {
477                                    query.append(_ORDER_BY_ENTITY_ALIAS);
478                                    query.append(orderByFields[i]);
479    
480                                    if ((i + 1) < orderByFields.length) {
481                                            if (orderByComparator.isAscending() ^ previous) {
482                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
483                                            }
484                                            else {
485                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
486                                            }
487                                    }
488                                    else {
489                                            if (orderByComparator.isAscending() ^ previous) {
490                                                    query.append(ORDER_BY_ASC);
491                                            }
492                                            else {
493                                                    query.append(ORDER_BY_DESC);
494                                            }
495                                    }
496                            }
497                    }
498                    else {
499                            query.append(UserNotificationDeliveryModelImpl.ORDER_BY_JPQL);
500                    }
501    
502                    String sql = query.toString();
503    
504                    Query q = session.createQuery(sql);
505    
506                    q.setFirstResult(0);
507                    q.setMaxResults(2);
508    
509                    QueryPos qPos = QueryPos.getInstance(q);
510    
511                    qPos.add(userId);
512    
513                    if (orderByComparator != null) {
514                            Object[] values = orderByComparator.getOrderByConditionValues(userNotificationDelivery);
515    
516                            for (Object value : values) {
517                                    qPos.add(value);
518                            }
519                    }
520    
521                    List<UserNotificationDelivery> list = q.list();
522    
523                    if (list.size() == 2) {
524                            return list.get(1);
525                    }
526                    else {
527                            return null;
528                    }
529            }
530    
531            /**
532             * Removes all the user notification deliveries where userId = &#63; from the database.
533             *
534             * @param userId the user ID
535             */
536            @Override
537            public void removeByUserId(long userId) {
538                    for (UserNotificationDelivery userNotificationDelivery : findByUserId(
539                                    userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
540                            remove(userNotificationDelivery);
541                    }
542            }
543    
544            /**
545             * Returns the number of user notification deliveries where userId = &#63;.
546             *
547             * @param userId the user ID
548             * @return the number of matching user notification deliveries
549             */
550            @Override
551            public int countByUserId(long userId) {
552                    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
553    
554                    Object[] finderArgs = new Object[] { userId };
555    
556                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
557    
558                    if (count == null) {
559                            StringBundler query = new StringBundler(2);
560    
561                            query.append(_SQL_COUNT_USERNOTIFICATIONDELIVERY_WHERE);
562    
563                            query.append(_FINDER_COLUMN_USERID_USERID_2);
564    
565                            String sql = query.toString();
566    
567                            Session session = null;
568    
569                            try {
570                                    session = openSession();
571    
572                                    Query q = session.createQuery(sql);
573    
574                                    QueryPos qPos = QueryPos.getInstance(q);
575    
576                                    qPos.add(userId);
577    
578                                    count = (Long)q.uniqueResult();
579    
580                                    finderCache.putResult(finderPath, finderArgs, count);
581                            }
582                            catch (Exception e) {
583                                    finderCache.removeResult(finderPath, finderArgs);
584    
585                                    throw processException(e);
586                            }
587                            finally {
588                                    closeSession(session);
589                            }
590                    }
591    
592                    return count.intValue();
593            }
594    
595            private static final String _FINDER_COLUMN_USERID_USERID_2 = "userNotificationDelivery.userId = ?";
596            public static final FinderPath FINDER_PATH_FETCH_BY_U_P_C_N_D = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
597                            UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
598                            UserNotificationDeliveryImpl.class, FINDER_CLASS_NAME_ENTITY,
599                            "fetchByU_P_C_N_D",
600                            new String[] {
601                                    Long.class.getName(), String.class.getName(),
602                                    Long.class.getName(), Integer.class.getName(),
603                                    Integer.class.getName()
604                            },
605                            UserNotificationDeliveryModelImpl.USERID_COLUMN_BITMASK |
606                            UserNotificationDeliveryModelImpl.PORTLETID_COLUMN_BITMASK |
607                            UserNotificationDeliveryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
608                            UserNotificationDeliveryModelImpl.NOTIFICATIONTYPE_COLUMN_BITMASK |
609                            UserNotificationDeliveryModelImpl.DELIVERYTYPE_COLUMN_BITMASK);
610            public static final FinderPath FINDER_PATH_COUNT_BY_U_P_C_N_D = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
611                            UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED, Long.class,
612                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_P_C_N_D",
613                            new String[] {
614                                    Long.class.getName(), String.class.getName(),
615                                    Long.class.getName(), Integer.class.getName(),
616                                    Integer.class.getName()
617                            });
618    
619            /**
620             * Returns the user notification delivery where userId = &#63; and portletId = &#63; and classNameId = &#63; and notificationType = &#63; and deliveryType = &#63; or throws a {@link NoSuchUserNotificationDeliveryException} if it could not be found.
621             *
622             * @param userId the user ID
623             * @param portletId the portlet ID
624             * @param classNameId the class name ID
625             * @param notificationType the notification type
626             * @param deliveryType the delivery type
627             * @return the matching user notification delivery
628             * @throws NoSuchUserNotificationDeliveryException if a matching user notification delivery could not be found
629             */
630            @Override
631            public UserNotificationDelivery findByU_P_C_N_D(long userId,
632                    String portletId, long classNameId, int notificationType,
633                    int deliveryType) throws NoSuchUserNotificationDeliveryException {
634                    UserNotificationDelivery userNotificationDelivery = fetchByU_P_C_N_D(userId,
635                                    portletId, classNameId, notificationType, deliveryType);
636    
637                    if (userNotificationDelivery == null) {
638                            StringBundler msg = new StringBundler(12);
639    
640                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
641    
642                            msg.append("userId=");
643                            msg.append(userId);
644    
645                            msg.append(", portletId=");
646                            msg.append(portletId);
647    
648                            msg.append(", classNameId=");
649                            msg.append(classNameId);
650    
651                            msg.append(", notificationType=");
652                            msg.append(notificationType);
653    
654                            msg.append(", deliveryType=");
655                            msg.append(deliveryType);
656    
657                            msg.append(StringPool.CLOSE_CURLY_BRACE);
658    
659                            if (_log.isWarnEnabled()) {
660                                    _log.warn(msg.toString());
661                            }
662    
663                            throw new NoSuchUserNotificationDeliveryException(msg.toString());
664                    }
665    
666                    return userNotificationDelivery;
667            }
668    
669            /**
670             * Returns the user notification delivery where userId = &#63; and portletId = &#63; and classNameId = &#63; and notificationType = &#63; and deliveryType = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
671             *
672             * @param userId the user ID
673             * @param portletId the portlet ID
674             * @param classNameId the class name ID
675             * @param notificationType the notification type
676             * @param deliveryType the delivery type
677             * @return the matching user notification delivery, or <code>null</code> if a matching user notification delivery could not be found
678             */
679            @Override
680            public UserNotificationDelivery fetchByU_P_C_N_D(long userId,
681                    String portletId, long classNameId, int notificationType,
682                    int deliveryType) {
683                    return fetchByU_P_C_N_D(userId, portletId, classNameId,
684                            notificationType, deliveryType, true);
685            }
686    
687            /**
688             * Returns the user notification delivery where userId = &#63; and portletId = &#63; and classNameId = &#63; and notificationType = &#63; and deliveryType = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
689             *
690             * @param userId the user ID
691             * @param portletId the portlet ID
692             * @param classNameId the class name ID
693             * @param notificationType the notification type
694             * @param deliveryType the delivery type
695             * @param retrieveFromCache whether to retrieve from the finder cache
696             * @return the matching user notification delivery, or <code>null</code> if a matching user notification delivery could not be found
697             */
698            @Override
699            public UserNotificationDelivery fetchByU_P_C_N_D(long userId,
700                    String portletId, long classNameId, int notificationType,
701                    int deliveryType, boolean retrieveFromCache) {
702                    Object[] finderArgs = new Object[] {
703                                    userId, portletId, classNameId, notificationType, deliveryType
704                            };
705    
706                    Object result = null;
707    
708                    if (retrieveFromCache) {
709                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
710                                            finderArgs, this);
711                    }
712    
713                    if (result instanceof UserNotificationDelivery) {
714                            UserNotificationDelivery userNotificationDelivery = (UserNotificationDelivery)result;
715    
716                            if ((userId != userNotificationDelivery.getUserId()) ||
717                                            !Validator.equals(portletId,
718                                                    userNotificationDelivery.getPortletId()) ||
719                                            (classNameId != userNotificationDelivery.getClassNameId()) ||
720                                            (notificationType != userNotificationDelivery.getNotificationType()) ||
721                                            (deliveryType != userNotificationDelivery.getDeliveryType())) {
722                                    result = null;
723                            }
724                    }
725    
726                    if (result == null) {
727                            StringBundler query = new StringBundler(7);
728    
729                            query.append(_SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE);
730    
731                            query.append(_FINDER_COLUMN_U_P_C_N_D_USERID_2);
732    
733                            boolean bindPortletId = false;
734    
735                            if (portletId == null) {
736                                    query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_1);
737                            }
738                            else if (portletId.equals(StringPool.BLANK)) {
739                                    query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_3);
740                            }
741                            else {
742                                    bindPortletId = true;
743    
744                                    query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_2);
745                            }
746    
747                            query.append(_FINDER_COLUMN_U_P_C_N_D_CLASSNAMEID_2);
748    
749                            query.append(_FINDER_COLUMN_U_P_C_N_D_NOTIFICATIONTYPE_2);
750    
751                            query.append(_FINDER_COLUMN_U_P_C_N_D_DELIVERYTYPE_2);
752    
753                            String sql = query.toString();
754    
755                            Session session = null;
756    
757                            try {
758                                    session = openSession();
759    
760                                    Query q = session.createQuery(sql);
761    
762                                    QueryPos qPos = QueryPos.getInstance(q);
763    
764                                    qPos.add(userId);
765    
766                                    if (bindPortletId) {
767                                            qPos.add(portletId);
768                                    }
769    
770                                    qPos.add(classNameId);
771    
772                                    qPos.add(notificationType);
773    
774                                    qPos.add(deliveryType);
775    
776                                    List<UserNotificationDelivery> list = q.list();
777    
778                                    if (list.isEmpty()) {
779                                            finderCache.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
780                                                    finderArgs, list);
781                                    }
782                                    else {
783                                            UserNotificationDelivery userNotificationDelivery = list.get(0);
784    
785                                            result = userNotificationDelivery;
786    
787                                            cacheResult(userNotificationDelivery);
788    
789                                            if ((userNotificationDelivery.getUserId() != userId) ||
790                                                            (userNotificationDelivery.getPortletId() == null) ||
791                                                            !userNotificationDelivery.getPortletId()
792                                                                                                                     .equals(portletId) ||
793                                                            (userNotificationDelivery.getClassNameId() != classNameId) ||
794                                                            (userNotificationDelivery.getNotificationType() != notificationType) ||
795                                                            (userNotificationDelivery.getDeliveryType() != deliveryType)) {
796                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
797                                                            finderArgs, userNotificationDelivery);
798                                            }
799                                    }
800                            }
801                            catch (Exception e) {
802                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
803                                            finderArgs);
804    
805                                    throw processException(e);
806                            }
807                            finally {
808                                    closeSession(session);
809                            }
810                    }
811    
812                    if (result instanceof List<?>) {
813                            return null;
814                    }
815                    else {
816                            return (UserNotificationDelivery)result;
817                    }
818            }
819    
820            /**
821             * Removes the user notification delivery where userId = &#63; and portletId = &#63; and classNameId = &#63; and notificationType = &#63; and deliveryType = &#63; from the database.
822             *
823             * @param userId the user ID
824             * @param portletId the portlet ID
825             * @param classNameId the class name ID
826             * @param notificationType the notification type
827             * @param deliveryType the delivery type
828             * @return the user notification delivery that was removed
829             */
830            @Override
831            public UserNotificationDelivery removeByU_P_C_N_D(long userId,
832                    String portletId, long classNameId, int notificationType,
833                    int deliveryType) throws NoSuchUserNotificationDeliveryException {
834                    UserNotificationDelivery userNotificationDelivery = findByU_P_C_N_D(userId,
835                                    portletId, classNameId, notificationType, deliveryType);
836    
837                    return remove(userNotificationDelivery);
838            }
839    
840            /**
841             * Returns the number of user notification deliveries where userId = &#63; and portletId = &#63; and classNameId = &#63; and notificationType = &#63; and deliveryType = &#63;.
842             *
843             * @param userId the user ID
844             * @param portletId the portlet ID
845             * @param classNameId the class name ID
846             * @param notificationType the notification type
847             * @param deliveryType the delivery type
848             * @return the number of matching user notification deliveries
849             */
850            @Override
851            public int countByU_P_C_N_D(long userId, String portletId,
852                    long classNameId, int notificationType, int deliveryType) {
853                    FinderPath finderPath = FINDER_PATH_COUNT_BY_U_P_C_N_D;
854    
855                    Object[] finderArgs = new Object[] {
856                                    userId, portletId, classNameId, notificationType, deliveryType
857                            };
858    
859                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
860    
861                    if (count == null) {
862                            StringBundler query = new StringBundler(6);
863    
864                            query.append(_SQL_COUNT_USERNOTIFICATIONDELIVERY_WHERE);
865    
866                            query.append(_FINDER_COLUMN_U_P_C_N_D_USERID_2);
867    
868                            boolean bindPortletId = false;
869    
870                            if (portletId == null) {
871                                    query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_1);
872                            }
873                            else if (portletId.equals(StringPool.BLANK)) {
874                                    query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_3);
875                            }
876                            else {
877                                    bindPortletId = true;
878    
879                                    query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_2);
880                            }
881    
882                            query.append(_FINDER_COLUMN_U_P_C_N_D_CLASSNAMEID_2);
883    
884                            query.append(_FINDER_COLUMN_U_P_C_N_D_NOTIFICATIONTYPE_2);
885    
886                            query.append(_FINDER_COLUMN_U_P_C_N_D_DELIVERYTYPE_2);
887    
888                            String sql = query.toString();
889    
890                            Session session = null;
891    
892                            try {
893                                    session = openSession();
894    
895                                    Query q = session.createQuery(sql);
896    
897                                    QueryPos qPos = QueryPos.getInstance(q);
898    
899                                    qPos.add(userId);
900    
901                                    if (bindPortletId) {
902                                            qPos.add(portletId);
903                                    }
904    
905                                    qPos.add(classNameId);
906    
907                                    qPos.add(notificationType);
908    
909                                    qPos.add(deliveryType);
910    
911                                    count = (Long)q.uniqueResult();
912    
913                                    finderCache.putResult(finderPath, finderArgs, count);
914                            }
915                            catch (Exception e) {
916                                    finderCache.removeResult(finderPath, finderArgs);
917    
918                                    throw processException(e);
919                            }
920                            finally {
921                                    closeSession(session);
922                            }
923                    }
924    
925                    return count.intValue();
926            }
927    
928            private static final String _FINDER_COLUMN_U_P_C_N_D_USERID_2 = "userNotificationDelivery.userId = ? AND ";
929            private static final String _FINDER_COLUMN_U_P_C_N_D_PORTLETID_1 = "userNotificationDelivery.portletId IS NULL AND ";
930            private static final String _FINDER_COLUMN_U_P_C_N_D_PORTLETID_2 = "userNotificationDelivery.portletId = ? AND ";
931            private static final String _FINDER_COLUMN_U_P_C_N_D_PORTLETID_3 = "(userNotificationDelivery.portletId IS NULL OR userNotificationDelivery.portletId = '') AND ";
932            private static final String _FINDER_COLUMN_U_P_C_N_D_CLASSNAMEID_2 = "userNotificationDelivery.classNameId = ? AND ";
933            private static final String _FINDER_COLUMN_U_P_C_N_D_NOTIFICATIONTYPE_2 = "userNotificationDelivery.notificationType = ? AND ";
934            private static final String _FINDER_COLUMN_U_P_C_N_D_DELIVERYTYPE_2 = "userNotificationDelivery.deliveryType = ?";
935    
936            public UserNotificationDeliveryPersistenceImpl() {
937                    setModelClass(UserNotificationDelivery.class);
938            }
939    
940            /**
941             * Caches the user notification delivery in the entity cache if it is enabled.
942             *
943             * @param userNotificationDelivery the user notification delivery
944             */
945            @Override
946            public void cacheResult(UserNotificationDelivery userNotificationDelivery) {
947                    entityCache.putResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
948                            UserNotificationDeliveryImpl.class,
949                            userNotificationDelivery.getPrimaryKey(), userNotificationDelivery);
950    
951                    finderCache.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
952                            new Object[] {
953                                    userNotificationDelivery.getUserId(),
954                                    userNotificationDelivery.getPortletId(),
955                                    userNotificationDelivery.getClassNameId(),
956                                    userNotificationDelivery.getNotificationType(),
957                                    userNotificationDelivery.getDeliveryType()
958                            }, userNotificationDelivery);
959    
960                    userNotificationDelivery.resetOriginalValues();
961            }
962    
963            /**
964             * Caches the user notification deliveries in the entity cache if it is enabled.
965             *
966             * @param userNotificationDeliveries the user notification deliveries
967             */
968            @Override
969            public void cacheResult(
970                    List<UserNotificationDelivery> userNotificationDeliveries) {
971                    for (UserNotificationDelivery userNotificationDelivery : userNotificationDeliveries) {
972                            if (entityCache.getResult(
973                                                    UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
974                                                    UserNotificationDeliveryImpl.class,
975                                                    userNotificationDelivery.getPrimaryKey()) == null) {
976                                    cacheResult(userNotificationDelivery);
977                            }
978                            else {
979                                    userNotificationDelivery.resetOriginalValues();
980                            }
981                    }
982            }
983    
984            /**
985             * Clears the cache for all user notification deliveries.
986             *
987             * <p>
988             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
989             * </p>
990             */
991            @Override
992            public void clearCache() {
993                    entityCache.clearCache(UserNotificationDeliveryImpl.class);
994    
995                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
996                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
997                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
998            }
999    
1000            /**
1001             * Clears the cache for the user notification delivery.
1002             *
1003             * <p>
1004             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
1005             * </p>
1006             */
1007            @Override
1008            public void clearCache(UserNotificationDelivery userNotificationDelivery) {
1009                    entityCache.removeResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1010                            UserNotificationDeliveryImpl.class,
1011                            userNotificationDelivery.getPrimaryKey());
1012    
1013                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1014                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1015    
1016                    clearUniqueFindersCache((UserNotificationDeliveryModelImpl)userNotificationDelivery);
1017            }
1018    
1019            @Override
1020            public void clearCache(
1021                    List<UserNotificationDelivery> userNotificationDeliveries) {
1022                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1023                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1024    
1025                    for (UserNotificationDelivery userNotificationDelivery : userNotificationDeliveries) {
1026                            entityCache.removeResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1027                                    UserNotificationDeliveryImpl.class,
1028                                    userNotificationDelivery.getPrimaryKey());
1029    
1030                            clearUniqueFindersCache((UserNotificationDeliveryModelImpl)userNotificationDelivery);
1031                    }
1032            }
1033    
1034            protected void cacheUniqueFindersCache(
1035                    UserNotificationDeliveryModelImpl userNotificationDeliveryModelImpl,
1036                    boolean isNew) {
1037                    if (isNew) {
1038                            Object[] args = new Object[] {
1039                                            userNotificationDeliveryModelImpl.getUserId(),
1040                                            userNotificationDeliveryModelImpl.getPortletId(),
1041                                            userNotificationDeliveryModelImpl.getClassNameId(),
1042                                            userNotificationDeliveryModelImpl.getNotificationType(),
1043                                            userNotificationDeliveryModelImpl.getDeliveryType()
1044                                    };
1045    
1046                            finderCache.putResult(FINDER_PATH_COUNT_BY_U_P_C_N_D, args,
1047                                    Long.valueOf(1));
1048                            finderCache.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D, args,
1049                                    userNotificationDeliveryModelImpl);
1050                    }
1051                    else {
1052                            if ((userNotificationDeliveryModelImpl.getColumnBitmask() &
1053                                            FINDER_PATH_FETCH_BY_U_P_C_N_D.getColumnBitmask()) != 0) {
1054                                    Object[] args = new Object[] {
1055                                                    userNotificationDeliveryModelImpl.getUserId(),
1056                                                    userNotificationDeliveryModelImpl.getPortletId(),
1057                                                    userNotificationDeliveryModelImpl.getClassNameId(),
1058                                                    userNotificationDeliveryModelImpl.getNotificationType(),
1059                                                    userNotificationDeliveryModelImpl.getDeliveryType()
1060                                            };
1061    
1062                                    finderCache.putResult(FINDER_PATH_COUNT_BY_U_P_C_N_D, args,
1063                                            Long.valueOf(1));
1064                                    finderCache.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D, args,
1065                                            userNotificationDeliveryModelImpl);
1066                            }
1067                    }
1068            }
1069    
1070            protected void clearUniqueFindersCache(
1071                    UserNotificationDeliveryModelImpl userNotificationDeliveryModelImpl) {
1072                    Object[] args = new Object[] {
1073                                    userNotificationDeliveryModelImpl.getUserId(),
1074                                    userNotificationDeliveryModelImpl.getPortletId(),
1075                                    userNotificationDeliveryModelImpl.getClassNameId(),
1076                                    userNotificationDeliveryModelImpl.getNotificationType(),
1077                                    userNotificationDeliveryModelImpl.getDeliveryType()
1078                            };
1079    
1080                    finderCache.removeResult(FINDER_PATH_COUNT_BY_U_P_C_N_D, args);
1081                    finderCache.removeResult(FINDER_PATH_FETCH_BY_U_P_C_N_D, args);
1082    
1083                    if ((userNotificationDeliveryModelImpl.getColumnBitmask() &
1084                                    FINDER_PATH_FETCH_BY_U_P_C_N_D.getColumnBitmask()) != 0) {
1085                            args = new Object[] {
1086                                            userNotificationDeliveryModelImpl.getOriginalUserId(),
1087                                            userNotificationDeliveryModelImpl.getOriginalPortletId(),
1088                                            userNotificationDeliveryModelImpl.getOriginalClassNameId(),
1089                                            userNotificationDeliveryModelImpl.getOriginalNotificationType(),
1090                                            userNotificationDeliveryModelImpl.getOriginalDeliveryType()
1091                                    };
1092    
1093                            finderCache.removeResult(FINDER_PATH_COUNT_BY_U_P_C_N_D, args);
1094                            finderCache.removeResult(FINDER_PATH_FETCH_BY_U_P_C_N_D, args);
1095                    }
1096            }
1097    
1098            /**
1099             * Creates a new user notification delivery with the primary key. Does not add the user notification delivery to the database.
1100             *
1101             * @param userNotificationDeliveryId the primary key for the new user notification delivery
1102             * @return the new user notification delivery
1103             */
1104            @Override
1105            public UserNotificationDelivery create(long userNotificationDeliveryId) {
1106                    UserNotificationDelivery userNotificationDelivery = new UserNotificationDeliveryImpl();
1107    
1108                    userNotificationDelivery.setNew(true);
1109                    userNotificationDelivery.setPrimaryKey(userNotificationDeliveryId);
1110    
1111                    return userNotificationDelivery;
1112            }
1113    
1114            /**
1115             * Removes the user notification delivery with the primary key from the database. Also notifies the appropriate model listeners.
1116             *
1117             * @param userNotificationDeliveryId the primary key of the user notification delivery
1118             * @return the user notification delivery that was removed
1119             * @throws NoSuchUserNotificationDeliveryException if a user notification delivery with the primary key could not be found
1120             */
1121            @Override
1122            public UserNotificationDelivery remove(long userNotificationDeliveryId)
1123                    throws NoSuchUserNotificationDeliveryException {
1124                    return remove((Serializable)userNotificationDeliveryId);
1125            }
1126    
1127            /**
1128             * Removes the user notification delivery with the primary key from the database. Also notifies the appropriate model listeners.
1129             *
1130             * @param primaryKey the primary key of the user notification delivery
1131             * @return the user notification delivery that was removed
1132             * @throws NoSuchUserNotificationDeliveryException if a user notification delivery with the primary key could not be found
1133             */
1134            @Override
1135            public UserNotificationDelivery remove(Serializable primaryKey)
1136                    throws NoSuchUserNotificationDeliveryException {
1137                    Session session = null;
1138    
1139                    try {
1140                            session = openSession();
1141    
1142                            UserNotificationDelivery userNotificationDelivery = (UserNotificationDelivery)session.get(UserNotificationDeliveryImpl.class,
1143                                            primaryKey);
1144    
1145                            if (userNotificationDelivery == null) {
1146                                    if (_log.isWarnEnabled()) {
1147                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1148                                    }
1149    
1150                                    throw new NoSuchUserNotificationDeliveryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1151                                            primaryKey);
1152                            }
1153    
1154                            return remove(userNotificationDelivery);
1155                    }
1156                    catch (NoSuchUserNotificationDeliveryException nsee) {
1157                            throw nsee;
1158                    }
1159                    catch (Exception e) {
1160                            throw processException(e);
1161                    }
1162                    finally {
1163                            closeSession(session);
1164                    }
1165            }
1166    
1167            @Override
1168            protected UserNotificationDelivery removeImpl(
1169                    UserNotificationDelivery userNotificationDelivery) {
1170                    userNotificationDelivery = toUnwrappedModel(userNotificationDelivery);
1171    
1172                    Session session = null;
1173    
1174                    try {
1175                            session = openSession();
1176    
1177                            if (!session.contains(userNotificationDelivery)) {
1178                                    userNotificationDelivery = (UserNotificationDelivery)session.get(UserNotificationDeliveryImpl.class,
1179                                                    userNotificationDelivery.getPrimaryKeyObj());
1180                            }
1181    
1182                            if (userNotificationDelivery != null) {
1183                                    session.delete(userNotificationDelivery);
1184                            }
1185                    }
1186                    catch (Exception e) {
1187                            throw processException(e);
1188                    }
1189                    finally {
1190                            closeSession(session);
1191                    }
1192    
1193                    if (userNotificationDelivery != null) {
1194                            clearCache(userNotificationDelivery);
1195                    }
1196    
1197                    return userNotificationDelivery;
1198            }
1199    
1200            @Override
1201            public UserNotificationDelivery updateImpl(
1202                    UserNotificationDelivery userNotificationDelivery) {
1203                    userNotificationDelivery = toUnwrappedModel(userNotificationDelivery);
1204    
1205                    boolean isNew = userNotificationDelivery.isNew();
1206    
1207                    UserNotificationDeliveryModelImpl userNotificationDeliveryModelImpl = (UserNotificationDeliveryModelImpl)userNotificationDelivery;
1208    
1209                    Session session = null;
1210    
1211                    try {
1212                            session = openSession();
1213    
1214                            if (userNotificationDelivery.isNew()) {
1215                                    session.save(userNotificationDelivery);
1216    
1217                                    userNotificationDelivery.setNew(false);
1218                            }
1219                            else {
1220                                    userNotificationDelivery = (UserNotificationDelivery)session.merge(userNotificationDelivery);
1221                            }
1222                    }
1223                    catch (Exception e) {
1224                            throw processException(e);
1225                    }
1226                    finally {
1227                            closeSession(session);
1228                    }
1229    
1230                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1231    
1232                    if (isNew || !UserNotificationDeliveryModelImpl.COLUMN_BITMASK_ENABLED) {
1233                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1234                    }
1235    
1236                    else {
1237                            if ((userNotificationDeliveryModelImpl.getColumnBitmask() &
1238                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
1239                                    Object[] args = new Object[] {
1240                                                    userNotificationDeliveryModelImpl.getOriginalUserId()
1241                                            };
1242    
1243                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1244                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1245                                            args);
1246    
1247                                    args = new Object[] {
1248                                                    userNotificationDeliveryModelImpl.getUserId()
1249                                            };
1250    
1251                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1252                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1253                                            args);
1254                            }
1255                    }
1256    
1257                    entityCache.putResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1258                            UserNotificationDeliveryImpl.class,
1259                            userNotificationDelivery.getPrimaryKey(), userNotificationDelivery,
1260                            false);
1261    
1262                    clearUniqueFindersCache(userNotificationDeliveryModelImpl);
1263                    cacheUniqueFindersCache(userNotificationDeliveryModelImpl, isNew);
1264    
1265                    userNotificationDelivery.resetOriginalValues();
1266    
1267                    return userNotificationDelivery;
1268            }
1269    
1270            protected UserNotificationDelivery toUnwrappedModel(
1271                    UserNotificationDelivery userNotificationDelivery) {
1272                    if (userNotificationDelivery instanceof UserNotificationDeliveryImpl) {
1273                            return userNotificationDelivery;
1274                    }
1275    
1276                    UserNotificationDeliveryImpl userNotificationDeliveryImpl = new UserNotificationDeliveryImpl();
1277    
1278                    userNotificationDeliveryImpl.setNew(userNotificationDelivery.isNew());
1279                    userNotificationDeliveryImpl.setPrimaryKey(userNotificationDelivery.getPrimaryKey());
1280    
1281                    userNotificationDeliveryImpl.setMvccVersion(userNotificationDelivery.getMvccVersion());
1282                    userNotificationDeliveryImpl.setUserNotificationDeliveryId(userNotificationDelivery.getUserNotificationDeliveryId());
1283                    userNotificationDeliveryImpl.setCompanyId(userNotificationDelivery.getCompanyId());
1284                    userNotificationDeliveryImpl.setUserId(userNotificationDelivery.getUserId());
1285                    userNotificationDeliveryImpl.setPortletId(userNotificationDelivery.getPortletId());
1286                    userNotificationDeliveryImpl.setClassNameId(userNotificationDelivery.getClassNameId());
1287                    userNotificationDeliveryImpl.setNotificationType(userNotificationDelivery.getNotificationType());
1288                    userNotificationDeliveryImpl.setDeliveryType(userNotificationDelivery.getDeliveryType());
1289                    userNotificationDeliveryImpl.setDeliver(userNotificationDelivery.isDeliver());
1290    
1291                    return userNotificationDeliveryImpl;
1292            }
1293    
1294            /**
1295             * Returns the user notification delivery with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1296             *
1297             * @param primaryKey the primary key of the user notification delivery
1298             * @return the user notification delivery
1299             * @throws NoSuchUserNotificationDeliveryException if a user notification delivery with the primary key could not be found
1300             */
1301            @Override
1302            public UserNotificationDelivery findByPrimaryKey(Serializable primaryKey)
1303                    throws NoSuchUserNotificationDeliveryException {
1304                    UserNotificationDelivery userNotificationDelivery = fetchByPrimaryKey(primaryKey);
1305    
1306                    if (userNotificationDelivery == null) {
1307                            if (_log.isWarnEnabled()) {
1308                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1309                            }
1310    
1311                            throw new NoSuchUserNotificationDeliveryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1312                                    primaryKey);
1313                    }
1314    
1315                    return userNotificationDelivery;
1316            }
1317    
1318            /**
1319             * Returns the user notification delivery with the primary key or throws a {@link NoSuchUserNotificationDeliveryException} if it could not be found.
1320             *
1321             * @param userNotificationDeliveryId the primary key of the user notification delivery
1322             * @return the user notification delivery
1323             * @throws NoSuchUserNotificationDeliveryException if a user notification delivery with the primary key could not be found
1324             */
1325            @Override
1326            public UserNotificationDelivery findByPrimaryKey(
1327                    long userNotificationDeliveryId)
1328                    throws NoSuchUserNotificationDeliveryException {
1329                    return findByPrimaryKey((Serializable)userNotificationDeliveryId);
1330            }
1331    
1332            /**
1333             * Returns the user notification delivery with the primary key or returns <code>null</code> if it could not be found.
1334             *
1335             * @param primaryKey the primary key of the user notification delivery
1336             * @return the user notification delivery, or <code>null</code> if a user notification delivery with the primary key could not be found
1337             */
1338            @Override
1339            public UserNotificationDelivery fetchByPrimaryKey(Serializable primaryKey) {
1340                    UserNotificationDelivery userNotificationDelivery = (UserNotificationDelivery)entityCache.getResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1341                                    UserNotificationDeliveryImpl.class, primaryKey);
1342    
1343                    if (userNotificationDelivery == _nullUserNotificationDelivery) {
1344                            return null;
1345                    }
1346    
1347                    if (userNotificationDelivery == null) {
1348                            Session session = null;
1349    
1350                            try {
1351                                    session = openSession();
1352    
1353                                    userNotificationDelivery = (UserNotificationDelivery)session.get(UserNotificationDeliveryImpl.class,
1354                                                    primaryKey);
1355    
1356                                    if (userNotificationDelivery != null) {
1357                                            cacheResult(userNotificationDelivery);
1358                                    }
1359                                    else {
1360                                            entityCache.putResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1361                                                    UserNotificationDeliveryImpl.class, primaryKey,
1362                                                    _nullUserNotificationDelivery);
1363                                    }
1364                            }
1365                            catch (Exception e) {
1366                                    entityCache.removeResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1367                                            UserNotificationDeliveryImpl.class, primaryKey);
1368    
1369                                    throw processException(e);
1370                            }
1371                            finally {
1372                                    closeSession(session);
1373                            }
1374                    }
1375    
1376                    return userNotificationDelivery;
1377            }
1378    
1379            /**
1380             * Returns the user notification delivery with the primary key or returns <code>null</code> if it could not be found.
1381             *
1382             * @param userNotificationDeliveryId the primary key of the user notification delivery
1383             * @return the user notification delivery, or <code>null</code> if a user notification delivery with the primary key could not be found
1384             */
1385            @Override
1386            public UserNotificationDelivery fetchByPrimaryKey(
1387                    long userNotificationDeliveryId) {
1388                    return fetchByPrimaryKey((Serializable)userNotificationDeliveryId);
1389            }
1390    
1391            @Override
1392            public Map<Serializable, UserNotificationDelivery> fetchByPrimaryKeys(
1393                    Set<Serializable> primaryKeys) {
1394                    if (primaryKeys.isEmpty()) {
1395                            return Collections.emptyMap();
1396                    }
1397    
1398                    Map<Serializable, UserNotificationDelivery> map = new HashMap<Serializable, UserNotificationDelivery>();
1399    
1400                    if (primaryKeys.size() == 1) {
1401                            Iterator<Serializable> iterator = primaryKeys.iterator();
1402    
1403                            Serializable primaryKey = iterator.next();
1404    
1405                            UserNotificationDelivery userNotificationDelivery = fetchByPrimaryKey(primaryKey);
1406    
1407                            if (userNotificationDelivery != null) {
1408                                    map.put(primaryKey, userNotificationDelivery);
1409                            }
1410    
1411                            return map;
1412                    }
1413    
1414                    Set<Serializable> uncachedPrimaryKeys = null;
1415    
1416                    for (Serializable primaryKey : primaryKeys) {
1417                            UserNotificationDelivery userNotificationDelivery = (UserNotificationDelivery)entityCache.getResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1418                                            UserNotificationDeliveryImpl.class, primaryKey);
1419    
1420                            if (userNotificationDelivery == null) {
1421                                    if (uncachedPrimaryKeys == null) {
1422                                            uncachedPrimaryKeys = new HashSet<Serializable>();
1423                                    }
1424    
1425                                    uncachedPrimaryKeys.add(primaryKey);
1426                            }
1427                            else {
1428                                    map.put(primaryKey, userNotificationDelivery);
1429                            }
1430                    }
1431    
1432                    if (uncachedPrimaryKeys == null) {
1433                            return map;
1434                    }
1435    
1436                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1437                                    1);
1438    
1439                    query.append(_SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE_PKS_IN);
1440    
1441                    for (Serializable primaryKey : uncachedPrimaryKeys) {
1442                            query.append(String.valueOf(primaryKey));
1443    
1444                            query.append(StringPool.COMMA);
1445                    }
1446    
1447                    query.setIndex(query.index() - 1);
1448    
1449                    query.append(StringPool.CLOSE_PARENTHESIS);
1450    
1451                    String sql = query.toString();
1452    
1453                    Session session = null;
1454    
1455                    try {
1456                            session = openSession();
1457    
1458                            Query q = session.createQuery(sql);
1459    
1460                            for (UserNotificationDelivery userNotificationDelivery : (List<UserNotificationDelivery>)q.list()) {
1461                                    map.put(userNotificationDelivery.getPrimaryKeyObj(),
1462                                            userNotificationDelivery);
1463    
1464                                    cacheResult(userNotificationDelivery);
1465    
1466                                    uncachedPrimaryKeys.remove(userNotificationDelivery.getPrimaryKeyObj());
1467                            }
1468    
1469                            for (Serializable primaryKey : uncachedPrimaryKeys) {
1470                                    entityCache.putResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1471                                            UserNotificationDeliveryImpl.class, primaryKey,
1472                                            _nullUserNotificationDelivery);
1473                            }
1474                    }
1475                    catch (Exception e) {
1476                            throw processException(e);
1477                    }
1478                    finally {
1479                            closeSession(session);
1480                    }
1481    
1482                    return map;
1483            }
1484    
1485            /**
1486             * Returns all the user notification deliveries.
1487             *
1488             * @return the user notification deliveries
1489             */
1490            @Override
1491            public List<UserNotificationDelivery> findAll() {
1492                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1493            }
1494    
1495            /**
1496             * Returns a range of all the user notification deliveries.
1497             *
1498             * <p>
1499             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserNotificationDeliveryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1500             * </p>
1501             *
1502             * @param start the lower bound of the range of user notification deliveries
1503             * @param end the upper bound of the range of user notification deliveries (not inclusive)
1504             * @return the range of user notification deliveries
1505             */
1506            @Override
1507            public List<UserNotificationDelivery> findAll(int start, int end) {
1508                    return findAll(start, end, null);
1509            }
1510    
1511            /**
1512             * Returns an ordered range of all the user notification deliveries.
1513             *
1514             * <p>
1515             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserNotificationDeliveryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1516             * </p>
1517             *
1518             * @param start the lower bound of the range of user notification deliveries
1519             * @param end the upper bound of the range of user notification deliveries (not inclusive)
1520             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1521             * @return the ordered range of user notification deliveries
1522             */
1523            @Override
1524            public List<UserNotificationDelivery> findAll(int start, int end,
1525                    OrderByComparator<UserNotificationDelivery> orderByComparator) {
1526                    return findAll(start, end, orderByComparator, true);
1527            }
1528    
1529            /**
1530             * Returns an ordered range of all the user notification deliveries.
1531             *
1532             * <p>
1533             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserNotificationDeliveryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1534             * </p>
1535             *
1536             * @param start the lower bound of the range of user notification deliveries
1537             * @param end the upper bound of the range of user notification deliveries (not inclusive)
1538             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1539             * @param retrieveFromCache whether to retrieve from the finder cache
1540             * @return the ordered range of user notification deliveries
1541             */
1542            @Override
1543            public List<UserNotificationDelivery> findAll(int start, int end,
1544                    OrderByComparator<UserNotificationDelivery> orderByComparator,
1545                    boolean retrieveFromCache) {
1546                    boolean pagination = true;
1547                    FinderPath finderPath = null;
1548                    Object[] finderArgs = null;
1549    
1550                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1551                                    (orderByComparator == null)) {
1552                            pagination = false;
1553                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1554                            finderArgs = FINDER_ARGS_EMPTY;
1555                    }
1556                    else {
1557                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1558                            finderArgs = new Object[] { start, end, orderByComparator };
1559                    }
1560    
1561                    List<UserNotificationDelivery> list = null;
1562    
1563                    if (retrieveFromCache) {
1564                            list = (List<UserNotificationDelivery>)finderCache.getResult(finderPath,
1565                                            finderArgs, this);
1566                    }
1567    
1568                    if (list == null) {
1569                            StringBundler query = null;
1570                            String sql = null;
1571    
1572                            if (orderByComparator != null) {
1573                                    query = new StringBundler(2 +
1574                                                    (orderByComparator.getOrderByFields().length * 3));
1575    
1576                                    query.append(_SQL_SELECT_USERNOTIFICATIONDELIVERY);
1577    
1578                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1579                                            orderByComparator);
1580    
1581                                    sql = query.toString();
1582                            }
1583                            else {
1584                                    sql = _SQL_SELECT_USERNOTIFICATIONDELIVERY;
1585    
1586                                    if (pagination) {
1587                                            sql = sql.concat(UserNotificationDeliveryModelImpl.ORDER_BY_JPQL);
1588                                    }
1589                            }
1590    
1591                            Session session = null;
1592    
1593                            try {
1594                                    session = openSession();
1595    
1596                                    Query q = session.createQuery(sql);
1597    
1598                                    if (!pagination) {
1599                                            list = (List<UserNotificationDelivery>)QueryUtil.list(q,
1600                                                            getDialect(), start, end, false);
1601    
1602                                            Collections.sort(list);
1603    
1604                                            list = Collections.unmodifiableList(list);
1605                                    }
1606                                    else {
1607                                            list = (List<UserNotificationDelivery>)QueryUtil.list(q,
1608                                                            getDialect(), start, end);
1609                                    }
1610    
1611                                    cacheResult(list);
1612    
1613                                    finderCache.putResult(finderPath, finderArgs, list);
1614                            }
1615                            catch (Exception e) {
1616                                    finderCache.removeResult(finderPath, finderArgs);
1617    
1618                                    throw processException(e);
1619                            }
1620                            finally {
1621                                    closeSession(session);
1622                            }
1623                    }
1624    
1625                    return list;
1626            }
1627    
1628            /**
1629             * Removes all the user notification deliveries from the database.
1630             *
1631             */
1632            @Override
1633            public void removeAll() {
1634                    for (UserNotificationDelivery userNotificationDelivery : findAll()) {
1635                            remove(userNotificationDelivery);
1636                    }
1637            }
1638    
1639            /**
1640             * Returns the number of user notification deliveries.
1641             *
1642             * @return the number of user notification deliveries
1643             */
1644            @Override
1645            public int countAll() {
1646                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1647                                    FINDER_ARGS_EMPTY, this);
1648    
1649                    if (count == null) {
1650                            Session session = null;
1651    
1652                            try {
1653                                    session = openSession();
1654    
1655                                    Query q = session.createQuery(_SQL_COUNT_USERNOTIFICATIONDELIVERY);
1656    
1657                                    count = (Long)q.uniqueResult();
1658    
1659                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1660                                            count);
1661                            }
1662                            catch (Exception e) {
1663                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1664                                            FINDER_ARGS_EMPTY);
1665    
1666                                    throw processException(e);
1667                            }
1668                            finally {
1669                                    closeSession(session);
1670                            }
1671                    }
1672    
1673                    return count.intValue();
1674            }
1675    
1676            @Override
1677            protected Map<String, Integer> getTableColumnsMap() {
1678                    return UserNotificationDeliveryModelImpl.TABLE_COLUMNS_MAP;
1679            }
1680    
1681            /**
1682             * Initializes the user notification delivery persistence.
1683             */
1684            public void afterPropertiesSet() {
1685            }
1686    
1687            public void destroy() {
1688                    entityCache.removeCache(UserNotificationDeliveryImpl.class.getName());
1689                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1690                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1691                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1692            }
1693    
1694            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1695            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1696            private static final String _SQL_SELECT_USERNOTIFICATIONDELIVERY = "SELECT userNotificationDelivery FROM UserNotificationDelivery userNotificationDelivery";
1697            private static final String _SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE_PKS_IN =
1698                    "SELECT userNotificationDelivery FROM UserNotificationDelivery userNotificationDelivery WHERE userNotificationDeliveryId IN (";
1699            private static final String _SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE = "SELECT userNotificationDelivery FROM UserNotificationDelivery userNotificationDelivery WHERE ";
1700            private static final String _SQL_COUNT_USERNOTIFICATIONDELIVERY = "SELECT COUNT(userNotificationDelivery) FROM UserNotificationDelivery userNotificationDelivery";
1701            private static final String _SQL_COUNT_USERNOTIFICATIONDELIVERY_WHERE = "SELECT COUNT(userNotificationDelivery) FROM UserNotificationDelivery userNotificationDelivery WHERE ";
1702            private static final String _ORDER_BY_ENTITY_ALIAS = "userNotificationDelivery.";
1703            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserNotificationDelivery exists with the primary key ";
1704            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserNotificationDelivery exists with the key {";
1705            private static final Log _log = LogFactoryUtil.getLog(UserNotificationDeliveryPersistenceImpl.class);
1706            private static final UserNotificationDelivery _nullUserNotificationDelivery = new UserNotificationDeliveryImpl() {
1707                            @Override
1708                            public Object clone() {
1709                                    return this;
1710                            }
1711    
1712                            @Override
1713                            public CacheModel<UserNotificationDelivery> toCacheModel() {
1714                                    return _nullUserNotificationDeliveryCacheModel;
1715                            }
1716                    };
1717    
1718            private static final CacheModel<UserNotificationDelivery> _nullUserNotificationDeliveryCacheModel =
1719                    new NullCacheModel();
1720    
1721            private static class NullCacheModel implements CacheModel<UserNotificationDelivery>,
1722                    MVCCModel {
1723                    @Override
1724                    public long getMvccVersion() {
1725                            return -1;
1726                    }
1727    
1728                    @Override
1729                    public void setMvccVersion(long mvccVersion) {
1730                    }
1731    
1732                    @Override
1733                    public UserNotificationDelivery toEntityModel() {
1734                            return _nullUserNotificationDelivery;
1735                    }
1736            }
1737    }