001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.announcements.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.ResourcePersistence;
040    import com.liferay.portal.service.persistence.UserPersistence;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.announcements.NoSuchDeliveryException;
044    import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
045    import com.liferay.portlet.announcements.model.impl.AnnouncementsDeliveryImpl;
046    import com.liferay.portlet.announcements.model.impl.AnnouncementsDeliveryModelImpl;
047    
048    import java.io.Serializable;
049    
050    import java.util.ArrayList;
051    import java.util.Collections;
052    import java.util.List;
053    
054    /**
055     * The persistence implementation for the announcements delivery service.
056     *
057     * <p>
058     * Never modify or reference this class directly. Always use {@link AnnouncementsDeliveryUtil} to access the announcements delivery persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
059     * </p>
060     *
061     * <p>
062     * Caching information and settings can be found in <code>portal.properties</code>
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see AnnouncementsDeliveryPersistence
067     * @see AnnouncementsDeliveryUtil
068     * @generated
069     */
070    public class AnnouncementsDeliveryPersistenceImpl extends BasePersistenceImpl<AnnouncementsDelivery>
071            implements AnnouncementsDeliveryPersistence {
072            public static final String FINDER_CLASS_NAME_ENTITY = AnnouncementsDeliveryImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
074                    ".List";
075            public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
076                            AnnouncementsDeliveryModelImpl.FINDER_CACHE_ENABLED,
077                            FINDER_CLASS_NAME_LIST, "findByUserId",
078                            new String[] {
079                                    Long.class.getName(),
080                                    
081                            "java.lang.Integer", "java.lang.Integer",
082                                    "com.liferay.portal.kernel.util.OrderByComparator"
083                            });
084            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
085                            AnnouncementsDeliveryModelImpl.FINDER_CACHE_ENABLED,
086                            FINDER_CLASS_NAME_LIST, "countByUserId",
087                            new String[] { Long.class.getName() });
088            public static final FinderPath FINDER_PATH_FETCH_BY_U_T = new FinderPath(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
089                            AnnouncementsDeliveryModelImpl.FINDER_CACHE_ENABLED,
090                            FINDER_CLASS_NAME_ENTITY, "fetchByU_T",
091                            new String[] { Long.class.getName(), String.class.getName() });
092            public static final FinderPath FINDER_PATH_COUNT_BY_U_T = new FinderPath(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
093                            AnnouncementsDeliveryModelImpl.FINDER_CACHE_ENABLED,
094                            FINDER_CLASS_NAME_LIST, "countByU_T",
095                            new String[] { Long.class.getName(), String.class.getName() });
096            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
097                            AnnouncementsDeliveryModelImpl.FINDER_CACHE_ENABLED,
098                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
099            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
100                            AnnouncementsDeliveryModelImpl.FINDER_CACHE_ENABLED,
101                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
102    
103            /**
104             * Caches the announcements delivery in the entity cache if it is enabled.
105             *
106             * @param announcementsDelivery the announcements delivery to cache
107             */
108            public void cacheResult(AnnouncementsDelivery announcementsDelivery) {
109                    EntityCacheUtil.putResult(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
110                            AnnouncementsDeliveryImpl.class,
111                            announcementsDelivery.getPrimaryKey(), announcementsDelivery);
112    
113                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
114                            new Object[] {
115                                    new Long(announcementsDelivery.getUserId()),
116                                    
117                            announcementsDelivery.getType()
118                            }, announcementsDelivery);
119            }
120    
121            /**
122             * Caches the announcements deliveries in the entity cache if it is enabled.
123             *
124             * @param announcementsDeliveries the announcements deliveries to cache
125             */
126            public void cacheResult(List<AnnouncementsDelivery> announcementsDeliveries) {
127                    for (AnnouncementsDelivery announcementsDelivery : announcementsDeliveries) {
128                            if (EntityCacheUtil.getResult(
129                                                    AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
130                                                    AnnouncementsDeliveryImpl.class,
131                                                    announcementsDelivery.getPrimaryKey(), this) == null) {
132                                    cacheResult(announcementsDelivery);
133                            }
134                    }
135            }
136    
137            /**
138             * Clears the cache for all announcements deliveries.
139             *
140             * <p>
141             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
142             * </p>
143             */
144            public void clearCache() {
145                    CacheRegistryUtil.clear(AnnouncementsDeliveryImpl.class.getName());
146                    EntityCacheUtil.clearCache(AnnouncementsDeliveryImpl.class.getName());
147                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
148                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
149            }
150    
151            /**
152             * Clears the cache for the announcements delivery.
153             *
154             * <p>
155             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
156             * </p>
157             */
158            public void clearCache(AnnouncementsDelivery announcementsDelivery) {
159                    EntityCacheUtil.removeResult(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
160                            AnnouncementsDeliveryImpl.class,
161                            announcementsDelivery.getPrimaryKey());
162    
163                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T,
164                            new Object[] {
165                                    new Long(announcementsDelivery.getUserId()),
166                                    
167                            announcementsDelivery.getType()
168                            });
169            }
170    
171            /**
172             * Creates a new announcements delivery with the primary key. Does not add the announcements delivery to the database.
173             *
174             * @param deliveryId the primary key for the new announcements delivery
175             * @return the new announcements delivery
176             */
177            public AnnouncementsDelivery create(long deliveryId) {
178                    AnnouncementsDelivery announcementsDelivery = new AnnouncementsDeliveryImpl();
179    
180                    announcementsDelivery.setNew(true);
181                    announcementsDelivery.setPrimaryKey(deliveryId);
182    
183                    return announcementsDelivery;
184            }
185    
186            /**
187             * Removes the announcements delivery with the primary key from the database. Also notifies the appropriate model listeners.
188             *
189             * @param primaryKey the primary key of the announcements delivery to remove
190             * @return the announcements delivery that was removed
191             * @throws com.liferay.portal.NoSuchModelException if a announcements delivery with the primary key could not be found
192             * @throws SystemException if a system exception occurred
193             */
194            public AnnouncementsDelivery remove(Serializable primaryKey)
195                    throws NoSuchModelException, SystemException {
196                    return remove(((Long)primaryKey).longValue());
197            }
198    
199            /**
200             * Removes the announcements delivery with the primary key from the database. Also notifies the appropriate model listeners.
201             *
202             * @param deliveryId the primary key of the announcements delivery to remove
203             * @return the announcements delivery that was removed
204             * @throws com.liferay.portlet.announcements.NoSuchDeliveryException if a announcements delivery with the primary key could not be found
205             * @throws SystemException if a system exception occurred
206             */
207            public AnnouncementsDelivery remove(long deliveryId)
208                    throws NoSuchDeliveryException, SystemException {
209                    Session session = null;
210    
211                    try {
212                            session = openSession();
213    
214                            AnnouncementsDelivery announcementsDelivery = (AnnouncementsDelivery)session.get(AnnouncementsDeliveryImpl.class,
215                                            new Long(deliveryId));
216    
217                            if (announcementsDelivery == null) {
218                                    if (_log.isWarnEnabled()) {
219                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + deliveryId);
220                                    }
221    
222                                    throw new NoSuchDeliveryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
223                                            deliveryId);
224                            }
225    
226                            return remove(announcementsDelivery);
227                    }
228                    catch (NoSuchDeliveryException nsee) {
229                            throw nsee;
230                    }
231                    catch (Exception e) {
232                            throw processException(e);
233                    }
234                    finally {
235                            closeSession(session);
236                    }
237            }
238    
239            protected AnnouncementsDelivery removeImpl(
240                    AnnouncementsDelivery announcementsDelivery) throws SystemException {
241                    announcementsDelivery = toUnwrappedModel(announcementsDelivery);
242    
243                    Session session = null;
244    
245                    try {
246                            session = openSession();
247    
248                            if (announcementsDelivery.isCachedModel() ||
249                                            BatchSessionUtil.isEnabled()) {
250                                    Object staleObject = session.get(AnnouncementsDeliveryImpl.class,
251                                                    announcementsDelivery.getPrimaryKeyObj());
252    
253                                    if (staleObject != null) {
254                                            session.evict(staleObject);
255                                    }
256                            }
257    
258                            session.delete(announcementsDelivery);
259    
260                            session.flush();
261                    }
262                    catch (Exception e) {
263                            throw processException(e);
264                    }
265                    finally {
266                            closeSession(session);
267                    }
268    
269                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
270    
271                    AnnouncementsDeliveryModelImpl announcementsDeliveryModelImpl = (AnnouncementsDeliveryModelImpl)announcementsDelivery;
272    
273                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T,
274                            new Object[] {
275                                    new Long(announcementsDeliveryModelImpl.getOriginalUserId()),
276                                    
277                            announcementsDeliveryModelImpl.getOriginalType()
278                            });
279    
280                    EntityCacheUtil.removeResult(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
281                            AnnouncementsDeliveryImpl.class,
282                            announcementsDelivery.getPrimaryKey());
283    
284                    return announcementsDelivery;
285            }
286    
287            public AnnouncementsDelivery updateImpl(
288                    com.liferay.portlet.announcements.model.AnnouncementsDelivery announcementsDelivery,
289                    boolean merge) throws SystemException {
290                    announcementsDelivery = toUnwrappedModel(announcementsDelivery);
291    
292                    boolean isNew = announcementsDelivery.isNew();
293    
294                    AnnouncementsDeliveryModelImpl announcementsDeliveryModelImpl = (AnnouncementsDeliveryModelImpl)announcementsDelivery;
295    
296                    Session session = null;
297    
298                    try {
299                            session = openSession();
300    
301                            BatchSessionUtil.update(session, announcementsDelivery, merge);
302    
303                            announcementsDelivery.setNew(false);
304                    }
305                    catch (Exception e) {
306                            throw processException(e);
307                    }
308                    finally {
309                            closeSession(session);
310                    }
311    
312                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
313    
314                    EntityCacheUtil.putResult(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
315                            AnnouncementsDeliveryImpl.class,
316                            announcementsDelivery.getPrimaryKey(), announcementsDelivery);
317    
318                    if (!isNew &&
319                                    ((announcementsDelivery.getUserId() != announcementsDeliveryModelImpl.getOriginalUserId()) ||
320                                    !Validator.equals(announcementsDelivery.getType(),
321                                            announcementsDeliveryModelImpl.getOriginalType()))) {
322                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T,
323                                    new Object[] {
324                                            new Long(announcementsDeliveryModelImpl.getOriginalUserId()),
325                                            
326                                    announcementsDeliveryModelImpl.getOriginalType()
327                                    });
328                    }
329    
330                    if (isNew ||
331                                    ((announcementsDelivery.getUserId() != announcementsDeliveryModelImpl.getOriginalUserId()) ||
332                                    !Validator.equals(announcementsDelivery.getType(),
333                                            announcementsDeliveryModelImpl.getOriginalType()))) {
334                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
335                                    new Object[] {
336                                            new Long(announcementsDelivery.getUserId()),
337                                            
338                                    announcementsDelivery.getType()
339                                    }, announcementsDelivery);
340                    }
341    
342                    return announcementsDelivery;
343            }
344    
345            protected AnnouncementsDelivery toUnwrappedModel(
346                    AnnouncementsDelivery announcementsDelivery) {
347                    if (announcementsDelivery instanceof AnnouncementsDeliveryImpl) {
348                            return announcementsDelivery;
349                    }
350    
351                    AnnouncementsDeliveryImpl announcementsDeliveryImpl = new AnnouncementsDeliveryImpl();
352    
353                    announcementsDeliveryImpl.setNew(announcementsDelivery.isNew());
354                    announcementsDeliveryImpl.setPrimaryKey(announcementsDelivery.getPrimaryKey());
355    
356                    announcementsDeliveryImpl.setDeliveryId(announcementsDelivery.getDeliveryId());
357                    announcementsDeliveryImpl.setCompanyId(announcementsDelivery.getCompanyId());
358                    announcementsDeliveryImpl.setUserId(announcementsDelivery.getUserId());
359                    announcementsDeliveryImpl.setType(announcementsDelivery.getType());
360                    announcementsDeliveryImpl.setEmail(announcementsDelivery.isEmail());
361                    announcementsDeliveryImpl.setSms(announcementsDelivery.isSms());
362                    announcementsDeliveryImpl.setWebsite(announcementsDelivery.isWebsite());
363    
364                    return announcementsDeliveryImpl;
365            }
366    
367            /**
368             * Finds the announcements delivery with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
369             *
370             * @param primaryKey the primary key of the announcements delivery to find
371             * @return the announcements delivery
372             * @throws com.liferay.portal.NoSuchModelException if a announcements delivery with the primary key could not be found
373             * @throws SystemException if a system exception occurred
374             */
375            public AnnouncementsDelivery findByPrimaryKey(Serializable primaryKey)
376                    throws NoSuchModelException, SystemException {
377                    return findByPrimaryKey(((Long)primaryKey).longValue());
378            }
379    
380            /**
381             * Finds the announcements delivery with the primary key or throws a {@link com.liferay.portlet.announcements.NoSuchDeliveryException} if it could not be found.
382             *
383             * @param deliveryId the primary key of the announcements delivery to find
384             * @return the announcements delivery
385             * @throws com.liferay.portlet.announcements.NoSuchDeliveryException if a announcements delivery with the primary key could not be found
386             * @throws SystemException if a system exception occurred
387             */
388            public AnnouncementsDelivery findByPrimaryKey(long deliveryId)
389                    throws NoSuchDeliveryException, SystemException {
390                    AnnouncementsDelivery announcementsDelivery = fetchByPrimaryKey(deliveryId);
391    
392                    if (announcementsDelivery == null) {
393                            if (_log.isWarnEnabled()) {
394                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + deliveryId);
395                            }
396    
397                            throw new NoSuchDeliveryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
398                                    deliveryId);
399                    }
400    
401                    return announcementsDelivery;
402            }
403    
404            /**
405             * Finds the announcements delivery with the primary key or returns <code>null</code> if it could not be found.
406             *
407             * @param primaryKey the primary key of the announcements delivery to find
408             * @return the announcements delivery, or <code>null</code> if a announcements delivery with the primary key could not be found
409             * @throws SystemException if a system exception occurred
410             */
411            public AnnouncementsDelivery fetchByPrimaryKey(Serializable primaryKey)
412                    throws SystemException {
413                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
414            }
415    
416            /**
417             * Finds the announcements delivery with the primary key or returns <code>null</code> if it could not be found.
418             *
419             * @param deliveryId the primary key of the announcements delivery to find
420             * @return the announcements delivery, or <code>null</code> if a announcements delivery with the primary key could not be found
421             * @throws SystemException if a system exception occurred
422             */
423            public AnnouncementsDelivery fetchByPrimaryKey(long deliveryId)
424                    throws SystemException {
425                    AnnouncementsDelivery announcementsDelivery = (AnnouncementsDelivery)EntityCacheUtil.getResult(AnnouncementsDeliveryModelImpl.ENTITY_CACHE_ENABLED,
426                                    AnnouncementsDeliveryImpl.class, deliveryId, this);
427    
428                    if (announcementsDelivery == null) {
429                            Session session = null;
430    
431                            try {
432                                    session = openSession();
433    
434                                    announcementsDelivery = (AnnouncementsDelivery)session.get(AnnouncementsDeliveryImpl.class,
435                                                    new Long(deliveryId));
436                            }
437                            catch (Exception e) {
438                                    throw processException(e);
439                            }
440                            finally {
441                                    if (announcementsDelivery != null) {
442                                            cacheResult(announcementsDelivery);
443                                    }
444    
445                                    closeSession(session);
446                            }
447                    }
448    
449                    return announcementsDelivery;
450            }
451    
452            /**
453             * Finds all the announcements deliveries where userId = &#63;.
454             *
455             * @param userId the user id to search with
456             * @return the matching announcements deliveries
457             * @throws SystemException if a system exception occurred
458             */
459            public List<AnnouncementsDelivery> findByUserId(long userId)
460                    throws SystemException {
461                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
462            }
463    
464            /**
465             * Finds a range of all the announcements deliveries where userId = &#63;.
466             *
467             * <p>
468             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
469             * </p>
470             *
471             * @param userId the user id to search with
472             * @param start the lower bound of the range of announcements deliveries to return
473             * @param end the upper bound of the range of announcements deliveries to return (not inclusive)
474             * @return the range of matching announcements deliveries
475             * @throws SystemException if a system exception occurred
476             */
477            public List<AnnouncementsDelivery> findByUserId(long userId, int start,
478                    int end) throws SystemException {
479                    return findByUserId(userId, start, end, null);
480            }
481    
482            /**
483             * Finds an ordered range of all the announcements deliveries where userId = &#63;.
484             *
485             * <p>
486             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
487             * </p>
488             *
489             * @param userId the user id to search with
490             * @param start the lower bound of the range of announcements deliveries to return
491             * @param end the upper bound of the range of announcements deliveries to return (not inclusive)
492             * @param orderByComparator the comparator to order the results by
493             * @return the ordered range of matching announcements deliveries
494             * @throws SystemException if a system exception occurred
495             */
496            public List<AnnouncementsDelivery> findByUserId(long userId, int start,
497                    int end, OrderByComparator orderByComparator) throws SystemException {
498                    Object[] finderArgs = new Object[] {
499                                    userId,
500                                    
501                                    String.valueOf(start), String.valueOf(end),
502                                    String.valueOf(orderByComparator)
503                            };
504    
505                    List<AnnouncementsDelivery> list = (List<AnnouncementsDelivery>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
506                                    finderArgs, this);
507    
508                    if (list == null) {
509                            Session session = null;
510    
511                            try {
512                                    session = openSession();
513    
514                                    StringBundler query = null;
515    
516                                    if (orderByComparator != null) {
517                                            query = new StringBundler(3 +
518                                                            (orderByComparator.getOrderByFields().length * 3));
519                                    }
520                                    else {
521                                            query = new StringBundler(2);
522                                    }
523    
524                                    query.append(_SQL_SELECT_ANNOUNCEMENTSDELIVERY_WHERE);
525    
526                                    query.append(_FINDER_COLUMN_USERID_USERID_2);
527    
528                                    if (orderByComparator != null) {
529                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
530                                                    orderByComparator);
531                                    }
532    
533                                    String sql = query.toString();
534    
535                                    Query q = session.createQuery(sql);
536    
537                                    QueryPos qPos = QueryPos.getInstance(q);
538    
539                                    qPos.add(userId);
540    
541                                    list = (List<AnnouncementsDelivery>)QueryUtil.list(q,
542                                                    getDialect(), start, end);
543                            }
544                            catch (Exception e) {
545                                    throw processException(e);
546                            }
547                            finally {
548                                    if (list == null) {
549                                            list = new ArrayList<AnnouncementsDelivery>();
550                                    }
551    
552                                    cacheResult(list);
553    
554                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
555                                            finderArgs, list);
556    
557                                    closeSession(session);
558                            }
559                    }
560    
561                    return list;
562            }
563    
564            /**
565             * Finds the first announcements delivery in the ordered set where userId = &#63;.
566             *
567             * <p>
568             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
569             * </p>
570             *
571             * @param userId the user id to search with
572             * @param orderByComparator the comparator to order the set by
573             * @return the first matching announcements delivery
574             * @throws com.liferay.portlet.announcements.NoSuchDeliveryException if a matching announcements delivery could not be found
575             * @throws SystemException if a system exception occurred
576             */
577            public AnnouncementsDelivery findByUserId_First(long userId,
578                    OrderByComparator orderByComparator)
579                    throws NoSuchDeliveryException, SystemException {
580                    List<AnnouncementsDelivery> list = findByUserId(userId, 0, 1,
581                                    orderByComparator);
582    
583                    if (list.isEmpty()) {
584                            StringBundler msg = new StringBundler(4);
585    
586                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
587    
588                            msg.append("userId=");
589                            msg.append(userId);
590    
591                            msg.append(StringPool.CLOSE_CURLY_BRACE);
592    
593                            throw new NoSuchDeliveryException(msg.toString());
594                    }
595                    else {
596                            return list.get(0);
597                    }
598            }
599    
600            /**
601             * Finds the last announcements delivery in the ordered set where userId = &#63;.
602             *
603             * <p>
604             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
605             * </p>
606             *
607             * @param userId the user id to search with
608             * @param orderByComparator the comparator to order the set by
609             * @return the last matching announcements delivery
610             * @throws com.liferay.portlet.announcements.NoSuchDeliveryException if a matching announcements delivery could not be found
611             * @throws SystemException if a system exception occurred
612             */
613            public AnnouncementsDelivery findByUserId_Last(long userId,
614                    OrderByComparator orderByComparator)
615                    throws NoSuchDeliveryException, SystemException {
616                    int count = countByUserId(userId);
617    
618                    List<AnnouncementsDelivery> list = findByUserId(userId, count - 1,
619                                    count, orderByComparator);
620    
621                    if (list.isEmpty()) {
622                            StringBundler msg = new StringBundler(4);
623    
624                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
625    
626                            msg.append("userId=");
627                            msg.append(userId);
628    
629                            msg.append(StringPool.CLOSE_CURLY_BRACE);
630    
631                            throw new NoSuchDeliveryException(msg.toString());
632                    }
633                    else {
634                            return list.get(0);
635                    }
636            }
637    
638            /**
639             * Finds the announcements deliveries before and after the current announcements delivery in the ordered set where userId = &#63;.
640             *
641             * <p>
642             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
643             * </p>
644             *
645             * @param deliveryId the primary key of the current announcements delivery
646             * @param userId the user id to search with
647             * @param orderByComparator the comparator to order the set by
648             * @return the previous, current, and next announcements delivery
649             * @throws com.liferay.portlet.announcements.NoSuchDeliveryException if a announcements delivery with the primary key could not be found
650             * @throws SystemException if a system exception occurred
651             */
652            public AnnouncementsDelivery[] findByUserId_PrevAndNext(long deliveryId,
653                    long userId, OrderByComparator orderByComparator)
654                    throws NoSuchDeliveryException, SystemException {
655                    AnnouncementsDelivery announcementsDelivery = findByPrimaryKey(deliveryId);
656    
657                    Session session = null;
658    
659                    try {
660                            session = openSession();
661    
662                            AnnouncementsDelivery[] array = new AnnouncementsDeliveryImpl[3];
663    
664                            array[0] = getByUserId_PrevAndNext(session, announcementsDelivery,
665                                            userId, orderByComparator, true);
666    
667                            array[1] = announcementsDelivery;
668    
669                            array[2] = getByUserId_PrevAndNext(session, announcementsDelivery,
670                                            userId, orderByComparator, false);
671    
672                            return array;
673                    }
674                    catch (Exception e) {
675                            throw processException(e);
676                    }
677                    finally {
678                            closeSession(session);
679                    }
680            }
681    
682            protected AnnouncementsDelivery getByUserId_PrevAndNext(Session session,
683                    AnnouncementsDelivery announcementsDelivery, long userId,
684                    OrderByComparator orderByComparator, boolean previous) {
685                    StringBundler query = null;
686    
687                    if (orderByComparator != null) {
688                            query = new StringBundler(6 +
689                                            (orderByComparator.getOrderByFields().length * 6));
690                    }
691                    else {
692                            query = new StringBundler(3);
693                    }
694    
695                    query.append(_SQL_SELECT_ANNOUNCEMENTSDELIVERY_WHERE);
696    
697                    query.append(_FINDER_COLUMN_USERID_USERID_2);
698    
699                    if (orderByComparator != null) {
700                            String[] orderByFields = orderByComparator.getOrderByFields();
701    
702                            if (orderByFields.length > 0) {
703                                    query.append(WHERE_AND);
704                            }
705    
706                            for (int i = 0; i < orderByFields.length; i++) {
707                                    query.append(_ORDER_BY_ENTITY_ALIAS);
708                                    query.append(orderByFields[i]);
709    
710                                    if ((i + 1) < orderByFields.length) {
711                                            if (orderByComparator.isAscending() ^ previous) {
712                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
713                                            }
714                                            else {
715                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
716                                            }
717                                    }
718                                    else {
719                                            if (orderByComparator.isAscending() ^ previous) {
720                                                    query.append(WHERE_GREATER_THAN);
721                                            }
722                                            else {
723                                                    query.append(WHERE_LESSER_THAN);
724                                            }
725                                    }
726                            }
727    
728                            query.append(ORDER_BY_CLAUSE);
729    
730                            for (int i = 0; i < orderByFields.length; i++) {
731                                    query.append(_ORDER_BY_ENTITY_ALIAS);
732                                    query.append(orderByFields[i]);
733    
734                                    if ((i + 1) < orderByFields.length) {
735                                            if (orderByComparator.isAscending() ^ previous) {
736                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
737                                            }
738                                            else {
739                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
740                                            }
741                                    }
742                                    else {
743                                            if (orderByComparator.isAscending() ^ previous) {
744                                                    query.append(ORDER_BY_ASC);
745                                            }
746                                            else {
747                                                    query.append(ORDER_BY_DESC);
748                                            }
749                                    }
750                            }
751                    }
752    
753                    String sql = query.toString();
754    
755                    Query q = session.createQuery(sql);
756    
757                    q.setFirstResult(0);
758                    q.setMaxResults(2);
759    
760                    QueryPos qPos = QueryPos.getInstance(q);
761    
762                    qPos.add(userId);
763    
764                    if (orderByComparator != null) {
765                            Object[] values = orderByComparator.getOrderByValues(announcementsDelivery);
766    
767                            for (Object value : values) {
768                                    qPos.add(value);
769                            }
770                    }
771    
772                    List<AnnouncementsDelivery> list = q.list();
773    
774                    if (list.size() == 2) {
775                            return list.get(1);
776                    }
777                    else {
778                            return null;
779                    }
780            }
781    
782            /**
783             * Finds the announcements delivery where userId = &#63; and type = &#63; or throws a {@link com.liferay.portlet.announcements.NoSuchDeliveryException} if it could not be found.
784             *
785             * @param userId the user id to search with
786             * @param type the type to search with
787             * @return the matching announcements delivery
788             * @throws com.liferay.portlet.announcements.NoSuchDeliveryException if a matching announcements delivery could not be found
789             * @throws SystemException if a system exception occurred
790             */
791            public AnnouncementsDelivery findByU_T(long userId, String type)
792                    throws NoSuchDeliveryException, SystemException {
793                    AnnouncementsDelivery announcementsDelivery = fetchByU_T(userId, type);
794    
795                    if (announcementsDelivery == null) {
796                            StringBundler msg = new StringBundler(6);
797    
798                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
799    
800                            msg.append("userId=");
801                            msg.append(userId);
802    
803                            msg.append(", type=");
804                            msg.append(type);
805    
806                            msg.append(StringPool.CLOSE_CURLY_BRACE);
807    
808                            if (_log.isWarnEnabled()) {
809                                    _log.warn(msg.toString());
810                            }
811    
812                            throw new NoSuchDeliveryException(msg.toString());
813                    }
814    
815                    return announcementsDelivery;
816            }
817    
818            /**
819             * Finds the announcements delivery where userId = &#63; and type = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
820             *
821             * @param userId the user id to search with
822             * @param type the type to search with
823             * @return the matching announcements delivery, or <code>null</code> if a matching announcements delivery could not be found
824             * @throws SystemException if a system exception occurred
825             */
826            public AnnouncementsDelivery fetchByU_T(long userId, String type)
827                    throws SystemException {
828                    return fetchByU_T(userId, type, true);
829            }
830    
831            /**
832             * Finds the announcements delivery where userId = &#63; and type = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
833             *
834             * @param userId the user id to search with
835             * @param type the type to search with
836             * @return the matching announcements delivery, or <code>null</code> if a matching announcements delivery could not be found
837             * @throws SystemException if a system exception occurred
838             */
839            public AnnouncementsDelivery fetchByU_T(long userId, String type,
840                    boolean retrieveFromCache) throws SystemException {
841                    Object[] finderArgs = new Object[] { userId, type };
842    
843                    Object result = null;
844    
845                    if (retrieveFromCache) {
846                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_T,
847                                            finderArgs, this);
848                    }
849    
850                    if (result == null) {
851                            Session session = null;
852    
853                            try {
854                                    session = openSession();
855    
856                                    StringBundler query = new StringBundler(3);
857    
858                                    query.append(_SQL_SELECT_ANNOUNCEMENTSDELIVERY_WHERE);
859    
860                                    query.append(_FINDER_COLUMN_U_T_USERID_2);
861    
862                                    if (type == null) {
863                                            query.append(_FINDER_COLUMN_U_T_TYPE_1);
864                                    }
865                                    else {
866                                            if (type.equals(StringPool.BLANK)) {
867                                                    query.append(_FINDER_COLUMN_U_T_TYPE_3);
868                                            }
869                                            else {
870                                                    query.append(_FINDER_COLUMN_U_T_TYPE_2);
871                                            }
872                                    }
873    
874                                    String sql = query.toString();
875    
876                                    Query q = session.createQuery(sql);
877    
878                                    QueryPos qPos = QueryPos.getInstance(q);
879    
880                                    qPos.add(userId);
881    
882                                    if (type != null) {
883                                            qPos.add(type);
884                                    }
885    
886                                    List<AnnouncementsDelivery> list = q.list();
887    
888                                    result = list;
889    
890                                    AnnouncementsDelivery announcementsDelivery = null;
891    
892                                    if (list.isEmpty()) {
893                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
894                                                    finderArgs, list);
895                                    }
896                                    else {
897                                            announcementsDelivery = list.get(0);
898    
899                                            cacheResult(announcementsDelivery);
900    
901                                            if ((announcementsDelivery.getUserId() != userId) ||
902                                                            (announcementsDelivery.getType() == null) ||
903                                                            !announcementsDelivery.getType().equals(type)) {
904                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
905                                                            finderArgs, announcementsDelivery);
906                                            }
907                                    }
908    
909                                    return announcementsDelivery;
910                            }
911                            catch (Exception e) {
912                                    throw processException(e);
913                            }
914                            finally {
915                                    if (result == null) {
916                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
917                                                    finderArgs, new ArrayList<AnnouncementsDelivery>());
918                                    }
919    
920                                    closeSession(session);
921                            }
922                    }
923                    else {
924                            if (result instanceof List<?>) {
925                                    return null;
926                            }
927                            else {
928                                    return (AnnouncementsDelivery)result;
929                            }
930                    }
931            }
932    
933            /**
934             * Finds all the announcements deliveries.
935             *
936             * @return the announcements deliveries
937             * @throws SystemException if a system exception occurred
938             */
939            public List<AnnouncementsDelivery> findAll() throws SystemException {
940                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
941            }
942    
943            /**
944             * Finds a range of all the announcements deliveries.
945             *
946             * <p>
947             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
948             * </p>
949             *
950             * @param start the lower bound of the range of announcements deliveries to return
951             * @param end the upper bound of the range of announcements deliveries to return (not inclusive)
952             * @return the range of announcements deliveries
953             * @throws SystemException if a system exception occurred
954             */
955            public List<AnnouncementsDelivery> findAll(int start, int end)
956                    throws SystemException {
957                    return findAll(start, end, null);
958            }
959    
960            /**
961             * Finds an ordered range of all the announcements deliveries.
962             *
963             * <p>
964             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
965             * </p>
966             *
967             * @param start the lower bound of the range of announcements deliveries to return
968             * @param end the upper bound of the range of announcements deliveries to return (not inclusive)
969             * @param orderByComparator the comparator to order the results by
970             * @return the ordered range of announcements deliveries
971             * @throws SystemException if a system exception occurred
972             */
973            public List<AnnouncementsDelivery> findAll(int start, int end,
974                    OrderByComparator orderByComparator) throws SystemException {
975                    Object[] finderArgs = new Object[] {
976                                    String.valueOf(start), String.valueOf(end),
977                                    String.valueOf(orderByComparator)
978                            };
979    
980                    List<AnnouncementsDelivery> list = (List<AnnouncementsDelivery>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
981                                    finderArgs, this);
982    
983                    if (list == null) {
984                            Session session = null;
985    
986                            try {
987                                    session = openSession();
988    
989                                    StringBundler query = null;
990                                    String sql = null;
991    
992                                    if (orderByComparator != null) {
993                                            query = new StringBundler(2 +
994                                                            (orderByComparator.getOrderByFields().length * 3));
995    
996                                            query.append(_SQL_SELECT_ANNOUNCEMENTSDELIVERY);
997    
998                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
999                                                    orderByComparator);
1000    
1001                                            sql = query.toString();
1002                                    }
1003                                    else {
1004                                            sql = _SQL_SELECT_ANNOUNCEMENTSDELIVERY;
1005                                    }
1006    
1007                                    Query q = session.createQuery(sql);
1008    
1009                                    if (orderByComparator == null) {
1010                                            list = (List<AnnouncementsDelivery>)QueryUtil.list(q,
1011                                                            getDialect(), start, end, false);
1012    
1013                                            Collections.sort(list);
1014                                    }
1015                                    else {
1016                                            list = (List<AnnouncementsDelivery>)QueryUtil.list(q,
1017                                                            getDialect(), start, end);
1018                                    }
1019                            }
1020                            catch (Exception e) {
1021                                    throw processException(e);
1022                            }
1023                            finally {
1024                                    if (list == null) {
1025                                            list = new ArrayList<AnnouncementsDelivery>();
1026                                    }
1027    
1028                                    cacheResult(list);
1029    
1030                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1031    
1032                                    closeSession(session);
1033                            }
1034                    }
1035    
1036                    return list;
1037            }
1038    
1039            /**
1040             * Removes all the announcements deliveries where userId = &#63; from the database.
1041             *
1042             * @param userId the user id to search with
1043             * @throws SystemException if a system exception occurred
1044             */
1045            public void removeByUserId(long userId) throws SystemException {
1046                    for (AnnouncementsDelivery announcementsDelivery : findByUserId(userId)) {
1047                            remove(announcementsDelivery);
1048                    }
1049            }
1050    
1051            /**
1052             * Removes the announcements delivery where userId = &#63; and type = &#63; from the database.
1053             *
1054             * @param userId the user id to search with
1055             * @param type the type to search with
1056             * @throws SystemException if a system exception occurred
1057             */
1058            public void removeByU_T(long userId, String type)
1059                    throws NoSuchDeliveryException, SystemException {
1060                    AnnouncementsDelivery announcementsDelivery = findByU_T(userId, type);
1061    
1062                    remove(announcementsDelivery);
1063            }
1064    
1065            /**
1066             * Removes all the announcements deliveries from the database.
1067             *
1068             * @throws SystemException if a system exception occurred
1069             */
1070            public void removeAll() throws SystemException {
1071                    for (AnnouncementsDelivery announcementsDelivery : findAll()) {
1072                            remove(announcementsDelivery);
1073                    }
1074            }
1075    
1076            /**
1077             * Counts all the announcements deliveries where userId = &#63;.
1078             *
1079             * @param userId the user id to search with
1080             * @return the number of matching announcements deliveries
1081             * @throws SystemException if a system exception occurred
1082             */
1083            public int countByUserId(long userId) throws SystemException {
1084                    Object[] finderArgs = new Object[] { userId };
1085    
1086                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1087                                    finderArgs, this);
1088    
1089                    if (count == null) {
1090                            Session session = null;
1091    
1092                            try {
1093                                    session = openSession();
1094    
1095                                    StringBundler query = new StringBundler(2);
1096    
1097                                    query.append(_SQL_COUNT_ANNOUNCEMENTSDELIVERY_WHERE);
1098    
1099                                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1100    
1101                                    String sql = query.toString();
1102    
1103                                    Query q = session.createQuery(sql);
1104    
1105                                    QueryPos qPos = QueryPos.getInstance(q);
1106    
1107                                    qPos.add(userId);
1108    
1109                                    count = (Long)q.uniqueResult();
1110                            }
1111                            catch (Exception e) {
1112                                    throw processException(e);
1113                            }
1114                            finally {
1115                                    if (count == null) {
1116                                            count = Long.valueOf(0);
1117                                    }
1118    
1119                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1120                                            finderArgs, count);
1121    
1122                                    closeSession(session);
1123                            }
1124                    }
1125    
1126                    return count.intValue();
1127            }
1128    
1129            /**
1130             * Counts all the announcements deliveries where userId = &#63; and type = &#63;.
1131             *
1132             * @param userId the user id to search with
1133             * @param type the type to search with
1134             * @return the number of matching announcements deliveries
1135             * @throws SystemException if a system exception occurred
1136             */
1137            public int countByU_T(long userId, String type) throws SystemException {
1138                    Object[] finderArgs = new Object[] { userId, type };
1139    
1140                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_T,
1141                                    finderArgs, this);
1142    
1143                    if (count == null) {
1144                            Session session = null;
1145    
1146                            try {
1147                                    session = openSession();
1148    
1149                                    StringBundler query = new StringBundler(3);
1150    
1151                                    query.append(_SQL_COUNT_ANNOUNCEMENTSDELIVERY_WHERE);
1152    
1153                                    query.append(_FINDER_COLUMN_U_T_USERID_2);
1154    
1155                                    if (type == null) {
1156                                            query.append(_FINDER_COLUMN_U_T_TYPE_1);
1157                                    }
1158                                    else {
1159                                            if (type.equals(StringPool.BLANK)) {
1160                                                    query.append(_FINDER_COLUMN_U_T_TYPE_3);
1161                                            }
1162                                            else {
1163                                                    query.append(_FINDER_COLUMN_U_T_TYPE_2);
1164                                            }
1165                                    }
1166    
1167                                    String sql = query.toString();
1168    
1169                                    Query q = session.createQuery(sql);
1170    
1171                                    QueryPos qPos = QueryPos.getInstance(q);
1172    
1173                                    qPos.add(userId);
1174    
1175                                    if (type != null) {
1176                                            qPos.add(type);
1177                                    }
1178    
1179                                    count = (Long)q.uniqueResult();
1180                            }
1181                            catch (Exception e) {
1182                                    throw processException(e);
1183                            }
1184                            finally {
1185                                    if (count == null) {
1186                                            count = Long.valueOf(0);
1187                                    }
1188    
1189                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_T, finderArgs,
1190                                            count);
1191    
1192                                    closeSession(session);
1193                            }
1194                    }
1195    
1196                    return count.intValue();
1197            }
1198    
1199            /**
1200             * Counts all the announcements deliveries.
1201             *
1202             * @return the number of announcements deliveries
1203             * @throws SystemException if a system exception occurred
1204             */
1205            public int countAll() throws SystemException {
1206                    Object[] finderArgs = new Object[0];
1207    
1208                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1209                                    finderArgs, this);
1210    
1211                    if (count == null) {
1212                            Session session = null;
1213    
1214                            try {
1215                                    session = openSession();
1216    
1217                                    Query q = session.createQuery(_SQL_COUNT_ANNOUNCEMENTSDELIVERY);
1218    
1219                                    count = (Long)q.uniqueResult();
1220                            }
1221                            catch (Exception e) {
1222                                    throw processException(e);
1223                            }
1224                            finally {
1225                                    if (count == null) {
1226                                            count = Long.valueOf(0);
1227                                    }
1228    
1229                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1230                                            count);
1231    
1232                                    closeSession(session);
1233                            }
1234                    }
1235    
1236                    return count.intValue();
1237            }
1238    
1239            /**
1240             * Initializes the announcements delivery persistence.
1241             */
1242            public void afterPropertiesSet() {
1243                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1244                                            com.liferay.portal.util.PropsUtil.get(
1245                                                    "value.object.listener.com.liferay.portlet.announcements.model.AnnouncementsDelivery")));
1246    
1247                    if (listenerClassNames.length > 0) {
1248                            try {
1249                                    List<ModelListener<AnnouncementsDelivery>> listenersList = new ArrayList<ModelListener<AnnouncementsDelivery>>();
1250    
1251                                    for (String listenerClassName : listenerClassNames) {
1252                                            listenersList.add((ModelListener<AnnouncementsDelivery>)InstanceFactory.newInstance(
1253                                                            listenerClassName));
1254                                    }
1255    
1256                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1257                            }
1258                            catch (Exception e) {
1259                                    _log.error(e);
1260                            }
1261                    }
1262            }
1263    
1264            @BeanReference(type = AnnouncementsDeliveryPersistence.class)
1265            protected AnnouncementsDeliveryPersistence announcementsDeliveryPersistence;
1266            @BeanReference(type = AnnouncementsEntryPersistence.class)
1267            protected AnnouncementsEntryPersistence announcementsEntryPersistence;
1268            @BeanReference(type = AnnouncementsFlagPersistence.class)
1269            protected AnnouncementsFlagPersistence announcementsFlagPersistence;
1270            @BeanReference(type = ResourcePersistence.class)
1271            protected ResourcePersistence resourcePersistence;
1272            @BeanReference(type = UserPersistence.class)
1273            protected UserPersistence userPersistence;
1274            private static final String _SQL_SELECT_ANNOUNCEMENTSDELIVERY = "SELECT announcementsDelivery FROM AnnouncementsDelivery announcementsDelivery";
1275            private static final String _SQL_SELECT_ANNOUNCEMENTSDELIVERY_WHERE = "SELECT announcementsDelivery FROM AnnouncementsDelivery announcementsDelivery WHERE ";
1276            private static final String _SQL_COUNT_ANNOUNCEMENTSDELIVERY = "SELECT COUNT(announcementsDelivery) FROM AnnouncementsDelivery announcementsDelivery";
1277            private static final String _SQL_COUNT_ANNOUNCEMENTSDELIVERY_WHERE = "SELECT COUNT(announcementsDelivery) FROM AnnouncementsDelivery announcementsDelivery WHERE ";
1278            private static final String _FINDER_COLUMN_USERID_USERID_2 = "announcementsDelivery.userId = ?";
1279            private static final String _FINDER_COLUMN_U_T_USERID_2 = "announcementsDelivery.userId = ? AND ";
1280            private static final String _FINDER_COLUMN_U_T_TYPE_1 = "announcementsDelivery.type IS NULL";
1281            private static final String _FINDER_COLUMN_U_T_TYPE_2 = "announcementsDelivery.type = ?";
1282            private static final String _FINDER_COLUMN_U_T_TYPE_3 = "(announcementsDelivery.type IS NULL OR announcementsDelivery.type = ?)";
1283            private static final String _ORDER_BY_ENTITY_ALIAS = "announcementsDelivery.";
1284            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AnnouncementsDelivery exists with the primary key ";
1285            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AnnouncementsDelivery exists with the key {";
1286            private static Log _log = LogFactoryUtil.getLog(AnnouncementsDeliveryPersistenceImpl.class);
1287    }