001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.announcements.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.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.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.BatchSessionUtil;
043    import com.liferay.portal.service.persistence.CompanyPersistence;
044    import com.liferay.portal.service.persistence.GroupPersistence;
045    import com.liferay.portal.service.persistence.OrganizationPersistence;
046    import com.liferay.portal.service.persistence.ResourcePersistence;
047    import com.liferay.portal.service.persistence.RolePersistence;
048    import com.liferay.portal.service.persistence.UserGroupPersistence;
049    import com.liferay.portal.service.persistence.UserPersistence;
050    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051    
052    import com.liferay.portlet.announcements.NoSuchEntryException;
053    import com.liferay.portlet.announcements.model.AnnouncementsEntry;
054    import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryImpl;
055    import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryModelImpl;
056    
057    import java.io.Serializable;
058    
059    import java.util.ArrayList;
060    import java.util.Collections;
061    import java.util.List;
062    
063    /**
064     * The persistence implementation for the announcements entry service.
065     *
066     * <p>
067     * Caching information and settings can be found in <code>portal.properties</code>
068     * </p>
069     *
070     * @author Brian Wing Shun Chan
071     * @see AnnouncementsEntryPersistence
072     * @see AnnouncementsEntryUtil
073     * @generated
074     */
075    public class AnnouncementsEntryPersistenceImpl extends BasePersistenceImpl<AnnouncementsEntry>
076            implements AnnouncementsEntryPersistence {
077            /*
078             * NOTE FOR DEVELOPERS:
079             *
080             * 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.
081             */
082            public static final String FINDER_CLASS_NAME_ENTITY = AnnouncementsEntryImpl.class.getName();
083            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084                    ".List1";
085            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086                    ".List2";
087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
088                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
089                            AnnouncementsEntryImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
091                            new String[] {
092                                    String.class.getName(),
093                                    
094                            "java.lang.Integer", "java.lang.Integer",
095                                    "com.liferay.portal.kernel.util.OrderByComparator"
096                            });
097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
098                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
099                            AnnouncementsEntryImpl.class,
100                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
101                            new String[] { String.class.getName() },
102                            AnnouncementsEntryModelImpl.UUID_COLUMN_BITMASK);
103            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
104                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
106                            new String[] { String.class.getName() });
107            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
108                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
109                            AnnouncementsEntryImpl.class,
110                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
111                            new String[] {
112                                    Long.class.getName(),
113                                    
114                            "java.lang.Integer", "java.lang.Integer",
115                                    "com.liferay.portal.kernel.util.OrderByComparator"
116                            });
117            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
118                    new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
119                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
120                            AnnouncementsEntryImpl.class,
121                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
122                            new String[] { Long.class.getName() },
123                            AnnouncementsEntryModelImpl.USERID_COLUMN_BITMASK);
124            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
125                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
126                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
127                            new String[] { Long.class.getName() });
128            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
129                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
130                            AnnouncementsEntryImpl.class,
131                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
132                            new String[] {
133                                    Long.class.getName(), Long.class.getName(),
134                                    
135                            "java.lang.Integer", "java.lang.Integer",
136                                    "com.liferay.portal.kernel.util.OrderByComparator"
137                            });
138            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
139                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
140                            AnnouncementsEntryImpl.class,
141                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
142                            new String[] { Long.class.getName(), Long.class.getName() },
143                            AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
144                            AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK);
145            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
146                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
147                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
148                            new String[] { Long.class.getName(), Long.class.getName() });
149            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
150                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
151                            AnnouncementsEntryImpl.class,
152                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_A",
153                            new String[] {
154                                    Long.class.getName(), Long.class.getName(),
155                                    Boolean.class.getName(),
156                                    
157                            "java.lang.Integer", "java.lang.Integer",
158                                    "com.liferay.portal.kernel.util.OrderByComparator"
159                            });
160            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
161                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
162                            AnnouncementsEntryImpl.class,
163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_A",
164                            new String[] {
165                                    Long.class.getName(), Long.class.getName(),
166                                    Boolean.class.getName()
167                            },
168                            AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
169                            AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK |
170                            AnnouncementsEntryModelImpl.ALERT_COLUMN_BITMASK);
171            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
172                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
173                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_A",
174                            new String[] {
175                                    Long.class.getName(), Long.class.getName(),
176                                    Boolean.class.getName()
177                            });
178            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
179                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
180                            AnnouncementsEntryImpl.class,
181                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
182            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
183                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
184                            AnnouncementsEntryImpl.class,
185                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
186            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
187                            AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
188                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
189    
190            /**
191             * Caches the announcements entry in the entity cache if it is enabled.
192             *
193             * @param announcementsEntry the announcements entry
194             */
195            public void cacheResult(AnnouncementsEntry announcementsEntry) {
196                    EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
197                            AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
198                            announcementsEntry);
199    
200                    announcementsEntry.resetOriginalValues();
201            }
202    
203            /**
204             * Caches the announcements entries in the entity cache if it is enabled.
205             *
206             * @param announcementsEntries the announcements entries
207             */
208            public void cacheResult(List<AnnouncementsEntry> announcementsEntries) {
209                    for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
210                            if (EntityCacheUtil.getResult(
211                                                    AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
212                                                    AnnouncementsEntryImpl.class,
213                                                    announcementsEntry.getPrimaryKey()) == null) {
214                                    cacheResult(announcementsEntry);
215                            }
216                            else {
217                                    announcementsEntry.resetOriginalValues();
218                            }
219                    }
220            }
221    
222            /**
223             * Clears the cache for all announcements entries.
224             *
225             * <p>
226             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
227             * </p>
228             */
229            @Override
230            public void clearCache() {
231                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
232                            CacheRegistryUtil.clear(AnnouncementsEntryImpl.class.getName());
233                    }
234    
235                    EntityCacheUtil.clearCache(AnnouncementsEntryImpl.class.getName());
236    
237                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
238                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
239                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
240            }
241    
242            /**
243             * Clears the cache for the announcements entry.
244             *
245             * <p>
246             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
247             * </p>
248             */
249            @Override
250            public void clearCache(AnnouncementsEntry announcementsEntry) {
251                    EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
252                            AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
253    
254                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
255                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
256            }
257    
258            /**
259             * Creates a new announcements entry with the primary key. Does not add the announcements entry to the database.
260             *
261             * @param entryId the primary key for the new announcements entry
262             * @return the new announcements entry
263             */
264            public AnnouncementsEntry create(long entryId) {
265                    AnnouncementsEntry announcementsEntry = new AnnouncementsEntryImpl();
266    
267                    announcementsEntry.setNew(true);
268                    announcementsEntry.setPrimaryKey(entryId);
269    
270                    String uuid = PortalUUIDUtil.generate();
271    
272                    announcementsEntry.setUuid(uuid);
273    
274                    return announcementsEntry;
275            }
276    
277            /**
278             * Removes the announcements entry with the primary key from the database. Also notifies the appropriate model listeners.
279             *
280             * @param primaryKey the primary key of the announcements entry
281             * @return the announcements entry that was removed
282             * @throws com.liferay.portal.NoSuchModelException if a announcements entry with the primary key could not be found
283             * @throws SystemException if a system exception occurred
284             */
285            @Override
286            public AnnouncementsEntry remove(Serializable primaryKey)
287                    throws NoSuchModelException, SystemException {
288                    return remove(((Long)primaryKey).longValue());
289            }
290    
291            /**
292             * Removes the announcements entry with the primary key from the database. Also notifies the appropriate model listeners.
293             *
294             * @param entryId the primary key of the announcements entry
295             * @return the announcements entry that was removed
296             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
297             * @throws SystemException if a system exception occurred
298             */
299            public AnnouncementsEntry remove(long entryId)
300                    throws NoSuchEntryException, SystemException {
301                    Session session = null;
302    
303                    try {
304                            session = openSession();
305    
306                            AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
307                                            Long.valueOf(entryId));
308    
309                            if (announcementsEntry == null) {
310                                    if (_log.isWarnEnabled()) {
311                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
312                                    }
313    
314                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
315                                            entryId);
316                            }
317    
318                            return announcementsEntryPersistence.remove(announcementsEntry);
319                    }
320                    catch (NoSuchEntryException nsee) {
321                            throw nsee;
322                    }
323                    catch (Exception e) {
324                            throw processException(e);
325                    }
326                    finally {
327                            closeSession(session);
328                    }
329            }
330    
331            /**
332             * Removes the announcements entry from the database. Also notifies the appropriate model listeners.
333             *
334             * @param announcementsEntry the announcements entry
335             * @return the announcements entry that was removed
336             * @throws SystemException if a system exception occurred
337             */
338            @Override
339            public AnnouncementsEntry remove(AnnouncementsEntry announcementsEntry)
340                    throws SystemException {
341                    return super.remove(announcementsEntry);
342            }
343    
344            @Override
345            protected AnnouncementsEntry removeImpl(
346                    AnnouncementsEntry announcementsEntry) throws SystemException {
347                    announcementsEntry = toUnwrappedModel(announcementsEntry);
348    
349                    Session session = null;
350    
351                    try {
352                            session = openSession();
353    
354                            BatchSessionUtil.delete(session, announcementsEntry);
355                    }
356                    catch (Exception e) {
357                            throw processException(e);
358                    }
359                    finally {
360                            closeSession(session);
361                    }
362    
363                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
364                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
365    
366                    EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
367                            AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
368    
369                    return announcementsEntry;
370            }
371    
372            @Override
373            public AnnouncementsEntry updateImpl(
374                    com.liferay.portlet.announcements.model.AnnouncementsEntry announcementsEntry,
375                    boolean merge) throws SystemException {
376                    announcementsEntry = toUnwrappedModel(announcementsEntry);
377    
378                    boolean isNew = announcementsEntry.isNew();
379    
380                    AnnouncementsEntryModelImpl announcementsEntryModelImpl = (AnnouncementsEntryModelImpl)announcementsEntry;
381    
382                    if (Validator.isNull(announcementsEntry.getUuid())) {
383                            String uuid = PortalUUIDUtil.generate();
384    
385                            announcementsEntry.setUuid(uuid);
386                    }
387    
388                    Session session = null;
389    
390                    try {
391                            session = openSession();
392    
393                            BatchSessionUtil.update(session, announcementsEntry, merge);
394    
395                            announcementsEntry.setNew(false);
396                    }
397                    catch (Exception e) {
398                            throw processException(e);
399                    }
400                    finally {
401                            closeSession(session);
402                    }
403    
404                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
405    
406                    if (isNew || !AnnouncementsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
407                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
408                    }
409    
410                    else {
411                            if ((announcementsEntryModelImpl.getColumnBitmask() &
412                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
413                                    Object[] args = new Object[] {
414                                                    announcementsEntryModelImpl.getOriginalUuid()
415                                            };
416    
417                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
418                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
419                                            args);
420    
421                                    args = new Object[] { announcementsEntryModelImpl.getUuid() };
422    
423                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
424                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
425                                            args);
426                            }
427    
428                            if ((announcementsEntryModelImpl.getColumnBitmask() &
429                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
430                                    Object[] args = new Object[] {
431                                                    Long.valueOf(announcementsEntryModelImpl.getOriginalUserId())
432                                            };
433    
434                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
435                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
436                                            args);
437    
438                                    args = new Object[] {
439                                                    Long.valueOf(announcementsEntryModelImpl.getUserId())
440                                            };
441    
442                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
443                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
444                                            args);
445                            }
446    
447                            if ((announcementsEntryModelImpl.getColumnBitmask() &
448                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
449                                    Object[] args = new Object[] {
450                                                    Long.valueOf(announcementsEntryModelImpl.getOriginalClassNameId()),
451                                                    Long.valueOf(announcementsEntryModelImpl.getOriginalClassPK())
452                                            };
453    
454                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
455                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
456                                            args);
457    
458                                    args = new Object[] {
459                                                    Long.valueOf(announcementsEntryModelImpl.getClassNameId()),
460                                                    Long.valueOf(announcementsEntryModelImpl.getClassPK())
461                                            };
462    
463                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
464                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
465                                            args);
466                            }
467    
468                            if ((announcementsEntryModelImpl.getColumnBitmask() &
469                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A.getColumnBitmask()) != 0) {
470                                    Object[] args = new Object[] {
471                                                    Long.valueOf(announcementsEntryModelImpl.getOriginalClassNameId()),
472                                                    Long.valueOf(announcementsEntryModelImpl.getOriginalClassPK()),
473                                                    Boolean.valueOf(announcementsEntryModelImpl.getOriginalAlert())
474                                            };
475    
476                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
477                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
478                                            args);
479    
480                                    args = new Object[] {
481                                                    Long.valueOf(announcementsEntryModelImpl.getClassNameId()),
482                                                    Long.valueOf(announcementsEntryModelImpl.getClassPK()),
483                                                    Boolean.valueOf(announcementsEntryModelImpl.getAlert())
484                                            };
485    
486                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
487                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
488                                            args);
489                            }
490                    }
491    
492                    EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
493                            AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
494                            announcementsEntry);
495    
496                    return announcementsEntry;
497            }
498    
499            protected AnnouncementsEntry toUnwrappedModel(
500                    AnnouncementsEntry announcementsEntry) {
501                    if (announcementsEntry instanceof AnnouncementsEntryImpl) {
502                            return announcementsEntry;
503                    }
504    
505                    AnnouncementsEntryImpl announcementsEntryImpl = new AnnouncementsEntryImpl();
506    
507                    announcementsEntryImpl.setNew(announcementsEntry.isNew());
508                    announcementsEntryImpl.setPrimaryKey(announcementsEntry.getPrimaryKey());
509    
510                    announcementsEntryImpl.setUuid(announcementsEntry.getUuid());
511                    announcementsEntryImpl.setEntryId(announcementsEntry.getEntryId());
512                    announcementsEntryImpl.setCompanyId(announcementsEntry.getCompanyId());
513                    announcementsEntryImpl.setUserId(announcementsEntry.getUserId());
514                    announcementsEntryImpl.setUserName(announcementsEntry.getUserName());
515                    announcementsEntryImpl.setCreateDate(announcementsEntry.getCreateDate());
516                    announcementsEntryImpl.setModifiedDate(announcementsEntry.getModifiedDate());
517                    announcementsEntryImpl.setClassNameId(announcementsEntry.getClassNameId());
518                    announcementsEntryImpl.setClassPK(announcementsEntry.getClassPK());
519                    announcementsEntryImpl.setTitle(announcementsEntry.getTitle());
520                    announcementsEntryImpl.setContent(announcementsEntry.getContent());
521                    announcementsEntryImpl.setUrl(announcementsEntry.getUrl());
522                    announcementsEntryImpl.setType(announcementsEntry.getType());
523                    announcementsEntryImpl.setDisplayDate(announcementsEntry.getDisplayDate());
524                    announcementsEntryImpl.setExpirationDate(announcementsEntry.getExpirationDate());
525                    announcementsEntryImpl.setPriority(announcementsEntry.getPriority());
526                    announcementsEntryImpl.setAlert(announcementsEntry.isAlert());
527    
528                    return announcementsEntryImpl;
529            }
530    
531            /**
532             * Returns the announcements entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
533             *
534             * @param primaryKey the primary key of the announcements entry
535             * @return the announcements entry
536             * @throws com.liferay.portal.NoSuchModelException if a announcements entry with the primary key could not be found
537             * @throws SystemException if a system exception occurred
538             */
539            @Override
540            public AnnouncementsEntry findByPrimaryKey(Serializable primaryKey)
541                    throws NoSuchModelException, SystemException {
542                    return findByPrimaryKey(((Long)primaryKey).longValue());
543            }
544    
545            /**
546             * Returns the announcements entry with the primary key or throws a {@link com.liferay.portlet.announcements.NoSuchEntryException} if it could not be found.
547             *
548             * @param entryId the primary key of the announcements entry
549             * @return the announcements entry
550             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
551             * @throws SystemException if a system exception occurred
552             */
553            public AnnouncementsEntry findByPrimaryKey(long entryId)
554                    throws NoSuchEntryException, SystemException {
555                    AnnouncementsEntry announcementsEntry = fetchByPrimaryKey(entryId);
556    
557                    if (announcementsEntry == null) {
558                            if (_log.isWarnEnabled()) {
559                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
560                            }
561    
562                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
563                                    entryId);
564                    }
565    
566                    return announcementsEntry;
567            }
568    
569            /**
570             * Returns the announcements entry with the primary key or returns <code>null</code> if it could not be found.
571             *
572             * @param primaryKey the primary key of the announcements entry
573             * @return the announcements entry, or <code>null</code> if a announcements entry with the primary key could not be found
574             * @throws SystemException if a system exception occurred
575             */
576            @Override
577            public AnnouncementsEntry fetchByPrimaryKey(Serializable primaryKey)
578                    throws SystemException {
579                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
580            }
581    
582            /**
583             * Returns the announcements entry with the primary key or returns <code>null</code> if it could not be found.
584             *
585             * @param entryId the primary key of the announcements entry
586             * @return the announcements entry, or <code>null</code> if a announcements entry with the primary key could not be found
587             * @throws SystemException if a system exception occurred
588             */
589            public AnnouncementsEntry fetchByPrimaryKey(long entryId)
590                    throws SystemException {
591                    AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)EntityCacheUtil.getResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
592                                    AnnouncementsEntryImpl.class, entryId);
593    
594                    if (announcementsEntry == _nullAnnouncementsEntry) {
595                            return null;
596                    }
597    
598                    if (announcementsEntry == null) {
599                            Session session = null;
600    
601                            boolean hasException = false;
602    
603                            try {
604                                    session = openSession();
605    
606                                    announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
607                                                    Long.valueOf(entryId));
608                            }
609                            catch (Exception e) {
610                                    hasException = true;
611    
612                                    throw processException(e);
613                            }
614                            finally {
615                                    if (announcementsEntry != null) {
616                                            cacheResult(announcementsEntry);
617                                    }
618                                    else if (!hasException) {
619                                            EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
620                                                    AnnouncementsEntryImpl.class, entryId,
621                                                    _nullAnnouncementsEntry);
622                                    }
623    
624                                    closeSession(session);
625                            }
626                    }
627    
628                    return announcementsEntry;
629            }
630    
631            /**
632             * Returns all the announcements entries where uuid = &#63;.
633             *
634             * @param uuid the uuid
635             * @return the matching announcements entries
636             * @throws SystemException if a system exception occurred
637             */
638            public List<AnnouncementsEntry> findByUuid(String uuid)
639                    throws SystemException {
640                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
641            }
642    
643            /**
644             * Returns a range of all the announcements entries where uuid = &#63;.
645             *
646             * <p>
647             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
648             * </p>
649             *
650             * @param uuid the uuid
651             * @param start the lower bound of the range of announcements entries
652             * @param end the upper bound of the range of announcements entries (not inclusive)
653             * @return the range of matching announcements entries
654             * @throws SystemException if a system exception occurred
655             */
656            public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end)
657                    throws SystemException {
658                    return findByUuid(uuid, start, end, null);
659            }
660    
661            /**
662             * Returns an ordered range of all the announcements entries where uuid = &#63;.
663             *
664             * <p>
665             * 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.
666             * </p>
667             *
668             * @param uuid the uuid
669             * @param start the lower bound of the range of announcements entries
670             * @param end the upper bound of the range of announcements entries (not inclusive)
671             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
672             * @return the ordered range of matching announcements entries
673             * @throws SystemException if a system exception occurred
674             */
675            public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end,
676                    OrderByComparator orderByComparator) throws SystemException {
677                    FinderPath finderPath = null;
678                    Object[] finderArgs = null;
679    
680                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
681                                    (orderByComparator == null)) {
682                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
683                            finderArgs = new Object[] { uuid };
684                    }
685                    else {
686                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
687                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
688                    }
689    
690                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
691                                    finderArgs, this);
692    
693                    if (list == null) {
694                            StringBundler query = null;
695    
696                            if (orderByComparator != null) {
697                                    query = new StringBundler(3 +
698                                                    (orderByComparator.getOrderByFields().length * 3));
699                            }
700                            else {
701                                    query = new StringBundler(3);
702                            }
703    
704                            query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
705    
706                            if (uuid == null) {
707                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
708                            }
709                            else {
710                                    if (uuid.equals(StringPool.BLANK)) {
711                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
712                                    }
713                                    else {
714                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
715                                    }
716                            }
717    
718                            if (orderByComparator != null) {
719                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
720                                            orderByComparator);
721                            }
722    
723                            else {
724                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
725                            }
726    
727                            String sql = query.toString();
728    
729                            Session session = null;
730    
731                            try {
732                                    session = openSession();
733    
734                                    Query q = session.createQuery(sql);
735    
736                                    QueryPos qPos = QueryPos.getInstance(q);
737    
738                                    if (uuid != null) {
739                                            qPos.add(uuid);
740                                    }
741    
742                                    list = (List<AnnouncementsEntry>)QueryUtil.list(q,
743                                                    getDialect(), start, end);
744                            }
745                            catch (Exception e) {
746                                    throw processException(e);
747                            }
748                            finally {
749                                    if (list == null) {
750                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
751                                    }
752                                    else {
753                                            cacheResult(list);
754    
755                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
756                                    }
757    
758                                    closeSession(session);
759                            }
760                    }
761    
762                    return list;
763            }
764    
765            /**
766             * Returns the first announcements entry in the ordered set where uuid = &#63;.
767             *
768             * <p>
769             * 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.
770             * </p>
771             *
772             * @param uuid the uuid
773             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
774             * @return the first matching announcements entry
775             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
776             * @throws SystemException if a system exception occurred
777             */
778            public AnnouncementsEntry findByUuid_First(String uuid,
779                    OrderByComparator orderByComparator)
780                    throws NoSuchEntryException, SystemException {
781                    List<AnnouncementsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
782    
783                    if (list.isEmpty()) {
784                            StringBundler msg = new StringBundler(4);
785    
786                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
787    
788                            msg.append("uuid=");
789                            msg.append(uuid);
790    
791                            msg.append(StringPool.CLOSE_CURLY_BRACE);
792    
793                            throw new NoSuchEntryException(msg.toString());
794                    }
795                    else {
796                            return list.get(0);
797                    }
798            }
799    
800            /**
801             * Returns the last announcements entry in the ordered set where uuid = &#63;.
802             *
803             * <p>
804             * 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.
805             * </p>
806             *
807             * @param uuid the uuid
808             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
809             * @return the last matching announcements entry
810             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
811             * @throws SystemException if a system exception occurred
812             */
813            public AnnouncementsEntry findByUuid_Last(String uuid,
814                    OrderByComparator orderByComparator)
815                    throws NoSuchEntryException, SystemException {
816                    int count = countByUuid(uuid);
817    
818                    List<AnnouncementsEntry> list = findByUuid(uuid, count - 1, count,
819                                    orderByComparator);
820    
821                    if (list.isEmpty()) {
822                            StringBundler msg = new StringBundler(4);
823    
824                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
825    
826                            msg.append("uuid=");
827                            msg.append(uuid);
828    
829                            msg.append(StringPool.CLOSE_CURLY_BRACE);
830    
831                            throw new NoSuchEntryException(msg.toString());
832                    }
833                    else {
834                            return list.get(0);
835                    }
836            }
837    
838            /**
839             * Returns the announcements entries before and after the current announcements entry in the ordered set where uuid = &#63;.
840             *
841             * <p>
842             * 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.
843             * </p>
844             *
845             * @param entryId the primary key of the current announcements entry
846             * @param uuid the uuid
847             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
848             * @return the previous, current, and next announcements entry
849             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
850             * @throws SystemException if a system exception occurred
851             */
852            public AnnouncementsEntry[] findByUuid_PrevAndNext(long entryId,
853                    String uuid, OrderByComparator orderByComparator)
854                    throws NoSuchEntryException, SystemException {
855                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
856    
857                    Session session = null;
858    
859                    try {
860                            session = openSession();
861    
862                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
863    
864                            array[0] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
865                                            orderByComparator, true);
866    
867                            array[1] = announcementsEntry;
868    
869                            array[2] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
870                                            orderByComparator, false);
871    
872                            return array;
873                    }
874                    catch (Exception e) {
875                            throw processException(e);
876                    }
877                    finally {
878                            closeSession(session);
879                    }
880            }
881    
882            protected AnnouncementsEntry getByUuid_PrevAndNext(Session session,
883                    AnnouncementsEntry announcementsEntry, String uuid,
884                    OrderByComparator orderByComparator, boolean previous) {
885                    StringBundler query = null;
886    
887                    if (orderByComparator != null) {
888                            query = new StringBundler(6 +
889                                            (orderByComparator.getOrderByFields().length * 6));
890                    }
891                    else {
892                            query = new StringBundler(3);
893                    }
894    
895                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
896    
897                    if (uuid == null) {
898                            query.append(_FINDER_COLUMN_UUID_UUID_1);
899                    }
900                    else {
901                            if (uuid.equals(StringPool.BLANK)) {
902                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
903                            }
904                            else {
905                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
906                            }
907                    }
908    
909                    if (orderByComparator != null) {
910                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
911    
912                            if (orderByConditionFields.length > 0) {
913                                    query.append(WHERE_AND);
914                            }
915    
916                            for (int i = 0; i < orderByConditionFields.length; i++) {
917                                    query.append(_ORDER_BY_ENTITY_ALIAS);
918                                    query.append(orderByConditionFields[i]);
919    
920                                    if ((i + 1) < orderByConditionFields.length) {
921                                            if (orderByComparator.isAscending() ^ previous) {
922                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
923                                            }
924                                            else {
925                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
926                                            }
927                                    }
928                                    else {
929                                            if (orderByComparator.isAscending() ^ previous) {
930                                                    query.append(WHERE_GREATER_THAN);
931                                            }
932                                            else {
933                                                    query.append(WHERE_LESSER_THAN);
934                                            }
935                                    }
936                            }
937    
938                            query.append(ORDER_BY_CLAUSE);
939    
940                            String[] orderByFields = orderByComparator.getOrderByFields();
941    
942                            for (int i = 0; i < orderByFields.length; i++) {
943                                    query.append(_ORDER_BY_ENTITY_ALIAS);
944                                    query.append(orderByFields[i]);
945    
946                                    if ((i + 1) < orderByFields.length) {
947                                            if (orderByComparator.isAscending() ^ previous) {
948                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
949                                            }
950                                            else {
951                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
952                                            }
953                                    }
954                                    else {
955                                            if (orderByComparator.isAscending() ^ previous) {
956                                                    query.append(ORDER_BY_ASC);
957                                            }
958                                            else {
959                                                    query.append(ORDER_BY_DESC);
960                                            }
961                                    }
962                            }
963                    }
964    
965                    else {
966                            query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
967                    }
968    
969                    String sql = query.toString();
970    
971                    Query q = session.createQuery(sql);
972    
973                    q.setFirstResult(0);
974                    q.setMaxResults(2);
975    
976                    QueryPos qPos = QueryPos.getInstance(q);
977    
978                    if (uuid != null) {
979                            qPos.add(uuid);
980                    }
981    
982                    if (orderByComparator != null) {
983                            Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
984    
985                            for (Object value : values) {
986                                    qPos.add(value);
987                            }
988                    }
989    
990                    List<AnnouncementsEntry> list = q.list();
991    
992                    if (list.size() == 2) {
993                            return list.get(1);
994                    }
995                    else {
996                            return null;
997                    }
998            }
999    
1000            /**
1001             * Returns all the announcements entries that the user has permission to view where uuid = &#63;.
1002             *
1003             * @param uuid the uuid
1004             * @return the matching announcements entries that the user has permission to view
1005             * @throws SystemException if a system exception occurred
1006             */
1007            public List<AnnouncementsEntry> filterFindByUuid(String uuid)
1008                    throws SystemException {
1009                    return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1010            }
1011    
1012            /**
1013             * Returns a range of all the announcements entries that the user has permission to view where uuid = &#63;.
1014             *
1015             * <p>
1016             * 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.
1017             * </p>
1018             *
1019             * @param uuid the uuid
1020             * @param start the lower bound of the range of announcements entries
1021             * @param end the upper bound of the range of announcements entries (not inclusive)
1022             * @return the range of matching announcements entries that the user has permission to view
1023             * @throws SystemException if a system exception occurred
1024             */
1025            public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
1026                    int end) throws SystemException {
1027                    return filterFindByUuid(uuid, start, end, null);
1028            }
1029    
1030            /**
1031             * Returns an ordered range of all the announcements entries that the user has permissions to view where uuid = &#63;.
1032             *
1033             * <p>
1034             * 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.
1035             * </p>
1036             *
1037             * @param uuid the uuid
1038             * @param start the lower bound of the range of announcements entries
1039             * @param end the upper bound of the range of announcements entries (not inclusive)
1040             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1041             * @return the ordered range of matching announcements entries that the user has permission to view
1042             * @throws SystemException if a system exception occurred
1043             */
1044            public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
1045                    int end, OrderByComparator orderByComparator) throws SystemException {
1046                    if (!InlineSQLHelperUtil.isEnabled()) {
1047                            return findByUuid(uuid, start, end, orderByComparator);
1048                    }
1049    
1050                    StringBundler query = null;
1051    
1052                    if (orderByComparator != null) {
1053                            query = new StringBundler(3 +
1054                                            (orderByComparator.getOrderByFields().length * 3));
1055                    }
1056                    else {
1057                            query = new StringBundler(3);
1058                    }
1059    
1060                    if (getDB().isSupportsInlineDistinct()) {
1061                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1062                    }
1063                    else {
1064                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1065                    }
1066    
1067                    if (uuid == null) {
1068                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1069                    }
1070                    else {
1071                            if (uuid.equals(StringPool.BLANK)) {
1072                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1073                            }
1074                            else {
1075                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1076                            }
1077                    }
1078    
1079                    if (!getDB().isSupportsInlineDistinct()) {
1080                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1081                    }
1082    
1083                    if (orderByComparator != null) {
1084                            if (getDB().isSupportsInlineDistinct()) {
1085                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1086                                            orderByComparator);
1087                            }
1088                            else {
1089                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1090                                            orderByComparator);
1091                            }
1092                    }
1093    
1094                    else {
1095                            if (getDB().isSupportsInlineDistinct()) {
1096                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1097                            }
1098                            else {
1099                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1100                            }
1101                    }
1102    
1103                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1104                                    AnnouncementsEntry.class.getName(),
1105                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1106    
1107                    Session session = null;
1108    
1109                    try {
1110                            session = openSession();
1111    
1112                            SQLQuery q = session.createSQLQuery(sql);
1113    
1114                            if (getDB().isSupportsInlineDistinct()) {
1115                                    q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1116                            }
1117                            else {
1118                                    q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1119                            }
1120    
1121                            QueryPos qPos = QueryPos.getInstance(q);
1122    
1123                            if (uuid != null) {
1124                                    qPos.add(uuid);
1125                            }
1126    
1127                            return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
1128                                    start, end);
1129                    }
1130                    catch (Exception e) {
1131                            throw processException(e);
1132                    }
1133                    finally {
1134                            closeSession(session);
1135                    }
1136            }
1137    
1138            /**
1139             * Returns the announcements entries before and after the current announcements entry in the ordered set of announcements entries that the user has permission to view where uuid = &#63;.
1140             *
1141             * @param entryId the primary key of the current announcements entry
1142             * @param uuid the uuid
1143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1144             * @return the previous, current, and next announcements entry
1145             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
1146             * @throws SystemException if a system exception occurred
1147             */
1148            public AnnouncementsEntry[] filterFindByUuid_PrevAndNext(long entryId,
1149                    String uuid, OrderByComparator orderByComparator)
1150                    throws NoSuchEntryException, SystemException {
1151                    if (!InlineSQLHelperUtil.isEnabled()) {
1152                            return findByUuid_PrevAndNext(entryId, uuid, orderByComparator);
1153                    }
1154    
1155                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1156    
1157                    Session session = null;
1158    
1159                    try {
1160                            session = openSession();
1161    
1162                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1163    
1164                            array[0] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
1165                                            uuid, orderByComparator, true);
1166    
1167                            array[1] = announcementsEntry;
1168    
1169                            array[2] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
1170                                            uuid, orderByComparator, false);
1171    
1172                            return array;
1173                    }
1174                    catch (Exception e) {
1175                            throw processException(e);
1176                    }
1177                    finally {
1178                            closeSession(session);
1179                    }
1180            }
1181    
1182            protected AnnouncementsEntry filterGetByUuid_PrevAndNext(Session session,
1183                    AnnouncementsEntry announcementsEntry, String uuid,
1184                    OrderByComparator orderByComparator, boolean previous) {
1185                    StringBundler query = null;
1186    
1187                    if (orderByComparator != null) {
1188                            query = new StringBundler(6 +
1189                                            (orderByComparator.getOrderByFields().length * 6));
1190                    }
1191                    else {
1192                            query = new StringBundler(3);
1193                    }
1194    
1195                    if (getDB().isSupportsInlineDistinct()) {
1196                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1197                    }
1198                    else {
1199                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1200                    }
1201    
1202                    if (uuid == null) {
1203                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1204                    }
1205                    else {
1206                            if (uuid.equals(StringPool.BLANK)) {
1207                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1208                            }
1209                            else {
1210                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1211                            }
1212                    }
1213    
1214                    if (!getDB().isSupportsInlineDistinct()) {
1215                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1216                    }
1217    
1218                    if (orderByComparator != null) {
1219                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1220    
1221                            if (orderByConditionFields.length > 0) {
1222                                    query.append(WHERE_AND);
1223                            }
1224    
1225                            for (int i = 0; i < orderByConditionFields.length; i++) {
1226                                    if (getDB().isSupportsInlineDistinct()) {
1227                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1228                                    }
1229                                    else {
1230                                            query.append(_ORDER_BY_ENTITY_TABLE);
1231                                    }
1232    
1233                                    query.append(orderByConditionFields[i]);
1234    
1235                                    if ((i + 1) < orderByConditionFields.length) {
1236                                            if (orderByComparator.isAscending() ^ previous) {
1237                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1238                                            }
1239                                            else {
1240                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1241                                            }
1242                                    }
1243                                    else {
1244                                            if (orderByComparator.isAscending() ^ previous) {
1245                                                    query.append(WHERE_GREATER_THAN);
1246                                            }
1247                                            else {
1248                                                    query.append(WHERE_LESSER_THAN);
1249                                            }
1250                                    }
1251                            }
1252    
1253                            query.append(ORDER_BY_CLAUSE);
1254    
1255                            String[] orderByFields = orderByComparator.getOrderByFields();
1256    
1257                            for (int i = 0; i < orderByFields.length; i++) {
1258                                    if (getDB().isSupportsInlineDistinct()) {
1259                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1260                                    }
1261                                    else {
1262                                            query.append(_ORDER_BY_ENTITY_TABLE);
1263                                    }
1264    
1265                                    query.append(orderByFields[i]);
1266    
1267                                    if ((i + 1) < orderByFields.length) {
1268                                            if (orderByComparator.isAscending() ^ previous) {
1269                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1270                                            }
1271                                            else {
1272                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1273                                            }
1274                                    }
1275                                    else {
1276                                            if (orderByComparator.isAscending() ^ previous) {
1277                                                    query.append(ORDER_BY_ASC);
1278                                            }
1279                                            else {
1280                                                    query.append(ORDER_BY_DESC);
1281                                            }
1282                                    }
1283                            }
1284                    }
1285    
1286                    else {
1287                            if (getDB().isSupportsInlineDistinct()) {
1288                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1289                            }
1290                            else {
1291                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1292                            }
1293                    }
1294    
1295                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1296                                    AnnouncementsEntry.class.getName(),
1297                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1298    
1299                    SQLQuery q = session.createSQLQuery(sql);
1300    
1301                    q.setFirstResult(0);
1302                    q.setMaxResults(2);
1303    
1304                    if (getDB().isSupportsInlineDistinct()) {
1305                            q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1306                    }
1307                    else {
1308                            q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1309                    }
1310    
1311                    QueryPos qPos = QueryPos.getInstance(q);
1312    
1313                    if (uuid != null) {
1314                            qPos.add(uuid);
1315                    }
1316    
1317                    if (orderByComparator != null) {
1318                            Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1319    
1320                            for (Object value : values) {
1321                                    qPos.add(value);
1322                            }
1323                    }
1324    
1325                    List<AnnouncementsEntry> list = q.list();
1326    
1327                    if (list.size() == 2) {
1328                            return list.get(1);
1329                    }
1330                    else {
1331                            return null;
1332                    }
1333            }
1334    
1335            /**
1336             * Returns all the announcements entries where userId = &#63;.
1337             *
1338             * @param userId the user ID
1339             * @return the matching announcements entries
1340             * @throws SystemException if a system exception occurred
1341             */
1342            public List<AnnouncementsEntry> findByUserId(long userId)
1343                    throws SystemException {
1344                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1345            }
1346    
1347            /**
1348             * Returns a range of all the announcements entries where userId = &#63;.
1349             *
1350             * <p>
1351             * 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.
1352             * </p>
1353             *
1354             * @param userId the user ID
1355             * @param start the lower bound of the range of announcements entries
1356             * @param end the upper bound of the range of announcements entries (not inclusive)
1357             * @return the range of matching announcements entries
1358             * @throws SystemException if a system exception occurred
1359             */
1360            public List<AnnouncementsEntry> findByUserId(long userId, int start, int end)
1361                    throws SystemException {
1362                    return findByUserId(userId, start, end, null);
1363            }
1364    
1365            /**
1366             * Returns an ordered range of all the announcements entries where userId = &#63;.
1367             *
1368             * <p>
1369             * 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.
1370             * </p>
1371             *
1372             * @param userId the user ID
1373             * @param start the lower bound of the range of announcements entries
1374             * @param end the upper bound of the range of announcements entries (not inclusive)
1375             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1376             * @return the ordered range of matching announcements entries
1377             * @throws SystemException if a system exception occurred
1378             */
1379            public List<AnnouncementsEntry> findByUserId(long userId, int start,
1380                    int end, OrderByComparator orderByComparator) throws SystemException {
1381                    FinderPath finderPath = null;
1382                    Object[] finderArgs = null;
1383    
1384                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1385                                    (orderByComparator == null)) {
1386                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1387                            finderArgs = new Object[] { userId };
1388                    }
1389                    else {
1390                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1391                            finderArgs = new Object[] { userId, start, end, orderByComparator };
1392                    }
1393    
1394                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
1395                                    finderArgs, this);
1396    
1397                    if (list == null) {
1398                            StringBundler query = null;
1399    
1400                            if (orderByComparator != null) {
1401                                    query = new StringBundler(3 +
1402                                                    (orderByComparator.getOrderByFields().length * 3));
1403                            }
1404                            else {
1405                                    query = new StringBundler(3);
1406                            }
1407    
1408                            query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1409    
1410                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1411    
1412                            if (orderByComparator != null) {
1413                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1414                                            orderByComparator);
1415                            }
1416    
1417                            else {
1418                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1419                            }
1420    
1421                            String sql = query.toString();
1422    
1423                            Session session = null;
1424    
1425                            try {
1426                                    session = openSession();
1427    
1428                                    Query q = session.createQuery(sql);
1429    
1430                                    QueryPos qPos = QueryPos.getInstance(q);
1431    
1432                                    qPos.add(userId);
1433    
1434                                    list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1435                                                    getDialect(), start, end);
1436                            }
1437                            catch (Exception e) {
1438                                    throw processException(e);
1439                            }
1440                            finally {
1441                                    if (list == null) {
1442                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1443                                    }
1444                                    else {
1445                                            cacheResult(list);
1446    
1447                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1448                                    }
1449    
1450                                    closeSession(session);
1451                            }
1452                    }
1453    
1454                    return list;
1455            }
1456    
1457            /**
1458             * Returns the first announcements entry in the ordered set where userId = &#63;.
1459             *
1460             * <p>
1461             * 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.
1462             * </p>
1463             *
1464             * @param userId the user ID
1465             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1466             * @return the first matching announcements entry
1467             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
1468             * @throws SystemException if a system exception occurred
1469             */
1470            public AnnouncementsEntry findByUserId_First(long userId,
1471                    OrderByComparator orderByComparator)
1472                    throws NoSuchEntryException, SystemException {
1473                    List<AnnouncementsEntry> list = findByUserId(userId, 0, 1,
1474                                    orderByComparator);
1475    
1476                    if (list.isEmpty()) {
1477                            StringBundler msg = new StringBundler(4);
1478    
1479                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1480    
1481                            msg.append("userId=");
1482                            msg.append(userId);
1483    
1484                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1485    
1486                            throw new NoSuchEntryException(msg.toString());
1487                    }
1488                    else {
1489                            return list.get(0);
1490                    }
1491            }
1492    
1493            /**
1494             * Returns the last announcements entry in the ordered set where userId = &#63;.
1495             *
1496             * <p>
1497             * 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.
1498             * </p>
1499             *
1500             * @param userId the user ID
1501             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1502             * @return the last matching announcements entry
1503             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
1504             * @throws SystemException if a system exception occurred
1505             */
1506            public AnnouncementsEntry findByUserId_Last(long userId,
1507                    OrderByComparator orderByComparator)
1508                    throws NoSuchEntryException, SystemException {
1509                    int count = countByUserId(userId);
1510    
1511                    List<AnnouncementsEntry> list = findByUserId(userId, count - 1, count,
1512                                    orderByComparator);
1513    
1514                    if (list.isEmpty()) {
1515                            StringBundler msg = new StringBundler(4);
1516    
1517                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1518    
1519                            msg.append("userId=");
1520                            msg.append(userId);
1521    
1522                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1523    
1524                            throw new NoSuchEntryException(msg.toString());
1525                    }
1526                    else {
1527                            return list.get(0);
1528                    }
1529            }
1530    
1531            /**
1532             * Returns the announcements entries before and after the current announcements entry in the ordered set where userId = &#63;.
1533             *
1534             * <p>
1535             * 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.
1536             * </p>
1537             *
1538             * @param entryId the primary key of the current announcements entry
1539             * @param userId the user ID
1540             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1541             * @return the previous, current, and next announcements entry
1542             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
1543             * @throws SystemException if a system exception occurred
1544             */
1545            public AnnouncementsEntry[] findByUserId_PrevAndNext(long entryId,
1546                    long userId, OrderByComparator orderByComparator)
1547                    throws NoSuchEntryException, SystemException {
1548                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1549    
1550                    Session session = null;
1551    
1552                    try {
1553                            session = openSession();
1554    
1555                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1556    
1557                            array[0] = getByUserId_PrevAndNext(session, announcementsEntry,
1558                                            userId, orderByComparator, true);
1559    
1560                            array[1] = announcementsEntry;
1561    
1562                            array[2] = getByUserId_PrevAndNext(session, announcementsEntry,
1563                                            userId, orderByComparator, false);
1564    
1565                            return array;
1566                    }
1567                    catch (Exception e) {
1568                            throw processException(e);
1569                    }
1570                    finally {
1571                            closeSession(session);
1572                    }
1573            }
1574    
1575            protected AnnouncementsEntry getByUserId_PrevAndNext(Session session,
1576                    AnnouncementsEntry announcementsEntry, long userId,
1577                    OrderByComparator orderByComparator, boolean previous) {
1578                    StringBundler query = null;
1579    
1580                    if (orderByComparator != null) {
1581                            query = new StringBundler(6 +
1582                                            (orderByComparator.getOrderByFields().length * 6));
1583                    }
1584                    else {
1585                            query = new StringBundler(3);
1586                    }
1587    
1588                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1589    
1590                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1591    
1592                    if (orderByComparator != null) {
1593                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1594    
1595                            if (orderByConditionFields.length > 0) {
1596                                    query.append(WHERE_AND);
1597                            }
1598    
1599                            for (int i = 0; i < orderByConditionFields.length; i++) {
1600                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1601                                    query.append(orderByConditionFields[i]);
1602    
1603                                    if ((i + 1) < orderByConditionFields.length) {
1604                                            if (orderByComparator.isAscending() ^ previous) {
1605                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1606                                            }
1607                                            else {
1608                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1609                                            }
1610                                    }
1611                                    else {
1612                                            if (orderByComparator.isAscending() ^ previous) {
1613                                                    query.append(WHERE_GREATER_THAN);
1614                                            }
1615                                            else {
1616                                                    query.append(WHERE_LESSER_THAN);
1617                                            }
1618                                    }
1619                            }
1620    
1621                            query.append(ORDER_BY_CLAUSE);
1622    
1623                            String[] orderByFields = orderByComparator.getOrderByFields();
1624    
1625                            for (int i = 0; i < orderByFields.length; i++) {
1626                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1627                                    query.append(orderByFields[i]);
1628    
1629                                    if ((i + 1) < orderByFields.length) {
1630                                            if (orderByComparator.isAscending() ^ previous) {
1631                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1632                                            }
1633                                            else {
1634                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1635                                            }
1636                                    }
1637                                    else {
1638                                            if (orderByComparator.isAscending() ^ previous) {
1639                                                    query.append(ORDER_BY_ASC);
1640                                            }
1641                                            else {
1642                                                    query.append(ORDER_BY_DESC);
1643                                            }
1644                                    }
1645                            }
1646                    }
1647    
1648                    else {
1649                            query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1650                    }
1651    
1652                    String sql = query.toString();
1653    
1654                    Query q = session.createQuery(sql);
1655    
1656                    q.setFirstResult(0);
1657                    q.setMaxResults(2);
1658    
1659                    QueryPos qPos = QueryPos.getInstance(q);
1660    
1661                    qPos.add(userId);
1662    
1663                    if (orderByComparator != null) {
1664                            Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1665    
1666                            for (Object value : values) {
1667                                    qPos.add(value);
1668                            }
1669                    }
1670    
1671                    List<AnnouncementsEntry> list = q.list();
1672    
1673                    if (list.size() == 2) {
1674                            return list.get(1);
1675                    }
1676                    else {
1677                            return null;
1678                    }
1679            }
1680    
1681            /**
1682             * Returns all the announcements entries that the user has permission to view where userId = &#63;.
1683             *
1684             * @param userId the user ID
1685             * @return the matching announcements entries that the user has permission to view
1686             * @throws SystemException if a system exception occurred
1687             */
1688            public List<AnnouncementsEntry> filterFindByUserId(long userId)
1689                    throws SystemException {
1690                    return filterFindByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1691                            null);
1692            }
1693    
1694            /**
1695             * Returns a range of all the announcements entries that the user has permission to view where userId = &#63;.
1696             *
1697             * <p>
1698             * 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.
1699             * </p>
1700             *
1701             * @param userId the user ID
1702             * @param start the lower bound of the range of announcements entries
1703             * @param end the upper bound of the range of announcements entries (not inclusive)
1704             * @return the range of matching announcements entries that the user has permission to view
1705             * @throws SystemException if a system exception occurred
1706             */
1707            public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
1708                    int end) throws SystemException {
1709                    return filterFindByUserId(userId, start, end, null);
1710            }
1711    
1712            /**
1713             * Returns an ordered range of all the announcements entries that the user has permissions to view where userId = &#63;.
1714             *
1715             * <p>
1716             * 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.
1717             * </p>
1718             *
1719             * @param userId the user ID
1720             * @param start the lower bound of the range of announcements entries
1721             * @param end the upper bound of the range of announcements entries (not inclusive)
1722             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1723             * @return the ordered range of matching announcements entries that the user has permission to view
1724             * @throws SystemException if a system exception occurred
1725             */
1726            public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
1727                    int end, OrderByComparator orderByComparator) throws SystemException {
1728                    if (!InlineSQLHelperUtil.isEnabled()) {
1729                            return findByUserId(userId, start, end, orderByComparator);
1730                    }
1731    
1732                    StringBundler query = null;
1733    
1734                    if (orderByComparator != null) {
1735                            query = new StringBundler(3 +
1736                                            (orderByComparator.getOrderByFields().length * 3));
1737                    }
1738                    else {
1739                            query = new StringBundler(3);
1740                    }
1741    
1742                    if (getDB().isSupportsInlineDistinct()) {
1743                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1744                    }
1745                    else {
1746                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1747                    }
1748    
1749                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1750    
1751                    if (!getDB().isSupportsInlineDistinct()) {
1752                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1753                    }
1754    
1755                    if (orderByComparator != null) {
1756                            if (getDB().isSupportsInlineDistinct()) {
1757                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1758                                            orderByComparator);
1759                            }
1760                            else {
1761                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1762                                            orderByComparator);
1763                            }
1764                    }
1765    
1766                    else {
1767                            if (getDB().isSupportsInlineDistinct()) {
1768                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1769                            }
1770                            else {
1771                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1772                            }
1773                    }
1774    
1775                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1776                                    AnnouncementsEntry.class.getName(),
1777                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1778    
1779                    Session session = null;
1780    
1781                    try {
1782                            session = openSession();
1783    
1784                            SQLQuery q = session.createSQLQuery(sql);
1785    
1786                            if (getDB().isSupportsInlineDistinct()) {
1787                                    q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1788                            }
1789                            else {
1790                                    q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1791                            }
1792    
1793                            QueryPos qPos = QueryPos.getInstance(q);
1794    
1795                            qPos.add(userId);
1796    
1797                            return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
1798                                    start, end);
1799                    }
1800                    catch (Exception e) {
1801                            throw processException(e);
1802                    }
1803                    finally {
1804                            closeSession(session);
1805                    }
1806            }
1807    
1808            /**
1809             * Returns the announcements entries before and after the current announcements entry in the ordered set of announcements entries that the user has permission to view where userId = &#63;.
1810             *
1811             * @param entryId the primary key of the current announcements entry
1812             * @param userId the user ID
1813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1814             * @return the previous, current, and next announcements entry
1815             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
1816             * @throws SystemException if a system exception occurred
1817             */
1818            public AnnouncementsEntry[] filterFindByUserId_PrevAndNext(long entryId,
1819                    long userId, OrderByComparator orderByComparator)
1820                    throws NoSuchEntryException, SystemException {
1821                    if (!InlineSQLHelperUtil.isEnabled()) {
1822                            return findByUserId_PrevAndNext(entryId, userId, orderByComparator);
1823                    }
1824    
1825                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1826    
1827                    Session session = null;
1828    
1829                    try {
1830                            session = openSession();
1831    
1832                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1833    
1834                            array[0] = filterGetByUserId_PrevAndNext(session,
1835                                            announcementsEntry, userId, orderByComparator, true);
1836    
1837                            array[1] = announcementsEntry;
1838    
1839                            array[2] = filterGetByUserId_PrevAndNext(session,
1840                                            announcementsEntry, userId, orderByComparator, false);
1841    
1842                            return array;
1843                    }
1844                    catch (Exception e) {
1845                            throw processException(e);
1846                    }
1847                    finally {
1848                            closeSession(session);
1849                    }
1850            }
1851    
1852            protected AnnouncementsEntry filterGetByUserId_PrevAndNext(
1853                    Session session, AnnouncementsEntry announcementsEntry, long userId,
1854                    OrderByComparator orderByComparator, boolean previous) {
1855                    StringBundler query = null;
1856    
1857                    if (orderByComparator != null) {
1858                            query = new StringBundler(6 +
1859                                            (orderByComparator.getOrderByFields().length * 6));
1860                    }
1861                    else {
1862                            query = new StringBundler(3);
1863                    }
1864    
1865                    if (getDB().isSupportsInlineDistinct()) {
1866                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1867                    }
1868                    else {
1869                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1870                    }
1871    
1872                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1873    
1874                    if (!getDB().isSupportsInlineDistinct()) {
1875                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1876                    }
1877    
1878                    if (orderByComparator != null) {
1879                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1880    
1881                            if (orderByConditionFields.length > 0) {
1882                                    query.append(WHERE_AND);
1883                            }
1884    
1885                            for (int i = 0; i < orderByConditionFields.length; i++) {
1886                                    if (getDB().isSupportsInlineDistinct()) {
1887                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1888                                    }
1889                                    else {
1890                                            query.append(_ORDER_BY_ENTITY_TABLE);
1891                                    }
1892    
1893                                    query.append(orderByConditionFields[i]);
1894    
1895                                    if ((i + 1) < orderByConditionFields.length) {
1896                                            if (orderByComparator.isAscending() ^ previous) {
1897                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1898                                            }
1899                                            else {
1900                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1901                                            }
1902                                    }
1903                                    else {
1904                                            if (orderByComparator.isAscending() ^ previous) {
1905                                                    query.append(WHERE_GREATER_THAN);
1906                                            }
1907                                            else {
1908                                                    query.append(WHERE_LESSER_THAN);
1909                                            }
1910                                    }
1911                            }
1912    
1913                            query.append(ORDER_BY_CLAUSE);
1914    
1915                            String[] orderByFields = orderByComparator.getOrderByFields();
1916    
1917                            for (int i = 0; i < orderByFields.length; i++) {
1918                                    if (getDB().isSupportsInlineDistinct()) {
1919                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1920                                    }
1921                                    else {
1922                                            query.append(_ORDER_BY_ENTITY_TABLE);
1923                                    }
1924    
1925                                    query.append(orderByFields[i]);
1926    
1927                                    if ((i + 1) < orderByFields.length) {
1928                                            if (orderByComparator.isAscending() ^ previous) {
1929                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1930                                            }
1931                                            else {
1932                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1933                                            }
1934                                    }
1935                                    else {
1936                                            if (orderByComparator.isAscending() ^ previous) {
1937                                                    query.append(ORDER_BY_ASC);
1938                                            }
1939                                            else {
1940                                                    query.append(ORDER_BY_DESC);
1941                                            }
1942                                    }
1943                            }
1944                    }
1945    
1946                    else {
1947                            if (getDB().isSupportsInlineDistinct()) {
1948                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1949                            }
1950                            else {
1951                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1952                            }
1953                    }
1954    
1955                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1956                                    AnnouncementsEntry.class.getName(),
1957                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1958    
1959                    SQLQuery q = session.createSQLQuery(sql);
1960    
1961                    q.setFirstResult(0);
1962                    q.setMaxResults(2);
1963    
1964                    if (getDB().isSupportsInlineDistinct()) {
1965                            q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1966                    }
1967                    else {
1968                            q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1969                    }
1970    
1971                    QueryPos qPos = QueryPos.getInstance(q);
1972    
1973                    qPos.add(userId);
1974    
1975                    if (orderByComparator != null) {
1976                            Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1977    
1978                            for (Object value : values) {
1979                                    qPos.add(value);
1980                            }
1981                    }
1982    
1983                    List<AnnouncementsEntry> list = q.list();
1984    
1985                    if (list.size() == 2) {
1986                            return list.get(1);
1987                    }
1988                    else {
1989                            return null;
1990                    }
1991            }
1992    
1993            /**
1994             * Returns all the announcements entries where classNameId = &#63; and classPK = &#63;.
1995             *
1996             * @param classNameId the class name ID
1997             * @param classPK the class p k
1998             * @return the matching announcements entries
1999             * @throws SystemException if a system exception occurred
2000             */
2001            public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK)
2002                    throws SystemException {
2003                    return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
2004                            QueryUtil.ALL_POS, null);
2005            }
2006    
2007            /**
2008             * Returns a range of all the announcements entries where classNameId = &#63; and classPK = &#63;.
2009             *
2010             * <p>
2011             * 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.
2012             * </p>
2013             *
2014             * @param classNameId the class name ID
2015             * @param classPK the class p k
2016             * @param start the lower bound of the range of announcements entries
2017             * @param end the upper bound of the range of announcements entries (not inclusive)
2018             * @return the range of matching announcements entries
2019             * @throws SystemException if a system exception occurred
2020             */
2021            public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
2022                    int start, int end) throws SystemException {
2023                    return findByC_C(classNameId, classPK, start, end, null);
2024            }
2025    
2026            /**
2027             * Returns an ordered range of all the announcements entries where classNameId = &#63; and classPK = &#63;.
2028             *
2029             * <p>
2030             * 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.
2031             * </p>
2032             *
2033             * @param classNameId the class name ID
2034             * @param classPK the class p k
2035             * @param start the lower bound of the range of announcements entries
2036             * @param end the upper bound of the range of announcements entries (not inclusive)
2037             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2038             * @return the ordered range of matching announcements entries
2039             * @throws SystemException if a system exception occurred
2040             */
2041            public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
2042                    int start, int end, OrderByComparator orderByComparator)
2043                    throws SystemException {
2044                    FinderPath finderPath = null;
2045                    Object[] finderArgs = null;
2046    
2047                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2048                                    (orderByComparator == null)) {
2049                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2050                            finderArgs = new Object[] { classNameId, classPK };
2051                    }
2052                    else {
2053                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2054                            finderArgs = new Object[] {
2055                                            classNameId, classPK,
2056                                            
2057                                            start, end, orderByComparator
2058                                    };
2059                    }
2060    
2061                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
2062                                    finderArgs, this);
2063    
2064                    if (list == null) {
2065                            StringBundler query = null;
2066    
2067                            if (orderByComparator != null) {
2068                                    query = new StringBundler(4 +
2069                                                    (orderByComparator.getOrderByFields().length * 3));
2070                            }
2071                            else {
2072                                    query = new StringBundler(4);
2073                            }
2074    
2075                            query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2076    
2077                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2078    
2079                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2080    
2081                            if (orderByComparator != null) {
2082                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2083                                            orderByComparator);
2084                            }
2085    
2086                            else {
2087                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2088                            }
2089    
2090                            String sql = query.toString();
2091    
2092                            Session session = null;
2093    
2094                            try {
2095                                    session = openSession();
2096    
2097                                    Query q = session.createQuery(sql);
2098    
2099                                    QueryPos qPos = QueryPos.getInstance(q);
2100    
2101                                    qPos.add(classNameId);
2102    
2103                                    qPos.add(classPK);
2104    
2105                                    list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2106                                                    getDialect(), start, end);
2107                            }
2108                            catch (Exception e) {
2109                                    throw processException(e);
2110                            }
2111                            finally {
2112                                    if (list == null) {
2113                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2114                                    }
2115                                    else {
2116                                            cacheResult(list);
2117    
2118                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2119                                    }
2120    
2121                                    closeSession(session);
2122                            }
2123                    }
2124    
2125                    return list;
2126            }
2127    
2128            /**
2129             * Returns the first announcements entry in the ordered set where classNameId = &#63; and classPK = &#63;.
2130             *
2131             * <p>
2132             * 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.
2133             * </p>
2134             *
2135             * @param classNameId the class name ID
2136             * @param classPK the class p k
2137             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2138             * @return the first matching announcements entry
2139             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
2140             * @throws SystemException if a system exception occurred
2141             */
2142            public AnnouncementsEntry findByC_C_First(long classNameId, long classPK,
2143                    OrderByComparator orderByComparator)
2144                    throws NoSuchEntryException, SystemException {
2145                    List<AnnouncementsEntry> list = findByC_C(classNameId, classPK, 0, 1,
2146                                    orderByComparator);
2147    
2148                    if (list.isEmpty()) {
2149                            StringBundler msg = new StringBundler(6);
2150    
2151                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2152    
2153                            msg.append("classNameId=");
2154                            msg.append(classNameId);
2155    
2156                            msg.append(", classPK=");
2157                            msg.append(classPK);
2158    
2159                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2160    
2161                            throw new NoSuchEntryException(msg.toString());
2162                    }
2163                    else {
2164                            return list.get(0);
2165                    }
2166            }
2167    
2168            /**
2169             * Returns the last announcements entry in the ordered set where classNameId = &#63; and classPK = &#63;.
2170             *
2171             * <p>
2172             * 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.
2173             * </p>
2174             *
2175             * @param classNameId the class name ID
2176             * @param classPK the class p k
2177             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2178             * @return the last matching announcements entry
2179             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
2180             * @throws SystemException if a system exception occurred
2181             */
2182            public AnnouncementsEntry findByC_C_Last(long classNameId, long classPK,
2183                    OrderByComparator orderByComparator)
2184                    throws NoSuchEntryException, SystemException {
2185                    int count = countByC_C(classNameId, classPK);
2186    
2187                    List<AnnouncementsEntry> list = findByC_C(classNameId, classPK,
2188                                    count - 1, count, orderByComparator);
2189    
2190                    if (list.isEmpty()) {
2191                            StringBundler msg = new StringBundler(6);
2192    
2193                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2194    
2195                            msg.append("classNameId=");
2196                            msg.append(classNameId);
2197    
2198                            msg.append(", classPK=");
2199                            msg.append(classPK);
2200    
2201                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2202    
2203                            throw new NoSuchEntryException(msg.toString());
2204                    }
2205                    else {
2206                            return list.get(0);
2207                    }
2208            }
2209    
2210            /**
2211             * Returns the announcements entries before and after the current announcements entry in the ordered set where classNameId = &#63; and classPK = &#63;.
2212             *
2213             * <p>
2214             * 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.
2215             * </p>
2216             *
2217             * @param entryId the primary key of the current announcements entry
2218             * @param classNameId the class name ID
2219             * @param classPK the class p k
2220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2221             * @return the previous, current, and next announcements entry
2222             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
2223             * @throws SystemException if a system exception occurred
2224             */
2225            public AnnouncementsEntry[] findByC_C_PrevAndNext(long entryId,
2226                    long classNameId, long classPK, OrderByComparator orderByComparator)
2227                    throws NoSuchEntryException, SystemException {
2228                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2229    
2230                    Session session = null;
2231    
2232                    try {
2233                            session = openSession();
2234    
2235                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2236    
2237                            array[0] = getByC_C_PrevAndNext(session, announcementsEntry,
2238                                            classNameId, classPK, orderByComparator, true);
2239    
2240                            array[1] = announcementsEntry;
2241    
2242                            array[2] = getByC_C_PrevAndNext(session, announcementsEntry,
2243                                            classNameId, classPK, orderByComparator, false);
2244    
2245                            return array;
2246                    }
2247                    catch (Exception e) {
2248                            throw processException(e);
2249                    }
2250                    finally {
2251                            closeSession(session);
2252                    }
2253            }
2254    
2255            protected AnnouncementsEntry getByC_C_PrevAndNext(Session session,
2256                    AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
2257                    OrderByComparator orderByComparator, boolean previous) {
2258                    StringBundler query = null;
2259    
2260                    if (orderByComparator != null) {
2261                            query = new StringBundler(6 +
2262                                            (orderByComparator.getOrderByFields().length * 6));
2263                    }
2264                    else {
2265                            query = new StringBundler(3);
2266                    }
2267    
2268                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2269    
2270                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2271    
2272                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2273    
2274                    if (orderByComparator != null) {
2275                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2276    
2277                            if (orderByConditionFields.length > 0) {
2278                                    query.append(WHERE_AND);
2279                            }
2280    
2281                            for (int i = 0; i < orderByConditionFields.length; i++) {
2282                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2283                                    query.append(orderByConditionFields[i]);
2284    
2285                                    if ((i + 1) < orderByConditionFields.length) {
2286                                            if (orderByComparator.isAscending() ^ previous) {
2287                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2288                                            }
2289                                            else {
2290                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2291                                            }
2292                                    }
2293                                    else {
2294                                            if (orderByComparator.isAscending() ^ previous) {
2295                                                    query.append(WHERE_GREATER_THAN);
2296                                            }
2297                                            else {
2298                                                    query.append(WHERE_LESSER_THAN);
2299                                            }
2300                                    }
2301                            }
2302    
2303                            query.append(ORDER_BY_CLAUSE);
2304    
2305                            String[] orderByFields = orderByComparator.getOrderByFields();
2306    
2307                            for (int i = 0; i < orderByFields.length; i++) {
2308                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2309                                    query.append(orderByFields[i]);
2310    
2311                                    if ((i + 1) < orderByFields.length) {
2312                                            if (orderByComparator.isAscending() ^ previous) {
2313                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2314                                            }
2315                                            else {
2316                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2317                                            }
2318                                    }
2319                                    else {
2320                                            if (orderByComparator.isAscending() ^ previous) {
2321                                                    query.append(ORDER_BY_ASC);
2322                                            }
2323                                            else {
2324                                                    query.append(ORDER_BY_DESC);
2325                                            }
2326                                    }
2327                            }
2328                    }
2329    
2330                    else {
2331                            query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2332                    }
2333    
2334                    String sql = query.toString();
2335    
2336                    Query q = session.createQuery(sql);
2337    
2338                    q.setFirstResult(0);
2339                    q.setMaxResults(2);
2340    
2341                    QueryPos qPos = QueryPos.getInstance(q);
2342    
2343                    qPos.add(classNameId);
2344    
2345                    qPos.add(classPK);
2346    
2347                    if (orderByComparator != null) {
2348                            Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2349    
2350                            for (Object value : values) {
2351                                    qPos.add(value);
2352                            }
2353                    }
2354    
2355                    List<AnnouncementsEntry> list = q.list();
2356    
2357                    if (list.size() == 2) {
2358                            return list.get(1);
2359                    }
2360                    else {
2361                            return null;
2362                    }
2363            }
2364    
2365            /**
2366             * Returns all the announcements entries that the user has permission to view where classNameId = &#63; and classPK = &#63;.
2367             *
2368             * @param classNameId the class name ID
2369             * @param classPK the class p k
2370             * @return the matching announcements entries that the user has permission to view
2371             * @throws SystemException if a system exception occurred
2372             */
2373            public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
2374                    long classPK) throws SystemException {
2375                    return filterFindByC_C(classNameId, classPK, QueryUtil.ALL_POS,
2376                            QueryUtil.ALL_POS, null);
2377            }
2378    
2379            /**
2380             * Returns a range of all the announcements entries that the user has permission to view where classNameId = &#63; and classPK = &#63;.
2381             *
2382             * <p>
2383             * 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.
2384             * </p>
2385             *
2386             * @param classNameId the class name ID
2387             * @param classPK the class p k
2388             * @param start the lower bound of the range of announcements entries
2389             * @param end the upper bound of the range of announcements entries (not inclusive)
2390             * @return the range of matching announcements entries that the user has permission to view
2391             * @throws SystemException if a system exception occurred
2392             */
2393            public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
2394                    long classPK, int start, int end) throws SystemException {
2395                    return filterFindByC_C(classNameId, classPK, start, end, null);
2396            }
2397    
2398            /**
2399             * Returns an ordered range of all the announcements entries that the user has permissions to view where classNameId = &#63; and classPK = &#63;.
2400             *
2401             * <p>
2402             * 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.
2403             * </p>
2404             *
2405             * @param classNameId the class name ID
2406             * @param classPK the class p k
2407             * @param start the lower bound of the range of announcements entries
2408             * @param end the upper bound of the range of announcements entries (not inclusive)
2409             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2410             * @return the ordered range of matching announcements entries that the user has permission to view
2411             * @throws SystemException if a system exception occurred
2412             */
2413            public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
2414                    long classPK, int start, int end, OrderByComparator orderByComparator)
2415                    throws SystemException {
2416                    if (!InlineSQLHelperUtil.isEnabled()) {
2417                            return findByC_C(classNameId, classPK, start, end, orderByComparator);
2418                    }
2419    
2420                    StringBundler query = null;
2421    
2422                    if (orderByComparator != null) {
2423                            query = new StringBundler(4 +
2424                                            (orderByComparator.getOrderByFields().length * 3));
2425                    }
2426                    else {
2427                            query = new StringBundler(4);
2428                    }
2429    
2430                    if (getDB().isSupportsInlineDistinct()) {
2431                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2432                    }
2433                    else {
2434                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2435                    }
2436    
2437                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2438    
2439                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2440    
2441                    if (!getDB().isSupportsInlineDistinct()) {
2442                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2443                    }
2444    
2445                    if (orderByComparator != null) {
2446                            if (getDB().isSupportsInlineDistinct()) {
2447                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2448                                            orderByComparator);
2449                            }
2450                            else {
2451                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2452                                            orderByComparator);
2453                            }
2454                    }
2455    
2456                    else {
2457                            if (getDB().isSupportsInlineDistinct()) {
2458                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2459                            }
2460                            else {
2461                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2462                            }
2463                    }
2464    
2465                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2466                                    AnnouncementsEntry.class.getName(),
2467                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2468    
2469                    Session session = null;
2470    
2471                    try {
2472                            session = openSession();
2473    
2474                            SQLQuery q = session.createSQLQuery(sql);
2475    
2476                            if (getDB().isSupportsInlineDistinct()) {
2477                                    q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2478                            }
2479                            else {
2480                                    q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2481                            }
2482    
2483                            QueryPos qPos = QueryPos.getInstance(q);
2484    
2485                            qPos.add(classNameId);
2486    
2487                            qPos.add(classPK);
2488    
2489                            return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
2490                                    start, end);
2491                    }
2492                    catch (Exception e) {
2493                            throw processException(e);
2494                    }
2495                    finally {
2496                            closeSession(session);
2497                    }
2498            }
2499    
2500            /**
2501             * Returns the announcements entries before and after the current announcements entry in the ordered set of announcements entries that the user has permission to view where classNameId = &#63; and classPK = &#63;.
2502             *
2503             * @param entryId the primary key of the current announcements entry
2504             * @param classNameId the class name ID
2505             * @param classPK the class p k
2506             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2507             * @return the previous, current, and next announcements entry
2508             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
2509             * @throws SystemException if a system exception occurred
2510             */
2511            public AnnouncementsEntry[] filterFindByC_C_PrevAndNext(long entryId,
2512                    long classNameId, long classPK, OrderByComparator orderByComparator)
2513                    throws NoSuchEntryException, SystemException {
2514                    if (!InlineSQLHelperUtil.isEnabled()) {
2515                            return findByC_C_PrevAndNext(entryId, classNameId, classPK,
2516                                    orderByComparator);
2517                    }
2518    
2519                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2520    
2521                    Session session = null;
2522    
2523                    try {
2524                            session = openSession();
2525    
2526                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2527    
2528                            array[0] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
2529                                            classNameId, classPK, orderByComparator, true);
2530    
2531                            array[1] = announcementsEntry;
2532    
2533                            array[2] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
2534                                            classNameId, classPK, orderByComparator, false);
2535    
2536                            return array;
2537                    }
2538                    catch (Exception e) {
2539                            throw processException(e);
2540                    }
2541                    finally {
2542                            closeSession(session);
2543                    }
2544            }
2545    
2546            protected AnnouncementsEntry filterGetByC_C_PrevAndNext(Session session,
2547                    AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
2548                    OrderByComparator orderByComparator, boolean previous) {
2549                    StringBundler query = null;
2550    
2551                    if (orderByComparator != null) {
2552                            query = new StringBundler(6 +
2553                                            (orderByComparator.getOrderByFields().length * 6));
2554                    }
2555                    else {
2556                            query = new StringBundler(3);
2557                    }
2558    
2559                    if (getDB().isSupportsInlineDistinct()) {
2560                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2561                    }
2562                    else {
2563                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2564                    }
2565    
2566                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2567    
2568                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2569    
2570                    if (!getDB().isSupportsInlineDistinct()) {
2571                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2572                    }
2573    
2574                    if (orderByComparator != null) {
2575                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2576    
2577                            if (orderByConditionFields.length > 0) {
2578                                    query.append(WHERE_AND);
2579                            }
2580    
2581                            for (int i = 0; i < orderByConditionFields.length; i++) {
2582                                    if (getDB().isSupportsInlineDistinct()) {
2583                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2584                                    }
2585                                    else {
2586                                            query.append(_ORDER_BY_ENTITY_TABLE);
2587                                    }
2588    
2589                                    query.append(orderByConditionFields[i]);
2590    
2591                                    if ((i + 1) < orderByConditionFields.length) {
2592                                            if (orderByComparator.isAscending() ^ previous) {
2593                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2594                                            }
2595                                            else {
2596                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2597                                            }
2598                                    }
2599                                    else {
2600                                            if (orderByComparator.isAscending() ^ previous) {
2601                                                    query.append(WHERE_GREATER_THAN);
2602                                            }
2603                                            else {
2604                                                    query.append(WHERE_LESSER_THAN);
2605                                            }
2606                                    }
2607                            }
2608    
2609                            query.append(ORDER_BY_CLAUSE);
2610    
2611                            String[] orderByFields = orderByComparator.getOrderByFields();
2612    
2613                            for (int i = 0; i < orderByFields.length; i++) {
2614                                    if (getDB().isSupportsInlineDistinct()) {
2615                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2616                                    }
2617                                    else {
2618                                            query.append(_ORDER_BY_ENTITY_TABLE);
2619                                    }
2620    
2621                                    query.append(orderByFields[i]);
2622    
2623                                    if ((i + 1) < orderByFields.length) {
2624                                            if (orderByComparator.isAscending() ^ previous) {
2625                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2626                                            }
2627                                            else {
2628                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2629                                            }
2630                                    }
2631                                    else {
2632                                            if (orderByComparator.isAscending() ^ previous) {
2633                                                    query.append(ORDER_BY_ASC);
2634                                            }
2635                                            else {
2636                                                    query.append(ORDER_BY_DESC);
2637                                            }
2638                                    }
2639                            }
2640                    }
2641    
2642                    else {
2643                            if (getDB().isSupportsInlineDistinct()) {
2644                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2645                            }
2646                            else {
2647                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2648                            }
2649                    }
2650    
2651                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2652                                    AnnouncementsEntry.class.getName(),
2653                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2654    
2655                    SQLQuery q = session.createSQLQuery(sql);
2656    
2657                    q.setFirstResult(0);
2658                    q.setMaxResults(2);
2659    
2660                    if (getDB().isSupportsInlineDistinct()) {
2661                            q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2662                    }
2663                    else {
2664                            q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2665                    }
2666    
2667                    QueryPos qPos = QueryPos.getInstance(q);
2668    
2669                    qPos.add(classNameId);
2670    
2671                    qPos.add(classPK);
2672    
2673                    if (orderByComparator != null) {
2674                            Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2675    
2676                            for (Object value : values) {
2677                                    qPos.add(value);
2678                            }
2679                    }
2680    
2681                    List<AnnouncementsEntry> list = q.list();
2682    
2683                    if (list.size() == 2) {
2684                            return list.get(1);
2685                    }
2686                    else {
2687                            return null;
2688                    }
2689            }
2690    
2691            /**
2692             * Returns all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2693             *
2694             * @param classNameId the class name ID
2695             * @param classPK the class p k
2696             * @param alert the alert
2697             * @return the matching announcements entries
2698             * @throws SystemException if a system exception occurred
2699             */
2700            public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
2701                    boolean alert) throws SystemException {
2702                    return findByC_C_A(classNameId, classPK, alert, QueryUtil.ALL_POS,
2703                            QueryUtil.ALL_POS, null);
2704            }
2705    
2706            /**
2707             * Returns a range of all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2708             *
2709             * <p>
2710             * 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.
2711             * </p>
2712             *
2713             * @param classNameId the class name ID
2714             * @param classPK the class p k
2715             * @param alert the alert
2716             * @param start the lower bound of the range of announcements entries
2717             * @param end the upper bound of the range of announcements entries (not inclusive)
2718             * @return the range of matching announcements entries
2719             * @throws SystemException if a system exception occurred
2720             */
2721            public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
2722                    boolean alert, int start, int end) throws SystemException {
2723                    return findByC_C_A(classNameId, classPK, alert, start, end, null);
2724            }
2725    
2726            /**
2727             * Returns an ordered range of all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2728             *
2729             * <p>
2730             * 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.
2731             * </p>
2732             *
2733             * @param classNameId the class name ID
2734             * @param classPK the class p k
2735             * @param alert the alert
2736             * @param start the lower bound of the range of announcements entries
2737             * @param end the upper bound of the range of announcements entries (not inclusive)
2738             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2739             * @return the ordered range of matching announcements entries
2740             * @throws SystemException if a system exception occurred
2741             */
2742            public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
2743                    boolean alert, int start, int end, OrderByComparator orderByComparator)
2744                    throws SystemException {
2745                    FinderPath finderPath = null;
2746                    Object[] finderArgs = null;
2747    
2748                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2749                                    (orderByComparator == null)) {
2750                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A;
2751                            finderArgs = new Object[] { classNameId, classPK, alert };
2752                    }
2753                    else {
2754                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A;
2755                            finderArgs = new Object[] {
2756                                            classNameId, classPK, alert,
2757                                            
2758                                            start, end, orderByComparator
2759                                    };
2760                    }
2761    
2762                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
2763                                    finderArgs, this);
2764    
2765                    if (list == null) {
2766                            StringBundler query = null;
2767    
2768                            if (orderByComparator != null) {
2769                                    query = new StringBundler(5 +
2770                                                    (orderByComparator.getOrderByFields().length * 3));
2771                            }
2772                            else {
2773                                    query = new StringBundler(5);
2774                            }
2775    
2776                            query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2777    
2778                            query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
2779    
2780                            query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
2781    
2782                            query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
2783    
2784                            if (orderByComparator != null) {
2785                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2786                                            orderByComparator);
2787                            }
2788    
2789                            else {
2790                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2791                            }
2792    
2793                            String sql = query.toString();
2794    
2795                            Session session = null;
2796    
2797                            try {
2798                                    session = openSession();
2799    
2800                                    Query q = session.createQuery(sql);
2801    
2802                                    QueryPos qPos = QueryPos.getInstance(q);
2803    
2804                                    qPos.add(classNameId);
2805    
2806                                    qPos.add(classPK);
2807    
2808                                    qPos.add(alert);
2809    
2810                                    list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2811                                                    getDialect(), start, end);
2812                            }
2813                            catch (Exception e) {
2814                                    throw processException(e);
2815                            }
2816                            finally {
2817                                    if (list == null) {
2818                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2819                                    }
2820                                    else {
2821                                            cacheResult(list);
2822    
2823                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2824                                    }
2825    
2826                                    closeSession(session);
2827                            }
2828                    }
2829    
2830                    return list;
2831            }
2832    
2833            /**
2834             * Returns the first announcements entry in the ordered set where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2835             *
2836             * <p>
2837             * 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.
2838             * </p>
2839             *
2840             * @param classNameId the class name ID
2841             * @param classPK the class p k
2842             * @param alert the alert
2843             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2844             * @return the first matching announcements entry
2845             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
2846             * @throws SystemException if a system exception occurred
2847             */
2848            public AnnouncementsEntry findByC_C_A_First(long classNameId, long classPK,
2849                    boolean alert, OrderByComparator orderByComparator)
2850                    throws NoSuchEntryException, SystemException {
2851                    List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
2852                                    alert, 0, 1, orderByComparator);
2853    
2854                    if (list.isEmpty()) {
2855                            StringBundler msg = new StringBundler(8);
2856    
2857                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2858    
2859                            msg.append("classNameId=");
2860                            msg.append(classNameId);
2861    
2862                            msg.append(", classPK=");
2863                            msg.append(classPK);
2864    
2865                            msg.append(", alert=");
2866                            msg.append(alert);
2867    
2868                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2869    
2870                            throw new NoSuchEntryException(msg.toString());
2871                    }
2872                    else {
2873                            return list.get(0);
2874                    }
2875            }
2876    
2877            /**
2878             * Returns the last announcements entry in the ordered set where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2879             *
2880             * <p>
2881             * 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.
2882             * </p>
2883             *
2884             * @param classNameId the class name ID
2885             * @param classPK the class p k
2886             * @param alert the alert
2887             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2888             * @return the last matching announcements entry
2889             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a matching announcements entry could not be found
2890             * @throws SystemException if a system exception occurred
2891             */
2892            public AnnouncementsEntry findByC_C_A_Last(long classNameId, long classPK,
2893                    boolean alert, OrderByComparator orderByComparator)
2894                    throws NoSuchEntryException, SystemException {
2895                    int count = countByC_C_A(classNameId, classPK, alert);
2896    
2897                    List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
2898                                    alert, count - 1, count, orderByComparator);
2899    
2900                    if (list.isEmpty()) {
2901                            StringBundler msg = new StringBundler(8);
2902    
2903                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2904    
2905                            msg.append("classNameId=");
2906                            msg.append(classNameId);
2907    
2908                            msg.append(", classPK=");
2909                            msg.append(classPK);
2910    
2911                            msg.append(", alert=");
2912                            msg.append(alert);
2913    
2914                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2915    
2916                            throw new NoSuchEntryException(msg.toString());
2917                    }
2918                    else {
2919                            return list.get(0);
2920                    }
2921            }
2922    
2923            /**
2924             * Returns the announcements entries before and after the current announcements entry in the ordered set where classNameId = &#63; and classPK = &#63; and alert = &#63;.
2925             *
2926             * <p>
2927             * 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.
2928             * </p>
2929             *
2930             * @param entryId the primary key of the current announcements entry
2931             * @param classNameId the class name ID
2932             * @param classPK the class p k
2933             * @param alert the alert
2934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2935             * @return the previous, current, and next announcements entry
2936             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
2937             * @throws SystemException if a system exception occurred
2938             */
2939            public AnnouncementsEntry[] findByC_C_A_PrevAndNext(long entryId,
2940                    long classNameId, long classPK, boolean alert,
2941                    OrderByComparator orderByComparator)
2942                    throws NoSuchEntryException, SystemException {
2943                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2944    
2945                    Session session = null;
2946    
2947                    try {
2948                            session = openSession();
2949    
2950                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2951    
2952                            array[0] = getByC_C_A_PrevAndNext(session, announcementsEntry,
2953                                            classNameId, classPK, alert, orderByComparator, true);
2954    
2955                            array[1] = announcementsEntry;
2956    
2957                            array[2] = getByC_C_A_PrevAndNext(session, announcementsEntry,
2958                                            classNameId, classPK, alert, orderByComparator, false);
2959    
2960                            return array;
2961                    }
2962                    catch (Exception e) {
2963                            throw processException(e);
2964                    }
2965                    finally {
2966                            closeSession(session);
2967                    }
2968            }
2969    
2970            protected AnnouncementsEntry getByC_C_A_PrevAndNext(Session session,
2971                    AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
2972                    boolean alert, OrderByComparator orderByComparator, boolean previous) {
2973                    StringBundler query = null;
2974    
2975                    if (orderByComparator != null) {
2976                            query = new StringBundler(6 +
2977                                            (orderByComparator.getOrderByFields().length * 6));
2978                    }
2979                    else {
2980                            query = new StringBundler(3);
2981                    }
2982    
2983                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2984    
2985                    query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
2986    
2987                    query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
2988    
2989                    query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
2990    
2991                    if (orderByComparator != null) {
2992                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2993    
2994                            if (orderByConditionFields.length > 0) {
2995                                    query.append(WHERE_AND);
2996                            }
2997    
2998                            for (int i = 0; i < orderByConditionFields.length; i++) {
2999                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3000                                    query.append(orderByConditionFields[i]);
3001    
3002                                    if ((i + 1) < orderByConditionFields.length) {
3003                                            if (orderByComparator.isAscending() ^ previous) {
3004                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3005                                            }
3006                                            else {
3007                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3008                                            }
3009                                    }
3010                                    else {
3011                                            if (orderByComparator.isAscending() ^ previous) {
3012                                                    query.append(WHERE_GREATER_THAN);
3013                                            }
3014                                            else {
3015                                                    query.append(WHERE_LESSER_THAN);
3016                                            }
3017                                    }
3018                            }
3019    
3020                            query.append(ORDER_BY_CLAUSE);
3021    
3022                            String[] orderByFields = orderByComparator.getOrderByFields();
3023    
3024                            for (int i = 0; i < orderByFields.length; i++) {
3025                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3026                                    query.append(orderByFields[i]);
3027    
3028                                    if ((i + 1) < orderByFields.length) {
3029                                            if (orderByComparator.isAscending() ^ previous) {
3030                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3031                                            }
3032                                            else {
3033                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3034                                            }
3035                                    }
3036                                    else {
3037                                            if (orderByComparator.isAscending() ^ previous) {
3038                                                    query.append(ORDER_BY_ASC);
3039                                            }
3040                                            else {
3041                                                    query.append(ORDER_BY_DESC);
3042                                            }
3043                                    }
3044                            }
3045                    }
3046    
3047                    else {
3048                            query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3049                    }
3050    
3051                    String sql = query.toString();
3052    
3053                    Query q = session.createQuery(sql);
3054    
3055                    q.setFirstResult(0);
3056                    q.setMaxResults(2);
3057    
3058                    QueryPos qPos = QueryPos.getInstance(q);
3059    
3060                    qPos.add(classNameId);
3061    
3062                    qPos.add(classPK);
3063    
3064                    qPos.add(alert);
3065    
3066                    if (orderByComparator != null) {
3067                            Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3068    
3069                            for (Object value : values) {
3070                                    qPos.add(value);
3071                            }
3072                    }
3073    
3074                    List<AnnouncementsEntry> list = q.list();
3075    
3076                    if (list.size() == 2) {
3077                            return list.get(1);
3078                    }
3079                    else {
3080                            return null;
3081                    }
3082            }
3083    
3084            /**
3085             * Returns all the announcements entries that the user has permission to view where classNameId = &#63; and classPK = &#63; and alert = &#63;.
3086             *
3087             * @param classNameId the class name ID
3088             * @param classPK the class p k
3089             * @param alert the alert
3090             * @return the matching announcements entries that the user has permission to view
3091             * @throws SystemException if a system exception occurred
3092             */
3093            public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
3094                    long classPK, boolean alert) throws SystemException {
3095                    return filterFindByC_C_A(classNameId, classPK, alert,
3096                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3097            }
3098    
3099            /**
3100             * Returns a range of all the announcements entries that the user has permission to view where classNameId = &#63; and classPK = &#63; and alert = &#63;.
3101             *
3102             * <p>
3103             * 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.
3104             * </p>
3105             *
3106             * @param classNameId the class name ID
3107             * @param classPK the class p k
3108             * @param alert the alert
3109             * @param start the lower bound of the range of announcements entries
3110             * @param end the upper bound of the range of announcements entries (not inclusive)
3111             * @return the range of matching announcements entries that the user has permission to view
3112             * @throws SystemException if a system exception occurred
3113             */
3114            public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
3115                    long classPK, boolean alert, int start, int end)
3116                    throws SystemException {
3117                    return filterFindByC_C_A(classNameId, classPK, alert, start, end, null);
3118            }
3119    
3120            /**
3121             * Returns an ordered range of all the announcements entries that the user has permissions to view where classNameId = &#63; and classPK = &#63; and alert = &#63;.
3122             *
3123             * <p>
3124             * 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.
3125             * </p>
3126             *
3127             * @param classNameId the class name ID
3128             * @param classPK the class p k
3129             * @param alert the alert
3130             * @param start the lower bound of the range of announcements entries
3131             * @param end the upper bound of the range of announcements entries (not inclusive)
3132             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3133             * @return the ordered range of matching announcements entries that the user has permission to view
3134             * @throws SystemException if a system exception occurred
3135             */
3136            public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
3137                    long classPK, boolean alert, int start, int end,
3138                    OrderByComparator orderByComparator) throws SystemException {
3139                    if (!InlineSQLHelperUtil.isEnabled()) {
3140                            return findByC_C_A(classNameId, classPK, alert, start, end,
3141                                    orderByComparator);
3142                    }
3143    
3144                    StringBundler query = null;
3145    
3146                    if (orderByComparator != null) {
3147                            query = new StringBundler(5 +
3148                                            (orderByComparator.getOrderByFields().length * 3));
3149                    }
3150                    else {
3151                            query = new StringBundler(5);
3152                    }
3153    
3154                    if (getDB().isSupportsInlineDistinct()) {
3155                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3156                    }
3157                    else {
3158                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3159                    }
3160    
3161                    query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
3162    
3163                    query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
3164    
3165                    query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
3166    
3167                    if (!getDB().isSupportsInlineDistinct()) {
3168                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3169                    }
3170    
3171                    if (orderByComparator != null) {
3172                            if (getDB().isSupportsInlineDistinct()) {
3173                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3174                                            orderByComparator);
3175                            }
3176                            else {
3177                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3178                                            orderByComparator);
3179                            }
3180                    }
3181    
3182                    else {
3183                            if (getDB().isSupportsInlineDistinct()) {
3184                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3185                            }
3186                            else {
3187                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3188                            }
3189                    }
3190    
3191                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3192                                    AnnouncementsEntry.class.getName(),
3193                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3194    
3195                    Session session = null;
3196    
3197                    try {
3198                            session = openSession();
3199    
3200                            SQLQuery q = session.createSQLQuery(sql);
3201    
3202                            if (getDB().isSupportsInlineDistinct()) {
3203                                    q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3204                            }
3205                            else {
3206                                    q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3207                            }
3208    
3209                            QueryPos qPos = QueryPos.getInstance(q);
3210    
3211                            qPos.add(classNameId);
3212    
3213                            qPos.add(classPK);
3214    
3215                            qPos.add(alert);
3216    
3217                            return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
3218                                    start, end);
3219                    }
3220                    catch (Exception e) {
3221                            throw processException(e);
3222                    }
3223                    finally {
3224                            closeSession(session);
3225                    }
3226            }
3227    
3228            /**
3229             * Returns the announcements entries before and after the current announcements entry in the ordered set of announcements entries that the user has permission to view where classNameId = &#63; and classPK = &#63; and alert = &#63;.
3230             *
3231             * @param entryId the primary key of the current announcements entry
3232             * @param classNameId the class name ID
3233             * @param classPK the class p k
3234             * @param alert the alert
3235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3236             * @return the previous, current, and next announcements entry
3237             * @throws com.liferay.portlet.announcements.NoSuchEntryException if a announcements entry with the primary key could not be found
3238             * @throws SystemException if a system exception occurred
3239             */
3240            public AnnouncementsEntry[] filterFindByC_C_A_PrevAndNext(long entryId,
3241                    long classNameId, long classPK, boolean alert,
3242                    OrderByComparator orderByComparator)
3243                    throws NoSuchEntryException, SystemException {
3244                    if (!InlineSQLHelperUtil.isEnabled()) {
3245                            return findByC_C_A_PrevAndNext(entryId, classNameId, classPK,
3246                                    alert, orderByComparator);
3247                    }
3248    
3249                    AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3250    
3251                    Session session = null;
3252    
3253                    try {
3254                            session = openSession();
3255    
3256                            AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3257    
3258                            array[0] = filterGetByC_C_A_PrevAndNext(session,
3259                                            announcementsEntry, classNameId, classPK, alert,
3260                                            orderByComparator, true);
3261    
3262                            array[1] = announcementsEntry;
3263    
3264                            array[2] = filterGetByC_C_A_PrevAndNext(session,
3265                                            announcementsEntry, classNameId, classPK, alert,
3266                                            orderByComparator, false);
3267    
3268                            return array;
3269                    }
3270                    catch (Exception e) {
3271                            throw processException(e);
3272                    }
3273                    finally {
3274                            closeSession(session);
3275                    }
3276            }
3277    
3278            protected AnnouncementsEntry filterGetByC_C_A_PrevAndNext(Session session,
3279                    AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3280                    boolean alert, OrderByComparator orderByComparator, boolean previous) {
3281                    StringBundler query = null;
3282    
3283                    if (orderByComparator != null) {
3284                            query = new StringBundler(6 +
3285                                            (orderByComparator.getOrderByFields().length * 6));
3286                    }
3287                    else {
3288                            query = new StringBundler(3);
3289                    }
3290    
3291                    if (getDB().isSupportsInlineDistinct()) {
3292                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3293                    }
3294                    else {
3295                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3296                    }
3297    
3298                    query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
3299    
3300                    query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
3301    
3302                    query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
3303    
3304                    if (!getDB().isSupportsInlineDistinct()) {
3305                            query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3306                    }
3307    
3308                    if (orderByComparator != null) {
3309                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3310    
3311                            if (orderByConditionFields.length > 0) {
3312                                    query.append(WHERE_AND);
3313                            }
3314    
3315                            for (int i = 0; i < orderByConditionFields.length; i++) {
3316                                    if (getDB().isSupportsInlineDistinct()) {
3317                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3318                                    }
3319                                    else {
3320                                            query.append(_ORDER_BY_ENTITY_TABLE);
3321                                    }
3322    
3323                                    query.append(orderByConditionFields[i]);
3324    
3325                                    if ((i + 1) < orderByConditionFields.length) {
3326                                            if (orderByComparator.isAscending() ^ previous) {
3327                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3328                                            }
3329                                            else {
3330                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3331                                            }
3332                                    }
3333                                    else {
3334                                            if (orderByComparator.isAscending() ^ previous) {
3335                                                    query.append(WHERE_GREATER_THAN);
3336                                            }
3337                                            else {
3338                                                    query.append(WHERE_LESSER_THAN);
3339                                            }
3340                                    }
3341                            }
3342    
3343                            query.append(ORDER_BY_CLAUSE);
3344    
3345                            String[] orderByFields = orderByComparator.getOrderByFields();
3346    
3347                            for (int i = 0; i < orderByFields.length; i++) {
3348                                    if (getDB().isSupportsInlineDistinct()) {
3349                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3350                                    }
3351                                    else {
3352                                            query.append(_ORDER_BY_ENTITY_TABLE);
3353                                    }
3354    
3355                                    query.append(orderByFields[i]);
3356    
3357                                    if ((i + 1) < orderByFields.length) {
3358                                            if (orderByComparator.isAscending() ^ previous) {
3359                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3360                                            }
3361                                            else {
3362                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3363                                            }
3364                                    }
3365                                    else {
3366                                            if (orderByComparator.isAscending() ^ previous) {
3367                                                    query.append(ORDER_BY_ASC);
3368                                            }
3369                                            else {
3370                                                    query.append(ORDER_BY_DESC);
3371                                            }
3372                                    }
3373                            }
3374                    }
3375    
3376                    else {
3377                            if (getDB().isSupportsInlineDistinct()) {
3378                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3379                            }
3380                            else {
3381                                    query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3382                            }
3383                    }
3384    
3385                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3386                                    AnnouncementsEntry.class.getName(),
3387                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3388    
3389                    SQLQuery q = session.createSQLQuery(sql);
3390    
3391                    q.setFirstResult(0);
3392                    q.setMaxResults(2);
3393    
3394                    if (getDB().isSupportsInlineDistinct()) {
3395                            q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3396                    }
3397                    else {
3398                            q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3399                    }
3400    
3401                    QueryPos qPos = QueryPos.getInstance(q);
3402    
3403                    qPos.add(classNameId);
3404    
3405                    qPos.add(classPK);
3406    
3407                    qPos.add(alert);
3408    
3409                    if (orderByComparator != null) {
3410                            Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3411    
3412                            for (Object value : values) {
3413                                    qPos.add(value);
3414                            }
3415                    }
3416    
3417                    List<AnnouncementsEntry> list = q.list();
3418    
3419                    if (list.size() == 2) {
3420                            return list.get(1);
3421                    }
3422                    else {
3423                            return null;
3424                    }
3425            }
3426    
3427            /**
3428             * Returns all the announcements entries.
3429             *
3430             * @return the announcements entries
3431             * @throws SystemException if a system exception occurred
3432             */
3433            public List<AnnouncementsEntry> findAll() throws SystemException {
3434                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3435            }
3436    
3437            /**
3438             * Returns a range of all the announcements entries.
3439             *
3440             * <p>
3441             * 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.
3442             * </p>
3443             *
3444             * @param start the lower bound of the range of announcements entries
3445             * @param end the upper bound of the range of announcements entries (not inclusive)
3446             * @return the range of announcements entries
3447             * @throws SystemException if a system exception occurred
3448             */
3449            public List<AnnouncementsEntry> findAll(int start, int end)
3450                    throws SystemException {
3451                    return findAll(start, end, null);
3452            }
3453    
3454            /**
3455             * Returns an ordered range of all the announcements entries.
3456             *
3457             * <p>
3458             * 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.
3459             * </p>
3460             *
3461             * @param start the lower bound of the range of announcements entries
3462             * @param end the upper bound of the range of announcements entries (not inclusive)
3463             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3464             * @return the ordered range of announcements entries
3465             * @throws SystemException if a system exception occurred
3466             */
3467            public List<AnnouncementsEntry> findAll(int start, int end,
3468                    OrderByComparator orderByComparator) throws SystemException {
3469                    FinderPath finderPath = null;
3470                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
3471    
3472                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3473                                    (orderByComparator == null)) {
3474                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3475                            finderArgs = FINDER_ARGS_EMPTY;
3476                    }
3477                    else {
3478                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3479                            finderArgs = new Object[] { start, end, orderByComparator };
3480                    }
3481    
3482                    List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
3483                                    finderArgs, this);
3484    
3485                    if (list == null) {
3486                            StringBundler query = null;
3487                            String sql = null;
3488    
3489                            if (orderByComparator != null) {
3490                                    query = new StringBundler(2 +
3491                                                    (orderByComparator.getOrderByFields().length * 3));
3492    
3493                                    query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY);
3494    
3495                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3496                                            orderByComparator);
3497    
3498                                    sql = query.toString();
3499                            }
3500                            else {
3501                                    sql = _SQL_SELECT_ANNOUNCEMENTSENTRY.concat(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3502                            }
3503    
3504                            Session session = null;
3505    
3506                            try {
3507                                    session = openSession();
3508    
3509                                    Query q = session.createQuery(sql);
3510    
3511                                    if (orderByComparator == null) {
3512                                            list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3513                                                            getDialect(), start, end, false);
3514    
3515                                            Collections.sort(list);
3516                                    }
3517                                    else {
3518                                            list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3519                                                            getDialect(), start, end);
3520                                    }
3521                            }
3522                            catch (Exception e) {
3523                                    throw processException(e);
3524                            }
3525                            finally {
3526                                    if (list == null) {
3527                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3528                                    }
3529                                    else {
3530                                            cacheResult(list);
3531    
3532                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3533                                    }
3534    
3535                                    closeSession(session);
3536                            }
3537                    }
3538    
3539                    return list;
3540            }
3541    
3542            /**
3543             * Removes all the announcements entries where uuid = &#63; from the database.
3544             *
3545             * @param uuid the uuid
3546             * @throws SystemException if a system exception occurred
3547             */
3548            public void removeByUuid(String uuid) throws SystemException {
3549                    for (AnnouncementsEntry announcementsEntry : findByUuid(uuid)) {
3550                            announcementsEntryPersistence.remove(announcementsEntry);
3551                    }
3552            }
3553    
3554            /**
3555             * Removes all the announcements entries where userId = &#63; from the database.
3556             *
3557             * @param userId the user ID
3558             * @throws SystemException if a system exception occurred
3559             */
3560            public void removeByUserId(long userId) throws SystemException {
3561                    for (AnnouncementsEntry announcementsEntry : findByUserId(userId)) {
3562                            announcementsEntryPersistence.remove(announcementsEntry);
3563                    }
3564            }
3565    
3566            /**
3567             * Removes all the announcements entries where classNameId = &#63; and classPK = &#63; from the database.
3568             *
3569             * @param classNameId the class name ID
3570             * @param classPK the class p k
3571             * @throws SystemException if a system exception occurred
3572             */
3573            public void removeByC_C(long classNameId, long classPK)
3574                    throws SystemException {
3575                    for (AnnouncementsEntry announcementsEntry : findByC_C(classNameId,
3576                                    classPK)) {
3577                            announcementsEntryPersistence.remove(announcementsEntry);
3578                    }
3579            }
3580    
3581            /**
3582             * Removes all the announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63; from the database.
3583             *
3584             * @param classNameId the class name ID
3585             * @param classPK the class p k
3586             * @param alert the alert
3587             * @throws SystemException if a system exception occurred
3588             */
3589            public void removeByC_C_A(long classNameId, long classPK, boolean alert)
3590                    throws SystemException {
3591                    for (AnnouncementsEntry announcementsEntry : findByC_C_A(classNameId,
3592                                    classPK, alert)) {
3593                            announcementsEntryPersistence.remove(announcementsEntry);
3594                    }
3595            }
3596    
3597            /**
3598             * Removes all the announcements entries from the database.
3599             *
3600             * @throws SystemException if a system exception occurred
3601             */
3602            public void removeAll() throws SystemException {
3603                    for (AnnouncementsEntry announcementsEntry : findAll()) {
3604                            announcementsEntryPersistence.remove(announcementsEntry);
3605                    }
3606            }
3607    
3608            /**
3609             * Returns the number of announcements entries where uuid = &#63;.
3610             *
3611             * @param uuid the uuid
3612             * @return the number of matching announcements entries
3613             * @throws SystemException if a system exception occurred
3614             */
3615            public int countByUuid(String uuid) throws SystemException {
3616                    Object[] finderArgs = new Object[] { uuid };
3617    
3618                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3619                                    finderArgs, this);
3620    
3621                    if (count == null) {
3622                            StringBundler query = new StringBundler(2);
3623    
3624                            query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3625    
3626                            if (uuid == null) {
3627                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
3628                            }
3629                            else {
3630                                    if (uuid.equals(StringPool.BLANK)) {
3631                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
3632                                    }
3633                                    else {
3634                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
3635                                    }
3636                            }
3637    
3638                            String sql = query.toString();
3639    
3640                            Session session = null;
3641    
3642                            try {
3643                                    session = openSession();
3644    
3645                                    Query q = session.createQuery(sql);
3646    
3647                                    QueryPos qPos = QueryPos.getInstance(q);
3648    
3649                                    if (uuid != null) {
3650                                            qPos.add(uuid);
3651                                    }
3652    
3653                                    count = (Long)q.uniqueResult();
3654                            }
3655                            catch (Exception e) {
3656                                    throw processException(e);
3657                            }
3658                            finally {
3659                                    if (count == null) {
3660                                            count = Long.valueOf(0);
3661                                    }
3662    
3663                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3664                                            finderArgs, count);
3665    
3666                                    closeSession(session);
3667                            }
3668                    }
3669    
3670                    return count.intValue();
3671            }
3672    
3673            /**
3674             * Returns the number of announcements entries that the user has permission to view where uuid = &#63;.
3675             *
3676             * @param uuid the uuid
3677             * @return the number of matching announcements entries that the user has permission to view
3678             * @throws SystemException if a system exception occurred
3679             */
3680            public int filterCountByUuid(String uuid) throws SystemException {
3681                    if (!InlineSQLHelperUtil.isEnabled()) {
3682                            return countByUuid(uuid);
3683                    }
3684    
3685                    StringBundler query = new StringBundler(2);
3686    
3687                    query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3688    
3689                    if (uuid == null) {
3690                            query.append(_FINDER_COLUMN_UUID_UUID_1);
3691                    }
3692                    else {
3693                            if (uuid.equals(StringPool.BLANK)) {
3694                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
3695                            }
3696                            else {
3697                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
3698                            }
3699                    }
3700    
3701                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3702                                    AnnouncementsEntry.class.getName(),
3703                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3704    
3705                    Session session = null;
3706    
3707                    try {
3708                            session = openSession();
3709    
3710                            SQLQuery q = session.createSQLQuery(sql);
3711    
3712                            q.addScalar(COUNT_COLUMN_NAME,
3713                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3714    
3715                            QueryPos qPos = QueryPos.getInstance(q);
3716    
3717                            if (uuid != null) {
3718                                    qPos.add(uuid);
3719                            }
3720    
3721                            Long count = (Long)q.uniqueResult();
3722    
3723                            return count.intValue();
3724                    }
3725                    catch (Exception e) {
3726                            throw processException(e);
3727                    }
3728                    finally {
3729                            closeSession(session);
3730                    }
3731            }
3732    
3733            /**
3734             * Returns the number of announcements entries where userId = &#63;.
3735             *
3736             * @param userId the user ID
3737             * @return the number of matching announcements entries
3738             * @throws SystemException if a system exception occurred
3739             */
3740            public int countByUserId(long userId) throws SystemException {
3741                    Object[] finderArgs = new Object[] { userId };
3742    
3743                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
3744                                    finderArgs, this);
3745    
3746                    if (count == null) {
3747                            StringBundler query = new StringBundler(2);
3748    
3749                            query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3750    
3751                            query.append(_FINDER_COLUMN_USERID_USERID_2);
3752    
3753                            String sql = query.toString();
3754    
3755                            Session session = null;
3756    
3757                            try {
3758                                    session = openSession();
3759    
3760                                    Query q = session.createQuery(sql);
3761    
3762                                    QueryPos qPos = QueryPos.getInstance(q);
3763    
3764                                    qPos.add(userId);
3765    
3766                                    count = (Long)q.uniqueResult();
3767                            }
3768                            catch (Exception e) {
3769                                    throw processException(e);
3770                            }
3771                            finally {
3772                                    if (count == null) {
3773                                            count = Long.valueOf(0);
3774                                    }
3775    
3776                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
3777                                            finderArgs, count);
3778    
3779                                    closeSession(session);
3780                            }
3781                    }
3782    
3783                    return count.intValue();
3784            }
3785    
3786            /**
3787             * Returns the number of announcements entries that the user has permission to view where userId = &#63;.
3788             *
3789             * @param userId the user ID
3790             * @return the number of matching announcements entries that the user has permission to view
3791             * @throws SystemException if a system exception occurred
3792             */
3793            public int filterCountByUserId(long userId) throws SystemException {
3794                    if (!InlineSQLHelperUtil.isEnabled()) {
3795                            return countByUserId(userId);
3796                    }
3797    
3798                    StringBundler query = new StringBundler(2);
3799    
3800                    query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3801    
3802                    query.append(_FINDER_COLUMN_USERID_USERID_2);
3803    
3804                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3805                                    AnnouncementsEntry.class.getName(),
3806                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3807    
3808                    Session session = null;
3809    
3810                    try {
3811                            session = openSession();
3812    
3813                            SQLQuery q = session.createSQLQuery(sql);
3814    
3815                            q.addScalar(COUNT_COLUMN_NAME,
3816                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3817    
3818                            QueryPos qPos = QueryPos.getInstance(q);
3819    
3820                            qPos.add(userId);
3821    
3822                            Long count = (Long)q.uniqueResult();
3823    
3824                            return count.intValue();
3825                    }
3826                    catch (Exception e) {
3827                            throw processException(e);
3828                    }
3829                    finally {
3830                            closeSession(session);
3831                    }
3832            }
3833    
3834            /**
3835             * Returns the number of announcements entries where classNameId = &#63; and classPK = &#63;.
3836             *
3837             * @param classNameId the class name ID
3838             * @param classPK the class p k
3839             * @return the number of matching announcements entries
3840             * @throws SystemException if a system exception occurred
3841             */
3842            public int countByC_C(long classNameId, long classPK)
3843                    throws SystemException {
3844                    Object[] finderArgs = new Object[] { classNameId, classPK };
3845    
3846                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
3847                                    finderArgs, this);
3848    
3849                    if (count == null) {
3850                            StringBundler query = new StringBundler(3);
3851    
3852                            query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3853    
3854                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3855    
3856                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3857    
3858                            String sql = query.toString();
3859    
3860                            Session session = null;
3861    
3862                            try {
3863                                    session = openSession();
3864    
3865                                    Query q = session.createQuery(sql);
3866    
3867                                    QueryPos qPos = QueryPos.getInstance(q);
3868    
3869                                    qPos.add(classNameId);
3870    
3871                                    qPos.add(classPK);
3872    
3873                                    count = (Long)q.uniqueResult();
3874                            }
3875                            catch (Exception e) {
3876                                    throw processException(e);
3877                            }
3878                            finally {
3879                                    if (count == null) {
3880                                            count = Long.valueOf(0);
3881                                    }
3882    
3883                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
3884                                            count);
3885    
3886                                    closeSession(session);
3887                            }
3888                    }
3889    
3890                    return count.intValue();
3891            }
3892    
3893            /**
3894             * Returns the number of announcements entries that the user has permission to view where classNameId = &#63; and classPK = &#63;.
3895             *
3896             * @param classNameId the class name ID
3897             * @param classPK the class p k
3898             * @return the number of matching announcements entries that the user has permission to view
3899             * @throws SystemException if a system exception occurred
3900             */
3901            public int filterCountByC_C(long classNameId, long classPK)
3902                    throws SystemException {
3903                    if (!InlineSQLHelperUtil.isEnabled()) {
3904                            return countByC_C(classNameId, classPK);
3905                    }
3906    
3907                    StringBundler query = new StringBundler(3);
3908    
3909                    query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3910    
3911                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3912    
3913                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3914    
3915                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3916                                    AnnouncementsEntry.class.getName(),
3917                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3918    
3919                    Session session = null;
3920    
3921                    try {
3922                            session = openSession();
3923    
3924                            SQLQuery q = session.createSQLQuery(sql);
3925    
3926                            q.addScalar(COUNT_COLUMN_NAME,
3927                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3928    
3929                            QueryPos qPos = QueryPos.getInstance(q);
3930    
3931                            qPos.add(classNameId);
3932    
3933                            qPos.add(classPK);
3934    
3935                            Long count = (Long)q.uniqueResult();
3936    
3937                            return count.intValue();
3938                    }
3939                    catch (Exception e) {
3940                            throw processException(e);
3941                    }
3942                    finally {
3943                            closeSession(session);
3944                    }
3945            }
3946    
3947            /**
3948             * Returns the number of announcements entries where classNameId = &#63; and classPK = &#63; and alert = &#63;.
3949             *
3950             * @param classNameId the class name ID
3951             * @param classPK the class p k
3952             * @param alert the alert
3953             * @return the number of matching announcements entries
3954             * @throws SystemException if a system exception occurred
3955             */
3956            public int countByC_C_A(long classNameId, long classPK, boolean alert)
3957                    throws SystemException {
3958                    Object[] finderArgs = new Object[] { classNameId, classPK, alert };
3959    
3960                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_A,
3961                                    finderArgs, this);
3962    
3963                    if (count == null) {
3964                            StringBundler query = new StringBundler(4);
3965    
3966                            query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3967    
3968                            query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
3969    
3970                            query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
3971    
3972                            query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
3973    
3974                            String sql = query.toString();
3975    
3976                            Session session = null;
3977    
3978                            try {
3979                                    session = openSession();
3980    
3981                                    Query q = session.createQuery(sql);
3982    
3983                                    QueryPos qPos = QueryPos.getInstance(q);
3984    
3985                                    qPos.add(classNameId);
3986    
3987                                    qPos.add(classPK);
3988    
3989                                    qPos.add(alert);
3990    
3991                                    count = (Long)q.uniqueResult();
3992                            }
3993                            catch (Exception e) {
3994                                    throw processException(e);
3995                            }
3996                            finally {
3997                                    if (count == null) {
3998                                            count = Long.valueOf(0);
3999                                    }
4000    
4001                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_A,
4002                                            finderArgs, count);
4003    
4004                                    closeSession(session);
4005                            }
4006                    }
4007    
4008                    return count.intValue();
4009            }
4010    
4011            /**
4012             * Returns the number of announcements entries that the user has permission to view where classNameId = &#63; and classPK = &#63; and alert = &#63;.
4013             *
4014             * @param classNameId the class name ID
4015             * @param classPK the class p k
4016             * @param alert the alert
4017             * @return the number of matching announcements entries that the user has permission to view
4018             * @throws SystemException if a system exception occurred
4019             */
4020            public int filterCountByC_C_A(long classNameId, long classPK, boolean alert)
4021                    throws SystemException {
4022                    if (!InlineSQLHelperUtil.isEnabled()) {
4023                            return countByC_C_A(classNameId, classPK, alert);
4024                    }
4025    
4026                    StringBundler query = new StringBundler(4);
4027    
4028                    query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4029    
4030                    query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4031    
4032                    query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4033    
4034                    query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4035    
4036                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4037                                    AnnouncementsEntry.class.getName(),
4038                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4039    
4040                    Session session = null;
4041    
4042                    try {
4043                            session = openSession();
4044    
4045                            SQLQuery q = session.createSQLQuery(sql);
4046    
4047                            q.addScalar(COUNT_COLUMN_NAME,
4048                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4049    
4050                            QueryPos qPos = QueryPos.getInstance(q);
4051    
4052                            qPos.add(classNameId);
4053    
4054                            qPos.add(classPK);
4055    
4056                            qPos.add(alert);
4057    
4058                            Long count = (Long)q.uniqueResult();
4059    
4060                            return count.intValue();
4061                    }
4062                    catch (Exception e) {
4063                            throw processException(e);
4064                    }
4065                    finally {
4066                            closeSession(session);
4067                    }
4068            }
4069    
4070            /**
4071             * Returns the number of announcements entries.
4072             *
4073             * @return the number of announcements entries
4074             * @throws SystemException if a system exception occurred
4075             */
4076            public int countAll() throws SystemException {
4077                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4078                                    FINDER_ARGS_EMPTY, this);
4079    
4080                    if (count == null) {
4081                            Session session = null;
4082    
4083                            try {
4084                                    session = openSession();
4085    
4086                                    Query q = session.createQuery(_SQL_COUNT_ANNOUNCEMENTSENTRY);
4087    
4088                                    count = (Long)q.uniqueResult();
4089                            }
4090                            catch (Exception e) {
4091                                    throw processException(e);
4092                            }
4093                            finally {
4094                                    if (count == null) {
4095                                            count = Long.valueOf(0);
4096                                    }
4097    
4098                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4099                                            FINDER_ARGS_EMPTY, count);
4100    
4101                                    closeSession(session);
4102                            }
4103                    }
4104    
4105                    return count.intValue();
4106            }
4107    
4108            /**
4109             * Initializes the announcements entry persistence.
4110             */
4111            public void afterPropertiesSet() {
4112                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4113                                            com.liferay.portal.util.PropsUtil.get(
4114                                                    "value.object.listener.com.liferay.portlet.announcements.model.AnnouncementsEntry")));
4115    
4116                    if (listenerClassNames.length > 0) {
4117                            try {
4118                                    List<ModelListener<AnnouncementsEntry>> listenersList = new ArrayList<ModelListener<AnnouncementsEntry>>();
4119    
4120                                    for (String listenerClassName : listenerClassNames) {
4121                                            listenersList.add((ModelListener<AnnouncementsEntry>)InstanceFactory.newInstance(
4122                                                            listenerClassName));
4123                                    }
4124    
4125                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4126                            }
4127                            catch (Exception e) {
4128                                    _log.error(e);
4129                            }
4130                    }
4131            }
4132    
4133            public void destroy() {
4134                    EntityCacheUtil.removeCache(AnnouncementsEntryImpl.class.getName());
4135                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4136                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4137            }
4138    
4139            @BeanReference(type = AnnouncementsDeliveryPersistence.class)
4140            protected AnnouncementsDeliveryPersistence announcementsDeliveryPersistence;
4141            @BeanReference(type = AnnouncementsEntryPersistence.class)
4142            protected AnnouncementsEntryPersistence announcementsEntryPersistence;
4143            @BeanReference(type = AnnouncementsFlagPersistence.class)
4144            protected AnnouncementsFlagPersistence announcementsFlagPersistence;
4145            @BeanReference(type = CompanyPersistence.class)
4146            protected CompanyPersistence companyPersistence;
4147            @BeanReference(type = GroupPersistence.class)
4148            protected GroupPersistence groupPersistence;
4149            @BeanReference(type = OrganizationPersistence.class)
4150            protected OrganizationPersistence organizationPersistence;
4151            @BeanReference(type = ResourcePersistence.class)
4152            protected ResourcePersistence resourcePersistence;
4153            @BeanReference(type = RolePersistence.class)
4154            protected RolePersistence rolePersistence;
4155            @BeanReference(type = UserPersistence.class)
4156            protected UserPersistence userPersistence;
4157            @BeanReference(type = UserGroupPersistence.class)
4158            protected UserGroupPersistence userGroupPersistence;
4159            private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry";
4160            private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry WHERE ";
4161            private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry";
4162            private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry WHERE ";
4163            private static final String _FINDER_COLUMN_UUID_UUID_1 = "announcementsEntry.uuid IS NULL";
4164            private static final String _FINDER_COLUMN_UUID_UUID_2 = "announcementsEntry.uuid = ?";
4165            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = ?)";
4166            private static final String _FINDER_COLUMN_USERID_USERID_2 = "announcementsEntry.userId = ?";
4167            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
4168            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "announcementsEntry.classPK = ?";
4169            private static final String _FINDER_COLUMN_C_C_A_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
4170            private static final String _FINDER_COLUMN_C_C_A_CLASSPK_2 = "announcementsEntry.classPK = ? AND ";
4171            private static final String _FINDER_COLUMN_C_C_A_ALERT_2 = "announcementsEntry.alert = ?";
4172            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "announcementsEntry.entryId";
4173            private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT DISTINCT {announcementsEntry.*} FROM AnnouncementsEntry announcementsEntry WHERE ";
4174            private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
4175                    "SELECT {AnnouncementsEntry.*} FROM (SELECT DISTINCT announcementsEntry.entryId FROM AnnouncementsEntry announcementsEntry WHERE ";
4176            private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
4177                    ") TEMP_TABLE INNER JOIN AnnouncementsEntry ON TEMP_TABLE.entryId = AnnouncementsEntry.entryId";
4178            private static final String _FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(DISTINCT announcementsEntry.entryId) AS COUNT_VALUE FROM AnnouncementsEntry announcementsEntry WHERE ";
4179            private static final String _FILTER_ENTITY_ALIAS = "announcementsEntry";
4180            private static final String _FILTER_ENTITY_TABLE = "AnnouncementsEntry";
4181            private static final String _ORDER_BY_ENTITY_ALIAS = "announcementsEntry.";
4182            private static final String _ORDER_BY_ENTITY_TABLE = "AnnouncementsEntry.";
4183            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AnnouncementsEntry exists with the primary key ";
4184            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AnnouncementsEntry exists with the key {";
4185            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4186            private static Log _log = LogFactoryUtil.getLog(AnnouncementsEntryPersistenceImpl.class);
4187            private static AnnouncementsEntry _nullAnnouncementsEntry = new AnnouncementsEntryImpl() {
4188                            @Override
4189                            public Object clone() {
4190                                    return this;
4191                            }
4192    
4193                            @Override
4194                            public CacheModel<AnnouncementsEntry> toCacheModel() {
4195                                    return _nullAnnouncementsEntryCacheModel;
4196                            }
4197                    };
4198    
4199            private static CacheModel<AnnouncementsEntry> _nullAnnouncementsEntryCacheModel =
4200                    new CacheModel<AnnouncementsEntry>() {
4201                            public AnnouncementsEntry toEntityModel() {
4202                                    return _nullAnnouncementsEntry;
4203                            }
4204                    };
4205    }