001
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.CompanyPersistence;
043 import com.liferay.portal.service.persistence.GroupPersistence;
044 import com.liferay.portal.service.persistence.OrganizationPersistence;
045 import com.liferay.portal.service.persistence.RolePersistence;
046 import com.liferay.portal.service.persistence.UserGroupPersistence;
047 import com.liferay.portal.service.persistence.UserPersistence;
048 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049
050 import com.liferay.portlet.announcements.NoSuchEntryException;
051 import com.liferay.portlet.announcements.model.AnnouncementsEntry;
052 import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryImpl;
053 import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryModelImpl;
054
055 import java.io.Serializable;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.List;
060
061
073 public class AnnouncementsEntryPersistenceImpl extends BasePersistenceImpl<AnnouncementsEntry>
074 implements AnnouncementsEntryPersistence {
075
080 public static final String FINDER_CLASS_NAME_ENTITY = AnnouncementsEntryImpl.class.getName();
081 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List1";
083 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List2";
085 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
086 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
087 AnnouncementsEntryImpl.class,
088 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
089 new String[] {
090 String.class.getName(),
091
092 "java.lang.Integer", "java.lang.Integer",
093 "com.liferay.portal.kernel.util.OrderByComparator"
094 });
095 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
096 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
097 AnnouncementsEntryImpl.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
099 new String[] { String.class.getName() },
100 AnnouncementsEntryModelImpl.UUID_COLUMN_BITMASK);
101 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
102 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
104 new String[] { String.class.getName() });
105 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
106 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
107 AnnouncementsEntryImpl.class,
108 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
109 new String[] {
110 String.class.getName(), Long.class.getName(),
111
112 "java.lang.Integer", "java.lang.Integer",
113 "com.liferay.portal.kernel.util.OrderByComparator"
114 });
115 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
116 new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
117 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
118 AnnouncementsEntryImpl.class,
119 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
120 new String[] { String.class.getName(), Long.class.getName() },
121 AnnouncementsEntryModelImpl.UUID_COLUMN_BITMASK |
122 AnnouncementsEntryModelImpl.COMPANYID_COLUMN_BITMASK);
123 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
124 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
125 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
126 new String[] { String.class.getName(), Long.class.getName() });
127 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
128 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
129 AnnouncementsEntryImpl.class,
130 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
131 new String[] {
132 Long.class.getName(),
133
134 "java.lang.Integer", "java.lang.Integer",
135 "com.liferay.portal.kernel.util.OrderByComparator"
136 });
137 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
138 new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
139 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
140 AnnouncementsEntryImpl.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
142 new String[] { Long.class.getName() },
143 AnnouncementsEntryModelImpl.USERID_COLUMN_BITMASK);
144 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
145 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
146 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
147 new String[] { Long.class.getName() });
148 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
149 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
150 AnnouncementsEntryImpl.class,
151 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
152 new String[] {
153 Long.class.getName(), Long.class.getName(),
154
155 "java.lang.Integer", "java.lang.Integer",
156 "com.liferay.portal.kernel.util.OrderByComparator"
157 });
158 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
159 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
160 AnnouncementsEntryImpl.class,
161 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
162 new String[] { Long.class.getName(), Long.class.getName() },
163 AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
164 AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK);
165 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
166 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
167 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
168 new String[] { Long.class.getName(), Long.class.getName() });
169 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
170 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
171 AnnouncementsEntryImpl.class,
172 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_A",
173 new String[] {
174 Long.class.getName(), Long.class.getName(),
175 Boolean.class.getName(),
176
177 "java.lang.Integer", "java.lang.Integer",
178 "com.liferay.portal.kernel.util.OrderByComparator"
179 });
180 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
181 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
182 AnnouncementsEntryImpl.class,
183 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_A",
184 new String[] {
185 Long.class.getName(), Long.class.getName(),
186 Boolean.class.getName()
187 },
188 AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
189 AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK |
190 AnnouncementsEntryModelImpl.ALERT_COLUMN_BITMASK);
191 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
192 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
193 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_A",
194 new String[] {
195 Long.class.getName(), Long.class.getName(),
196 Boolean.class.getName()
197 });
198 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
199 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
200 AnnouncementsEntryImpl.class,
201 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
202 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
203 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
204 AnnouncementsEntryImpl.class,
205 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
206 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
207 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
208 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
209
210
215 public void cacheResult(AnnouncementsEntry announcementsEntry) {
216 EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
217 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
218 announcementsEntry);
219
220 announcementsEntry.resetOriginalValues();
221 }
222
223
228 public void cacheResult(List<AnnouncementsEntry> announcementsEntries) {
229 for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
230 if (EntityCacheUtil.getResult(
231 AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
232 AnnouncementsEntryImpl.class,
233 announcementsEntry.getPrimaryKey()) == null) {
234 cacheResult(announcementsEntry);
235 }
236 else {
237 announcementsEntry.resetOriginalValues();
238 }
239 }
240 }
241
242
249 @Override
250 public void clearCache() {
251 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
252 CacheRegistryUtil.clear(AnnouncementsEntryImpl.class.getName());
253 }
254
255 EntityCacheUtil.clearCache(AnnouncementsEntryImpl.class.getName());
256
257 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
258 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
259 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
260 }
261
262
269 @Override
270 public void clearCache(AnnouncementsEntry announcementsEntry) {
271 EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
272 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
273
274 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
275 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
276 }
277
278 @Override
279 public void clearCache(List<AnnouncementsEntry> announcementsEntries) {
280 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
281 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
282
283 for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
284 EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
285 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
286 }
287 }
288
289
295 public AnnouncementsEntry create(long entryId) {
296 AnnouncementsEntry announcementsEntry = new AnnouncementsEntryImpl();
297
298 announcementsEntry.setNew(true);
299 announcementsEntry.setPrimaryKey(entryId);
300
301 String uuid = PortalUUIDUtil.generate();
302
303 announcementsEntry.setUuid(uuid);
304
305 return announcementsEntry;
306 }
307
308
316 public AnnouncementsEntry remove(long entryId)
317 throws NoSuchEntryException, SystemException {
318 return remove(Long.valueOf(entryId));
319 }
320
321
329 @Override
330 public AnnouncementsEntry remove(Serializable primaryKey)
331 throws NoSuchEntryException, SystemException {
332 Session session = null;
333
334 try {
335 session = openSession();
336
337 AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
338 primaryKey);
339
340 if (announcementsEntry == null) {
341 if (_log.isWarnEnabled()) {
342 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
343 }
344
345 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
346 primaryKey);
347 }
348
349 return remove(announcementsEntry);
350 }
351 catch (NoSuchEntryException nsee) {
352 throw nsee;
353 }
354 catch (Exception e) {
355 throw processException(e);
356 }
357 finally {
358 closeSession(session);
359 }
360 }
361
362 @Override
363 protected AnnouncementsEntry removeImpl(
364 AnnouncementsEntry announcementsEntry) throws SystemException {
365 announcementsEntry = toUnwrappedModel(announcementsEntry);
366
367 Session session = null;
368
369 try {
370 session = openSession();
371
372 if (announcementsEntry.isCachedModel()) {
373 announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
374 announcementsEntry.getPrimaryKeyObj());
375 }
376
377 session.delete(announcementsEntry);
378 }
379 catch (Exception e) {
380 throw processException(e);
381 }
382 finally {
383 closeSession(session);
384 }
385
386 clearCache(announcementsEntry);
387
388 return announcementsEntry;
389 }
390
391 @Override
392 public AnnouncementsEntry updateImpl(
393 com.liferay.portlet.announcements.model.AnnouncementsEntry announcementsEntry)
394 throws SystemException {
395 announcementsEntry = toUnwrappedModel(announcementsEntry);
396
397 boolean isNew = announcementsEntry.isNew();
398
399 AnnouncementsEntryModelImpl announcementsEntryModelImpl = (AnnouncementsEntryModelImpl)announcementsEntry;
400
401 if (Validator.isNull(announcementsEntry.getUuid())) {
402 String uuid = PortalUUIDUtil.generate();
403
404 announcementsEntry.setUuid(uuid);
405 }
406
407 Session session = null;
408
409 try {
410 session = openSession();
411
412 if (announcementsEntry.isNew()) {
413 session.save(announcementsEntry);
414
415 announcementsEntry.setNew(false);
416 }
417 else {
418 session.merge(announcementsEntry);
419 }
420 }
421 catch (Exception e) {
422 throw processException(e);
423 }
424 finally {
425 closeSession(session);
426 }
427
428 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
429
430 if (isNew || !AnnouncementsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
431 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
432 }
433
434 else {
435 if ((announcementsEntryModelImpl.getColumnBitmask() &
436 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
437 Object[] args = new Object[] {
438 announcementsEntryModelImpl.getOriginalUuid()
439 };
440
441 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
442 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
443 args);
444
445 args = new Object[] { announcementsEntryModelImpl.getUuid() };
446
447 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
448 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
449 args);
450 }
451
452 if ((announcementsEntryModelImpl.getColumnBitmask() &
453 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
454 Object[] args = new Object[] {
455 announcementsEntryModelImpl.getOriginalUuid(),
456 Long.valueOf(announcementsEntryModelImpl.getOriginalCompanyId())
457 };
458
459 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
460 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
461 args);
462
463 args = new Object[] {
464 announcementsEntryModelImpl.getUuid(),
465 Long.valueOf(announcementsEntryModelImpl.getCompanyId())
466 };
467
468 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
469 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
470 args);
471 }
472
473 if ((announcementsEntryModelImpl.getColumnBitmask() &
474 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
475 Object[] args = new Object[] {
476 Long.valueOf(announcementsEntryModelImpl.getOriginalUserId())
477 };
478
479 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
480 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
481 args);
482
483 args = new Object[] {
484 Long.valueOf(announcementsEntryModelImpl.getUserId())
485 };
486
487 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
488 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
489 args);
490 }
491
492 if ((announcementsEntryModelImpl.getColumnBitmask() &
493 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
494 Object[] args = new Object[] {
495 Long.valueOf(announcementsEntryModelImpl.getOriginalClassNameId()),
496 Long.valueOf(announcementsEntryModelImpl.getOriginalClassPK())
497 };
498
499 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
500 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
501 args);
502
503 args = new Object[] {
504 Long.valueOf(announcementsEntryModelImpl.getClassNameId()),
505 Long.valueOf(announcementsEntryModelImpl.getClassPK())
506 };
507
508 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
509 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
510 args);
511 }
512
513 if ((announcementsEntryModelImpl.getColumnBitmask() &
514 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A.getColumnBitmask()) != 0) {
515 Object[] args = new Object[] {
516 Long.valueOf(announcementsEntryModelImpl.getOriginalClassNameId()),
517 Long.valueOf(announcementsEntryModelImpl.getOriginalClassPK()),
518 Boolean.valueOf(announcementsEntryModelImpl.getOriginalAlert())
519 };
520
521 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
522 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
523 args);
524
525 args = new Object[] {
526 Long.valueOf(announcementsEntryModelImpl.getClassNameId()),
527 Long.valueOf(announcementsEntryModelImpl.getClassPK()),
528 Boolean.valueOf(announcementsEntryModelImpl.getAlert())
529 };
530
531 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
532 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
533 args);
534 }
535 }
536
537 EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
538 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
539 announcementsEntry);
540
541 return announcementsEntry;
542 }
543
544 protected AnnouncementsEntry toUnwrappedModel(
545 AnnouncementsEntry announcementsEntry) {
546 if (announcementsEntry instanceof AnnouncementsEntryImpl) {
547 return announcementsEntry;
548 }
549
550 AnnouncementsEntryImpl announcementsEntryImpl = new AnnouncementsEntryImpl();
551
552 announcementsEntryImpl.setNew(announcementsEntry.isNew());
553 announcementsEntryImpl.setPrimaryKey(announcementsEntry.getPrimaryKey());
554
555 announcementsEntryImpl.setUuid(announcementsEntry.getUuid());
556 announcementsEntryImpl.setEntryId(announcementsEntry.getEntryId());
557 announcementsEntryImpl.setCompanyId(announcementsEntry.getCompanyId());
558 announcementsEntryImpl.setUserId(announcementsEntry.getUserId());
559 announcementsEntryImpl.setUserName(announcementsEntry.getUserName());
560 announcementsEntryImpl.setCreateDate(announcementsEntry.getCreateDate());
561 announcementsEntryImpl.setModifiedDate(announcementsEntry.getModifiedDate());
562 announcementsEntryImpl.setClassNameId(announcementsEntry.getClassNameId());
563 announcementsEntryImpl.setClassPK(announcementsEntry.getClassPK());
564 announcementsEntryImpl.setTitle(announcementsEntry.getTitle());
565 announcementsEntryImpl.setContent(announcementsEntry.getContent());
566 announcementsEntryImpl.setUrl(announcementsEntry.getUrl());
567 announcementsEntryImpl.setType(announcementsEntry.getType());
568 announcementsEntryImpl.setDisplayDate(announcementsEntry.getDisplayDate());
569 announcementsEntryImpl.setExpirationDate(announcementsEntry.getExpirationDate());
570 announcementsEntryImpl.setPriority(announcementsEntry.getPriority());
571 announcementsEntryImpl.setAlert(announcementsEntry.isAlert());
572
573 return announcementsEntryImpl;
574 }
575
576
584 @Override
585 public AnnouncementsEntry findByPrimaryKey(Serializable primaryKey)
586 throws NoSuchModelException, SystemException {
587 return findByPrimaryKey(((Long)primaryKey).longValue());
588 }
589
590
598 public AnnouncementsEntry findByPrimaryKey(long entryId)
599 throws NoSuchEntryException, SystemException {
600 AnnouncementsEntry announcementsEntry = fetchByPrimaryKey(entryId);
601
602 if (announcementsEntry == null) {
603 if (_log.isWarnEnabled()) {
604 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
605 }
606
607 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
608 entryId);
609 }
610
611 return announcementsEntry;
612 }
613
614
621 @Override
622 public AnnouncementsEntry fetchByPrimaryKey(Serializable primaryKey)
623 throws SystemException {
624 return fetchByPrimaryKey(((Long)primaryKey).longValue());
625 }
626
627
634 public AnnouncementsEntry fetchByPrimaryKey(long entryId)
635 throws SystemException {
636 AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)EntityCacheUtil.getResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
637 AnnouncementsEntryImpl.class, entryId);
638
639 if (announcementsEntry == _nullAnnouncementsEntry) {
640 return null;
641 }
642
643 if (announcementsEntry == null) {
644 Session session = null;
645
646 boolean hasException = false;
647
648 try {
649 session = openSession();
650
651 announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
652 Long.valueOf(entryId));
653 }
654 catch (Exception e) {
655 hasException = true;
656
657 throw processException(e);
658 }
659 finally {
660 if (announcementsEntry != null) {
661 cacheResult(announcementsEntry);
662 }
663 else if (!hasException) {
664 EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
665 AnnouncementsEntryImpl.class, entryId,
666 _nullAnnouncementsEntry);
667 }
668
669 closeSession(session);
670 }
671 }
672
673 return announcementsEntry;
674 }
675
676
683 public List<AnnouncementsEntry> findByUuid(String uuid)
684 throws SystemException {
685 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
686 }
687
688
701 public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end)
702 throws SystemException {
703 return findByUuid(uuid, start, end, null);
704 }
705
706
720 public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end,
721 OrderByComparator orderByComparator) throws SystemException {
722 FinderPath finderPath = null;
723 Object[] finderArgs = null;
724
725 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
726 (orderByComparator == null)) {
727 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
728 finderArgs = new Object[] { uuid };
729 }
730 else {
731 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
732 finderArgs = new Object[] { uuid, start, end, orderByComparator };
733 }
734
735 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
736 finderArgs, this);
737
738 if ((list != null) && !list.isEmpty()) {
739 for (AnnouncementsEntry announcementsEntry : list) {
740 if (!Validator.equals(uuid, announcementsEntry.getUuid())) {
741 list = null;
742
743 break;
744 }
745 }
746 }
747
748 if (list == null) {
749 StringBundler query = null;
750
751 if (orderByComparator != null) {
752 query = new StringBundler(3 +
753 (orderByComparator.getOrderByFields().length * 3));
754 }
755 else {
756 query = new StringBundler(3);
757 }
758
759 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
760
761 if (uuid == null) {
762 query.append(_FINDER_COLUMN_UUID_UUID_1);
763 }
764 else {
765 if (uuid.equals(StringPool.BLANK)) {
766 query.append(_FINDER_COLUMN_UUID_UUID_3);
767 }
768 else {
769 query.append(_FINDER_COLUMN_UUID_UUID_2);
770 }
771 }
772
773 if (orderByComparator != null) {
774 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
775 orderByComparator);
776 }
777
778 else {
779 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
780 }
781
782 String sql = query.toString();
783
784 Session session = null;
785
786 try {
787 session = openSession();
788
789 Query q = session.createQuery(sql);
790
791 QueryPos qPos = QueryPos.getInstance(q);
792
793 if (uuid != null) {
794 qPos.add(uuid);
795 }
796
797 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
798 getDialect(), start, end);
799 }
800 catch (Exception e) {
801 throw processException(e);
802 }
803 finally {
804 if (list == null) {
805 FinderCacheUtil.removeResult(finderPath, finderArgs);
806 }
807 else {
808 cacheResult(list);
809
810 FinderCacheUtil.putResult(finderPath, finderArgs, list);
811 }
812
813 closeSession(session);
814 }
815 }
816
817 return list;
818 }
819
820
829 public AnnouncementsEntry findByUuid_First(String uuid,
830 OrderByComparator orderByComparator)
831 throws NoSuchEntryException, SystemException {
832 AnnouncementsEntry announcementsEntry = fetchByUuid_First(uuid,
833 orderByComparator);
834
835 if (announcementsEntry != null) {
836 return announcementsEntry;
837 }
838
839 StringBundler msg = new StringBundler(4);
840
841 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
842
843 msg.append("uuid=");
844 msg.append(uuid);
845
846 msg.append(StringPool.CLOSE_CURLY_BRACE);
847
848 throw new NoSuchEntryException(msg.toString());
849 }
850
851
859 public AnnouncementsEntry fetchByUuid_First(String uuid,
860 OrderByComparator orderByComparator) throws SystemException {
861 List<AnnouncementsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
862
863 if (!list.isEmpty()) {
864 return list.get(0);
865 }
866
867 return null;
868 }
869
870
879 public AnnouncementsEntry findByUuid_Last(String uuid,
880 OrderByComparator orderByComparator)
881 throws NoSuchEntryException, SystemException {
882 AnnouncementsEntry announcementsEntry = fetchByUuid_Last(uuid,
883 orderByComparator);
884
885 if (announcementsEntry != null) {
886 return announcementsEntry;
887 }
888
889 StringBundler msg = new StringBundler(4);
890
891 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
892
893 msg.append("uuid=");
894 msg.append(uuid);
895
896 msg.append(StringPool.CLOSE_CURLY_BRACE);
897
898 throw new NoSuchEntryException(msg.toString());
899 }
900
901
909 public AnnouncementsEntry fetchByUuid_Last(String uuid,
910 OrderByComparator orderByComparator) throws SystemException {
911 int count = countByUuid(uuid);
912
913 List<AnnouncementsEntry> list = findByUuid(uuid, count - 1, count,
914 orderByComparator);
915
916 if (!list.isEmpty()) {
917 return list.get(0);
918 }
919
920 return null;
921 }
922
923
933 public AnnouncementsEntry[] findByUuid_PrevAndNext(long entryId,
934 String uuid, OrderByComparator orderByComparator)
935 throws NoSuchEntryException, SystemException {
936 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
937
938 Session session = null;
939
940 try {
941 session = openSession();
942
943 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
944
945 array[0] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
946 orderByComparator, true);
947
948 array[1] = announcementsEntry;
949
950 array[2] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
951 orderByComparator, false);
952
953 return array;
954 }
955 catch (Exception e) {
956 throw processException(e);
957 }
958 finally {
959 closeSession(session);
960 }
961 }
962
963 protected AnnouncementsEntry getByUuid_PrevAndNext(Session session,
964 AnnouncementsEntry announcementsEntry, String uuid,
965 OrderByComparator orderByComparator, boolean previous) {
966 StringBundler query = null;
967
968 if (orderByComparator != null) {
969 query = new StringBundler(6 +
970 (orderByComparator.getOrderByFields().length * 6));
971 }
972 else {
973 query = new StringBundler(3);
974 }
975
976 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
977
978 if (uuid == null) {
979 query.append(_FINDER_COLUMN_UUID_UUID_1);
980 }
981 else {
982 if (uuid.equals(StringPool.BLANK)) {
983 query.append(_FINDER_COLUMN_UUID_UUID_3);
984 }
985 else {
986 query.append(_FINDER_COLUMN_UUID_UUID_2);
987 }
988 }
989
990 if (orderByComparator != null) {
991 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
992
993 if (orderByConditionFields.length > 0) {
994 query.append(WHERE_AND);
995 }
996
997 for (int i = 0; i < orderByConditionFields.length; i++) {
998 query.append(_ORDER_BY_ENTITY_ALIAS);
999 query.append(orderByConditionFields[i]);
1000
1001 if ((i + 1) < orderByConditionFields.length) {
1002 if (orderByComparator.isAscending() ^ previous) {
1003 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1004 }
1005 else {
1006 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1007 }
1008 }
1009 else {
1010 if (orderByComparator.isAscending() ^ previous) {
1011 query.append(WHERE_GREATER_THAN);
1012 }
1013 else {
1014 query.append(WHERE_LESSER_THAN);
1015 }
1016 }
1017 }
1018
1019 query.append(ORDER_BY_CLAUSE);
1020
1021 String[] orderByFields = orderByComparator.getOrderByFields();
1022
1023 for (int i = 0; i < orderByFields.length; i++) {
1024 query.append(_ORDER_BY_ENTITY_ALIAS);
1025 query.append(orderByFields[i]);
1026
1027 if ((i + 1) < orderByFields.length) {
1028 if (orderByComparator.isAscending() ^ previous) {
1029 query.append(ORDER_BY_ASC_HAS_NEXT);
1030 }
1031 else {
1032 query.append(ORDER_BY_DESC_HAS_NEXT);
1033 }
1034 }
1035 else {
1036 if (orderByComparator.isAscending() ^ previous) {
1037 query.append(ORDER_BY_ASC);
1038 }
1039 else {
1040 query.append(ORDER_BY_DESC);
1041 }
1042 }
1043 }
1044 }
1045
1046 else {
1047 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1048 }
1049
1050 String sql = query.toString();
1051
1052 Query q = session.createQuery(sql);
1053
1054 q.setFirstResult(0);
1055 q.setMaxResults(2);
1056
1057 QueryPos qPos = QueryPos.getInstance(q);
1058
1059 if (uuid != null) {
1060 qPos.add(uuid);
1061 }
1062
1063 if (orderByComparator != null) {
1064 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1065
1066 for (Object value : values) {
1067 qPos.add(value);
1068 }
1069 }
1070
1071 List<AnnouncementsEntry> list = q.list();
1072
1073 if (list.size() == 2) {
1074 return list.get(1);
1075 }
1076 else {
1077 return null;
1078 }
1079 }
1080
1081
1088 public List<AnnouncementsEntry> filterFindByUuid(String uuid)
1089 throws SystemException {
1090 return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1091 }
1092
1093
1106 public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
1107 int end) throws SystemException {
1108 return filterFindByUuid(uuid, start, end, null);
1109 }
1110
1111
1125 public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
1126 int end, OrderByComparator orderByComparator) throws SystemException {
1127 if (!InlineSQLHelperUtil.isEnabled()) {
1128 return findByUuid(uuid, start, end, orderByComparator);
1129 }
1130
1131 StringBundler query = null;
1132
1133 if (orderByComparator != null) {
1134 query = new StringBundler(3 +
1135 (orderByComparator.getOrderByFields().length * 3));
1136 }
1137 else {
1138 query = new StringBundler(3);
1139 }
1140
1141 if (getDB().isSupportsInlineDistinct()) {
1142 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1143 }
1144 else {
1145 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1146 }
1147
1148 if (uuid == null) {
1149 query.append(_FINDER_COLUMN_UUID_UUID_1);
1150 }
1151 else {
1152 if (uuid.equals(StringPool.BLANK)) {
1153 query.append(_FINDER_COLUMN_UUID_UUID_3);
1154 }
1155 else {
1156 query.append(_FINDER_COLUMN_UUID_UUID_2);
1157 }
1158 }
1159
1160 if (!getDB().isSupportsInlineDistinct()) {
1161 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1162 }
1163
1164 if (orderByComparator != null) {
1165 if (getDB().isSupportsInlineDistinct()) {
1166 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1167 orderByComparator);
1168 }
1169 else {
1170 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1171 orderByComparator);
1172 }
1173 }
1174
1175 else {
1176 if (getDB().isSupportsInlineDistinct()) {
1177 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1178 }
1179 else {
1180 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1181 }
1182 }
1183
1184 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1185 AnnouncementsEntry.class.getName(),
1186 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1187
1188 Session session = null;
1189
1190 try {
1191 session = openSession();
1192
1193 SQLQuery q = session.createSQLQuery(sql);
1194
1195 if (getDB().isSupportsInlineDistinct()) {
1196 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1197 }
1198 else {
1199 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1200 }
1201
1202 QueryPos qPos = QueryPos.getInstance(q);
1203
1204 if (uuid != null) {
1205 qPos.add(uuid);
1206 }
1207
1208 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
1209 start, end);
1210 }
1211 catch (Exception e) {
1212 throw processException(e);
1213 }
1214 finally {
1215 closeSession(session);
1216 }
1217 }
1218
1219
1229 public AnnouncementsEntry[] filterFindByUuid_PrevAndNext(long entryId,
1230 String uuid, OrderByComparator orderByComparator)
1231 throws NoSuchEntryException, SystemException {
1232 if (!InlineSQLHelperUtil.isEnabled()) {
1233 return findByUuid_PrevAndNext(entryId, uuid, orderByComparator);
1234 }
1235
1236 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1237
1238 Session session = null;
1239
1240 try {
1241 session = openSession();
1242
1243 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1244
1245 array[0] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
1246 uuid, orderByComparator, true);
1247
1248 array[1] = announcementsEntry;
1249
1250 array[2] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
1251 uuid, orderByComparator, false);
1252
1253 return array;
1254 }
1255 catch (Exception e) {
1256 throw processException(e);
1257 }
1258 finally {
1259 closeSession(session);
1260 }
1261 }
1262
1263 protected AnnouncementsEntry filterGetByUuid_PrevAndNext(Session session,
1264 AnnouncementsEntry announcementsEntry, String uuid,
1265 OrderByComparator orderByComparator, boolean previous) {
1266 StringBundler query = null;
1267
1268 if (orderByComparator != null) {
1269 query = new StringBundler(6 +
1270 (orderByComparator.getOrderByFields().length * 6));
1271 }
1272 else {
1273 query = new StringBundler(3);
1274 }
1275
1276 if (getDB().isSupportsInlineDistinct()) {
1277 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1278 }
1279 else {
1280 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1281 }
1282
1283 if (uuid == null) {
1284 query.append(_FINDER_COLUMN_UUID_UUID_1);
1285 }
1286 else {
1287 if (uuid.equals(StringPool.BLANK)) {
1288 query.append(_FINDER_COLUMN_UUID_UUID_3);
1289 }
1290 else {
1291 query.append(_FINDER_COLUMN_UUID_UUID_2);
1292 }
1293 }
1294
1295 if (!getDB().isSupportsInlineDistinct()) {
1296 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1297 }
1298
1299 if (orderByComparator != null) {
1300 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1301
1302 if (orderByConditionFields.length > 0) {
1303 query.append(WHERE_AND);
1304 }
1305
1306 for (int i = 0; i < orderByConditionFields.length; i++) {
1307 if (getDB().isSupportsInlineDistinct()) {
1308 query.append(_ORDER_BY_ENTITY_ALIAS);
1309 }
1310 else {
1311 query.append(_ORDER_BY_ENTITY_TABLE);
1312 }
1313
1314 query.append(orderByConditionFields[i]);
1315
1316 if ((i + 1) < orderByConditionFields.length) {
1317 if (orderByComparator.isAscending() ^ previous) {
1318 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1319 }
1320 else {
1321 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1322 }
1323 }
1324 else {
1325 if (orderByComparator.isAscending() ^ previous) {
1326 query.append(WHERE_GREATER_THAN);
1327 }
1328 else {
1329 query.append(WHERE_LESSER_THAN);
1330 }
1331 }
1332 }
1333
1334 query.append(ORDER_BY_CLAUSE);
1335
1336 String[] orderByFields = orderByComparator.getOrderByFields();
1337
1338 for (int i = 0; i < orderByFields.length; i++) {
1339 if (getDB().isSupportsInlineDistinct()) {
1340 query.append(_ORDER_BY_ENTITY_ALIAS);
1341 }
1342 else {
1343 query.append(_ORDER_BY_ENTITY_TABLE);
1344 }
1345
1346 query.append(orderByFields[i]);
1347
1348 if ((i + 1) < orderByFields.length) {
1349 if (orderByComparator.isAscending() ^ previous) {
1350 query.append(ORDER_BY_ASC_HAS_NEXT);
1351 }
1352 else {
1353 query.append(ORDER_BY_DESC_HAS_NEXT);
1354 }
1355 }
1356 else {
1357 if (orderByComparator.isAscending() ^ previous) {
1358 query.append(ORDER_BY_ASC);
1359 }
1360 else {
1361 query.append(ORDER_BY_DESC);
1362 }
1363 }
1364 }
1365 }
1366
1367 else {
1368 if (getDB().isSupportsInlineDistinct()) {
1369 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1370 }
1371 else {
1372 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1373 }
1374 }
1375
1376 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1377 AnnouncementsEntry.class.getName(),
1378 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1379
1380 SQLQuery q = session.createSQLQuery(sql);
1381
1382 q.setFirstResult(0);
1383 q.setMaxResults(2);
1384
1385 if (getDB().isSupportsInlineDistinct()) {
1386 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1387 }
1388 else {
1389 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1390 }
1391
1392 QueryPos qPos = QueryPos.getInstance(q);
1393
1394 if (uuid != null) {
1395 qPos.add(uuid);
1396 }
1397
1398 if (orderByComparator != null) {
1399 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1400
1401 for (Object value : values) {
1402 qPos.add(value);
1403 }
1404 }
1405
1406 List<AnnouncementsEntry> list = q.list();
1407
1408 if (list.size() == 2) {
1409 return list.get(1);
1410 }
1411 else {
1412 return null;
1413 }
1414 }
1415
1416
1424 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId)
1425 throws SystemException {
1426 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1427 QueryUtil.ALL_POS, null);
1428 }
1429
1430
1444 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId,
1445 int start, int end) throws SystemException {
1446 return findByUuid_C(uuid, companyId, start, end, null);
1447 }
1448
1449
1464 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId,
1465 int start, int end, OrderByComparator orderByComparator)
1466 throws SystemException {
1467 FinderPath finderPath = null;
1468 Object[] finderArgs = null;
1469
1470 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1471 (orderByComparator == null)) {
1472 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1473 finderArgs = new Object[] { uuid, companyId };
1474 }
1475 else {
1476 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1477 finderArgs = new Object[] {
1478 uuid, companyId,
1479
1480 start, end, orderByComparator
1481 };
1482 }
1483
1484 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
1485 finderArgs, this);
1486
1487 if ((list != null) && !list.isEmpty()) {
1488 for (AnnouncementsEntry announcementsEntry : list) {
1489 if (!Validator.equals(uuid, announcementsEntry.getUuid()) ||
1490 (companyId != announcementsEntry.getCompanyId())) {
1491 list = null;
1492
1493 break;
1494 }
1495 }
1496 }
1497
1498 if (list == null) {
1499 StringBundler query = null;
1500
1501 if (orderByComparator != null) {
1502 query = new StringBundler(4 +
1503 (orderByComparator.getOrderByFields().length * 3));
1504 }
1505 else {
1506 query = new StringBundler(4);
1507 }
1508
1509 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1510
1511 if (uuid == null) {
1512 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1513 }
1514 else {
1515 if (uuid.equals(StringPool.BLANK)) {
1516 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1517 }
1518 else {
1519 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1520 }
1521 }
1522
1523 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1524
1525 if (orderByComparator != null) {
1526 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1527 orderByComparator);
1528 }
1529
1530 else {
1531 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1532 }
1533
1534 String sql = query.toString();
1535
1536 Session session = null;
1537
1538 try {
1539 session = openSession();
1540
1541 Query q = session.createQuery(sql);
1542
1543 QueryPos qPos = QueryPos.getInstance(q);
1544
1545 if (uuid != null) {
1546 qPos.add(uuid);
1547 }
1548
1549 qPos.add(companyId);
1550
1551 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1552 getDialect(), start, end);
1553 }
1554 catch (Exception e) {
1555 throw processException(e);
1556 }
1557 finally {
1558 if (list == null) {
1559 FinderCacheUtil.removeResult(finderPath, finderArgs);
1560 }
1561 else {
1562 cacheResult(list);
1563
1564 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1565 }
1566
1567 closeSession(session);
1568 }
1569 }
1570
1571 return list;
1572 }
1573
1574
1584 public AnnouncementsEntry findByUuid_C_First(String uuid, long companyId,
1585 OrderByComparator orderByComparator)
1586 throws NoSuchEntryException, SystemException {
1587 AnnouncementsEntry announcementsEntry = fetchByUuid_C_First(uuid,
1588 companyId, orderByComparator);
1589
1590 if (announcementsEntry != null) {
1591 return announcementsEntry;
1592 }
1593
1594 StringBundler msg = new StringBundler(6);
1595
1596 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1597
1598 msg.append("uuid=");
1599 msg.append(uuid);
1600
1601 msg.append(", companyId=");
1602 msg.append(companyId);
1603
1604 msg.append(StringPool.CLOSE_CURLY_BRACE);
1605
1606 throw new NoSuchEntryException(msg.toString());
1607 }
1608
1609
1618 public AnnouncementsEntry fetchByUuid_C_First(String uuid, long companyId,
1619 OrderByComparator orderByComparator) throws SystemException {
1620 List<AnnouncementsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1621 orderByComparator);
1622
1623 if (!list.isEmpty()) {
1624 return list.get(0);
1625 }
1626
1627 return null;
1628 }
1629
1630
1640 public AnnouncementsEntry findByUuid_C_Last(String uuid, long companyId,
1641 OrderByComparator orderByComparator)
1642 throws NoSuchEntryException, SystemException {
1643 AnnouncementsEntry announcementsEntry = fetchByUuid_C_Last(uuid,
1644 companyId, orderByComparator);
1645
1646 if (announcementsEntry != null) {
1647 return announcementsEntry;
1648 }
1649
1650 StringBundler msg = new StringBundler(6);
1651
1652 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1653
1654 msg.append("uuid=");
1655 msg.append(uuid);
1656
1657 msg.append(", companyId=");
1658 msg.append(companyId);
1659
1660 msg.append(StringPool.CLOSE_CURLY_BRACE);
1661
1662 throw new NoSuchEntryException(msg.toString());
1663 }
1664
1665
1674 public AnnouncementsEntry fetchByUuid_C_Last(String uuid, long companyId,
1675 OrderByComparator orderByComparator) throws SystemException {
1676 int count = countByUuid_C(uuid, companyId);
1677
1678 List<AnnouncementsEntry> list = findByUuid_C(uuid, companyId,
1679 count - 1, count, orderByComparator);
1680
1681 if (!list.isEmpty()) {
1682 return list.get(0);
1683 }
1684
1685 return null;
1686 }
1687
1688
1699 public AnnouncementsEntry[] findByUuid_C_PrevAndNext(long entryId,
1700 String uuid, long companyId, OrderByComparator orderByComparator)
1701 throws NoSuchEntryException, SystemException {
1702 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1703
1704 Session session = null;
1705
1706 try {
1707 session = openSession();
1708
1709 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1710
1711 array[0] = getByUuid_C_PrevAndNext(session, announcementsEntry,
1712 uuid, companyId, orderByComparator, true);
1713
1714 array[1] = announcementsEntry;
1715
1716 array[2] = getByUuid_C_PrevAndNext(session, announcementsEntry,
1717 uuid, companyId, orderByComparator, false);
1718
1719 return array;
1720 }
1721 catch (Exception e) {
1722 throw processException(e);
1723 }
1724 finally {
1725 closeSession(session);
1726 }
1727 }
1728
1729 protected AnnouncementsEntry getByUuid_C_PrevAndNext(Session session,
1730 AnnouncementsEntry announcementsEntry, String uuid, long companyId,
1731 OrderByComparator orderByComparator, boolean previous) {
1732 StringBundler query = null;
1733
1734 if (orderByComparator != null) {
1735 query = new StringBundler(6 +
1736 (orderByComparator.getOrderByFields().length * 6));
1737 }
1738 else {
1739 query = new StringBundler(3);
1740 }
1741
1742 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1743
1744 if (uuid == null) {
1745 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1746 }
1747 else {
1748 if (uuid.equals(StringPool.BLANK)) {
1749 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1750 }
1751 else {
1752 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1753 }
1754 }
1755
1756 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1757
1758 if (orderByComparator != null) {
1759 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1760
1761 if (orderByConditionFields.length > 0) {
1762 query.append(WHERE_AND);
1763 }
1764
1765 for (int i = 0; i < orderByConditionFields.length; i++) {
1766 query.append(_ORDER_BY_ENTITY_ALIAS);
1767 query.append(orderByConditionFields[i]);
1768
1769 if ((i + 1) < orderByConditionFields.length) {
1770 if (orderByComparator.isAscending() ^ previous) {
1771 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1772 }
1773 else {
1774 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1775 }
1776 }
1777 else {
1778 if (orderByComparator.isAscending() ^ previous) {
1779 query.append(WHERE_GREATER_THAN);
1780 }
1781 else {
1782 query.append(WHERE_LESSER_THAN);
1783 }
1784 }
1785 }
1786
1787 query.append(ORDER_BY_CLAUSE);
1788
1789 String[] orderByFields = orderByComparator.getOrderByFields();
1790
1791 for (int i = 0; i < orderByFields.length; i++) {
1792 query.append(_ORDER_BY_ENTITY_ALIAS);
1793 query.append(orderByFields[i]);
1794
1795 if ((i + 1) < orderByFields.length) {
1796 if (orderByComparator.isAscending() ^ previous) {
1797 query.append(ORDER_BY_ASC_HAS_NEXT);
1798 }
1799 else {
1800 query.append(ORDER_BY_DESC_HAS_NEXT);
1801 }
1802 }
1803 else {
1804 if (orderByComparator.isAscending() ^ previous) {
1805 query.append(ORDER_BY_ASC);
1806 }
1807 else {
1808 query.append(ORDER_BY_DESC);
1809 }
1810 }
1811 }
1812 }
1813
1814 else {
1815 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1816 }
1817
1818 String sql = query.toString();
1819
1820 Query q = session.createQuery(sql);
1821
1822 q.setFirstResult(0);
1823 q.setMaxResults(2);
1824
1825 QueryPos qPos = QueryPos.getInstance(q);
1826
1827 if (uuid != null) {
1828 qPos.add(uuid);
1829 }
1830
1831 qPos.add(companyId);
1832
1833 if (orderByComparator != null) {
1834 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1835
1836 for (Object value : values) {
1837 qPos.add(value);
1838 }
1839 }
1840
1841 List<AnnouncementsEntry> list = q.list();
1842
1843 if (list.size() == 2) {
1844 return list.get(1);
1845 }
1846 else {
1847 return null;
1848 }
1849 }
1850
1851
1859 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1860 long companyId) throws SystemException {
1861 return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1862 QueryUtil.ALL_POS, null);
1863 }
1864
1865
1879 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1880 long companyId, int start, int end) throws SystemException {
1881 return filterFindByUuid_C(uuid, companyId, start, end, null);
1882 }
1883
1884
1899 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1900 long companyId, int start, int end, OrderByComparator orderByComparator)
1901 throws SystemException {
1902 if (!InlineSQLHelperUtil.isEnabled()) {
1903 return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1904 }
1905
1906 StringBundler query = null;
1907
1908 if (orderByComparator != null) {
1909 query = new StringBundler(4 +
1910 (orderByComparator.getOrderByFields().length * 3));
1911 }
1912 else {
1913 query = new StringBundler(4);
1914 }
1915
1916 if (getDB().isSupportsInlineDistinct()) {
1917 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1918 }
1919 else {
1920 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1921 }
1922
1923 if (uuid == null) {
1924 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1925 }
1926 else {
1927 if (uuid.equals(StringPool.BLANK)) {
1928 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1929 }
1930 else {
1931 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1932 }
1933 }
1934
1935 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1936
1937 if (!getDB().isSupportsInlineDistinct()) {
1938 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1939 }
1940
1941 if (orderByComparator != null) {
1942 if (getDB().isSupportsInlineDistinct()) {
1943 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1944 orderByComparator);
1945 }
1946 else {
1947 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1948 orderByComparator);
1949 }
1950 }
1951
1952 else {
1953 if (getDB().isSupportsInlineDistinct()) {
1954 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1955 }
1956 else {
1957 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1958 }
1959 }
1960
1961 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1962 AnnouncementsEntry.class.getName(),
1963 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1964
1965 Session session = null;
1966
1967 try {
1968 session = openSession();
1969
1970 SQLQuery q = session.createSQLQuery(sql);
1971
1972 if (getDB().isSupportsInlineDistinct()) {
1973 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1974 }
1975 else {
1976 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1977 }
1978
1979 QueryPos qPos = QueryPos.getInstance(q);
1980
1981 if (uuid != null) {
1982 qPos.add(uuid);
1983 }
1984
1985 qPos.add(companyId);
1986
1987 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
1988 start, end);
1989 }
1990 catch (Exception e) {
1991 throw processException(e);
1992 }
1993 finally {
1994 closeSession(session);
1995 }
1996 }
1997
1998
2009 public AnnouncementsEntry[] filterFindByUuid_C_PrevAndNext(long entryId,
2010 String uuid, long companyId, OrderByComparator orderByComparator)
2011 throws NoSuchEntryException, SystemException {
2012 if (!InlineSQLHelperUtil.isEnabled()) {
2013 return findByUuid_C_PrevAndNext(entryId, uuid, companyId,
2014 orderByComparator);
2015 }
2016
2017 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2018
2019 Session session = null;
2020
2021 try {
2022 session = openSession();
2023
2024 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2025
2026 array[0] = filterGetByUuid_C_PrevAndNext(session,
2027 announcementsEntry, uuid, companyId, orderByComparator, true);
2028
2029 array[1] = announcementsEntry;
2030
2031 array[2] = filterGetByUuid_C_PrevAndNext(session,
2032 announcementsEntry, uuid, companyId, orderByComparator,
2033 false);
2034
2035 return array;
2036 }
2037 catch (Exception e) {
2038 throw processException(e);
2039 }
2040 finally {
2041 closeSession(session);
2042 }
2043 }
2044
2045 protected AnnouncementsEntry filterGetByUuid_C_PrevAndNext(
2046 Session session, AnnouncementsEntry announcementsEntry, String uuid,
2047 long companyId, OrderByComparator orderByComparator, boolean previous) {
2048 StringBundler query = null;
2049
2050 if (orderByComparator != null) {
2051 query = new StringBundler(6 +
2052 (orderByComparator.getOrderByFields().length * 6));
2053 }
2054 else {
2055 query = new StringBundler(3);
2056 }
2057
2058 if (getDB().isSupportsInlineDistinct()) {
2059 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2060 }
2061 else {
2062 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2063 }
2064
2065 if (uuid == null) {
2066 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
2067 }
2068 else {
2069 if (uuid.equals(StringPool.BLANK)) {
2070 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
2071 }
2072 else {
2073 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
2074 }
2075 }
2076
2077 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2078
2079 if (!getDB().isSupportsInlineDistinct()) {
2080 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2081 }
2082
2083 if (orderByComparator != null) {
2084 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2085
2086 if (orderByConditionFields.length > 0) {
2087 query.append(WHERE_AND);
2088 }
2089
2090 for (int i = 0; i < orderByConditionFields.length; i++) {
2091 if (getDB().isSupportsInlineDistinct()) {
2092 query.append(_ORDER_BY_ENTITY_ALIAS);
2093 }
2094 else {
2095 query.append(_ORDER_BY_ENTITY_TABLE);
2096 }
2097
2098 query.append(orderByConditionFields[i]);
2099
2100 if ((i + 1) < orderByConditionFields.length) {
2101 if (orderByComparator.isAscending() ^ previous) {
2102 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2103 }
2104 else {
2105 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2106 }
2107 }
2108 else {
2109 if (orderByComparator.isAscending() ^ previous) {
2110 query.append(WHERE_GREATER_THAN);
2111 }
2112 else {
2113 query.append(WHERE_LESSER_THAN);
2114 }
2115 }
2116 }
2117
2118 query.append(ORDER_BY_CLAUSE);
2119
2120 String[] orderByFields = orderByComparator.getOrderByFields();
2121
2122 for (int i = 0; i < orderByFields.length; i++) {
2123 if (getDB().isSupportsInlineDistinct()) {
2124 query.append(_ORDER_BY_ENTITY_ALIAS);
2125 }
2126 else {
2127 query.append(_ORDER_BY_ENTITY_TABLE);
2128 }
2129
2130 query.append(orderByFields[i]);
2131
2132 if ((i + 1) < orderByFields.length) {
2133 if (orderByComparator.isAscending() ^ previous) {
2134 query.append(ORDER_BY_ASC_HAS_NEXT);
2135 }
2136 else {
2137 query.append(ORDER_BY_DESC_HAS_NEXT);
2138 }
2139 }
2140 else {
2141 if (orderByComparator.isAscending() ^ previous) {
2142 query.append(ORDER_BY_ASC);
2143 }
2144 else {
2145 query.append(ORDER_BY_DESC);
2146 }
2147 }
2148 }
2149 }
2150
2151 else {
2152 if (getDB().isSupportsInlineDistinct()) {
2153 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2154 }
2155 else {
2156 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2157 }
2158 }
2159
2160 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2161 AnnouncementsEntry.class.getName(),
2162 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2163
2164 SQLQuery q = session.createSQLQuery(sql);
2165
2166 q.setFirstResult(0);
2167 q.setMaxResults(2);
2168
2169 if (getDB().isSupportsInlineDistinct()) {
2170 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2171 }
2172 else {
2173 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2174 }
2175
2176 QueryPos qPos = QueryPos.getInstance(q);
2177
2178 if (uuid != null) {
2179 qPos.add(uuid);
2180 }
2181
2182 qPos.add(companyId);
2183
2184 if (orderByComparator != null) {
2185 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2186
2187 for (Object value : values) {
2188 qPos.add(value);
2189 }
2190 }
2191
2192 List<AnnouncementsEntry> list = q.list();
2193
2194 if (list.size() == 2) {
2195 return list.get(1);
2196 }
2197 else {
2198 return null;
2199 }
2200 }
2201
2202
2209 public List<AnnouncementsEntry> findByUserId(long userId)
2210 throws SystemException {
2211 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2212 }
2213
2214
2227 public List<AnnouncementsEntry> findByUserId(long userId, int start, int end)
2228 throws SystemException {
2229 return findByUserId(userId, start, end, null);
2230 }
2231
2232
2246 public List<AnnouncementsEntry> findByUserId(long userId, int start,
2247 int end, OrderByComparator orderByComparator) throws SystemException {
2248 FinderPath finderPath = null;
2249 Object[] finderArgs = null;
2250
2251 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2252 (orderByComparator == null)) {
2253 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
2254 finderArgs = new Object[] { userId };
2255 }
2256 else {
2257 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
2258 finderArgs = new Object[] { userId, start, end, orderByComparator };
2259 }
2260
2261 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
2262 finderArgs, this);
2263
2264 if ((list != null) && !list.isEmpty()) {
2265 for (AnnouncementsEntry announcementsEntry : list) {
2266 if ((userId != announcementsEntry.getUserId())) {
2267 list = null;
2268
2269 break;
2270 }
2271 }
2272 }
2273
2274 if (list == null) {
2275 StringBundler query = null;
2276
2277 if (orderByComparator != null) {
2278 query = new StringBundler(3 +
2279 (orderByComparator.getOrderByFields().length * 3));
2280 }
2281 else {
2282 query = new StringBundler(3);
2283 }
2284
2285 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2286
2287 query.append(_FINDER_COLUMN_USERID_USERID_2);
2288
2289 if (orderByComparator != null) {
2290 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2291 orderByComparator);
2292 }
2293
2294 else {
2295 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2296 }
2297
2298 String sql = query.toString();
2299
2300 Session session = null;
2301
2302 try {
2303 session = openSession();
2304
2305 Query q = session.createQuery(sql);
2306
2307 QueryPos qPos = QueryPos.getInstance(q);
2308
2309 qPos.add(userId);
2310
2311 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2312 getDialect(), start, end);
2313 }
2314 catch (Exception e) {
2315 throw processException(e);
2316 }
2317 finally {
2318 if (list == null) {
2319 FinderCacheUtil.removeResult(finderPath, finderArgs);
2320 }
2321 else {
2322 cacheResult(list);
2323
2324 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2325 }
2326
2327 closeSession(session);
2328 }
2329 }
2330
2331 return list;
2332 }
2333
2334
2343 public AnnouncementsEntry findByUserId_First(long userId,
2344 OrderByComparator orderByComparator)
2345 throws NoSuchEntryException, SystemException {
2346 AnnouncementsEntry announcementsEntry = fetchByUserId_First(userId,
2347 orderByComparator);
2348
2349 if (announcementsEntry != null) {
2350 return announcementsEntry;
2351 }
2352
2353 StringBundler msg = new StringBundler(4);
2354
2355 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2356
2357 msg.append("userId=");
2358 msg.append(userId);
2359
2360 msg.append(StringPool.CLOSE_CURLY_BRACE);
2361
2362 throw new NoSuchEntryException(msg.toString());
2363 }
2364
2365
2373 public AnnouncementsEntry fetchByUserId_First(long userId,
2374 OrderByComparator orderByComparator) throws SystemException {
2375 List<AnnouncementsEntry> list = findByUserId(userId, 0, 1,
2376 orderByComparator);
2377
2378 if (!list.isEmpty()) {
2379 return list.get(0);
2380 }
2381
2382 return null;
2383 }
2384
2385
2394 public AnnouncementsEntry findByUserId_Last(long userId,
2395 OrderByComparator orderByComparator)
2396 throws NoSuchEntryException, SystemException {
2397 AnnouncementsEntry announcementsEntry = fetchByUserId_Last(userId,
2398 orderByComparator);
2399
2400 if (announcementsEntry != null) {
2401 return announcementsEntry;
2402 }
2403
2404 StringBundler msg = new StringBundler(4);
2405
2406 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2407
2408 msg.append("userId=");
2409 msg.append(userId);
2410
2411 msg.append(StringPool.CLOSE_CURLY_BRACE);
2412
2413 throw new NoSuchEntryException(msg.toString());
2414 }
2415
2416
2424 public AnnouncementsEntry fetchByUserId_Last(long userId,
2425 OrderByComparator orderByComparator) throws SystemException {
2426 int count = countByUserId(userId);
2427
2428 List<AnnouncementsEntry> list = findByUserId(userId, count - 1, count,
2429 orderByComparator);
2430
2431 if (!list.isEmpty()) {
2432 return list.get(0);
2433 }
2434
2435 return null;
2436 }
2437
2438
2448 public AnnouncementsEntry[] findByUserId_PrevAndNext(long entryId,
2449 long userId, OrderByComparator orderByComparator)
2450 throws NoSuchEntryException, SystemException {
2451 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2452
2453 Session session = null;
2454
2455 try {
2456 session = openSession();
2457
2458 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2459
2460 array[0] = getByUserId_PrevAndNext(session, announcementsEntry,
2461 userId, orderByComparator, true);
2462
2463 array[1] = announcementsEntry;
2464
2465 array[2] = getByUserId_PrevAndNext(session, announcementsEntry,
2466 userId, orderByComparator, false);
2467
2468 return array;
2469 }
2470 catch (Exception e) {
2471 throw processException(e);
2472 }
2473 finally {
2474 closeSession(session);
2475 }
2476 }
2477
2478 protected AnnouncementsEntry getByUserId_PrevAndNext(Session session,
2479 AnnouncementsEntry announcementsEntry, long userId,
2480 OrderByComparator orderByComparator, boolean previous) {
2481 StringBundler query = null;
2482
2483 if (orderByComparator != null) {
2484 query = new StringBundler(6 +
2485 (orderByComparator.getOrderByFields().length * 6));
2486 }
2487 else {
2488 query = new StringBundler(3);
2489 }
2490
2491 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2492
2493 query.append(_FINDER_COLUMN_USERID_USERID_2);
2494
2495 if (orderByComparator != null) {
2496 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2497
2498 if (orderByConditionFields.length > 0) {
2499 query.append(WHERE_AND);
2500 }
2501
2502 for (int i = 0; i < orderByConditionFields.length; i++) {
2503 query.append(_ORDER_BY_ENTITY_ALIAS);
2504 query.append(orderByConditionFields[i]);
2505
2506 if ((i + 1) < orderByConditionFields.length) {
2507 if (orderByComparator.isAscending() ^ previous) {
2508 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2509 }
2510 else {
2511 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2512 }
2513 }
2514 else {
2515 if (orderByComparator.isAscending() ^ previous) {
2516 query.append(WHERE_GREATER_THAN);
2517 }
2518 else {
2519 query.append(WHERE_LESSER_THAN);
2520 }
2521 }
2522 }
2523
2524 query.append(ORDER_BY_CLAUSE);
2525
2526 String[] orderByFields = orderByComparator.getOrderByFields();
2527
2528 for (int i = 0; i < orderByFields.length; i++) {
2529 query.append(_ORDER_BY_ENTITY_ALIAS);
2530 query.append(orderByFields[i]);
2531
2532 if ((i + 1) < orderByFields.length) {
2533 if (orderByComparator.isAscending() ^ previous) {
2534 query.append(ORDER_BY_ASC_HAS_NEXT);
2535 }
2536 else {
2537 query.append(ORDER_BY_DESC_HAS_NEXT);
2538 }
2539 }
2540 else {
2541 if (orderByComparator.isAscending() ^ previous) {
2542 query.append(ORDER_BY_ASC);
2543 }
2544 else {
2545 query.append(ORDER_BY_DESC);
2546 }
2547 }
2548 }
2549 }
2550
2551 else {
2552 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2553 }
2554
2555 String sql = query.toString();
2556
2557 Query q = session.createQuery(sql);
2558
2559 q.setFirstResult(0);
2560 q.setMaxResults(2);
2561
2562 QueryPos qPos = QueryPos.getInstance(q);
2563
2564 qPos.add(userId);
2565
2566 if (orderByComparator != null) {
2567 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2568
2569 for (Object value : values) {
2570 qPos.add(value);
2571 }
2572 }
2573
2574 List<AnnouncementsEntry> list = q.list();
2575
2576 if (list.size() == 2) {
2577 return list.get(1);
2578 }
2579 else {
2580 return null;
2581 }
2582 }
2583
2584
2591 public List<AnnouncementsEntry> filterFindByUserId(long userId)
2592 throws SystemException {
2593 return filterFindByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2594 null);
2595 }
2596
2597
2610 public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
2611 int end) throws SystemException {
2612 return filterFindByUserId(userId, start, end, null);
2613 }
2614
2615
2629 public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
2630 int end, OrderByComparator orderByComparator) throws SystemException {
2631 if (!InlineSQLHelperUtil.isEnabled()) {
2632 return findByUserId(userId, start, end, orderByComparator);
2633 }
2634
2635 StringBundler query = null;
2636
2637 if (orderByComparator != null) {
2638 query = new StringBundler(3 +
2639 (orderByComparator.getOrderByFields().length * 3));
2640 }
2641 else {
2642 query = new StringBundler(3);
2643 }
2644
2645 if (getDB().isSupportsInlineDistinct()) {
2646 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2647 }
2648 else {
2649 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2650 }
2651
2652 query.append(_FINDER_COLUMN_USERID_USERID_2);
2653
2654 if (!getDB().isSupportsInlineDistinct()) {
2655 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2656 }
2657
2658 if (orderByComparator != null) {
2659 if (getDB().isSupportsInlineDistinct()) {
2660 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2661 orderByComparator);
2662 }
2663 else {
2664 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2665 orderByComparator);
2666 }
2667 }
2668
2669 else {
2670 if (getDB().isSupportsInlineDistinct()) {
2671 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2672 }
2673 else {
2674 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2675 }
2676 }
2677
2678 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2679 AnnouncementsEntry.class.getName(),
2680 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2681
2682 Session session = null;
2683
2684 try {
2685 session = openSession();
2686
2687 SQLQuery q = session.createSQLQuery(sql);
2688
2689 if (getDB().isSupportsInlineDistinct()) {
2690 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2691 }
2692 else {
2693 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2694 }
2695
2696 QueryPos qPos = QueryPos.getInstance(q);
2697
2698 qPos.add(userId);
2699
2700 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
2701 start, end);
2702 }
2703 catch (Exception e) {
2704 throw processException(e);
2705 }
2706 finally {
2707 closeSession(session);
2708 }
2709 }
2710
2711
2721 public AnnouncementsEntry[] filterFindByUserId_PrevAndNext(long entryId,
2722 long userId, OrderByComparator orderByComparator)
2723 throws NoSuchEntryException, SystemException {
2724 if (!InlineSQLHelperUtil.isEnabled()) {
2725 return findByUserId_PrevAndNext(entryId, userId, orderByComparator);
2726 }
2727
2728 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2729
2730 Session session = null;
2731
2732 try {
2733 session = openSession();
2734
2735 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2736
2737 array[0] = filterGetByUserId_PrevAndNext(session,
2738 announcementsEntry, userId, orderByComparator, true);
2739
2740 array[1] = announcementsEntry;
2741
2742 array[2] = filterGetByUserId_PrevAndNext(session,
2743 announcementsEntry, userId, orderByComparator, false);
2744
2745 return array;
2746 }
2747 catch (Exception e) {
2748 throw processException(e);
2749 }
2750 finally {
2751 closeSession(session);
2752 }
2753 }
2754
2755 protected AnnouncementsEntry filterGetByUserId_PrevAndNext(
2756 Session session, AnnouncementsEntry announcementsEntry, long userId,
2757 OrderByComparator orderByComparator, boolean previous) {
2758 StringBundler query = null;
2759
2760 if (orderByComparator != null) {
2761 query = new StringBundler(6 +
2762 (orderByComparator.getOrderByFields().length * 6));
2763 }
2764 else {
2765 query = new StringBundler(3);
2766 }
2767
2768 if (getDB().isSupportsInlineDistinct()) {
2769 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2770 }
2771 else {
2772 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2773 }
2774
2775 query.append(_FINDER_COLUMN_USERID_USERID_2);
2776
2777 if (!getDB().isSupportsInlineDistinct()) {
2778 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2779 }
2780
2781 if (orderByComparator != null) {
2782 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2783
2784 if (orderByConditionFields.length > 0) {
2785 query.append(WHERE_AND);
2786 }
2787
2788 for (int i = 0; i < orderByConditionFields.length; i++) {
2789 if (getDB().isSupportsInlineDistinct()) {
2790 query.append(_ORDER_BY_ENTITY_ALIAS);
2791 }
2792 else {
2793 query.append(_ORDER_BY_ENTITY_TABLE);
2794 }
2795
2796 query.append(orderByConditionFields[i]);
2797
2798 if ((i + 1) < orderByConditionFields.length) {
2799 if (orderByComparator.isAscending() ^ previous) {
2800 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2801 }
2802 else {
2803 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2804 }
2805 }
2806 else {
2807 if (orderByComparator.isAscending() ^ previous) {
2808 query.append(WHERE_GREATER_THAN);
2809 }
2810 else {
2811 query.append(WHERE_LESSER_THAN);
2812 }
2813 }
2814 }
2815
2816 query.append(ORDER_BY_CLAUSE);
2817
2818 String[] orderByFields = orderByComparator.getOrderByFields();
2819
2820 for (int i = 0; i < orderByFields.length; i++) {
2821 if (getDB().isSupportsInlineDistinct()) {
2822 query.append(_ORDER_BY_ENTITY_ALIAS);
2823 }
2824 else {
2825 query.append(_ORDER_BY_ENTITY_TABLE);
2826 }
2827
2828 query.append(orderByFields[i]);
2829
2830 if ((i + 1) < orderByFields.length) {
2831 if (orderByComparator.isAscending() ^ previous) {
2832 query.append(ORDER_BY_ASC_HAS_NEXT);
2833 }
2834 else {
2835 query.append(ORDER_BY_DESC_HAS_NEXT);
2836 }
2837 }
2838 else {
2839 if (orderByComparator.isAscending() ^ previous) {
2840 query.append(ORDER_BY_ASC);
2841 }
2842 else {
2843 query.append(ORDER_BY_DESC);
2844 }
2845 }
2846 }
2847 }
2848
2849 else {
2850 if (getDB().isSupportsInlineDistinct()) {
2851 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2852 }
2853 else {
2854 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2855 }
2856 }
2857
2858 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2859 AnnouncementsEntry.class.getName(),
2860 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2861
2862 SQLQuery q = session.createSQLQuery(sql);
2863
2864 q.setFirstResult(0);
2865 q.setMaxResults(2);
2866
2867 if (getDB().isSupportsInlineDistinct()) {
2868 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2869 }
2870 else {
2871 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2872 }
2873
2874 QueryPos qPos = QueryPos.getInstance(q);
2875
2876 qPos.add(userId);
2877
2878 if (orderByComparator != null) {
2879 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2880
2881 for (Object value : values) {
2882 qPos.add(value);
2883 }
2884 }
2885
2886 List<AnnouncementsEntry> list = q.list();
2887
2888 if (list.size() == 2) {
2889 return list.get(1);
2890 }
2891 else {
2892 return null;
2893 }
2894 }
2895
2896
2904 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK)
2905 throws SystemException {
2906 return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
2907 QueryUtil.ALL_POS, null);
2908 }
2909
2910
2924 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
2925 int start, int end) throws SystemException {
2926 return findByC_C(classNameId, classPK, start, end, null);
2927 }
2928
2929
2944 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
2945 int start, int end, OrderByComparator orderByComparator)
2946 throws SystemException {
2947 FinderPath finderPath = null;
2948 Object[] finderArgs = null;
2949
2950 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2951 (orderByComparator == null)) {
2952 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2953 finderArgs = new Object[] { classNameId, classPK };
2954 }
2955 else {
2956 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2957 finderArgs = new Object[] {
2958 classNameId, classPK,
2959
2960 start, end, orderByComparator
2961 };
2962 }
2963
2964 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
2965 finderArgs, this);
2966
2967 if ((list != null) && !list.isEmpty()) {
2968 for (AnnouncementsEntry announcementsEntry : list) {
2969 if ((classNameId != announcementsEntry.getClassNameId()) ||
2970 (classPK != announcementsEntry.getClassPK())) {
2971 list = null;
2972
2973 break;
2974 }
2975 }
2976 }
2977
2978 if (list == null) {
2979 StringBundler query = null;
2980
2981 if (orderByComparator != null) {
2982 query = new StringBundler(4 +
2983 (orderByComparator.getOrderByFields().length * 3));
2984 }
2985 else {
2986 query = new StringBundler(4);
2987 }
2988
2989 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2990
2991 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2992
2993 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2994
2995 if (orderByComparator != null) {
2996 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2997 orderByComparator);
2998 }
2999
3000 else {
3001 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3002 }
3003
3004 String sql = query.toString();
3005
3006 Session session = null;
3007
3008 try {
3009 session = openSession();
3010
3011 Query q = session.createQuery(sql);
3012
3013 QueryPos qPos = QueryPos.getInstance(q);
3014
3015 qPos.add(classNameId);
3016
3017 qPos.add(classPK);
3018
3019 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3020 getDialect(), start, end);
3021 }
3022 catch (Exception e) {
3023 throw processException(e);
3024 }
3025 finally {
3026 if (list == null) {
3027 FinderCacheUtil.removeResult(finderPath, finderArgs);
3028 }
3029 else {
3030 cacheResult(list);
3031
3032 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3033 }
3034
3035 closeSession(session);
3036 }
3037 }
3038
3039 return list;
3040 }
3041
3042
3052 public AnnouncementsEntry findByC_C_First(long classNameId, long classPK,
3053 OrderByComparator orderByComparator)
3054 throws NoSuchEntryException, SystemException {
3055 AnnouncementsEntry announcementsEntry = fetchByC_C_First(classNameId,
3056 classPK, orderByComparator);
3057
3058 if (announcementsEntry != null) {
3059 return announcementsEntry;
3060 }
3061
3062 StringBundler msg = new StringBundler(6);
3063
3064 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3065
3066 msg.append("classNameId=");
3067 msg.append(classNameId);
3068
3069 msg.append(", classPK=");
3070 msg.append(classPK);
3071
3072 msg.append(StringPool.CLOSE_CURLY_BRACE);
3073
3074 throw new NoSuchEntryException(msg.toString());
3075 }
3076
3077
3086 public AnnouncementsEntry fetchByC_C_First(long classNameId, long classPK,
3087 OrderByComparator orderByComparator) throws SystemException {
3088 List<AnnouncementsEntry> list = findByC_C(classNameId, classPK, 0, 1,
3089 orderByComparator);
3090
3091 if (!list.isEmpty()) {
3092 return list.get(0);
3093 }
3094
3095 return null;
3096 }
3097
3098
3108 public AnnouncementsEntry findByC_C_Last(long classNameId, long classPK,
3109 OrderByComparator orderByComparator)
3110 throws NoSuchEntryException, SystemException {
3111 AnnouncementsEntry announcementsEntry = fetchByC_C_Last(classNameId,
3112 classPK, orderByComparator);
3113
3114 if (announcementsEntry != null) {
3115 return announcementsEntry;
3116 }
3117
3118 StringBundler msg = new StringBundler(6);
3119
3120 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3121
3122 msg.append("classNameId=");
3123 msg.append(classNameId);
3124
3125 msg.append(", classPK=");
3126 msg.append(classPK);
3127
3128 msg.append(StringPool.CLOSE_CURLY_BRACE);
3129
3130 throw new NoSuchEntryException(msg.toString());
3131 }
3132
3133
3142 public AnnouncementsEntry fetchByC_C_Last(long classNameId, long classPK,
3143 OrderByComparator orderByComparator) throws SystemException {
3144 int count = countByC_C(classNameId, classPK);
3145
3146 List<AnnouncementsEntry> list = findByC_C(classNameId, classPK,
3147 count - 1, count, orderByComparator);
3148
3149 if (!list.isEmpty()) {
3150 return list.get(0);
3151 }
3152
3153 return null;
3154 }
3155
3156
3167 public AnnouncementsEntry[] findByC_C_PrevAndNext(long entryId,
3168 long classNameId, long classPK, OrderByComparator orderByComparator)
3169 throws NoSuchEntryException, SystemException {
3170 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3171
3172 Session session = null;
3173
3174 try {
3175 session = openSession();
3176
3177 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3178
3179 array[0] = getByC_C_PrevAndNext(session, announcementsEntry,
3180 classNameId, classPK, orderByComparator, true);
3181
3182 array[1] = announcementsEntry;
3183
3184 array[2] = getByC_C_PrevAndNext(session, announcementsEntry,
3185 classNameId, classPK, orderByComparator, false);
3186
3187 return array;
3188 }
3189 catch (Exception e) {
3190 throw processException(e);
3191 }
3192 finally {
3193 closeSession(session);
3194 }
3195 }
3196
3197 protected AnnouncementsEntry getByC_C_PrevAndNext(Session session,
3198 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3199 OrderByComparator orderByComparator, boolean previous) {
3200 StringBundler query = null;
3201
3202 if (orderByComparator != null) {
3203 query = new StringBundler(6 +
3204 (orderByComparator.getOrderByFields().length * 6));
3205 }
3206 else {
3207 query = new StringBundler(3);
3208 }
3209
3210 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3211
3212 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3213
3214 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3215
3216 if (orderByComparator != null) {
3217 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3218
3219 if (orderByConditionFields.length > 0) {
3220 query.append(WHERE_AND);
3221 }
3222
3223 for (int i = 0; i < orderByConditionFields.length; i++) {
3224 query.append(_ORDER_BY_ENTITY_ALIAS);
3225 query.append(orderByConditionFields[i]);
3226
3227 if ((i + 1) < orderByConditionFields.length) {
3228 if (orderByComparator.isAscending() ^ previous) {
3229 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3230 }
3231 else {
3232 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3233 }
3234 }
3235 else {
3236 if (orderByComparator.isAscending() ^ previous) {
3237 query.append(WHERE_GREATER_THAN);
3238 }
3239 else {
3240 query.append(WHERE_LESSER_THAN);
3241 }
3242 }
3243 }
3244
3245 query.append(ORDER_BY_CLAUSE);
3246
3247 String[] orderByFields = orderByComparator.getOrderByFields();
3248
3249 for (int i = 0; i < orderByFields.length; i++) {
3250 query.append(_ORDER_BY_ENTITY_ALIAS);
3251 query.append(orderByFields[i]);
3252
3253 if ((i + 1) < orderByFields.length) {
3254 if (orderByComparator.isAscending() ^ previous) {
3255 query.append(ORDER_BY_ASC_HAS_NEXT);
3256 }
3257 else {
3258 query.append(ORDER_BY_DESC_HAS_NEXT);
3259 }
3260 }
3261 else {
3262 if (orderByComparator.isAscending() ^ previous) {
3263 query.append(ORDER_BY_ASC);
3264 }
3265 else {
3266 query.append(ORDER_BY_DESC);
3267 }
3268 }
3269 }
3270 }
3271
3272 else {
3273 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3274 }
3275
3276 String sql = query.toString();
3277
3278 Query q = session.createQuery(sql);
3279
3280 q.setFirstResult(0);
3281 q.setMaxResults(2);
3282
3283 QueryPos qPos = QueryPos.getInstance(q);
3284
3285 qPos.add(classNameId);
3286
3287 qPos.add(classPK);
3288
3289 if (orderByComparator != null) {
3290 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3291
3292 for (Object value : values) {
3293 qPos.add(value);
3294 }
3295 }
3296
3297 List<AnnouncementsEntry> list = q.list();
3298
3299 if (list.size() == 2) {
3300 return list.get(1);
3301 }
3302 else {
3303 return null;
3304 }
3305 }
3306
3307
3315 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3316 long classPK) throws SystemException {
3317 return filterFindByC_C(classNameId, classPK, QueryUtil.ALL_POS,
3318 QueryUtil.ALL_POS, null);
3319 }
3320
3321
3335 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3336 long classPK, int start, int end) throws SystemException {
3337 return filterFindByC_C(classNameId, classPK, start, end, null);
3338 }
3339
3340
3355 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3356 long classPK, int start, int end, OrderByComparator orderByComparator)
3357 throws SystemException {
3358 if (!InlineSQLHelperUtil.isEnabled()) {
3359 return findByC_C(classNameId, classPK, start, end, orderByComparator);
3360 }
3361
3362 StringBundler query = null;
3363
3364 if (orderByComparator != null) {
3365 query = new StringBundler(4 +
3366 (orderByComparator.getOrderByFields().length * 3));
3367 }
3368 else {
3369 query = new StringBundler(4);
3370 }
3371
3372 if (getDB().isSupportsInlineDistinct()) {
3373 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3374 }
3375 else {
3376 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3377 }
3378
3379 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3380
3381 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3382
3383 if (!getDB().isSupportsInlineDistinct()) {
3384 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3385 }
3386
3387 if (orderByComparator != null) {
3388 if (getDB().isSupportsInlineDistinct()) {
3389 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3390 orderByComparator);
3391 }
3392 else {
3393 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3394 orderByComparator);
3395 }
3396 }
3397
3398 else {
3399 if (getDB().isSupportsInlineDistinct()) {
3400 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3401 }
3402 else {
3403 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3404 }
3405 }
3406
3407 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3408 AnnouncementsEntry.class.getName(),
3409 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3410
3411 Session session = null;
3412
3413 try {
3414 session = openSession();
3415
3416 SQLQuery q = session.createSQLQuery(sql);
3417
3418 if (getDB().isSupportsInlineDistinct()) {
3419 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3420 }
3421 else {
3422 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3423 }
3424
3425 QueryPos qPos = QueryPos.getInstance(q);
3426
3427 qPos.add(classNameId);
3428
3429 qPos.add(classPK);
3430
3431 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
3432 start, end);
3433 }
3434 catch (Exception e) {
3435 throw processException(e);
3436 }
3437 finally {
3438 closeSession(session);
3439 }
3440 }
3441
3442
3453 public AnnouncementsEntry[] filterFindByC_C_PrevAndNext(long entryId,
3454 long classNameId, long classPK, OrderByComparator orderByComparator)
3455 throws NoSuchEntryException, SystemException {
3456 if (!InlineSQLHelperUtil.isEnabled()) {
3457 return findByC_C_PrevAndNext(entryId, classNameId, classPK,
3458 orderByComparator);
3459 }
3460
3461 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3462
3463 Session session = null;
3464
3465 try {
3466 session = openSession();
3467
3468 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3469
3470 array[0] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
3471 classNameId, classPK, orderByComparator, true);
3472
3473 array[1] = announcementsEntry;
3474
3475 array[2] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
3476 classNameId, classPK, orderByComparator, false);
3477
3478 return array;
3479 }
3480 catch (Exception e) {
3481 throw processException(e);
3482 }
3483 finally {
3484 closeSession(session);
3485 }
3486 }
3487
3488 protected AnnouncementsEntry filterGetByC_C_PrevAndNext(Session session,
3489 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3490 OrderByComparator orderByComparator, boolean previous) {
3491 StringBundler query = null;
3492
3493 if (orderByComparator != null) {
3494 query = new StringBundler(6 +
3495 (orderByComparator.getOrderByFields().length * 6));
3496 }
3497 else {
3498 query = new StringBundler(3);
3499 }
3500
3501 if (getDB().isSupportsInlineDistinct()) {
3502 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3503 }
3504 else {
3505 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3506 }
3507
3508 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3509
3510 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3511
3512 if (!getDB().isSupportsInlineDistinct()) {
3513 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3514 }
3515
3516 if (orderByComparator != null) {
3517 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3518
3519 if (orderByConditionFields.length > 0) {
3520 query.append(WHERE_AND);
3521 }
3522
3523 for (int i = 0; i < orderByConditionFields.length; i++) {
3524 if (getDB().isSupportsInlineDistinct()) {
3525 query.append(_ORDER_BY_ENTITY_ALIAS);
3526 }
3527 else {
3528 query.append(_ORDER_BY_ENTITY_TABLE);
3529 }
3530
3531 query.append(orderByConditionFields[i]);
3532
3533 if ((i + 1) < orderByConditionFields.length) {
3534 if (orderByComparator.isAscending() ^ previous) {
3535 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3536 }
3537 else {
3538 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3539 }
3540 }
3541 else {
3542 if (orderByComparator.isAscending() ^ previous) {
3543 query.append(WHERE_GREATER_THAN);
3544 }
3545 else {
3546 query.append(WHERE_LESSER_THAN);
3547 }
3548 }
3549 }
3550
3551 query.append(ORDER_BY_CLAUSE);
3552
3553 String[] orderByFields = orderByComparator.getOrderByFields();
3554
3555 for (int i = 0; i < orderByFields.length; i++) {
3556 if (getDB().isSupportsInlineDistinct()) {
3557 query.append(_ORDER_BY_ENTITY_ALIAS);
3558 }
3559 else {
3560 query.append(_ORDER_BY_ENTITY_TABLE);
3561 }
3562
3563 query.append(orderByFields[i]);
3564
3565 if ((i + 1) < orderByFields.length) {
3566 if (orderByComparator.isAscending() ^ previous) {
3567 query.append(ORDER_BY_ASC_HAS_NEXT);
3568 }
3569 else {
3570 query.append(ORDER_BY_DESC_HAS_NEXT);
3571 }
3572 }
3573 else {
3574 if (orderByComparator.isAscending() ^ previous) {
3575 query.append(ORDER_BY_ASC);
3576 }
3577 else {
3578 query.append(ORDER_BY_DESC);
3579 }
3580 }
3581 }
3582 }
3583
3584 else {
3585 if (getDB().isSupportsInlineDistinct()) {
3586 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3587 }
3588 else {
3589 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3590 }
3591 }
3592
3593 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3594 AnnouncementsEntry.class.getName(),
3595 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3596
3597 SQLQuery q = session.createSQLQuery(sql);
3598
3599 q.setFirstResult(0);
3600 q.setMaxResults(2);
3601
3602 if (getDB().isSupportsInlineDistinct()) {
3603 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3604 }
3605 else {
3606 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3607 }
3608
3609 QueryPos qPos = QueryPos.getInstance(q);
3610
3611 qPos.add(classNameId);
3612
3613 qPos.add(classPK);
3614
3615 if (orderByComparator != null) {
3616 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3617
3618 for (Object value : values) {
3619 qPos.add(value);
3620 }
3621 }
3622
3623 List<AnnouncementsEntry> list = q.list();
3624
3625 if (list.size() == 2) {
3626 return list.get(1);
3627 }
3628 else {
3629 return null;
3630 }
3631 }
3632
3633
3642 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3643 boolean alert) throws SystemException {
3644 return findByC_C_A(classNameId, classPK, alert, QueryUtil.ALL_POS,
3645 QueryUtil.ALL_POS, null);
3646 }
3647
3648
3663 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3664 boolean alert, int start, int end) throws SystemException {
3665 return findByC_C_A(classNameId, classPK, alert, start, end, null);
3666 }
3667
3668
3684 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3685 boolean alert, int start, int end, OrderByComparator orderByComparator)
3686 throws SystemException {
3687 FinderPath finderPath = null;
3688 Object[] finderArgs = null;
3689
3690 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3691 (orderByComparator == null)) {
3692 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A;
3693 finderArgs = new Object[] { classNameId, classPK, alert };
3694 }
3695 else {
3696 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A;
3697 finderArgs = new Object[] {
3698 classNameId, classPK, alert,
3699
3700 start, end, orderByComparator
3701 };
3702 }
3703
3704 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
3705 finderArgs, this);
3706
3707 if ((list != null) && !list.isEmpty()) {
3708 for (AnnouncementsEntry announcementsEntry : list) {
3709 if ((classNameId != announcementsEntry.getClassNameId()) ||
3710 (classPK != announcementsEntry.getClassPK()) ||
3711 (alert != announcementsEntry.getAlert())) {
3712 list = null;
3713
3714 break;
3715 }
3716 }
3717 }
3718
3719 if (list == null) {
3720 StringBundler query = null;
3721
3722 if (orderByComparator != null) {
3723 query = new StringBundler(5 +
3724 (orderByComparator.getOrderByFields().length * 3));
3725 }
3726 else {
3727 query = new StringBundler(5);
3728 }
3729
3730 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3731
3732 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
3733
3734 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
3735
3736 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
3737
3738 if (orderByComparator != null) {
3739 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3740 orderByComparator);
3741 }
3742
3743 else {
3744 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3745 }
3746
3747 String sql = query.toString();
3748
3749 Session session = null;
3750
3751 try {
3752 session = openSession();
3753
3754 Query q = session.createQuery(sql);
3755
3756 QueryPos qPos = QueryPos.getInstance(q);
3757
3758 qPos.add(classNameId);
3759
3760 qPos.add(classPK);
3761
3762 qPos.add(alert);
3763
3764 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3765 getDialect(), start, end);
3766 }
3767 catch (Exception e) {
3768 throw processException(e);
3769 }
3770 finally {
3771 if (list == null) {
3772 FinderCacheUtil.removeResult(finderPath, finderArgs);
3773 }
3774 else {
3775 cacheResult(list);
3776
3777 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3778 }
3779
3780 closeSession(session);
3781 }
3782 }
3783
3784 return list;
3785 }
3786
3787
3798 public AnnouncementsEntry findByC_C_A_First(long classNameId, long classPK,
3799 boolean alert, OrderByComparator orderByComparator)
3800 throws NoSuchEntryException, SystemException {
3801 AnnouncementsEntry announcementsEntry = fetchByC_C_A_First(classNameId,
3802 classPK, alert, orderByComparator);
3803
3804 if (announcementsEntry != null) {
3805 return announcementsEntry;
3806 }
3807
3808 StringBundler msg = new StringBundler(8);
3809
3810 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3811
3812 msg.append("classNameId=");
3813 msg.append(classNameId);
3814
3815 msg.append(", classPK=");
3816 msg.append(classPK);
3817
3818 msg.append(", alert=");
3819 msg.append(alert);
3820
3821 msg.append(StringPool.CLOSE_CURLY_BRACE);
3822
3823 throw new NoSuchEntryException(msg.toString());
3824 }
3825
3826
3836 public AnnouncementsEntry fetchByC_C_A_First(long classNameId,
3837 long classPK, boolean alert, OrderByComparator orderByComparator)
3838 throws SystemException {
3839 List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
3840 alert, 0, 1, orderByComparator);
3841
3842 if (!list.isEmpty()) {
3843 return list.get(0);
3844 }
3845
3846 return null;
3847 }
3848
3849
3860 public AnnouncementsEntry findByC_C_A_Last(long classNameId, long classPK,
3861 boolean alert, OrderByComparator orderByComparator)
3862 throws NoSuchEntryException, SystemException {
3863 AnnouncementsEntry announcementsEntry = fetchByC_C_A_Last(classNameId,
3864 classPK, alert, orderByComparator);
3865
3866 if (announcementsEntry != null) {
3867 return announcementsEntry;
3868 }
3869
3870 StringBundler msg = new StringBundler(8);
3871
3872 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3873
3874 msg.append("classNameId=");
3875 msg.append(classNameId);
3876
3877 msg.append(", classPK=");
3878 msg.append(classPK);
3879
3880 msg.append(", alert=");
3881 msg.append(alert);
3882
3883 msg.append(StringPool.CLOSE_CURLY_BRACE);
3884
3885 throw new NoSuchEntryException(msg.toString());
3886 }
3887
3888
3898 public AnnouncementsEntry fetchByC_C_A_Last(long classNameId, long classPK,
3899 boolean alert, OrderByComparator orderByComparator)
3900 throws SystemException {
3901 int count = countByC_C_A(classNameId, classPK, alert);
3902
3903 List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
3904 alert, count - 1, count, orderByComparator);
3905
3906 if (!list.isEmpty()) {
3907 return list.get(0);
3908 }
3909
3910 return null;
3911 }
3912
3913
3925 public AnnouncementsEntry[] findByC_C_A_PrevAndNext(long entryId,
3926 long classNameId, long classPK, boolean alert,
3927 OrderByComparator orderByComparator)
3928 throws NoSuchEntryException, SystemException {
3929 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3930
3931 Session session = null;
3932
3933 try {
3934 session = openSession();
3935
3936 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3937
3938 array[0] = getByC_C_A_PrevAndNext(session, announcementsEntry,
3939 classNameId, classPK, alert, orderByComparator, true);
3940
3941 array[1] = announcementsEntry;
3942
3943 array[2] = getByC_C_A_PrevAndNext(session, announcementsEntry,
3944 classNameId, classPK, alert, orderByComparator, false);
3945
3946 return array;
3947 }
3948 catch (Exception e) {
3949 throw processException(e);
3950 }
3951 finally {
3952 closeSession(session);
3953 }
3954 }
3955
3956 protected AnnouncementsEntry getByC_C_A_PrevAndNext(Session session,
3957 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3958 boolean alert, OrderByComparator orderByComparator, boolean previous) {
3959 StringBundler query = null;
3960
3961 if (orderByComparator != null) {
3962 query = new StringBundler(6 +
3963 (orderByComparator.getOrderByFields().length * 6));
3964 }
3965 else {
3966 query = new StringBundler(3);
3967 }
3968
3969 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3970
3971 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
3972
3973 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
3974
3975 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
3976
3977 if (orderByComparator != null) {
3978 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3979
3980 if (orderByConditionFields.length > 0) {
3981 query.append(WHERE_AND);
3982 }
3983
3984 for (int i = 0; i < orderByConditionFields.length; i++) {
3985 query.append(_ORDER_BY_ENTITY_ALIAS);
3986 query.append(orderByConditionFields[i]);
3987
3988 if ((i + 1) < orderByConditionFields.length) {
3989 if (orderByComparator.isAscending() ^ previous) {
3990 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3991 }
3992 else {
3993 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3994 }
3995 }
3996 else {
3997 if (orderByComparator.isAscending() ^ previous) {
3998 query.append(WHERE_GREATER_THAN);
3999 }
4000 else {
4001 query.append(WHERE_LESSER_THAN);
4002 }
4003 }
4004 }
4005
4006 query.append(ORDER_BY_CLAUSE);
4007
4008 String[] orderByFields = orderByComparator.getOrderByFields();
4009
4010 for (int i = 0; i < orderByFields.length; i++) {
4011 query.append(_ORDER_BY_ENTITY_ALIAS);
4012 query.append(orderByFields[i]);
4013
4014 if ((i + 1) < orderByFields.length) {
4015 if (orderByComparator.isAscending() ^ previous) {
4016 query.append(ORDER_BY_ASC_HAS_NEXT);
4017 }
4018 else {
4019 query.append(ORDER_BY_DESC_HAS_NEXT);
4020 }
4021 }
4022 else {
4023 if (orderByComparator.isAscending() ^ previous) {
4024 query.append(ORDER_BY_ASC);
4025 }
4026 else {
4027 query.append(ORDER_BY_DESC);
4028 }
4029 }
4030 }
4031 }
4032
4033 else {
4034 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4035 }
4036
4037 String sql = query.toString();
4038
4039 Query q = session.createQuery(sql);
4040
4041 q.setFirstResult(0);
4042 q.setMaxResults(2);
4043
4044 QueryPos qPos = QueryPos.getInstance(q);
4045
4046 qPos.add(classNameId);
4047
4048 qPos.add(classPK);
4049
4050 qPos.add(alert);
4051
4052 if (orderByComparator != null) {
4053 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
4054
4055 for (Object value : values) {
4056 qPos.add(value);
4057 }
4058 }
4059
4060 List<AnnouncementsEntry> list = q.list();
4061
4062 if (list.size() == 2) {
4063 return list.get(1);
4064 }
4065 else {
4066 return null;
4067 }
4068 }
4069
4070
4079 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4080 long classPK, boolean alert) throws SystemException {
4081 return filterFindByC_C_A(classNameId, classPK, alert,
4082 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4083 }
4084
4085
4100 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4101 long classPK, boolean alert, int start, int end)
4102 throws SystemException {
4103 return filterFindByC_C_A(classNameId, classPK, alert, start, end, null);
4104 }
4105
4106
4122 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4123 long classPK, boolean alert, int start, int end,
4124 OrderByComparator orderByComparator) throws SystemException {
4125 if (!InlineSQLHelperUtil.isEnabled()) {
4126 return findByC_C_A(classNameId, classPK, alert, start, end,
4127 orderByComparator);
4128 }
4129
4130 StringBundler query = null;
4131
4132 if (orderByComparator != null) {
4133 query = new StringBundler(5 +
4134 (orderByComparator.getOrderByFields().length * 3));
4135 }
4136 else {
4137 query = new StringBundler(5);
4138 }
4139
4140 if (getDB().isSupportsInlineDistinct()) {
4141 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4142 }
4143 else {
4144 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4145 }
4146
4147 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4148
4149 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4150
4151 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4152
4153 if (!getDB().isSupportsInlineDistinct()) {
4154 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4155 }
4156
4157 if (orderByComparator != null) {
4158 if (getDB().isSupportsInlineDistinct()) {
4159 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4160 orderByComparator);
4161 }
4162 else {
4163 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4164 orderByComparator);
4165 }
4166 }
4167
4168 else {
4169 if (getDB().isSupportsInlineDistinct()) {
4170 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4171 }
4172 else {
4173 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
4174 }
4175 }
4176
4177 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4178 AnnouncementsEntry.class.getName(),
4179 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4180
4181 Session session = null;
4182
4183 try {
4184 session = openSession();
4185
4186 SQLQuery q = session.createSQLQuery(sql);
4187
4188 if (getDB().isSupportsInlineDistinct()) {
4189 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
4190 }
4191 else {
4192 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
4193 }
4194
4195 QueryPos qPos = QueryPos.getInstance(q);
4196
4197 qPos.add(classNameId);
4198
4199 qPos.add(classPK);
4200
4201 qPos.add(alert);
4202
4203 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
4204 start, end);
4205 }
4206 catch (Exception e) {
4207 throw processException(e);
4208 }
4209 finally {
4210 closeSession(session);
4211 }
4212 }
4213
4214
4226 public AnnouncementsEntry[] filterFindByC_C_A_PrevAndNext(long entryId,
4227 long classNameId, long classPK, boolean alert,
4228 OrderByComparator orderByComparator)
4229 throws NoSuchEntryException, SystemException {
4230 if (!InlineSQLHelperUtil.isEnabled()) {
4231 return findByC_C_A_PrevAndNext(entryId, classNameId, classPK,
4232 alert, orderByComparator);
4233 }
4234
4235 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
4236
4237 Session session = null;
4238
4239 try {
4240 session = openSession();
4241
4242 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
4243
4244 array[0] = filterGetByC_C_A_PrevAndNext(session,
4245 announcementsEntry, classNameId, classPK, alert,
4246 orderByComparator, true);
4247
4248 array[1] = announcementsEntry;
4249
4250 array[2] = filterGetByC_C_A_PrevAndNext(session,
4251 announcementsEntry, classNameId, classPK, alert,
4252 orderByComparator, false);
4253
4254 return array;
4255 }
4256 catch (Exception e) {
4257 throw processException(e);
4258 }
4259 finally {
4260 closeSession(session);
4261 }
4262 }
4263
4264 protected AnnouncementsEntry filterGetByC_C_A_PrevAndNext(Session session,
4265 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
4266 boolean alert, OrderByComparator orderByComparator, boolean previous) {
4267 StringBundler query = null;
4268
4269 if (orderByComparator != null) {
4270 query = new StringBundler(6 +
4271 (orderByComparator.getOrderByFields().length * 6));
4272 }
4273 else {
4274 query = new StringBundler(3);
4275 }
4276
4277 if (getDB().isSupportsInlineDistinct()) {
4278 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4279 }
4280 else {
4281 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4282 }
4283
4284 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4285
4286 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4287
4288 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4289
4290 if (!getDB().isSupportsInlineDistinct()) {
4291 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4292 }
4293
4294 if (orderByComparator != null) {
4295 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4296
4297 if (orderByConditionFields.length > 0) {
4298 query.append(WHERE_AND);
4299 }
4300
4301 for (int i = 0; i < orderByConditionFields.length; i++) {
4302 if (getDB().isSupportsInlineDistinct()) {
4303 query.append(_ORDER_BY_ENTITY_ALIAS);
4304 }
4305 else {
4306 query.append(_ORDER_BY_ENTITY_TABLE);
4307 }
4308
4309 query.append(orderByConditionFields[i]);
4310
4311 if ((i + 1) < orderByConditionFields.length) {
4312 if (orderByComparator.isAscending() ^ previous) {
4313 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4314 }
4315 else {
4316 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4317 }
4318 }
4319 else {
4320 if (orderByComparator.isAscending() ^ previous) {
4321 query.append(WHERE_GREATER_THAN);
4322 }
4323 else {
4324 query.append(WHERE_LESSER_THAN);
4325 }
4326 }
4327 }
4328
4329 query.append(ORDER_BY_CLAUSE);
4330
4331 String[] orderByFields = orderByComparator.getOrderByFields();
4332
4333 for (int i = 0; i < orderByFields.length; i++) {
4334 if (getDB().isSupportsInlineDistinct()) {
4335 query.append(_ORDER_BY_ENTITY_ALIAS);
4336 }
4337 else {
4338 query.append(_ORDER_BY_ENTITY_TABLE);
4339 }
4340
4341 query.append(orderByFields[i]);
4342
4343 if ((i + 1) < orderByFields.length) {
4344 if (orderByComparator.isAscending() ^ previous) {
4345 query.append(ORDER_BY_ASC_HAS_NEXT);
4346 }
4347 else {
4348 query.append(ORDER_BY_DESC_HAS_NEXT);
4349 }
4350 }
4351 else {
4352 if (orderByComparator.isAscending() ^ previous) {
4353 query.append(ORDER_BY_ASC);
4354 }
4355 else {
4356 query.append(ORDER_BY_DESC);
4357 }
4358 }
4359 }
4360 }
4361
4362 else {
4363 if (getDB().isSupportsInlineDistinct()) {
4364 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4365 }
4366 else {
4367 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
4368 }
4369 }
4370
4371 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4372 AnnouncementsEntry.class.getName(),
4373 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4374
4375 SQLQuery q = session.createSQLQuery(sql);
4376
4377 q.setFirstResult(0);
4378 q.setMaxResults(2);
4379
4380 if (getDB().isSupportsInlineDistinct()) {
4381 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
4382 }
4383 else {
4384 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
4385 }
4386
4387 QueryPos qPos = QueryPos.getInstance(q);
4388
4389 qPos.add(classNameId);
4390
4391 qPos.add(classPK);
4392
4393 qPos.add(alert);
4394
4395 if (orderByComparator != null) {
4396 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
4397
4398 for (Object value : values) {
4399 qPos.add(value);
4400 }
4401 }
4402
4403 List<AnnouncementsEntry> list = q.list();
4404
4405 if (list.size() == 2) {
4406 return list.get(1);
4407 }
4408 else {
4409 return null;
4410 }
4411 }
4412
4413
4419 public List<AnnouncementsEntry> findAll() throws SystemException {
4420 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4421 }
4422
4423
4435 public List<AnnouncementsEntry> findAll(int start, int end)
4436 throws SystemException {
4437 return findAll(start, end, null);
4438 }
4439
4440
4453 public List<AnnouncementsEntry> findAll(int start, int end,
4454 OrderByComparator orderByComparator) throws SystemException {
4455 FinderPath finderPath = null;
4456 Object[] finderArgs = new Object[] { start, end, orderByComparator };
4457
4458 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4459 (orderByComparator == null)) {
4460 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4461 finderArgs = FINDER_ARGS_EMPTY;
4462 }
4463 else {
4464 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4465 finderArgs = new Object[] { start, end, orderByComparator };
4466 }
4467
4468 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
4469 finderArgs, this);
4470
4471 if (list == null) {
4472 StringBundler query = null;
4473 String sql = null;
4474
4475 if (orderByComparator != null) {
4476 query = new StringBundler(2 +
4477 (orderByComparator.getOrderByFields().length * 3));
4478
4479 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY);
4480
4481 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4482 orderByComparator);
4483
4484 sql = query.toString();
4485 }
4486 else {
4487 sql = _SQL_SELECT_ANNOUNCEMENTSENTRY.concat(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4488 }
4489
4490 Session session = null;
4491
4492 try {
4493 session = openSession();
4494
4495 Query q = session.createQuery(sql);
4496
4497 if (orderByComparator == null) {
4498 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
4499 getDialect(), start, end, false);
4500
4501 Collections.sort(list);
4502 }
4503 else {
4504 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
4505 getDialect(), start, end);
4506 }
4507 }
4508 catch (Exception e) {
4509 throw processException(e);
4510 }
4511 finally {
4512 if (list == null) {
4513 FinderCacheUtil.removeResult(finderPath, finderArgs);
4514 }
4515 else {
4516 cacheResult(list);
4517
4518 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4519 }
4520
4521 closeSession(session);
4522 }
4523 }
4524
4525 return list;
4526 }
4527
4528
4534 public void removeByUuid(String uuid) throws SystemException {
4535 for (AnnouncementsEntry announcementsEntry : findByUuid(uuid)) {
4536 remove(announcementsEntry);
4537 }
4538 }
4539
4540
4547 public void removeByUuid_C(String uuid, long companyId)
4548 throws SystemException {
4549 for (AnnouncementsEntry announcementsEntry : findByUuid_C(uuid,
4550 companyId)) {
4551 remove(announcementsEntry);
4552 }
4553 }
4554
4555
4561 public void removeByUserId(long userId) throws SystemException {
4562 for (AnnouncementsEntry announcementsEntry : findByUserId(userId)) {
4563 remove(announcementsEntry);
4564 }
4565 }
4566
4567
4574 public void removeByC_C(long classNameId, long classPK)
4575 throws SystemException {
4576 for (AnnouncementsEntry announcementsEntry : findByC_C(classNameId,
4577 classPK)) {
4578 remove(announcementsEntry);
4579 }
4580 }
4581
4582
4590 public void removeByC_C_A(long classNameId, long classPK, boolean alert)
4591 throws SystemException {
4592 for (AnnouncementsEntry announcementsEntry : findByC_C_A(classNameId,
4593 classPK, alert)) {
4594 remove(announcementsEntry);
4595 }
4596 }
4597
4598
4603 public void removeAll() throws SystemException {
4604 for (AnnouncementsEntry announcementsEntry : findAll()) {
4605 remove(announcementsEntry);
4606 }
4607 }
4608
4609
4616 public int countByUuid(String uuid) throws SystemException {
4617 Object[] finderArgs = new Object[] { uuid };
4618
4619 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4620 finderArgs, this);
4621
4622 if (count == null) {
4623 StringBundler query = new StringBundler(2);
4624
4625 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4626
4627 if (uuid == null) {
4628 query.append(_FINDER_COLUMN_UUID_UUID_1);
4629 }
4630 else {
4631 if (uuid.equals(StringPool.BLANK)) {
4632 query.append(_FINDER_COLUMN_UUID_UUID_3);
4633 }
4634 else {
4635 query.append(_FINDER_COLUMN_UUID_UUID_2);
4636 }
4637 }
4638
4639 String sql = query.toString();
4640
4641 Session session = null;
4642
4643 try {
4644 session = openSession();
4645
4646 Query q = session.createQuery(sql);
4647
4648 QueryPos qPos = QueryPos.getInstance(q);
4649
4650 if (uuid != null) {
4651 qPos.add(uuid);
4652 }
4653
4654 count = (Long)q.uniqueResult();
4655 }
4656 catch (Exception e) {
4657 throw processException(e);
4658 }
4659 finally {
4660 if (count == null) {
4661 count = Long.valueOf(0);
4662 }
4663
4664 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4665 finderArgs, count);
4666
4667 closeSession(session);
4668 }
4669 }
4670
4671 return count.intValue();
4672 }
4673
4674
4681 public int filterCountByUuid(String uuid) throws SystemException {
4682 if (!InlineSQLHelperUtil.isEnabled()) {
4683 return countByUuid(uuid);
4684 }
4685
4686 StringBundler query = new StringBundler(2);
4687
4688 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4689
4690 if (uuid == null) {
4691 query.append(_FINDER_COLUMN_UUID_UUID_1);
4692 }
4693 else {
4694 if (uuid.equals(StringPool.BLANK)) {
4695 query.append(_FINDER_COLUMN_UUID_UUID_3);
4696 }
4697 else {
4698 query.append(_FINDER_COLUMN_UUID_UUID_2);
4699 }
4700 }
4701
4702 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4703 AnnouncementsEntry.class.getName(),
4704 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4705
4706 Session session = null;
4707
4708 try {
4709 session = openSession();
4710
4711 SQLQuery q = session.createSQLQuery(sql);
4712
4713 q.addScalar(COUNT_COLUMN_NAME,
4714 com.liferay.portal.kernel.dao.orm.Type.LONG);
4715
4716 QueryPos qPos = QueryPos.getInstance(q);
4717
4718 if (uuid != null) {
4719 qPos.add(uuid);
4720 }
4721
4722 Long count = (Long)q.uniqueResult();
4723
4724 return count.intValue();
4725 }
4726 catch (Exception e) {
4727 throw processException(e);
4728 }
4729 finally {
4730 closeSession(session);
4731 }
4732 }
4733
4734
4742 public int countByUuid_C(String uuid, long companyId)
4743 throws SystemException {
4744 Object[] finderArgs = new Object[] { uuid, companyId };
4745
4746 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
4747 finderArgs, this);
4748
4749 if (count == null) {
4750 StringBundler query = new StringBundler(3);
4751
4752 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4753
4754 if (uuid == null) {
4755 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
4756 }
4757 else {
4758 if (uuid.equals(StringPool.BLANK)) {
4759 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
4760 }
4761 else {
4762 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
4763 }
4764 }
4765
4766 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
4767
4768 String sql = query.toString();
4769
4770 Session session = null;
4771
4772 try {
4773 session = openSession();
4774
4775 Query q = session.createQuery(sql);
4776
4777 QueryPos qPos = QueryPos.getInstance(q);
4778
4779 if (uuid != null) {
4780 qPos.add(uuid);
4781 }
4782
4783 qPos.add(companyId);
4784
4785 count = (Long)q.uniqueResult();
4786 }
4787 catch (Exception e) {
4788 throw processException(e);
4789 }
4790 finally {
4791 if (count == null) {
4792 count = Long.valueOf(0);
4793 }
4794
4795 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
4796 finderArgs, count);
4797
4798 closeSession(session);
4799 }
4800 }
4801
4802 return count.intValue();
4803 }
4804
4805
4813 public int filterCountByUuid_C(String uuid, long companyId)
4814 throws SystemException {
4815 if (!InlineSQLHelperUtil.isEnabled()) {
4816 return countByUuid_C(uuid, companyId);
4817 }
4818
4819 StringBundler query = new StringBundler(3);
4820
4821 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4822
4823 if (uuid == null) {
4824 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
4825 }
4826 else {
4827 if (uuid.equals(StringPool.BLANK)) {
4828 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
4829 }
4830 else {
4831 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
4832 }
4833 }
4834
4835 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
4836
4837 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4838 AnnouncementsEntry.class.getName(),
4839 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4840
4841 Session session = null;
4842
4843 try {
4844 session = openSession();
4845
4846 SQLQuery q = session.createSQLQuery(sql);
4847
4848 q.addScalar(COUNT_COLUMN_NAME,
4849 com.liferay.portal.kernel.dao.orm.Type.LONG);
4850
4851 QueryPos qPos = QueryPos.getInstance(q);
4852
4853 if (uuid != null) {
4854 qPos.add(uuid);
4855 }
4856
4857 qPos.add(companyId);
4858
4859 Long count = (Long)q.uniqueResult();
4860
4861 return count.intValue();
4862 }
4863 catch (Exception e) {
4864 throw processException(e);
4865 }
4866 finally {
4867 closeSession(session);
4868 }
4869 }
4870
4871
4878 public int countByUserId(long userId) throws SystemException {
4879 Object[] finderArgs = new Object[] { userId };
4880
4881 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
4882 finderArgs, this);
4883
4884 if (count == null) {
4885 StringBundler query = new StringBundler(2);
4886
4887 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4888
4889 query.append(_FINDER_COLUMN_USERID_USERID_2);
4890
4891 String sql = query.toString();
4892
4893 Session session = null;
4894
4895 try {
4896 session = openSession();
4897
4898 Query q = session.createQuery(sql);
4899
4900 QueryPos qPos = QueryPos.getInstance(q);
4901
4902 qPos.add(userId);
4903
4904 count = (Long)q.uniqueResult();
4905 }
4906 catch (Exception e) {
4907 throw processException(e);
4908 }
4909 finally {
4910 if (count == null) {
4911 count = Long.valueOf(0);
4912 }
4913
4914 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
4915 finderArgs, count);
4916
4917 closeSession(session);
4918 }
4919 }
4920
4921 return count.intValue();
4922 }
4923
4924
4931 public int filterCountByUserId(long userId) throws SystemException {
4932 if (!InlineSQLHelperUtil.isEnabled()) {
4933 return countByUserId(userId);
4934 }
4935
4936 StringBundler query = new StringBundler(2);
4937
4938 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4939
4940 query.append(_FINDER_COLUMN_USERID_USERID_2);
4941
4942 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4943 AnnouncementsEntry.class.getName(),
4944 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4945
4946 Session session = null;
4947
4948 try {
4949 session = openSession();
4950
4951 SQLQuery q = session.createSQLQuery(sql);
4952
4953 q.addScalar(COUNT_COLUMN_NAME,
4954 com.liferay.portal.kernel.dao.orm.Type.LONG);
4955
4956 QueryPos qPos = QueryPos.getInstance(q);
4957
4958 qPos.add(userId);
4959
4960 Long count = (Long)q.uniqueResult();
4961
4962 return count.intValue();
4963 }
4964 catch (Exception e) {
4965 throw processException(e);
4966 }
4967 finally {
4968 closeSession(session);
4969 }
4970 }
4971
4972
4980 public int countByC_C(long classNameId, long classPK)
4981 throws SystemException {
4982 Object[] finderArgs = new Object[] { classNameId, classPK };
4983
4984 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
4985 finderArgs, this);
4986
4987 if (count == null) {
4988 StringBundler query = new StringBundler(3);
4989
4990 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4991
4992 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
4993
4994 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
4995
4996 String sql = query.toString();
4997
4998 Session session = null;
4999
5000 try {
5001 session = openSession();
5002
5003 Query q = session.createQuery(sql);
5004
5005 QueryPos qPos = QueryPos.getInstance(q);
5006
5007 qPos.add(classNameId);
5008
5009 qPos.add(classPK);
5010
5011 count = (Long)q.uniqueResult();
5012 }
5013 catch (Exception e) {
5014 throw processException(e);
5015 }
5016 finally {
5017 if (count == null) {
5018 count = Long.valueOf(0);
5019 }
5020
5021 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
5022 count);
5023
5024 closeSession(session);
5025 }
5026 }
5027
5028 return count.intValue();
5029 }
5030
5031
5039 public int filterCountByC_C(long classNameId, long classPK)
5040 throws SystemException {
5041 if (!InlineSQLHelperUtil.isEnabled()) {
5042 return countByC_C(classNameId, classPK);
5043 }
5044
5045 StringBundler query = new StringBundler(3);
5046
5047 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
5048
5049 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
5050
5051 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
5052
5053 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5054 AnnouncementsEntry.class.getName(),
5055 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
5056
5057 Session session = null;
5058
5059 try {
5060 session = openSession();
5061
5062 SQLQuery q = session.createSQLQuery(sql);
5063
5064 q.addScalar(COUNT_COLUMN_NAME,
5065 com.liferay.portal.kernel.dao.orm.Type.LONG);
5066
5067 QueryPos qPos = QueryPos.getInstance(q);
5068
5069 qPos.add(classNameId);
5070
5071 qPos.add(classPK);
5072
5073 Long count = (Long)q.uniqueResult();
5074
5075 return count.intValue();
5076 }
5077 catch (Exception e) {
5078 throw processException(e);
5079 }
5080 finally {
5081 closeSession(session);
5082 }
5083 }
5084
5085
5094 public int countByC_C_A(long classNameId, long classPK, boolean alert)
5095 throws SystemException {
5096 Object[] finderArgs = new Object[] { classNameId, classPK, alert };
5097
5098 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_A,
5099 finderArgs, this);
5100
5101 if (count == null) {
5102 StringBundler query = new StringBundler(4);
5103
5104 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
5105
5106 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
5107
5108 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
5109
5110 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
5111
5112 String sql = query.toString();
5113
5114 Session session = null;
5115
5116 try {
5117 session = openSession();
5118
5119 Query q = session.createQuery(sql);
5120
5121 QueryPos qPos = QueryPos.getInstance(q);
5122
5123 qPos.add(classNameId);
5124
5125 qPos.add(classPK);
5126
5127 qPos.add(alert);
5128
5129 count = (Long)q.uniqueResult();
5130 }
5131 catch (Exception e) {
5132 throw processException(e);
5133 }
5134 finally {
5135 if (count == null) {
5136 count = Long.valueOf(0);
5137 }
5138
5139 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_A,
5140 finderArgs, count);
5141
5142 closeSession(session);
5143 }
5144 }
5145
5146 return count.intValue();
5147 }
5148
5149
5158 public int filterCountByC_C_A(long classNameId, long classPK, boolean alert)
5159 throws SystemException {
5160 if (!InlineSQLHelperUtil.isEnabled()) {
5161 return countByC_C_A(classNameId, classPK, alert);
5162 }
5163
5164 StringBundler query = new StringBundler(4);
5165
5166 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
5167
5168 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
5169
5170 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
5171
5172 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
5173
5174 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5175 AnnouncementsEntry.class.getName(),
5176 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
5177
5178 Session session = null;
5179
5180 try {
5181 session = openSession();
5182
5183 SQLQuery q = session.createSQLQuery(sql);
5184
5185 q.addScalar(COUNT_COLUMN_NAME,
5186 com.liferay.portal.kernel.dao.orm.Type.LONG);
5187
5188 QueryPos qPos = QueryPos.getInstance(q);
5189
5190 qPos.add(classNameId);
5191
5192 qPos.add(classPK);
5193
5194 qPos.add(alert);
5195
5196 Long count = (Long)q.uniqueResult();
5197
5198 return count.intValue();
5199 }
5200 catch (Exception e) {
5201 throw processException(e);
5202 }
5203 finally {
5204 closeSession(session);
5205 }
5206 }
5207
5208
5214 public int countAll() throws SystemException {
5215 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5216 FINDER_ARGS_EMPTY, this);
5217
5218 if (count == null) {
5219 Session session = null;
5220
5221 try {
5222 session = openSession();
5223
5224 Query q = session.createQuery(_SQL_COUNT_ANNOUNCEMENTSENTRY);
5225
5226 count = (Long)q.uniqueResult();
5227 }
5228 catch (Exception e) {
5229 throw processException(e);
5230 }
5231 finally {
5232 if (count == null) {
5233 count = Long.valueOf(0);
5234 }
5235
5236 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5237 FINDER_ARGS_EMPTY, count);
5238
5239 closeSession(session);
5240 }
5241 }
5242
5243 return count.intValue();
5244 }
5245
5246
5249 public void afterPropertiesSet() {
5250 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5251 com.liferay.portal.util.PropsUtil.get(
5252 "value.object.listener.com.liferay.portlet.announcements.model.AnnouncementsEntry")));
5253
5254 if (listenerClassNames.length > 0) {
5255 try {
5256 List<ModelListener<AnnouncementsEntry>> listenersList = new ArrayList<ModelListener<AnnouncementsEntry>>();
5257
5258 for (String listenerClassName : listenerClassNames) {
5259 listenersList.add((ModelListener<AnnouncementsEntry>)InstanceFactory.newInstance(
5260 listenerClassName));
5261 }
5262
5263 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5264 }
5265 catch (Exception e) {
5266 _log.error(e);
5267 }
5268 }
5269 }
5270
5271 public void destroy() {
5272 EntityCacheUtil.removeCache(AnnouncementsEntryImpl.class.getName());
5273 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5274 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5275 }
5276
5277 @BeanReference(type = AnnouncementsDeliveryPersistence.class)
5278 protected AnnouncementsDeliveryPersistence announcementsDeliveryPersistence;
5279 @BeanReference(type = AnnouncementsEntryPersistence.class)
5280 protected AnnouncementsEntryPersistence announcementsEntryPersistence;
5281 @BeanReference(type = AnnouncementsFlagPersistence.class)
5282 protected AnnouncementsFlagPersistence announcementsFlagPersistence;
5283 @BeanReference(type = CompanyPersistence.class)
5284 protected CompanyPersistence companyPersistence;
5285 @BeanReference(type = GroupPersistence.class)
5286 protected GroupPersistence groupPersistence;
5287 @BeanReference(type = OrganizationPersistence.class)
5288 protected OrganizationPersistence organizationPersistence;
5289 @BeanReference(type = RolePersistence.class)
5290 protected RolePersistence rolePersistence;
5291 @BeanReference(type = UserPersistence.class)
5292 protected UserPersistence userPersistence;
5293 @BeanReference(type = UserGroupPersistence.class)
5294 protected UserGroupPersistence userGroupPersistence;
5295 private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry";
5296 private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry WHERE ";
5297 private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry";
5298 private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry WHERE ";
5299 private static final String _FINDER_COLUMN_UUID_UUID_1 = "announcementsEntry.uuid IS NULL";
5300 private static final String _FINDER_COLUMN_UUID_UUID_2 = "announcementsEntry.uuid = ?";
5301 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = ?)";
5302 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "announcementsEntry.uuid IS NULL AND ";
5303 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "announcementsEntry.uuid = ? AND ";
5304 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = ?) AND ";
5305 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "announcementsEntry.companyId = ?";
5306 private static final String _FINDER_COLUMN_USERID_USERID_2 = "announcementsEntry.userId = ?";
5307 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
5308 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "announcementsEntry.classPK = ?";
5309 private static final String _FINDER_COLUMN_C_C_A_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
5310 private static final String _FINDER_COLUMN_C_C_A_CLASSPK_2 = "announcementsEntry.classPK = ? AND ";
5311 private static final String _FINDER_COLUMN_C_C_A_ALERT_2 = "announcementsEntry.alert = ?";
5312 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "announcementsEntry.entryId";
5313 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT DISTINCT {announcementsEntry.*} FROM AnnouncementsEntry announcementsEntry WHERE ";
5314 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
5315 "SELECT {AnnouncementsEntry.*} FROM (SELECT DISTINCT announcementsEntry.entryId FROM AnnouncementsEntry announcementsEntry WHERE ";
5316 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
5317 ") TEMP_TABLE INNER JOIN AnnouncementsEntry ON TEMP_TABLE.entryId = AnnouncementsEntry.entryId";
5318 private static final String _FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(DISTINCT announcementsEntry.entryId) AS COUNT_VALUE FROM AnnouncementsEntry announcementsEntry WHERE ";
5319 private static final String _FILTER_ENTITY_ALIAS = "announcementsEntry";
5320 private static final String _FILTER_ENTITY_TABLE = "AnnouncementsEntry";
5321 private static final String _ORDER_BY_ENTITY_ALIAS = "announcementsEntry.";
5322 private static final String _ORDER_BY_ENTITY_TABLE = "AnnouncementsEntry.";
5323 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AnnouncementsEntry exists with the primary key ";
5324 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AnnouncementsEntry exists with the key {";
5325 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5326 private static Log _log = LogFactoryUtil.getLog(AnnouncementsEntryPersistenceImpl.class);
5327 private static AnnouncementsEntry _nullAnnouncementsEntry = new AnnouncementsEntryImpl() {
5328 @Override
5329 public Object clone() {
5330 return this;
5331 }
5332
5333 @Override
5334 public CacheModel<AnnouncementsEntry> toCacheModel() {
5335 return _nullAnnouncementsEntryCacheModel;
5336 }
5337 };
5338
5339 private static CacheModel<AnnouncementsEntry> _nullAnnouncementsEntryCacheModel =
5340 new CacheModel<AnnouncementsEntry>() {
5341 public AnnouncementsEntry toEntityModel() {
5342 return _nullAnnouncementsEntry;
5343 }
5344 };
5345 }