001    /**
002     * Copyright (c) 2000-2011 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.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041    import com.liferay.portal.service.persistence.BatchSessionUtil;
042    import com.liferay.portal.service.persistence.CompanyPersistence;
043    import com.liferay.portal.service.persistence.GroupPersistence;
044    import com.liferay.portal.service.persistence.OrganizationPersistence;
045    import com.liferay.portal.service.persistence.ResourcePersistence;
046    import com.liferay.portal.service.persistence.RolePersistence;
047    import com.liferay.portal.service.persistence.UserGroupPersistence;
048    import com.liferay.portal.service.persistence.UserPersistence;
049    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050    
051    import com.liferay.portlet.announcements.NoSuchEntryException;
052    import com.liferay.portlet.announcements.model.AnnouncementsEntry;
053    import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryImpl;
054    import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryModelImpl;
055    
056    import java.io.Serializable;
057    
058    import java.util.ArrayList;
059    import java.util.Collections;
060    import java.util.List;
061    
062    /**
063     * The persistence implementation for the announcements entry service.
064     *
065     * <p>
066     * Never modify or reference this class directly. Always use {@link AnnouncementsEntryUtil} to access the announcements entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
067     * </p>
068     *
069     * <p>
070     * Caching information and settings can be found in <code>portal.properties</code>
071     * </p>
072     *
073     * @author Brian Wing Shun Chan
074     * @see AnnouncementsEntryPersistence
075     * @see AnnouncementsEntryUtil
076     * @generated
077     */
078    public class AnnouncementsEntryPersistenceImpl extends BasePersistenceImpl<AnnouncementsEntry>
079            implements AnnouncementsEntryPersistence {
080            public static final String FINDER_CLASS_NAME_ENTITY = AnnouncementsEntryImpl.class.getName();
081            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
082                    ".List";
083            public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
084                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
085                            FINDER_CLASS_NAME_LIST, "findByUuid",
086                            new String[] {
087                                    String.class.getName(),
088                                    
089                            "java.lang.Integer", "java.lang.Integer",
090                                    "com.liferay.portal.kernel.util.OrderByComparator"
091                            });
092            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
093                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
094                            FINDER_CLASS_NAME_LIST, "countByUuid",
095                            new String[] { String.class.getName() });
096            public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
097                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
098                            FINDER_CLASS_NAME_LIST, "findByUserId",
099                            new String[] {
100                                    Long.class.getName(),
101                                    
102                            "java.lang.Integer", "java.lang.Integer",
103                                    "com.liferay.portal.kernel.util.OrderByComparator"
104                            });
105            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
106                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
107                            FINDER_CLASS_NAME_LIST, "countByUserId",
108                            new String[] { Long.class.getName() });
109            public static final FinderPath FINDER_PATH_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
110                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
111                            FINDER_CLASS_NAME_LIST, "findByC_C",
112                            new String[] {
113                                    Long.class.getName(), Long.class.getName(),
114                                    
115                            "java.lang.Integer", "java.lang.Integer",
116                                    "com.liferay.portal.kernel.util.OrderByComparator"
117                            });
118            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
119                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
120                            FINDER_CLASS_NAME_LIST, "countByC_C",
121                            new String[] { Long.class.getName(), Long.class.getName() });
122            public static final FinderPath FINDER_PATH_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
123                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
124                            FINDER_CLASS_NAME_LIST, "findByC_C_A",
125                            new String[] {
126                                    Long.class.getName(), Long.class.getName(),
127                                    Boolean.class.getName(),
128                                    
129                            "java.lang.Integer", "java.lang.Integer",
130                                    "com.liferay.portal.kernel.util.OrderByComparator"
131                            });
132            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
133                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
134                            FINDER_CLASS_NAME_LIST, "countByC_C_A",
135                            new String[] {
136                                    Long.class.getName(), Long.class.getName(),
137                                    Boolean.class.getName()
138                            });
139            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
140                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
141                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
142            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
143                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
144                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
145    
146            /**
147             * Caches the announcements entry in the entity cache if it is enabled.
148             *
149             * @param announcementsEntry the announcements entry to cache
150             */
151            public void cacheResult(AnnouncementsEntry announcementsEntry) {
152                    EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
153                            AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
154                            announcementsEntry);
155            }
156    
157            /**
158             * Caches the announcements entries in the entity cache if it is enabled.
159             *
160             * @param announcementsEntries the announcements entries to cache
161             */
162            public void cacheResult(List<AnnouncementsEntry> announcementsEntries) {
163                    for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
164                            if (EntityCacheUtil.getResult(
165                                                    AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
166                                                    AnnouncementsEntryImpl.class,
167                                                    announcementsEntry.getPrimaryKey(), this) == null) {
168                                    cacheResult(announcementsEntry);
169                            }
170                    }
171            }
172    
173            /**
174             * Clears the cache for all announcements entries.
175             *
176             * <p>
177             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
178             * </p>
179             */
180            public void clearCache() {
181                    CacheRegistryUtil.clear(AnnouncementsEntryImpl.class.getName());
182                    EntityCacheUtil.clearCache(AnnouncementsEntryImpl.class.getName());
183                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
184                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
185            }
186    
187            /**
188             * Clears the cache for the announcements entry.
189             *
190             * <p>
191             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
192             * </p>
193             */
194            public void clearCache(AnnouncementsEntry announcementsEntry) {
195                    EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
196                            AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
197            }
198    
199            /**
200             * Creates a new announcements entry with the primary key. Does not add the announcements entry to the database.
201             *
202             * @param entryId the primary key for the new announcements entry
203             * @return the new announcements entry
204             */
205            public AnnouncementsEntry create(long entryId) {
206                    AnnouncementsEntry announcementsEntry = new AnnouncementsEntryImpl();
207    
208                    announcementsEntry.setNew(true);
209                    announcementsEntry.setPrimaryKey(entryId);
210    
211                    String uuid = PortalUUIDUtil.generate();
212    
213                    announcementsEntry.setUuid(uuid);
214    
215                    return announcementsEntry;
216            }
217    
218            /**
219             * Removes the announcements entry with the primary key from the database. Also notifies the appropriate model listeners.
220             *
221             * @param primaryKey the primary key of the announcements entry to remove
222             * @return the announcements entry that was removed
223             * @throws com.liferay.portal.NoSuchModelException if a announcements entry with the primary key could not be found
224             * @throws SystemException if a system exception occurred
225             */
226            public AnnouncementsEntry remove(Serializable primaryKey)
227                    throws NoSuchModelException, SystemException {
228                    return remove(((Long)primaryKey).longValue());
229            }
230    
231            /**
232             * Removes the announcements entry with the primary key from the database. Also notifies the appropriate model listeners.
233             *
234             * @param entryId the primary key of the announcements entry to remove
235             * @return the announcements entry that was removed
236             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
237             * @throws SystemException if a system exception occurred
238             */
239            public AnnouncementsEntry remove(long entryId)
240                    throws NoSuchEntryException, SystemException {
241                    Session session = null;
242    
243                    try {
244                            session = openSession();
245    
246                            AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
247                                            new Long(entryId));
248    
249                            if (announcementsEntry == null) {
250                                    if (_log.isWarnEnabled()) {
251                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
252                                    }
253    
254                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
255                                            entryId);
256                            }
257    
258                            return remove(announcementsEntry);
259                    }
260                    catch (NoSuchEntryException nsee) {
261                            throw nsee;
262                    }
263                    catch (Exception e) {
264                            throw processException(e);
265                    }
266                    finally {
267                            closeSession(session);
268                    }
269            }
270    
271            protected AnnouncementsEntry removeImpl(
272                    AnnouncementsEntry announcementsEntry) throws SystemException {
273                    announcementsEntry = toUnwrappedModel(announcementsEntry);
274    
275                    Session session = null;
276    
277                    try {
278                            session = openSession();
279    
280                            BatchSessionUtil.delete(session, announcementsEntry);
281                    }
282                    catch (Exception e) {
283                            throw processException(e);
284                    }
285                    finally {
286                            closeSession(session);
287                    }
288    
289                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
290    
291                    EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
292                            AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
293    
294                    return announcementsEntry;
295            }
296    
297            public AnnouncementsEntry updateImpl(
298                    com.liferay.portlet.announcements.model.AnnouncementsEntry announcementsEntry,
299                    boolean merge) throws SystemException {
300                    announcementsEntry = toUnwrappedModel(announcementsEntry);
301    
302                    if (Validator.isNull(announcementsEntry.getUuid())) {
303                            String uuid = PortalUUIDUtil.generate();
304    
305                            announcementsEntry.setUuid(uuid);
306                    }
307    
308                    Session session = null;
309    
310                    try {
311                            session = openSession();
312    
313                            BatchSessionUtil.update(session, announcementsEntry, merge);
314    
315                            announcementsEntry.setNew(false);
316                    }
317                    catch (Exception e) {
318                            throw processException(e);
319                    }
320                    finally {
321                            closeSession(session);
322                    }
323    
324                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
325    
326                    EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
327                            AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
328                            announcementsEntry);
329    
330                    return announcementsEntry;
331            }
332    
333            protected AnnouncementsEntry toUnwrappedModel(
334                    AnnouncementsEntry announcementsEntry) {
335                    if (announcementsEntry instanceof AnnouncementsEntryImpl) {
336                            return announcementsEntry;
337                    }
338    
339                    AnnouncementsEntryImpl announcementsEntryImpl = new AnnouncementsEntryImpl();
340    
341                    announcementsEntryImpl.setNew(announcementsEntry.isNew());
342                    announcementsEntryImpl.setPrimaryKey(announcementsEntry.getPrimaryKey());
343    
344                    announcementsEntryImpl.setUuid(announcementsEntry.getUuid());
345                    announcementsEntryImpl.setEntryId(announcementsEntry.getEntryId());
346                    announcementsEntryImpl.setCompanyId(announcementsEntry.getCompanyId());
347                    announcementsEntryImpl.setUserId(announcementsEntry.getUserId());
348                    announcementsEntryImpl.setUserName(announcementsEntry.getUserName());
349                    announcementsEntryImpl.setCreateDate(announcementsEntry.getCreateDate());
350                    announcementsEntryImpl.setModifiedDate(announcementsEntry.getModifiedDate());
351                    announcementsEntryImpl.setClassNameId(announcementsEntry.getClassNameId());
352                    announcementsEntryImpl.setClassPK(announcementsEntry.getClassPK());
353                    announcementsEntryImpl.setTitle(announcementsEntry.getTitle());
354                    announcementsEntryImpl.setContent(announcementsEntry.getContent());
355                    announcementsEntryImpl.setUrl(announcementsEntry.getUrl());
356                    announcementsEntryImpl.setType(announcementsEntry.getType());
357                    announcementsEntryImpl.setDisplayDate(announcementsEntry.getDisplayDate());
358                    announcementsEntryImpl.setExpirationDate(announcementsEntry.getExpirationDate());
359                    announcementsEntryImpl.setPriority(announcementsEntry.getPriority());
360                    announcementsEntryImpl.setAlert(announcementsEntry.isAlert());
361    
362                    return announcementsEntryImpl;
363            }
364    
365            /**
366             * Finds the announcements entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
367             *
368             * @param primaryKey the primary key of the announcements entry to find
369             * @return the announcements entry
370             * @throws com.liferay.portal.NoSuchModelException if a announcements entry with the primary key could not be found
371             * @throws SystemException if a system exception occurred
372             */
373            public AnnouncementsEntry findByPrimaryKey(Serializable primaryKey)
374                    throws NoSuchModelException, SystemException {
375                    return findByPrimaryKey(((Long)primaryKey).longValue());
376            }
377    
378            /**
379             * Finds the announcements entry with the primary key or throws a {@link com.liferay.portlet.announcements.NoSuchEntryException} if it could not be found.
380             *
381             * @param entryId the primary key of the announcements entry to find
382             * @return the announcements entry
383             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
384             * @throws SystemException if a system exception occurred
385             */
386            public AnnouncementsEntry findByPrimaryKey(long entryId)
387                    throws NoSuchEntryException, SystemException {
388                    AnnouncementsEntry announcementsEntry = fetchByPrimaryKey(entryId);
389    
390                    if (announcementsEntry == null) {
391                            if (_log.isWarnEnabled()) {
392                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
393                            }
394    
395                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
396                                    entryId);
397                    }
398    
399                    return announcementsEntry;
400            }
401    
402            /**
403             * Finds the announcements entry with the primary key or returns <code>null</code> if it could not be found.
404             *
405             * @param primaryKey the primary key of the announcements entry to find
406             * @return the announcements entry, or <code>null</code> if a announcements entry with the primary key could not be found
407             * @throws SystemException if a system exception occurred
408             */
409            public AnnouncementsEntry fetchByPrimaryKey(Serializable primaryKey)
410                    throws SystemException {
411                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
412            }
413    
414            /**
415             * Finds the announcements entry with the primary key or returns <code>null</code> if it could not be found.
416             *
417             * @param entryId the primary key of the announcements entry to find
418             * @return the announcements entry, or <code>null</code> if a announcements entry with the primary key could not be found
419             * @throws SystemException if a system exception occurred
420             */
421            public AnnouncementsEntry fetchByPrimaryKey(long entryId)
422                    throws SystemException {
423                    AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)EntityCacheUtil.getResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
424                                    AnnouncementsEntryImpl.class, entryId, this);
425    
426                    if (announcementsEntry == null) {
427                            Session session = null;
428    
429                            try {
430                                    session = openSession();
431    
432                                    announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
433                                                    new Long(entryId));
434                            }
435                            catch (Exception e) {
436                                    throw processException(e);
437                            }
438                            finally {
439                                    if (announcementsEntry != null) {
440                                            cacheResult(announcementsEntry);
441                                    }
442    
443                                    closeSession(session);
444                            }
445                    }
446    
447                    return announcementsEntry;
448            }
449    
450            /**
451             * Finds all the announcements entries where uuid = &#63;.
452             *
453             * @param uuid the uuid to search with
454             * @return the matching announcements entries
455             * @throws SystemException if a system exception occurred
456             */
457            public List<AnnouncementsEntry> findByUuid(String uuid)
458                    throws SystemException {
459                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
460            }
461    
462            /**
463             * Finds a range of all the announcements entries where uuid = &#63;.
464             *
465             * <p>
466             * 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.
467             * </p>
468             *
469             * @param uuid the uuid to search with
470             * @param start the lower bound of the range of announcements entries to return
471             * @param end the upper bound of the range of announcements entries to return (not inclusive)
472             * @return the range of matching announcements entries
473             * @throws SystemException if a system exception occurred
474             */
475            public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end)
476                    throws SystemException {
477                    return findByUuid(uuid, start, end, null);
478            }
479    
480            /**
481             * Finds an ordered range of all the announcements entries where uuid = &#63;.
482             *
483             * <p>
484             * 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.
485             * </p>
486             *
487             * @param uuid the uuid to search with
488             * @param start the lower bound of the range of announcements entries to return
489             * @param end the upper bound of the range of announcements entries to return (not inclusive)
490             * @param orderByComparator the comparator to order the results by
491             * @return the ordered range of matching announcements entries
492             * @throws SystemException if a system exception occurred
493             */
494            public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end,
495                    OrderByComparator orderByComparator) throws SystemException {
496                    Object[] finderArgs = new Object[] {
497                                    uuid,
498                                    
499                                    String.valueOf(start), String.valueOf(end),
500                                    String.valueOf(orderByComparator)
501                            };
502    
503                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
504                                    finderArgs, this);
505    
506                    if (list == null) {
507                            StringBundler query = null;
508    
509                            if (orderByComparator != null) {
510                                    query = new StringBundler(3 +
511                                                    (orderByComparator.getOrderByFields().length * 3));
512                            }
513                            else {
514                                    query = new StringBundler(3);
515                            }
516    
517                            query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
518    
519                            if (uuid == null) {
520                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
521                            }
522                            else {
523                                    if (uuid.equals(StringPool.BLANK)) {
524                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
525                                    }
526                                    else {
527                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
528                                    }
529                            }
530    
531                            if (orderByComparator != null) {
532                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
533                                            orderByComparator);
534                            }
535    
536                            else {
537                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
538                            }
539    
540                            String sql = query.toString();
541    
542                            Session session = null;
543    
544                            try {
545                                    session = openSession();
546    
547                                    Query q = session.createQuery(sql);
548    
549                                    QueryPos qPos = QueryPos.getInstance(q);
550    
551                                    if (uuid != null) {
552                                            qPos.add(uuid);
553                                    }
554    
555                                    list = (List<AnnouncementsEntry>)QueryUtil.list(q,
556                                                    getDialect(), start, end);
557                            }
558                            catch (Exception e) {
559                                    throw processException(e);
560                            }
561                            finally {
562                                    if (list == null) {
563                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_UUID,
564                                                    finderArgs);
565                                    }
566                                    else {
567                                            cacheResult(list);
568    
569                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID,
570                                                    finderArgs, list);
571                                    }
572    
573                                    closeSession(session);
574                            }
575                    }
576    
577                    return list;
578            }
579    
580            /**
581             * Finds the first announcements entry in the ordered set where uuid = &#63;.
582             *
583             * <p>
584             * 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.
585             * </p>
586             *
587             * @param uuid the uuid to search with
588             * @param orderByComparator the comparator to order the set by
589             * @return the first matching announcements entry
590             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
591             * @throws SystemException if a system exception occurred
592             */
593            public AnnouncementsEntry findByUuid_First(String uuid,
594                    OrderByComparator orderByComparator)
595                    throws NoSuchEntryException, SystemException {
596                    List<AnnouncementsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
597    
598                    if (list.isEmpty()) {
599                            StringBundler msg = new StringBundler(4);
600    
601                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
602    
603                            msg.append("uuid=");
604                            msg.append(uuid);
605    
606                            msg.append(StringPool.CLOSE_CURLY_BRACE);
607    
608                            throw new NoSuchEntryException(msg.toString());
609                    }
610                    else {
611                            return list.get(0);
612                    }
613            }
614    
615            /**
616             * Finds the last announcements entry in the ordered set where uuid = &#63;.
617             *
618             * <p>
619             * 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.
620             * </p>
621             *
622             * @param uuid the uuid to search with
623             * @param orderByComparator the comparator to order the set by
624             * @return the last matching announcements entry
625             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
626             * @throws SystemException if a system exception occurred
627             */
628            public AnnouncementsEntry findByUuid_Last(String uuid,
629                    OrderByComparator orderByComparator)
630                    throws NoSuchEntryException, SystemException {
631                    int count = countByUuid(uuid);
632    
633                    List<AnnouncementsEntry> list = findByUuid(uuid, count - 1, count,
634                                    orderByComparator);
635    
636                    if (list.isEmpty()) {
637                            StringBundler msg = new StringBundler(4);
638    
639                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
640    
641                            msg.append("uuid=");
642                            msg.append(uuid);
643    
644                            msg.append(StringPool.CLOSE_CURLY_BRACE);
645    
646                            throw new NoSuchEntryException(msg.toString());
647                    }
648                    else {
649                            return list.get(0);
650                    }
651            }
652    
653            /**
654             * Finds the announcements entries before and after the current announcements entry in the ordered set where uuid = &#63;.
655             *
656             * <p>
657             * 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.
658             * </p>
659             *
660             * @param entryId the primary key of the current announcements entry
661             * @param uuid the uuid to search with
662             * @param orderByComparator the comparator to order the set by
663             * @return the previous, current, and next announcements entry
664             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
665             * @throws SystemException if a system exception occurred
666             */
667            public AnnouncementsEntry[] findByUuid_PrevAndNext(long entryId,
668                    String uuid, OrderByComparator orderByComparator)
669                    throws NoSuchEntryException, SystemException {
670                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
671    
672                    Session session = null;
673    
674                    try {
675                            session = openSession();
676    
677                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
678    
679                            array[0] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
680                                            orderByComparator, true);
681    
682                            array[1] = announcementsEntry;
683    
684                            array[2] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
685                                            orderByComparator, false);
686    
687                            return array;
688                    }
689                    catch (Exception e) {
690                            throw processException(e);
691                    }
692                    finally {
693                            closeSession(session);
694                    }
695            }
696    
697            protected AnnouncementsEntry getByUuid_PrevAndNext(Session session,
698                    AnnouncementsEntry announcementsEntry, String uuid,
699                    OrderByComparator orderByComparator, boolean previous) {
700                    StringBundler query = null;
701    
702                    if (orderByComparator != null) {
703                            query = new StringBundler(6 +
704                                            (orderByComparator.getOrderByFields().length * 6));
705                    }
706                    else {
707                            query = new StringBundler(3);
708                    }
709    
710                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
711    
712                    if (uuid == null) {
713                            query.append(_FINDER_COLUMN_UUID_UUID_1);
714                    }
715                    else {
716                            if (uuid.equals(StringPool.BLANK)) {
717                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
718                            }
719                            else {
720                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
721                            }
722                    }
723    
724                    if (orderByComparator != null) {
725                            String[] orderByFields = orderByComparator.getOrderByFields();
726    
727                            if (orderByFields.length > 0) {
728                                    query.append(WHERE_AND);
729                            }
730    
731                            for (int i = 0; i < orderByFields.length; i++) {
732                                    query.append(_ORDER_BY_ENTITY_ALIAS);
733                                    query.append(orderByFields[i]);
734    
735                                    if ((i + 1) < orderByFields.length) {
736                                            if (orderByComparator.isAscending() ^ previous) {
737                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
738                                            }
739                                            else {
740                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
741                                            }
742                                    }
743                                    else {
744                                            if (orderByComparator.isAscending() ^ previous) {
745                                                    query.append(WHERE_GREATER_THAN);
746                                            }
747                                            else {
748                                                    query.append(WHERE_LESSER_THAN);
749                                            }
750                                    }
751                            }
752    
753                            query.append(ORDER_BY_CLAUSE);
754    
755                            for (int i = 0; i < orderByFields.length; i++) {
756                                    query.append(_ORDER_BY_ENTITY_ALIAS);
757                                    query.append(orderByFields[i]);
758    
759                                    if ((i + 1) < orderByFields.length) {
760                                            if (orderByComparator.isAscending() ^ previous) {
761                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
762                                            }
763                                            else {
764                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
765                                            }
766                                    }
767                                    else {
768                                            if (orderByComparator.isAscending() ^ previous) {
769                                                    query.append(ORDER_BY_ASC);
770                                            }
771                                            else {
772                                                    query.append(ORDER_BY_DESC);
773                                            }
774                                    }
775                            }
776                    }
777    
778                    else {
779                            query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
780                    }
781    
782                    String sql = query.toString();
783    
784                    Query q = session.createQuery(sql);
785    
786                    q.setFirstResult(0);
787                    q.setMaxResults(2);
788    
789                    QueryPos qPos = QueryPos.getInstance(q);
790    
791                    if (uuid != null) {
792                            qPos.add(uuid);
793                    }
794    
795                    if (orderByComparator != null) {
796                            Object[] values = orderByComparator.getOrderByValues(announcementsEntry);
797    
798                            for (Object value : values) {
799                                    qPos.add(value);
800                            }
801                    }
802    
803                    List<AnnouncementsEntry> list = q.list();
804    
805                    if (list.size() == 2) {
806                            return list.get(1);
807                    }
808                    else {
809                            return null;
810                    }
811            }
812    
813            /**
814             * Filters by the user's permissions and finds all the announcements entries where uuid = &#63;.
815             *
816             * @param uuid the uuid to search with
817             * @return the matching announcements entries that the user has permission to view
818             * @throws SystemException if a system exception occurred
819             */
820            public List<AnnouncementsEntry> filterFindByUuid(String uuid)
821                    throws SystemException {
822                    return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
823            }
824    
825            /**
826             * Filters by the user's permissions and finds a range of all the announcements entries where uuid = &#63;.
827             *
828             * <p>
829             * 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.
830             * </p>
831             *
832             * @param uuid the uuid to search with
833             * @param start the lower bound of the range of announcements entries to return
834             * @param end the upper bound of the range of announcements entries to return (not inclusive)
835             * @return the range of matching announcements entries that the user has permission to view
836             * @throws SystemException if a system exception occurred
837             */
838            public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
839                    int end) throws SystemException {
840                    return filterFindByUuid(uuid, start, end, null);
841            }
842    
843            /**
844             * Filters by the user's permissions and finds an ordered range of all the announcements entries where uuid = &#63;.
845             *
846             * <p>
847             * 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.
848             * </p>
849             *
850             * @param uuid the uuid to search with
851             * @param start the lower bound of the range of announcements entries to return
852             * @param end the upper bound of the range of announcements entries to return (not inclusive)
853             * @param orderByComparator the comparator to order the results by
854             * @return the ordered range of matching announcements entries that the user has permission to view
855             * @throws SystemException if a system exception occurred
856             */
857            public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
858                    int end, OrderByComparator orderByComparator) throws SystemException {
859                    if (!InlineSQLHelperUtil.isEnabled()) {
860                            return findByUuid(uuid, start, end, orderByComparator);
861                    }
862    
863                    StringBundler query = null;
864    
865                    if (orderByComparator != null) {
866                            query = new StringBundler(3 +
867                                            (orderByComparator.getOrderByFields().length * 3));
868                    }
869                    else {
870                            query = new StringBundler(3);
871                    }
872    
873                    if (getDB().isSupportsInlineDistinct()) {
874                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
875                    }
876                    else {
877                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
878                    }
879    
880                    if (uuid == null) {
881                            query.append(_FINDER_COLUMN_UUID_UUID_1);
882                    }
883                    else {
884                            if (uuid.equals(StringPool.BLANK)) {
885                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
886                            }
887                            else {
888                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
889                            }
890                    }
891    
892                    if (!getDB().isSupportsInlineDistinct()) {
893                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
894                    }
895    
896                    if (orderByComparator != null) {
897                            if (getDB().isSupportsInlineDistinct()) {
898                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
899                                            orderByComparator);
900                            }
901                            else {
902                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
903                                            orderByComparator);
904                            }
905                    }
906    
907                    else {
908                            if (getDB().isSupportsInlineDistinct()) {
909                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
910                            }
911                            else {
912                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
913                            }
914                    }
915    
916                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
917                                    AnnouncementsEntry.class.getName(), _FILTER_COLUMN_PK,
918                                    _FILTER_COLUMN_USERID);
919    
920                    Session session = null;
921    
922                    try {
923                            session = openSession();
924    
925                            SQLQuery q = session.createSQLQuery(sql);
926    
927                            if (getDB().isSupportsInlineDistinct()) {
928                                    q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
929                            }
930                            else {
931                                    q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
932                            }
933    
934                            QueryPos qPos = QueryPos.getInstance(q);
935    
936                            if (uuid != null) {
937                                    qPos.add(uuid);
938                            }
939    
940                            return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
941                                    start, end);
942                    }
943                    catch (Exception e) {
944                            throw processException(e);
945                    }
946                    finally {
947                            closeSession(session);
948                    }
949            }
950    
951            /**
952             * Finds all the announcements entries where userId = &#63;.
953             *
954             * @param userId the user id to search with
955             * @return the matching announcements entries
956             * @throws SystemException if a system exception occurred
957             */
958            public List<AnnouncementsEntry> findByUserId(long userId)
959                    throws SystemException {
960                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
961            }
962    
963            /**
964             * Finds a range of all the announcements entries where userId = &#63;.
965             *
966             * <p>
967             * 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.
968             * </p>
969             *
970             * @param userId the user id to search with
971             * @param start the lower bound of the range of announcements entries to return
972             * @param end the upper bound of the range of announcements entries to return (not inclusive)
973             * @return the range of matching announcements entries
974             * @throws SystemException if a system exception occurred
975             */
976            public List<AnnouncementsEntry> findByUserId(long userId, int start, int end)
977                    throws SystemException {
978                    return findByUserId(userId, start, end, null);
979            }
980    
981            /**
982             * Finds an ordered range of all the announcements entries where userId = &#63;.
983             *
984             * <p>
985             * 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.
986             * </p>
987             *
988             * @param userId the user id to search with
989             * @param start the lower bound of the range of announcements entries to return
990             * @param end the upper bound of the range of announcements entries to return (not inclusive)
991             * @param orderByComparator the comparator to order the results by
992             * @return the ordered range of matching announcements entries
993             * @throws SystemException if a system exception occurred
994             */
995            public List<AnnouncementsEntry> findByUserId(long userId, int start,
996                    int end, OrderByComparator orderByComparator) throws SystemException {
997                    Object[] finderArgs = new Object[] {
998                                    userId,
999                                    
1000                                    String.valueOf(start), String.valueOf(end),
1001                                    String.valueOf(orderByComparator)
1002                            };
1003    
1004                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
1005                                    finderArgs, this);
1006    
1007                    if (list == null) {
1008                            StringBundler query = null;
1009    
1010                            if (orderByComparator != null) {
1011                                    query = new StringBundler(3 +
1012                                                    (orderByComparator.getOrderByFields().length * 3));
1013                            }
1014                            else {
1015                                    query = new StringBundler(3);
1016                            }
1017    
1018                            query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1019    
1020                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1021    
1022                            if (orderByComparator != null) {
1023                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1024                                            orderByComparator);
1025                            }
1026    
1027                            else {
1028                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1029                            }
1030    
1031                            String sql = query.toString();
1032    
1033                            Session session = null;
1034    
1035                            try {
1036                                    session = openSession();
1037    
1038                                    Query q = session.createQuery(sql);
1039    
1040                                    QueryPos qPos = QueryPos.getInstance(q);
1041    
1042                                    qPos.add(userId);
1043    
1044                                    list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1045                                                    getDialect(), start, end);
1046                            }
1047                            catch (Exception e) {
1048                                    throw processException(e);
1049                            }
1050                            finally {
1051                                    if (list == null) {
1052                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_USERID,
1053                                                    finderArgs);
1054                                    }
1055                                    else {
1056                                            cacheResult(list);
1057    
1058                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
1059                                                    finderArgs, list);
1060                                    }
1061    
1062                                    closeSession(session);
1063                            }
1064                    }
1065    
1066                    return list;
1067            }
1068    
1069            /**
1070             * Finds the first announcements entry in the ordered set where userId = &#63;.
1071             *
1072             * <p>
1073             * 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.
1074             * </p>
1075             *
1076             * @param userId the user id to search with
1077             * @param orderByComparator the comparator to order the set by
1078             * @return the first matching announcements entry
1079             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
1080             * @throws SystemException if a system exception occurred
1081             */
1082            public AnnouncementsEntry findByUserId_First(long userId,
1083                    OrderByComparator orderByComparator)
1084                    throws NoSuchEntryException, SystemException {
1085                    List<AnnouncementsEntry> list = findByUserId(userId, 0, 1,
1086                                    orderByComparator);
1087    
1088                    if (list.isEmpty()) {
1089                            StringBundler msg = new StringBundler(4);
1090    
1091                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1092    
1093                            msg.append("userId=");
1094                            msg.append(userId);
1095    
1096                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1097    
1098                            throw new NoSuchEntryException(msg.toString());
1099                    }
1100                    else {
1101                            return list.get(0);
1102                    }
1103            }
1104    
1105            /**
1106             * Finds the last announcements entry in the ordered set where userId = &#63;.
1107             *
1108             * <p>
1109             * 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.
1110             * </p>
1111             *
1112             * @param userId the user id to search with
1113             * @param orderByComparator the comparator to order the set by
1114             * @return the last matching announcements entry
1115             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
1116             * @throws SystemException if a system exception occurred
1117             */
1118            public AnnouncementsEntry findByUserId_Last(long userId,
1119                    OrderByComparator orderByComparator)
1120                    throws NoSuchEntryException, SystemException {
1121                    int count = countByUserId(userId);
1122    
1123                    List<AnnouncementsEntry> list = findByUserId(userId, count - 1, count,
1124                                    orderByComparator);
1125    
1126                    if (list.isEmpty()) {
1127                            StringBundler msg = new StringBundler(4);
1128    
1129                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1130    
1131                            msg.append("userId=");
1132                            msg.append(userId);
1133    
1134                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1135    
1136                            throw new NoSuchEntryException(msg.toString());
1137                    }
1138                    else {
1139                            return list.get(0);
1140                    }
1141            }
1142    
1143            /**
1144             * Finds the announcements entries before and after the current announcements entry in the ordered set where userId = &#63;.
1145             *
1146             * <p>
1147             * 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.
1148             * </p>
1149             *
1150             * @param entryId the primary key of the current announcements entry
1151             * @param userId the user id to search with
1152             * @param orderByComparator the comparator to order the set by
1153             * @return the previous, current, and next announcements entry
1154             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
1155             * @throws SystemException if a system exception occurred
1156             */
1157            public AnnouncementsEntry[] findByUserId_PrevAndNext(long entryId,
1158                    long userId, OrderByComparator orderByComparator)
1159                    throws NoSuchEntryException, SystemException {
1160                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1161    
1162                    Session session = null;
1163    
1164                    try {
1165                            session = openSession();
1166    
1167                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1168    
1169                            array[0] = getByUserId_PrevAndNext(session, announcementsEntry,
1170                                            userId, orderByComparator, true);
1171    
1172                            array[1] = announcementsEntry;
1173    
1174                            array[2] = getByUserId_PrevAndNext(session, announcementsEntry,
1175                                            userId, orderByComparator, false);
1176    
1177                            return array;
1178                    }
1179                    catch (Exception e) {
1180                            throw processException(e);
1181                    }
1182                    finally {
1183                            closeSession(session);
1184                    }
1185            }
1186    
1187            protected AnnouncementsEntry getByUserId_PrevAndNext(Session session,
1188                    AnnouncementsEntry announcementsEntry, long userId,
1189                    OrderByComparator orderByComparator, boolean previous) {
1190                    StringBundler query = null;
1191    
1192                    if (orderByComparator != null) {
1193                            query = new StringBundler(6 +
1194                                            (orderByComparator.getOrderByFields().length * 6));
1195                    }
1196                    else {
1197                            query = new StringBundler(3);
1198                    }
1199    
1200                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1201    
1202                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1203    
1204                    if (orderByComparator != null) {
1205                            String[] orderByFields = orderByComparator.getOrderByFields();
1206    
1207                            if (orderByFields.length > 0) {
1208                                    query.append(WHERE_AND);
1209                            }
1210    
1211                            for (int i = 0; i < orderByFields.length; i++) {
1212                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1213                                    query.append(orderByFields[i]);
1214    
1215                                    if ((i + 1) < orderByFields.length) {
1216                                            if (orderByComparator.isAscending() ^ previous) {
1217                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1218                                            }
1219                                            else {
1220                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1221                                            }
1222                                    }
1223                                    else {
1224                                            if (orderByComparator.isAscending() ^ previous) {
1225                                                    query.append(WHERE_GREATER_THAN);
1226                                            }
1227                                            else {
1228                                                    query.append(WHERE_LESSER_THAN);
1229                                            }
1230                                    }
1231                            }
1232    
1233                            query.append(ORDER_BY_CLAUSE);
1234    
1235                            for (int i = 0; i < orderByFields.length; i++) {
1236                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1237                                    query.append(orderByFields[i]);
1238    
1239                                    if ((i + 1) < orderByFields.length) {
1240                                            if (orderByComparator.isAscending() ^ previous) {
1241                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1242                                            }
1243                                            else {
1244                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1245                                            }
1246                                    }
1247                                    else {
1248                                            if (orderByComparator.isAscending() ^ previous) {
1249                                                    query.append(ORDER_BY_ASC);
1250                                            }
1251                                            else {
1252                                                    query.append(ORDER_BY_DESC);
1253                                            }
1254                                    }
1255                            }
1256                    }
1257    
1258                    else {
1259                            query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1260                    }
1261    
1262                    String sql = query.toString();
1263    
1264                    Query q = session.createQuery(sql);
1265    
1266                    q.setFirstResult(0);
1267                    q.setMaxResults(2);
1268    
1269                    QueryPos qPos = QueryPos.getInstance(q);
1270    
1271                    qPos.add(userId);
1272    
1273                    if (orderByComparator != null) {
1274                            Object[] values = orderByComparator.getOrderByValues(announcementsEntry);
1275    
1276                            for (Object value : values) {
1277                                    qPos.add(value);
1278                            }
1279                    }
1280    
1281                    List<AnnouncementsEntry> list = q.list();
1282    
1283                    if (list.size() == 2) {
1284                            return list.get(1);
1285                    }
1286                    else {
1287                            return null;
1288                    }
1289            }
1290    
1291            /**
1292             * Filters by the user's permissions and finds all the announcements entries where userId = &#63;.
1293             *
1294             * @param userId the user id to search with
1295             * @return the matching announcements entries that the user has permission to view
1296             * @throws SystemException if a system exception occurred
1297             */
1298            public List<AnnouncementsEntry> filterFindByUserId(long userId)
1299                    throws SystemException {
1300                    return filterFindByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1301                            null);
1302            }
1303    
1304            /**
1305             * Filters by the user's permissions and finds a range of all the announcements entries where userId = &#63;.
1306             *
1307             * <p>
1308             * 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.
1309             * </p>
1310             *
1311             * @param userId the user id to search with
1312             * @param start the lower bound of the range of announcements entries to return
1313             * @param end the upper bound of the range of announcements entries to return (not inclusive)
1314             * @return the range of matching announcements entries that the user has permission to view
1315             * @throws SystemException if a system exception occurred
1316             */
1317            public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
1318                    int end) throws SystemException {
1319                    return filterFindByUserId(userId, start, end, null);
1320            }
1321    
1322            /**
1323             * Filters by the user's permissions and finds an ordered range of all the announcements entries where userId = &#63;.
1324             *
1325             * <p>
1326             * 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.
1327             * </p>
1328             *
1329             * @param userId the user id to search with
1330             * @param start the lower bound of the range of announcements entries to return
1331             * @param end the upper bound of the range of announcements entries to return (not inclusive)
1332             * @param orderByComparator the comparator to order the results by
1333             * @return the ordered range of matching announcements entries that the user has permission to view
1334             * @throws SystemException if a system exception occurred
1335             */
1336            public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
1337                    int end, OrderByComparator orderByComparator) throws SystemException {
1338                    if (!InlineSQLHelperUtil.isEnabled()) {
1339                            return findByUserId(userId, start, end, orderByComparator);
1340                    }
1341    
1342                    StringBundler query = null;
1343    
1344                    if (orderByComparator != null) {
1345                            query = new StringBundler(3 +
1346                                            (orderByComparator.getOrderByFields().length * 3));
1347                    }
1348                    else {
1349                            query = new StringBundler(3);
1350                    }
1351    
1352                    if (getDB().isSupportsInlineDistinct()) {
1353                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1354                    }
1355                    else {
1356                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1357                    }
1358    
1359                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1360    
1361                    if (!getDB().isSupportsInlineDistinct()) {
1362                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1363                    }
1364    
1365                    if (orderByComparator != null) {
1366                            if (getDB().isSupportsInlineDistinct()) {
1367                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1368                                            orderByComparator);
1369                            }
1370                            else {
1371                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1372                                            orderByComparator);
1373                            }
1374                    }
1375    
1376                    else {
1377                            if (getDB().isSupportsInlineDistinct()) {
1378                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1379                            }
1380                            else {
1381                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1382                            }
1383                    }
1384    
1385                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1386                                    AnnouncementsEntry.class.getName(), _FILTER_COLUMN_PK,
1387                                    _FILTER_COLUMN_USERID);
1388    
1389                    Session session = null;
1390    
1391                    try {
1392                            session = openSession();
1393    
1394                            SQLQuery q = session.createSQLQuery(sql);
1395    
1396                            if (getDB().isSupportsInlineDistinct()) {
1397                                    q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1398                            }
1399                            else {
1400                                    q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1401                            }
1402    
1403                            QueryPos qPos = QueryPos.getInstance(q);
1404    
1405                            qPos.add(userId);
1406    
1407                            return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
1408                                    start, end);
1409                    }
1410                    catch (Exception e) {
1411                            throw processException(e);
1412                    }
1413                    finally {
1414                            closeSession(session);
1415                    }
1416            }
1417    
1418            /**
1419             * Finds all the announcements entries where classNameId = &#63; and classPK = &#63;.
1420             *
1421             * @param classNameId the class name id to search with
1422             * @param classPK the class p k to search with
1423             * @return the matching announcements entries
1424             * @throws SystemException if a system exception occurred
1425             */
1426            public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK)
1427                    throws SystemException {
1428                    return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
1429                            QueryUtil.ALL_POS, null);
1430            }
1431    
1432            /**
1433             * Finds a range of all the announcements entries where classNameId = &#63; and classPK = &#63;.
1434             *
1435             * <p>
1436             * 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.
1437             * </p>
1438             *
1439             * @param classNameId the class name id to search with
1440             * @param classPK the class p k to search with
1441             * @param start the lower bound of the range of announcements entries to return
1442             * @param end the upper bound of the range of announcements entries to return (not inclusive)
1443             * @return the range of matching announcements entries
1444             * @throws SystemException if a system exception occurred
1445             */
1446            public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
1447                    int start, int end) throws SystemException {
1448                    return findByC_C(classNameId, classPK, start, end, null);
1449            }
1450    
1451            /**
1452             * Finds an ordered range of all the announcements entries where classNameId = &#63; and classPK = &#63;.
1453             *
1454             * <p>
1455             * 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.
1456             * </p>
1457             *
1458             * @param classNameId the class name id to search with
1459             * @param classPK the class p k to search with
1460             * @param start the lower bound of the range of announcements entries to return
1461             * @param end the upper bound of the range of announcements entries to return (not inclusive)
1462             * @param orderByComparator the comparator to order the results by
1463             * @return the ordered range of matching announcements entries
1464             * @throws SystemException if a system exception occurred
1465             */
1466            public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
1467                    int start, int end, OrderByComparator orderByComparator)
1468                    throws SystemException {
1469                    Object[] finderArgs = new Object[] {
1470                                    classNameId, classPK,
1471                                    
1472                                    String.valueOf(start), String.valueOf(end),
1473                                    String.valueOf(orderByComparator)
1474                            };
1475    
1476                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C,
1477                                    finderArgs, this);
1478    
1479                    if (list == null) {
1480                            StringBundler query = null;
1481    
1482                            if (orderByComparator != null) {
1483                                    query = new StringBundler(4 +
1484                                                    (orderByComparator.getOrderByFields().length * 3));
1485                            }
1486                            else {
1487                                    query = new StringBundler(4);
1488                            }
1489    
1490                            query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1491    
1492                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1493    
1494                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1495    
1496                            if (orderByComparator != null) {
1497                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1498                                            orderByComparator);
1499                            }
1500    
1501                            else {
1502                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1503                            }
1504    
1505                            String sql = query.toString();
1506    
1507                            Session session = null;
1508    
1509                            try {
1510                                    session = openSession();
1511    
1512                                    Query q = session.createQuery(sql);
1513    
1514                                    QueryPos qPos = QueryPos.getInstance(q);
1515    
1516                                    qPos.add(classNameId);
1517    
1518                                    qPos.add(classPK);
1519    
1520                                    list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1521                                                    getDialect(), start, end);
1522                            }
1523                            catch (Exception e) {
1524                                    throw processException(e);
1525                            }
1526                            finally {
1527                                    if (list == null) {
1528                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_C_C,
1529                                                    finderArgs);
1530                                    }
1531                                    else {
1532                                            cacheResult(list);
1533    
1534                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C,
1535                                                    finderArgs, list);
1536                                    }
1537    
1538                                    closeSession(session);
1539                            }
1540                    }
1541    
1542                    return list;
1543            }
1544    
1545            /**
1546             * Finds the first announcements entry in the ordered set where classNameId = &#63; and classPK = &#63;.
1547             *
1548             * <p>
1549             * 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.
1550             * </p>
1551             *
1552             * @param classNameId the class name id to search with
1553             * @param classPK the class p k to search with
1554             * @param orderByComparator the comparator to order the set by
1555             * @return the first matching announcements entry
1556             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
1557             * @throws SystemException if a system exception occurred
1558             */
1559            public AnnouncementsEntry findByC_C_First(long classNameId, long classPK,
1560                    OrderByComparator orderByComparator)
1561                    throws NoSuchEntryException, SystemException {
1562                    List<AnnouncementsEntry> list = findByC_C(classNameId, classPK, 0, 1,
1563                                    orderByComparator);
1564    
1565                    if (list.isEmpty()) {
1566                            StringBundler msg = new StringBundler(6);
1567    
1568                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1569    
1570                            msg.append("classNameId=");
1571                            msg.append(classNameId);
1572    
1573                            msg.append(", classPK=");
1574                            msg.append(classPK);
1575    
1576                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1577    
1578                            throw new NoSuchEntryException(msg.toString());
1579                    }
1580                    else {
1581                            return list.get(0);
1582                    }
1583            }
1584    
1585            /**
1586             * Finds the last announcements entry in the ordered set where classNameId = &#63; and classPK = &#63;.
1587             *
1588             * <p>
1589             * 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.
1590             * </p>
1591             *
1592             * @param classNameId the class name id to search with
1593             * @param classPK the class p k to search with
1594             * @param orderByComparator the comparator to order the set by
1595             * @return the last matching announcements entry
1596             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
1597             * @throws SystemException if a system exception occurred
1598             */
1599            public AnnouncementsEntry findByC_C_Last(long classNameId, long classPK,
1600                    OrderByComparator orderByComparator)
1601                    throws NoSuchEntryException, SystemException {
1602                    int count = countByC_C(classNameId, classPK);
1603    
1604                    List<AnnouncementsEntry> list = findByC_C(classNameId, classPK,
1605                                    count - 1, count, orderByComparator);
1606    
1607                    if (list.isEmpty()) {
1608                            StringBundler msg = new StringBundler(6);
1609    
1610                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1611    
1612                            msg.append("classNameId=");
1613                            msg.append(classNameId);
1614    
1615                            msg.append(", classPK=");
1616                            msg.append(classPK);
1617    
1618                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1619    
1620                            throw new NoSuchEntryException(msg.toString());
1621                    }
1622                    else {
1623                            return list.get(0);
1624                    }
1625            }
1626    
1627            /**
1628             * Finds the announcements entries before and after the current announcements entry in the ordered set where classNameId = &#63; and classPK = &#63;.
1629             *
1630             * <p>
1631             * 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.
1632             * </p>
1633             *
1634             * @param entryId the primary key of the current announcements entry
1635             * @param classNameId the class name id to search with
1636             * @param classPK the class p k to search with
1637             * @param orderByComparator the comparator to order the set by
1638             * @return the previous, current, and next announcements entry
1639             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
1640             * @throws SystemException if a system exception occurred
1641             */
1642            public AnnouncementsEntry[] findByC_C_PrevAndNext(long entryId,
1643                    long classNameId, long classPK, OrderByComparator orderByComparator)
1644                    throws NoSuchEntryException, SystemException {
1645                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1646    
1647                    Session session = null;
1648    
1649                    try {
1650                            session = openSession();
1651    
1652                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1653    
1654                            array[0] = getByC_C_PrevAndNext(session, announcementsEntry,
1655                                            classNameId, classPK, orderByComparator, true);
1656    
1657                            array[1] = announcementsEntry;
1658    
1659                            array[2] = getByC_C_PrevAndNext(session, announcementsEntry,
1660                                            classNameId, classPK, orderByComparator, false);
1661    
1662                            return array;
1663                    }
1664                    catch (Exception e) {
1665                            throw processException(e);
1666                    }
1667                    finally {
1668                            closeSession(session);
1669                    }
1670            }
1671    
1672            protected AnnouncementsEntry getByC_C_PrevAndNext(Session session,
1673                    AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
1674                    OrderByComparator orderByComparator, boolean previous) {
1675                    StringBundler query = null;
1676    
1677                    if (orderByComparator != null) {
1678                            query = new StringBundler(6 +
1679                                            (orderByComparator.getOrderByFields().length * 6));
1680                    }
1681                    else {
1682                            query = new StringBundler(3);
1683                    }
1684    
1685                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1686    
1687                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1688    
1689                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1690    
1691                    if (orderByComparator != null) {
1692                            String[] orderByFields = orderByComparator.getOrderByFields();
1693    
1694                            if (orderByFields.length > 0) {
1695                                    query.append(WHERE_AND);
1696                            }
1697    
1698                            for (int i = 0; i < orderByFields.length; i++) {
1699                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1700                                    query.append(orderByFields[i]);
1701    
1702                                    if ((i + 1) < orderByFields.length) {
1703                                            if (orderByComparator.isAscending() ^ previous) {
1704                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1705                                            }
1706                                            else {
1707                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1708                                            }
1709                                    }
1710                                    else {
1711                                            if (orderByComparator.isAscending() ^ previous) {
1712                                                    query.append(WHERE_GREATER_THAN);
1713                                            }
1714                                            else {
1715                                                    query.append(WHERE_LESSER_THAN);
1716                                            }
1717                                    }
1718                            }
1719    
1720                            query.append(ORDER_BY_CLAUSE);
1721    
1722                            for (int i = 0; i < orderByFields.length; i++) {
1723                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1724                                    query.append(orderByFields[i]);
1725    
1726                                    if ((i + 1) < orderByFields.length) {
1727                                            if (orderByComparator.isAscending() ^ previous) {
1728                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1729                                            }
1730                                            else {
1731                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1732                                            }
1733                                    }
1734                                    else {
1735                                            if (orderByComparator.isAscending() ^ previous) {
1736                                                    query.append(ORDER_BY_ASC);
1737                                            }
1738                                            else {
1739                                                    query.append(ORDER_BY_DESC);
1740                                            }
1741                                    }
1742                            }
1743                    }
1744    
1745                    else {
1746                            query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1747                    }
1748    
1749                    String sql = query.toString();
1750    
1751                    Query q = session.createQuery(sql);
1752    
1753                    q.setFirstResult(0);
1754                    q.setMaxResults(2);
1755    
1756                    QueryPos qPos = QueryPos.getInstance(q);
1757    
1758                    qPos.add(classNameId);
1759    
1760                    qPos.add(classPK);
1761    
1762                    if (orderByComparator != null) {
1763                            Object[] values = orderByComparator.getOrderByValues(announcementsEntry);
1764    
1765                            for (Object value : values) {
1766                                    qPos.add(value);
1767                            }
1768                    }
1769    
1770                    List<AnnouncementsEntry> list = q.list();
1771    
1772                    if (list.size() == 2) {
1773                            return list.get(1);
1774                    }
1775                    else {
1776                            return null;
1777                    }
1778            }
1779    
1780            /**
1781             * Filters by the user's permissions and finds all the announcements entries where classNameId = &#63; and classPK = &#63;.
1782             *
1783             * @param classNameId the class name id to search with
1784             * @param classPK the class p k to search with
1785             * @return the matching announcements entries that the user has permission to view
1786             * @throws SystemException if a system exception occurred
1787             */
1788            public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
1789                    long classPK) throws SystemException {
1790                    return filterFindByC_C(classNameId, classPK, QueryUtil.ALL_POS,
1791                            QueryUtil.ALL_POS, null);
1792            }
1793    
1794            /**
1795             * Filters by the user's permissions and finds a range of all the announcements entries where classNameId = &#63; and classPK = &#63;.
1796             *
1797             * <p>
1798             * 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.
1799             * </p>
1800             *
1801             * @param classNameId the class name id to search with
1802             * @param classPK the class p k to search with
1803             * @param start the lower bound of the range of announcements entries to return
1804             * @param end the upper bound of the range of announcements entries to return (not inclusive)
1805             * @return the range of matching announcements entries that the user has permission to view
1806             * @throws SystemException if a system exception occurred
1807             */
1808            public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
1809                    long classPK, int start, int end) throws SystemException {
1810                    return filterFindByC_C(classNameId, classPK, start, end, null);
1811            }
1812    
1813            /**
1814             * Filters by the user's permissions and finds an ordered range of all the announcements entries where classNameId = &#63; and classPK = &#63;.
1815             *
1816             * <p>
1817             * 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.
1818             * </p>
1819             *
1820             * @param classNameId the class name id to search with
1821             * @param classPK the class p k to search with
1822             * @param start the lower bound of the range of announcements entries to return
1823             * @param end the upper bound of the range of announcements entries to return (not inclusive)
1824             * @param orderByComparator the comparator to order the results by
1825             * @return the ordered range of matching announcements entries that the user has permission to view
1826             * @throws SystemException if a system exception occurred
1827             */
1828            public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
1829                    long classPK, int start, int end, OrderByComparator orderByComparator)
1830                    throws SystemException {
1831                    if (!InlineSQLHelperUtil.isEnabled()) {
1832                            return findByC_C(classNameId, classPK, start, end, orderByComparator);
1833                    }
1834    
1835                    StringBundler query = null;
1836    
1837                    if (orderByComparator != null) {
1838                            query = new StringBundler(4 +
1839                                            (orderByComparator.getOrderByFields().length * 3));
1840                    }
1841                    else {
1842                            query = new StringBundler(4);
1843                    }
1844    
1845                    if (getDB().isSupportsInlineDistinct()) {
1846                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1847                    }
1848                    else {
1849                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1850                    }
1851    
1852                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1853    
1854                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1855    
1856                    if (!getDB().isSupportsInlineDistinct()) {
1857                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1858                    }
1859    
1860                    if (orderByComparator != null) {
1861                            if (getDB().isSupportsInlineDistinct()) {
1862                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1863                                            orderByComparator);
1864                            }
1865                            else {
1866                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1867                                            orderByComparator);
1868                            }
1869                    }
1870    
1871                    else {
1872                            if (getDB().isSupportsInlineDistinct()) {
1873                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1874                            }
1875                            else {
1876                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1877                            }
1878                    }
1879    
1880                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1881                                    AnnouncementsEntry.class.getName(), _FILTER_COLUMN_PK,
1882                                    _FILTER_COLUMN_USERID);
1883    
1884                    Session session = null;
1885    
1886                    try {
1887                            session = openSession();
1888    
1889                            SQLQuery q = session.createSQLQuery(sql);
1890    
1891                            if (getDB().isSupportsInlineDistinct()) {
1892                                    q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1893                            }
1894                            else {
1895                                    q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1896                            }
1897    
1898                            QueryPos qPos = QueryPos.getInstance(q);
1899    
1900                            qPos.add(classNameId);
1901    
1902                            qPos.add(classPK);
1903    
1904                            return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
1905                                    start, end);
1906                    }
1907                    catch (Exception e) {
1908                            throw processException(e);
1909                    }
1910                    finally {
1911                            closeSession(session);
1912                    }
1913            }
1914    
1915            /**
1916             * Finds all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
1917             *
1918             * @param classNameId the class name id to search with
1919             * @param classPK the class p k to search with
1920             * @param alert the alert to search with
1921             * @return the matching announcements entries
1922             * @throws SystemException if a system exception occurred
1923             */
1924            public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
1925                    boolean alert) throws SystemException {
1926                    return findByC_C_A(classNameId, classPK, alert, QueryUtil.ALL_POS,
1927                            QueryUtil.ALL_POS, null);
1928            }
1929    
1930            /**
1931             * Finds a range of all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
1932             *
1933             * <p>
1934             * 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.
1935             * </p>
1936             *
1937             * @param classNameId the class name id to search with
1938             * @param classPK the class p k to search with
1939             * @param alert the alert to search with
1940             * @param start the lower bound of the range of announcements entries to return
1941             * @param end the upper bound of the range of announcements entries to return (not inclusive)
1942             * @return the range of matching announcements entries
1943             * @throws SystemException if a system exception occurred
1944             */
1945            public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
1946                    boolean alert, int start, int end) throws SystemException {
1947                    return findByC_C_A(classNameId, classPK, alert, start, end, null);
1948            }
1949    
1950            /**
1951             * Finds an ordered range of all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
1952             *
1953             * <p>
1954             * 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.
1955             * </p>
1956             *
1957             * @param classNameId the class name id to search with
1958             * @param classPK the class p k to search with
1959             * @param alert the alert to search with
1960             * @param start the lower bound of the range of announcements entries to return
1961             * @param end the upper bound of the range of announcements entries to return (not inclusive)
1962             * @param orderByComparator the comparator to order the results by
1963             * @return the ordered range of matching announcements entries
1964             * @throws SystemException if a system exception occurred
1965             */
1966            public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
1967                    boolean alert, int start, int end, OrderByComparator orderByComparator)
1968                    throws SystemException {
1969                    Object[] finderArgs = new Object[] {
1970                                    classNameId, classPK, alert,
1971                                    
1972                                    String.valueOf(start), String.valueOf(end),
1973                                    String.valueOf(orderByComparator)
1974                            };
1975    
1976                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C_A,
1977                                    finderArgs, this);
1978    
1979                    if (list == null) {
1980                            StringBundler query = null;
1981    
1982                            if (orderByComparator != null) {
1983                                    query = new StringBundler(5 +
1984                                                    (orderByComparator.getOrderByFields().length * 3));
1985                            }
1986                            else {
1987                                    query = new StringBundler(5);
1988                            }
1989    
1990                            query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1991    
1992                            query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
1993    
1994                            query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
1995    
1996                            query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
1997    
1998                            if (orderByComparator != null) {
1999                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2000                                            orderByComparator);
2001                            }
2002    
2003                            else {
2004                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2005                            }
2006    
2007                            String sql = query.toString();
2008    
2009                            Session session = null;
2010    
2011                            try {
2012                                    session = openSession();
2013    
2014                                    Query q = session.createQuery(sql);
2015    
2016                                    QueryPos qPos = QueryPos.getInstance(q);
2017    
2018                                    qPos.add(classNameId);
2019    
2020                                    qPos.add(classPK);
2021    
2022                                    qPos.add(alert);
2023    
2024                                    list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2025                                                    getDialect(), start, end);
2026                            }
2027                            catch (Exception e) {
2028                                    throw processException(e);
2029                            }
2030                            finally {
2031                                    if (list == null) {
2032                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_C_C_A,
2033                                                    finderArgs);
2034                                    }
2035                                    else {
2036                                            cacheResult(list);
2037    
2038                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C_A,
2039                                                    finderArgs, list);
2040                                    }
2041    
2042                                    closeSession(session);
2043                            }
2044                    }
2045    
2046                    return list;
2047            }
2048    
2049            /**
2050             * Finds the first announcements entry in the ordered set where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2051             *
2052             * <p>
2053             * 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.
2054             * </p>
2055             *
2056             * @param classNameId the class name id to search with
2057             * @param classPK the class p k to search with
2058             * @param alert the alert to search with
2059             * @param orderByComparator the comparator to order the set by
2060             * @return the first matching announcements entry
2061             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
2062             * @throws SystemException if a system exception occurred
2063             */
2064            public AnnouncementsEntry findByC_C_A_First(long classNameId, long classPK,
2065                    boolean alert, OrderByComparator orderByComparator)
2066                    throws NoSuchEntryException, SystemException {
2067                    List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
2068                                    alert, 0, 1, orderByComparator);
2069    
2070                    if (list.isEmpty()) {
2071                            StringBundler msg = new StringBundler(8);
2072    
2073                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2074    
2075                            msg.append("classNameId=");
2076                            msg.append(classNameId);
2077    
2078                            msg.append(", classPK=");
2079                            msg.append(classPK);
2080    
2081                            msg.append(", alert=");
2082                            msg.append(alert);
2083    
2084                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2085    
2086                            throw new NoSuchEntryException(msg.toString());
2087                    }
2088                    else {
2089                            return list.get(0);
2090                    }
2091            }
2092    
2093            /**
2094             * Finds the last announcements entry in the ordered set where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2095             *
2096             * <p>
2097             * 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.
2098             * </p>
2099             *
2100             * @param classNameId the class name id to search with
2101             * @param classPK the class p k to search with
2102             * @param alert the alert to search with
2103             * @param orderByComparator the comparator to order the set by
2104             * @return the last matching announcements entry
2105             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
2106             * @throws SystemException if a system exception occurred
2107             */
2108            public AnnouncementsEntry findByC_C_A_Last(long classNameId, long classPK,
2109                    boolean alert, OrderByComparator orderByComparator)
2110                    throws NoSuchEntryException, SystemException {
2111                    int count = countByC_C_A(classNameId, classPK, alert);
2112    
2113                    List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
2114                                    alert, count - 1, count, orderByComparator);
2115    
2116                    if (list.isEmpty()) {
2117                            StringBundler msg = new StringBundler(8);
2118    
2119                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2120    
2121                            msg.append("classNameId=");
2122                            msg.append(classNameId);
2123    
2124                            msg.append(", classPK=");
2125                            msg.append(classPK);
2126    
2127                            msg.append(", alert=");
2128                            msg.append(alert);
2129    
2130                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2131    
2132                            throw new NoSuchEntryException(msg.toString());
2133                    }
2134                    else {
2135                            return list.get(0);
2136                    }
2137            }
2138    
2139            /**
2140             * Finds the announcements entries before and after the current announcements entry in the ordered set where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2141             *
2142             * <p>
2143             * 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.
2144             * </p>
2145             *
2146             * @param entryId the primary key of the current announcements entry
2147             * @param classNameId the class name id to search with
2148             * @param classPK the class p k to search with
2149             * @param alert the alert to search with
2150             * @param orderByComparator the comparator to order the set by
2151             * @return the previous, current, and next announcements entry
2152             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
2153             * @throws SystemException if a system exception occurred
2154             */
2155            public AnnouncementsEntry[] findByC_C_A_PrevAndNext(long entryId,
2156                    long classNameId, long classPK, boolean alert,
2157                    OrderByComparator orderByComparator)
2158                    throws NoSuchEntryException, SystemException {
2159                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2160    
2161                    Session session = null;
2162    
2163                    try {
2164                            session = openSession();
2165    
2166                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2167    
2168                            array[0] = getByC_C_A_PrevAndNext(session, announcementsEntry,
2169                                            classNameId, classPK, alert, orderByComparator, true);
2170    
2171                            array[1] = announcementsEntry;
2172    
2173                            array[2] = getByC_C_A_PrevAndNext(session, announcementsEntry,
2174                                            classNameId, classPK, alert, orderByComparator, false);
2175    
2176                            return array;
2177                    }
2178                    catch (Exception e) {
2179                            throw processException(e);
2180                    }
2181                    finally {
2182                            closeSession(session);
2183                    }
2184            }
2185    
2186            protected AnnouncementsEntry getByC_C_A_PrevAndNext(Session session,
2187                    AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
2188                    boolean alert, OrderByComparator orderByComparator, boolean previous) {
2189                    StringBundler query = null;
2190    
2191                    if (orderByComparator != null) {
2192                            query = new StringBundler(6 +
2193                                            (orderByComparator.getOrderByFields().length * 6));
2194                    }
2195                    else {
2196                            query = new StringBundler(3);
2197                    }
2198    
2199                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2200    
2201                    query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
2202    
2203                    query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
2204    
2205                    query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
2206    
2207                    if (orderByComparator != null) {
2208                            String[] orderByFields = orderByComparator.getOrderByFields();
2209    
2210                            if (orderByFields.length > 0) {
2211                                    query.append(WHERE_AND);
2212                            }
2213    
2214                            for (int i = 0; i < orderByFields.length; i++) {
2215                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2216                                    query.append(orderByFields[i]);
2217    
2218                                    if ((i + 1) < orderByFields.length) {
2219                                            if (orderByComparator.isAscending() ^ previous) {
2220                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2221                                            }
2222                                            else {
2223                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2224                                            }
2225                                    }
2226                                    else {
2227                                            if (orderByComparator.isAscending() ^ previous) {
2228                                                    query.append(WHERE_GREATER_THAN);
2229                                            }
2230                                            else {
2231                                                    query.append(WHERE_LESSER_THAN);
2232                                            }
2233                                    }
2234                            }
2235    
2236                            query.append(ORDER_BY_CLAUSE);
2237    
2238                            for (int i = 0; i < orderByFields.length; i++) {
2239                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2240                                    query.append(orderByFields[i]);
2241    
2242                                    if ((i + 1) < orderByFields.length) {
2243                                            if (orderByComparator.isAscending() ^ previous) {
2244                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2245                                            }
2246                                            else {
2247                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2248                                            }
2249                                    }
2250                                    else {
2251                                            if (orderByComparator.isAscending() ^ previous) {
2252                                                    query.append(ORDER_BY_ASC);
2253                                            }
2254                                            else {
2255                                                    query.append(ORDER_BY_DESC);
2256                                            }
2257                                    }
2258                            }
2259                    }
2260    
2261                    else {
2262                            query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2263                    }
2264    
2265                    String sql = query.toString();
2266    
2267                    Query q = session.createQuery(sql);
2268    
2269                    q.setFirstResult(0);
2270                    q.setMaxResults(2);
2271    
2272                    QueryPos qPos = QueryPos.getInstance(q);
2273    
2274                    qPos.add(classNameId);
2275    
2276                    qPos.add(classPK);
2277    
2278                    qPos.add(alert);
2279    
2280                    if (orderByComparator != null) {
2281                            Object[] values = orderByComparator.getOrderByValues(announcementsEntry);
2282    
2283                            for (Object value : values) {
2284                                    qPos.add(value);
2285                            }
2286                    }
2287    
2288                    List<AnnouncementsEntry> list = q.list();
2289    
2290                    if (list.size() == 2) {
2291                            return list.get(1);
2292                    }
2293                    else {
2294                            return null;
2295                    }
2296            }
2297    
2298            /**
2299             * Filters by the user's permissions and finds all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2300             *
2301             * @param classNameId the class name id to search with
2302             * @param classPK the class p k to search with
2303             * @param alert the alert to search with
2304             * @return the matching announcements entries that the user has permission to view
2305             * @throws SystemException if a system exception occurred
2306             */
2307            public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
2308                    long classPK, boolean alert) throws SystemException {
2309                    return filterFindByC_C_A(classNameId, classPK, alert,
2310                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2311            }
2312    
2313            /**
2314             * Filters by the user's permissions and finds a range of all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2315             *
2316             * <p>
2317             * 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.
2318             * </p>
2319             *
2320             * @param classNameId the class name id to search with
2321             * @param classPK the class p k to search with
2322             * @param alert the alert to search with
2323             * @param start the lower bound of the range of announcements entries to return
2324             * @param end the upper bound of the range of announcements entries to return (not inclusive)
2325             * @return the range of matching announcements entries that the user has permission to view
2326             * @throws SystemException if a system exception occurred
2327             */
2328            public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
2329                    long classPK, boolean alert, int start, int end)
2330                    throws SystemException {
2331                    return filterFindByC_C_A(classNameId, classPK, alert, start, end, null);
2332            }
2333    
2334            /**
2335             * Filters by the user's permissions and finds an ordered range of all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2336             *
2337             * <p>
2338             * 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.
2339             * </p>
2340             *
2341             * @param classNameId the class name id to search with
2342             * @param classPK the class p k to search with
2343             * @param alert the alert to search with
2344             * @param start the lower bound of the range of announcements entries to return
2345             * @param end the upper bound of the range of announcements entries to return (not inclusive)
2346             * @param orderByComparator the comparator to order the results by
2347             * @return the ordered range of matching announcements entries that the user has permission to view
2348             * @throws SystemException if a system exception occurred
2349             */
2350            public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
2351                    long classPK, boolean alert, int start, int end,
2352                    OrderByComparator orderByComparator) throws SystemException {
2353                    if (!InlineSQLHelperUtil.isEnabled()) {
2354                            return findByC_C_A(classNameId, classPK, alert, start, end,
2355                                    orderByComparator);
2356                    }
2357    
2358                    StringBundler query = null;
2359    
2360                    if (orderByComparator != null) {
2361                            query = new StringBundler(5 +
2362                                            (orderByComparator.getOrderByFields().length * 3));
2363                    }
2364                    else {
2365                            query = new StringBundler(5);
2366                    }
2367    
2368                    if (getDB().isSupportsInlineDistinct()) {
2369                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2370                    }
2371                    else {
2372                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2373                    }
2374    
2375                    query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
2376    
2377                    query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
2378    
2379                    query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
2380    
2381                    if (!getDB().isSupportsInlineDistinct()) {
2382                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2383                    }
2384    
2385                    if (orderByComparator != null) {
2386                            if (getDB().isSupportsInlineDistinct()) {
2387                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2388                                            orderByComparator);
2389                            }
2390                            else {
2391                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2392                                            orderByComparator);
2393                            }
2394                    }
2395    
2396                    else {
2397                            if (getDB().isSupportsInlineDistinct()) {
2398                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2399                            }
2400                            else {
2401                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2402                            }
2403                    }
2404    
2405                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2406                                    AnnouncementsEntry.class.getName(), _FILTER_COLUMN_PK,
2407                                    _FILTER_COLUMN_USERID);
2408    
2409                    Session session = null;
2410    
2411                    try {
2412                            session = openSession();
2413    
2414                            SQLQuery q = session.createSQLQuery(sql);
2415    
2416                            if (getDB().isSupportsInlineDistinct()) {
2417                                    q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2418                            }
2419                            else {
2420                                    q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2421                            }
2422    
2423                            QueryPos qPos = QueryPos.getInstance(q);
2424    
2425                            qPos.add(classNameId);
2426    
2427                            qPos.add(classPK);
2428    
2429                            qPos.add(alert);
2430    
2431                            return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
2432                                    start, end);
2433                    }
2434                    catch (Exception e) {
2435                            throw processException(e);
2436                    }
2437                    finally {
2438                            closeSession(session);
2439                    }
2440            }
2441    
2442            /**
2443             * Finds all the announcements entries.
2444             *
2445             * @return the announcements entries
2446             * @throws SystemException if a system exception occurred
2447             */
2448            public List<AnnouncementsEntry> findAll() throws SystemException {
2449                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2450            }
2451    
2452            /**
2453             * Finds a range of all the announcements entries.
2454             *
2455             * <p>
2456             * 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.
2457             * </p>
2458             *
2459             * @param start the lower bound of the range of announcements entries to return
2460             * @param end the upper bound of the range of announcements entries to return (not inclusive)
2461             * @return the range of announcements entries
2462             * @throws SystemException if a system exception occurred
2463             */
2464            public List<AnnouncementsEntry> findAll(int start, int end)
2465                    throws SystemException {
2466                    return findAll(start, end, null);
2467            }
2468    
2469            /**
2470             * Finds an ordered range of all the announcements entries.
2471             *
2472             * <p>
2473             * 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.
2474             * </p>
2475             *
2476             * @param start the lower bound of the range of announcements entries to return
2477             * @param end the upper bound of the range of announcements entries to return (not inclusive)
2478             * @param orderByComparator the comparator to order the results by
2479             * @return the ordered range of announcements entries
2480             * @throws SystemException if a system exception occurred
2481             */
2482            public List<AnnouncementsEntry> findAll(int start, int end,
2483                    OrderByComparator orderByComparator) throws SystemException {
2484                    Object[] finderArgs = new Object[] {
2485                                    String.valueOf(start), String.valueOf(end),
2486                                    String.valueOf(orderByComparator)
2487                            };
2488    
2489                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2490                                    finderArgs, this);
2491    
2492                    if (list == null) {
2493                            StringBundler query = null;
2494                            String sql = null;
2495    
2496                            if (orderByComparator != null) {
2497                                    query = new StringBundler(2 +
2498                                                    (orderByComparator.getOrderByFields().length * 3));
2499    
2500                                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY);
2501    
2502                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2503                                            orderByComparator);
2504    
2505                                    sql = query.toString();
2506                            }
2507                            else {
2508                                    sql = _SQL_SELECT_ANNOUNCEMENTSENTRY.concat(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2509                            }
2510    
2511                            Session session = null;
2512    
2513                            try {
2514                                    session = openSession();
2515    
2516                                    Query q = session.createQuery(sql);
2517    
2518                                    if (orderByComparator == null) {
2519                                            list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2520                                                            getDialect(), start, end, false);
2521    
2522                                            Collections.sort(list);
2523                                    }
2524                                    else {
2525                                            list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2526                                                            getDialect(), start, end);
2527                                    }
2528                            }
2529                            catch (Exception e) {
2530                                    throw processException(e);
2531                            }
2532                            finally {
2533                                    if (list == null) {
2534                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
2535                                                    finderArgs);
2536                                    }
2537                                    else {
2538                                            cacheResult(list);
2539    
2540                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
2541                                                    list);
2542                                    }
2543    
2544                                    closeSession(session);
2545                            }
2546                    }
2547    
2548                    return list;
2549            }
2550    
2551            /**
2552             * Removes all the announcements entries where uuid = &#63; from the database.
2553             *
2554             * @param uuid the uuid to search with
2555             * @throws SystemException if a system exception occurred
2556             */
2557            public void removeByUuid(String uuid) throws SystemException {
2558                    for (AnnouncementsEntry announcementsEntry : findByUuid(uuid)) {
2559                            remove(announcementsEntry);
2560                    }
2561            }
2562    
2563            /**
2564             * Removes all the announcements entries where userId = &#63; from the database.
2565             *
2566             * @param userId the user id to search with
2567             * @throws SystemException if a system exception occurred
2568             */
2569            public void removeByUserId(long userId) throws SystemException {
2570                    for (AnnouncementsEntry announcementsEntry : findByUserId(userId)) {
2571                            remove(announcementsEntry);
2572                    }
2573            }
2574    
2575            /**
2576             * Removes all the announcements entries where classNameId = &#63; and classPK = &#63; from the database.
2577             *
2578             * @param classNameId the class name id to search with
2579             * @param classPK the class p k to search with
2580             * @throws SystemException if a system exception occurred
2581             */
2582            public void removeByC_C(long classNameId, long classPK)
2583                    throws SystemException {
2584                    for (AnnouncementsEntry announcementsEntry : findByC_C(classNameId,
2585                                    classPK)) {
2586                            remove(announcementsEntry);
2587                    }
2588            }
2589    
2590            /**
2591             * Removes all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63; from the database.
2592             *
2593             * @param classNameId the class name id to search with
2594             * @param classPK the class p k to search with
2595             * @param alert the alert to search with
2596             * @throws SystemException if a system exception occurred
2597             */
2598            public void removeByC_C_A(long classNameId, long classPK, boolean alert)
2599                    throws SystemException {
2600                    for (AnnouncementsEntry announcementsEntry : findByC_C_A(classNameId,
2601                                    classPK, alert)) {
2602                            remove(announcementsEntry);
2603                    }
2604            }
2605    
2606            /**
2607             * Removes all the announcements entries from the database.
2608             *
2609             * @throws SystemException if a system exception occurred
2610             */
2611            public void removeAll() throws SystemException {
2612                    for (AnnouncementsEntry announcementsEntry : findAll()) {
2613                            remove(announcementsEntry);
2614                    }
2615            }
2616    
2617            /**
2618             * Counts all the announcements entries where uuid = &#63;.
2619             *
2620             * @param uuid the uuid to search with
2621             * @return the number of matching announcements entries
2622             * @throws SystemException if a system exception occurred
2623             */
2624            public int countByUuid(String uuid) throws SystemException {
2625                    Object[] finderArgs = new Object[] { uuid };
2626    
2627                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2628                                    finderArgs, this);
2629    
2630                    if (count == null) {
2631                            StringBundler query = new StringBundler(2);
2632    
2633                            query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2634    
2635                            if (uuid == null) {
2636                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
2637                            }
2638                            else {
2639                                    if (uuid.equals(StringPool.BLANK)) {
2640                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
2641                                    }
2642                                    else {
2643                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
2644                                    }
2645                            }
2646    
2647                            String sql = query.toString();
2648    
2649                            Session session = null;
2650    
2651                            try {
2652                                    session = openSession();
2653    
2654                                    Query q = session.createQuery(sql);
2655    
2656                                    QueryPos qPos = QueryPos.getInstance(q);
2657    
2658                                    if (uuid != null) {
2659                                            qPos.add(uuid);
2660                                    }
2661    
2662                                    count = (Long)q.uniqueResult();
2663                            }
2664                            catch (Exception e) {
2665                                    throw processException(e);
2666                            }
2667                            finally {
2668                                    if (count == null) {
2669                                            count = Long.valueOf(0);
2670                                    }
2671    
2672                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2673                                            finderArgs, count);
2674    
2675                                    closeSession(session);
2676                            }
2677                    }
2678    
2679                    return count.intValue();
2680            }
2681    
2682            /**
2683             * Filters by the user's permissions and counts all the announcements entries where uuid = &#63;.
2684             *
2685             * @param uuid the uuid to search with
2686             * @return the number of matching announcements entries that the user has permission to view
2687             * @throws SystemException if a system exception occurred
2688             */
2689            public int filterCountByUuid(String uuid) throws SystemException {
2690                    if (!InlineSQLHelperUtil.isEnabled()) {
2691                            return countByUuid(uuid);
2692                    }
2693    
2694                    StringBundler query = new StringBundler(2);
2695    
2696                    query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2697    
2698                    if (uuid == null) {
2699                            query.append(_FINDER_COLUMN_UUID_UUID_1);
2700                    }
2701                    else {
2702                            if (uuid.equals(StringPool.BLANK)) {
2703                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
2704                            }
2705                            else {
2706                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
2707                            }
2708                    }
2709    
2710                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2711                                    AnnouncementsEntry.class.getName(), _FILTER_COLUMN_PK,
2712                                    _FILTER_COLUMN_USERID);
2713    
2714                    Session session = null;
2715    
2716                    try {
2717                            session = openSession();
2718    
2719                            SQLQuery q = session.createSQLQuery(sql);
2720    
2721                            q.addScalar(COUNT_COLUMN_NAME,
2722                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2723    
2724                            QueryPos qPos = QueryPos.getInstance(q);
2725    
2726                            if (uuid != null) {
2727                                    qPos.add(uuid);
2728                            }
2729    
2730                            Long count = (Long)q.uniqueResult();
2731    
2732                            return count.intValue();
2733                    }
2734                    catch (Exception e) {
2735                            throw processException(e);
2736                    }
2737                    finally {
2738                            closeSession(session);
2739                    }
2740            }
2741    
2742            /**
2743             * Counts all the announcements entries where userId = &#63;.
2744             *
2745             * @param userId the user id to search with
2746             * @return the number of matching announcements entries
2747             * @throws SystemException if a system exception occurred
2748             */
2749            public int countByUserId(long userId) throws SystemException {
2750                    Object[] finderArgs = new Object[] { userId };
2751    
2752                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2753                                    finderArgs, this);
2754    
2755                    if (count == null) {
2756                            StringBundler query = new StringBundler(2);
2757    
2758                            query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2759    
2760                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2761    
2762                            String sql = query.toString();
2763    
2764                            Session session = null;
2765    
2766                            try {
2767                                    session = openSession();
2768    
2769                                    Query q = session.createQuery(sql);
2770    
2771                                    QueryPos qPos = QueryPos.getInstance(q);
2772    
2773                                    qPos.add(userId);
2774    
2775                                    count = (Long)q.uniqueResult();
2776                            }
2777                            catch (Exception e) {
2778                                    throw processException(e);
2779                            }
2780                            finally {
2781                                    if (count == null) {
2782                                            count = Long.valueOf(0);
2783                                    }
2784    
2785                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2786                                            finderArgs, count);
2787    
2788                                    closeSession(session);
2789                            }
2790                    }
2791    
2792                    return count.intValue();
2793            }
2794    
2795            /**
2796             * Filters by the user's permissions and counts all the announcements entries where userId = &#63;.
2797             *
2798             * @param userId the user id to search with
2799             * @return the number of matching announcements entries that the user has permission to view
2800             * @throws SystemException if a system exception occurred
2801             */
2802            public int filterCountByUserId(long userId) throws SystemException {
2803                    if (!InlineSQLHelperUtil.isEnabled()) {
2804                            return countByUserId(userId);
2805                    }
2806    
2807                    StringBundler query = new StringBundler(2);
2808    
2809                    query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2810    
2811                    query.append(_FINDER_COLUMN_USERID_USERID_2);
2812    
2813                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2814                                    AnnouncementsEntry.class.getName(), _FILTER_COLUMN_PK,
2815                                    _FILTER_COLUMN_USERID);
2816    
2817                    Session session = null;
2818    
2819                    try {
2820                            session = openSession();
2821    
2822                            SQLQuery q = session.createSQLQuery(sql);
2823    
2824                            q.addScalar(COUNT_COLUMN_NAME,
2825                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2826    
2827                            QueryPos qPos = QueryPos.getInstance(q);
2828    
2829                            qPos.add(userId);
2830    
2831                            Long count = (Long)q.uniqueResult();
2832    
2833                            return count.intValue();
2834                    }
2835                    catch (Exception e) {
2836                            throw processException(e);
2837                    }
2838                    finally {
2839                            closeSession(session);
2840                    }
2841            }
2842    
2843            /**
2844             * Counts all the announcements entries where classNameId = &#63; and classPK = &#63;.
2845             *
2846             * @param classNameId the class name id to search with
2847             * @param classPK the class p k to search with
2848             * @return the number of matching announcements entries
2849             * @throws SystemException if a system exception occurred
2850             */
2851            public int countByC_C(long classNameId, long classPK)
2852                    throws SystemException {
2853                    Object[] finderArgs = new Object[] { classNameId, classPK };
2854    
2855                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
2856                                    finderArgs, this);
2857    
2858                    if (count == null) {
2859                            StringBundler query = new StringBundler(3);
2860    
2861                            query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2862    
2863                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2864    
2865                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2866    
2867                            String sql = query.toString();
2868    
2869                            Session session = null;
2870    
2871                            try {
2872                                    session = openSession();
2873    
2874                                    Query q = session.createQuery(sql);
2875    
2876                                    QueryPos qPos = QueryPos.getInstance(q);
2877    
2878                                    qPos.add(classNameId);
2879    
2880                                    qPos.add(classPK);
2881    
2882                                    count = (Long)q.uniqueResult();
2883                            }
2884                            catch (Exception e) {
2885                                    throw processException(e);
2886                            }
2887                            finally {
2888                                    if (count == null) {
2889                                            count = Long.valueOf(0);
2890                                    }
2891    
2892                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
2893                                            count);
2894    
2895                                    closeSession(session);
2896                            }
2897                    }
2898    
2899                    return count.intValue();
2900            }
2901    
2902            /**
2903             * Filters by the user's permissions and counts all the announcements entries where classNameId = &#63; and classPK = &#63;.
2904             *
2905             * @param classNameId the class name id to search with
2906             * @param classPK the class p k to search with
2907             * @return the number of matching announcements entries that the user has permission to view
2908             * @throws SystemException if a system exception occurred
2909             */
2910            public int filterCountByC_C(long classNameId, long classPK)
2911                    throws SystemException {
2912                    if (!InlineSQLHelperUtil.isEnabled()) {
2913                            return countByC_C(classNameId, classPK);
2914                    }
2915    
2916                    StringBundler query = new StringBundler(3);
2917    
2918                    query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2919    
2920                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2921    
2922                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2923    
2924                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2925                                    AnnouncementsEntry.class.getName(), _FILTER_COLUMN_PK,
2926                                    _FILTER_COLUMN_USERID);
2927    
2928                    Session session = null;
2929    
2930                    try {
2931                            session = openSession();
2932    
2933                            SQLQuery q = session.createSQLQuery(sql);
2934    
2935                            q.addScalar(COUNT_COLUMN_NAME,
2936                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2937    
2938                            QueryPos qPos = QueryPos.getInstance(q);
2939    
2940                            qPos.add(classNameId);
2941    
2942                            qPos.add(classPK);
2943    
2944                            Long count = (Long)q.uniqueResult();
2945    
2946                            return count.intValue();
2947                    }
2948                    catch (Exception e) {
2949                            throw processException(e);
2950                    }
2951                    finally {
2952                            closeSession(session);
2953                    }
2954            }
2955    
2956            /**
2957             * Counts all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2958             *
2959             * @param classNameId the class name id to search with
2960             * @param classPK the class p k to search with
2961             * @param alert the alert to search with
2962             * @return the number of matching announcements entries
2963             * @throws SystemException if a system exception occurred
2964             */
2965            public int countByC_C_A(long classNameId, long classPK, boolean alert)
2966                    throws SystemException {
2967                    Object[] finderArgs = new Object[] { classNameId, classPK, alert };
2968    
2969                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_A,
2970                                    finderArgs, this);
2971    
2972                    if (count == null) {
2973                            StringBundler query = new StringBundler(4);
2974    
2975                            query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2976    
2977                            query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
2978    
2979                            query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
2980    
2981                            query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
2982    
2983                            String sql = query.toString();
2984    
2985                            Session session = null;
2986    
2987                            try {
2988                                    session = openSession();
2989    
2990                                    Query q = session.createQuery(sql);
2991    
2992                                    QueryPos qPos = QueryPos.getInstance(q);
2993    
2994                                    qPos.add(classNameId);
2995    
2996                                    qPos.add(classPK);
2997    
2998                                    qPos.add(alert);
2999    
3000                                    count = (Long)q.uniqueResult();
3001                            }
3002                            catch (Exception e) {
3003                                    throw processException(e);
3004                            }
3005                            finally {
3006                                    if (count == null) {
3007                                            count = Long.valueOf(0);
3008                                    }
3009    
3010                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_A,
3011                                            finderArgs, count);
3012    
3013                                    closeSession(session);
3014                            }
3015                    }
3016    
3017                    return count.intValue();
3018            }
3019    
3020            /**
3021             * Filters by the user's permissions and counts all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
3022             *
3023             * @param classNameId the class name id to search with
3024             * @param classPK the class p k to search with
3025             * @param alert the alert to search with
3026             * @return the number of matching announcements entries that the user has permission to view
3027             * @throws SystemException if a system exception occurred
3028             */
3029            public int filterCountByC_C_A(long classNameId, long classPK, boolean alert)
3030                    throws SystemException {
3031                    if (!InlineSQLHelperUtil.isEnabled()) {
3032                            return countByC_C_A(classNameId, classPK, alert);
3033                    }
3034    
3035                    StringBundler query = new StringBundler(4);
3036    
3037                    query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3038    
3039                    query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
3040    
3041                    query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
3042    
3043                    query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
3044    
3045                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3046                                    AnnouncementsEntry.class.getName(), _FILTER_COLUMN_PK,
3047                                    _FILTER_COLUMN_USERID);
3048    
3049                    Session session = null;
3050    
3051                    try {
3052                            session = openSession();
3053    
3054                            SQLQuery q = session.createSQLQuery(sql);
3055    
3056                            q.addScalar(COUNT_COLUMN_NAME,
3057                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3058    
3059                            QueryPos qPos = QueryPos.getInstance(q);
3060    
3061                            qPos.add(classNameId);
3062    
3063                            qPos.add(classPK);
3064    
3065                            qPos.add(alert);
3066    
3067                            Long count = (Long)q.uniqueResult();
3068    
3069                            return count.intValue();
3070                    }
3071                    catch (Exception e) {
3072                            throw processException(e);
3073                    }
3074                    finally {
3075                            closeSession(session);
3076                    }
3077            }
3078    
3079            /**
3080             * Counts all the announcements entries.
3081             *
3082             * @return the number of announcements entries
3083             * @throws SystemException if a system exception occurred
3084             */
3085            public int countAll() throws SystemException {
3086                    Object[] finderArgs = new Object[0];
3087    
3088                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3089                                    finderArgs, this);
3090    
3091                    if (count == null) {
3092                            Session session = null;
3093    
3094                            try {
3095                                    session = openSession();
3096    
3097                                    Query q = session.createQuery(_SQL_COUNT_ANNOUNCEMENTSENTRY);
3098    
3099                                    count = (Long)q.uniqueResult();
3100                            }
3101                            catch (Exception e) {
3102                                    throw processException(e);
3103                            }
3104                            finally {
3105                                    if (count == null) {
3106                                            count = Long.valueOf(0);
3107                                    }
3108    
3109                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3110                                            count);
3111    
3112                                    closeSession(session);
3113                            }
3114                    }
3115    
3116                    return count.intValue();
3117            }
3118    
3119            /**
3120             * Initializes the announcements entry persistence.
3121             */
3122            public void afterPropertiesSet() {
3123                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3124                                            com.liferay.portal.util.PropsUtil.get(
3125                                                    "value.object.listener.com.liferay.portlet.announcements.model.AnnouncementsEntry")));
3126    
3127                    if (listenerClassNames.length > 0) {
3128                            try {
3129                                    List<ModelListener<AnnouncementsEntry>> listenersList = new ArrayList<ModelListener<AnnouncementsEntry>>();
3130    
3131                                    for (String listenerClassName : listenerClassNames) {
3132                                            listenersList.add((ModelListener<AnnouncementsEntry>)InstanceFactory.newInstance(
3133                                                            listenerClassName));
3134                                    }
3135    
3136                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3137                            }
3138                            catch (Exception e) {
3139                                    _log.error(e);
3140                            }
3141                    }
3142            }
3143    
3144            public void destroy() {
3145                    EntityCacheUtil.removeCache(AnnouncementsEntryImpl.class.getName());
3146                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3147                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
3148            }
3149    
3150            @BeanReference(type = AnnouncementsDeliveryPersistence.class)
3151            protected AnnouncementsDeliveryPersistence announcementsDeliveryPersistence;
3152            @BeanReference(type = AnnouncementsEntryPersistence.class)
3153            protected AnnouncementsEntryPersistence announcementsEntryPersistence;
3154            @BeanReference(type = AnnouncementsFlagPersistence.class)
3155            protected AnnouncementsFlagPersistence announcementsFlagPersistence;
3156            @BeanReference(type = CompanyPersistence.class)
3157            protected CompanyPersistence companyPersistence;
3158            @BeanReference(type = GroupPersistence.class)
3159            protected GroupPersistence groupPersistence;
3160            @BeanReference(type = OrganizationPersistence.class)
3161            protected OrganizationPersistence organizationPersistence;
3162            @BeanReference(type = ResourcePersistence.class)
3163            protected ResourcePersistence resourcePersistence;
3164            @BeanReference(type = RolePersistence.class)
3165            protected RolePersistence rolePersistence;
3166            @BeanReference(type = UserPersistence.class)
3167            protected UserPersistence userPersistence;
3168            @BeanReference(type = UserGroupPersistence.class)
3169            protected UserGroupPersistence userGroupPersistence;
3170            private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry";
3171            private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry WHERE ";
3172            private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry";
3173            private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry WHERE ";
3174            private static final String _FINDER_COLUMN_UUID_UUID_1 = "announcementsEntry.uuid IS NULL";
3175            private static final String _FINDER_COLUMN_UUID_UUID_2 = "announcementsEntry.uuid = ?";
3176            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = ?)";
3177            private static final String _FINDER_COLUMN_USERID_USERID_2 = "announcementsEntry.userId = ?";
3178            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
3179            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "announcementsEntry.classPK = ?";
3180            private static final String _FINDER_COLUMN_C_C_A_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
3181            private static final String _FINDER_COLUMN_C_C_A_CLASSPK_2 = "announcementsEntry.classPK = ? AND ";
3182            private static final String _FINDER_COLUMN_C_C_A_ALERT_2 = "announcementsEntry.alert = ?";
3183            private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT DISTINCT {announcementsEntry.*} FROM AnnouncementsEntry announcementsEntry WHERE ";
3184            private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
3185                    "SELECT {AnnouncementsEntry.*} FROM (SELECT DISTINCT announcementsEntry.entryId FROM AnnouncementsEntry announcementsEntry WHERE ";
3186            private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
3187                    ") TEMP_TABLE INNER JOIN AnnouncementsEntry ON TEMP_TABLE.entryId = AnnouncementsEntry.entryId";
3188            private static final String _FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(DISTINCT announcementsEntry.entryId) AS COUNT_VALUE FROM AnnouncementsEntry announcementsEntry WHERE ";
3189            private static final String _FILTER_COLUMN_PK = "announcementsEntry.entryId";
3190            private static final String _FILTER_COLUMN_USERID = "announcementsEntry.userId";
3191            private static final String _FILTER_ENTITY_ALIAS = "announcementsEntry";
3192            private static final String _FILTER_ENTITY_TABLE = "AnnouncementsEntry";
3193            private static final String _ORDER_BY_ENTITY_ALIAS = "announcementsEntry.";
3194            private static final String _ORDER_BY_ENTITY_TABLE = "AnnouncementsEntry.";
3195            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AnnouncementsEntry exists with the primary key ";
3196            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AnnouncementsEntry exists with the key {";
3197            private static Log _log = LogFactoryUtil.getLog(AnnouncementsEntryPersistenceImpl.class);
3198    }