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