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