001
014
015 package com.liferay.portlet.journal.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.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.service.persistence.BatchSessionUtil;
040 import com.liferay.portal.service.persistence.GroupPersistence;
041 import com.liferay.portal.service.persistence.LayoutPersistence;
042 import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
043 import com.liferay.portal.service.persistence.ResourcePersistence;
044 import com.liferay.portal.service.persistence.UserPersistence;
045 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046
047 import com.liferay.portlet.journal.NoSuchContentSearchException;
048 import com.liferay.portlet.journal.model.JournalContentSearch;
049 import com.liferay.portlet.journal.model.impl.JournalContentSearchImpl;
050 import com.liferay.portlet.journal.model.impl.JournalContentSearchModelImpl;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057
058
070 public class JournalContentSearchPersistenceImpl extends BasePersistenceImpl<JournalContentSearch>
071 implements JournalContentSearchPersistence {
072
077 public static final String FINDER_CLASS_NAME_ENTITY = JournalContentSearchImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List1";
080 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List2";
082 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ARTICLEID =
083 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
084 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
085 JournalContentSearchImpl.class,
086 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByArticleId",
087 new String[] {
088 String.class.getName(),
089
090 "java.lang.Integer", "java.lang.Integer",
091 "com.liferay.portal.kernel.util.OrderByComparator"
092 });
093 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID =
094 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
095 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
096 JournalContentSearchImpl.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByArticleId",
098 new String[] { String.class.getName() },
099 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
100 public static final FinderPath FINDER_PATH_COUNT_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
101 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByArticleId",
103 new String[] { String.class.getName() });
104 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
105 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
106 JournalContentSearchImpl.class,
107 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
108 new String[] {
109 Long.class.getName(), Boolean.class.getName(),
110
111 "java.lang.Integer", "java.lang.Integer",
112 "com.liferay.portal.kernel.util.OrderByComparator"
113 });
114 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
115 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
116 JournalContentSearchImpl.class,
117 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
118 new String[] { Long.class.getName(), Boolean.class.getName() },
119 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
120 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK);
121 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
122 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
123 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
124 new String[] { Long.class.getName(), Boolean.class.getName() });
125 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
126 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
127 JournalContentSearchImpl.class,
128 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_A",
129 new String[] {
130 Long.class.getName(), String.class.getName(),
131
132 "java.lang.Integer", "java.lang.Integer",
133 "com.liferay.portal.kernel.util.OrderByComparator"
134 });
135 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
136 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
137 JournalContentSearchImpl.class,
138 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
139 new String[] { Long.class.getName(), String.class.getName() },
140 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
141 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
142 public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
143 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
144 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
145 new String[] { Long.class.getName(), String.class.getName() });
146 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
147 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
148 JournalContentSearchImpl.class,
149 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_L",
150 new String[] {
151 Long.class.getName(), Boolean.class.getName(),
152 Long.class.getName(),
153
154 "java.lang.Integer", "java.lang.Integer",
155 "com.liferay.portal.kernel.util.OrderByComparator"
156 });
157 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
158 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
159 JournalContentSearchImpl.class,
160 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_L",
161 new String[] {
162 Long.class.getName(), Boolean.class.getName(),
163 Long.class.getName()
164 },
165 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
166 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
167 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK);
168 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
169 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
170 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L",
171 new String[] {
172 Long.class.getName(), Boolean.class.getName(),
173 Long.class.getName()
174 });
175 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
176 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
177 JournalContentSearchImpl.class,
178 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_A",
179 new String[] {
180 Long.class.getName(), Boolean.class.getName(),
181 String.class.getName(),
182
183 "java.lang.Integer", "java.lang.Integer",
184 "com.liferay.portal.kernel.util.OrderByComparator"
185 });
186 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
187 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
188 JournalContentSearchImpl.class,
189 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_A",
190 new String[] {
191 Long.class.getName(), Boolean.class.getName(),
192 String.class.getName()
193 },
194 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
195 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
196 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
197 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
198 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
199 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_A",
200 new String[] {
201 Long.class.getName(), Boolean.class.getName(),
202 String.class.getName()
203 });
204 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
205 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
206 JournalContentSearchImpl.class,
207 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_L_P",
208 new String[] {
209 Long.class.getName(), Boolean.class.getName(),
210 Long.class.getName(), String.class.getName(),
211
212 "java.lang.Integer", "java.lang.Integer",
213 "com.liferay.portal.kernel.util.OrderByComparator"
214 });
215 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P =
216 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
217 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
218 JournalContentSearchImpl.class,
219 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_L_P",
220 new String[] {
221 Long.class.getName(), Boolean.class.getName(),
222 Long.class.getName(), String.class.getName()
223 },
224 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
225 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
226 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK |
227 JournalContentSearchModelImpl.PORTLETID_COLUMN_BITMASK);
228 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
229 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
230 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L_P",
231 new String[] {
232 Long.class.getName(), Boolean.class.getName(),
233 Long.class.getName(), String.class.getName()
234 });
235 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
236 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
237 JournalContentSearchImpl.class, FINDER_CLASS_NAME_ENTITY,
238 "fetchByG_P_L_P_A",
239 new String[] {
240 Long.class.getName(), Boolean.class.getName(),
241 Long.class.getName(), String.class.getName(),
242 String.class.getName()
243 },
244 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
245 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
246 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK |
247 JournalContentSearchModelImpl.PORTLETID_COLUMN_BITMASK |
248 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
249 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
250 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
251 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L_P_A",
252 new String[] {
253 Long.class.getName(), Boolean.class.getName(),
254 Long.class.getName(), String.class.getName(),
255 String.class.getName()
256 });
257 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
258 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
259 JournalContentSearchImpl.class,
260 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
261 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
262 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
263 JournalContentSearchImpl.class,
264 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
265 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
266 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
267 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
268
269
274 public void cacheResult(JournalContentSearch journalContentSearch) {
275 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
276 JournalContentSearchImpl.class,
277 journalContentSearch.getPrimaryKey(), journalContentSearch);
278
279 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
280 new Object[] {
281 Long.valueOf(journalContentSearch.getGroupId()),
282 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
283 Long.valueOf(journalContentSearch.getLayoutId()),
284
285 journalContentSearch.getPortletId(),
286
287 journalContentSearch.getArticleId()
288 }, journalContentSearch);
289
290 journalContentSearch.resetOriginalValues();
291 }
292
293
298 public void cacheResult(List<JournalContentSearch> journalContentSearchs) {
299 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
300 if (EntityCacheUtil.getResult(
301 JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
302 JournalContentSearchImpl.class,
303 journalContentSearch.getPrimaryKey()) == null) {
304 cacheResult(journalContentSearch);
305 }
306 else {
307 journalContentSearch.resetOriginalValues();
308 }
309 }
310 }
311
312
319 @Override
320 public void clearCache() {
321 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
322 CacheRegistryUtil.clear(JournalContentSearchImpl.class.getName());
323 }
324
325 EntityCacheUtil.clearCache(JournalContentSearchImpl.class.getName());
326
327 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
328 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
329 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
330 }
331
332
339 @Override
340 public void clearCache(JournalContentSearch journalContentSearch) {
341 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
342 JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
343
344 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
345 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
346
347 clearUniqueFindersCache(journalContentSearch);
348 }
349
350 @Override
351 public void clearCache(List<JournalContentSearch> journalContentSearchs) {
352 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
353 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
354
355 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
356 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
357 JournalContentSearchImpl.class,
358 journalContentSearch.getPrimaryKey());
359
360 clearUniqueFindersCache(journalContentSearch);
361 }
362 }
363
364 protected void cacheUniqueFindersCache(
365 JournalContentSearch journalContentSearch) {
366 if (journalContentSearch.isNew()) {
367 Object[] args = new Object[] {
368 Long.valueOf(journalContentSearch.getGroupId()),
369 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
370 Long.valueOf(journalContentSearch.getLayoutId()),
371
372 journalContentSearch.getPortletId(),
373
374 journalContentSearch.getArticleId()
375 };
376
377 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args,
378 Long.valueOf(1));
379 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args,
380 journalContentSearch);
381 }
382 else {
383 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
384
385 if ((journalContentSearchModelImpl.getColumnBitmask() &
386 FINDER_PATH_FETCH_BY_G_P_L_P_A.getColumnBitmask()) != 0) {
387 Object[] args = new Object[] {
388 Long.valueOf(journalContentSearch.getGroupId()),
389 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
390 Long.valueOf(journalContentSearch.getLayoutId()),
391
392 journalContentSearch.getPortletId(),
393
394 journalContentSearch.getArticleId()
395 };
396
397 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args,
398 Long.valueOf(1));
399 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args,
400 journalContentSearch);
401 }
402 }
403 }
404
405 protected void clearUniqueFindersCache(
406 JournalContentSearch journalContentSearch) {
407 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
408
409 Object[] args = new Object[] {
410 Long.valueOf(journalContentSearch.getGroupId()),
411 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
412 Long.valueOf(journalContentSearch.getLayoutId()),
413
414 journalContentSearch.getPortletId(),
415
416 journalContentSearch.getArticleId()
417 };
418
419 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args);
420 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args);
421
422 if ((journalContentSearchModelImpl.getColumnBitmask() &
423 FINDER_PATH_FETCH_BY_G_P_L_P_A.getColumnBitmask()) != 0) {
424 args = new Object[] {
425 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
426 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
427 Long.valueOf(journalContentSearchModelImpl.getOriginalLayoutId()),
428
429 journalContentSearchModelImpl.getOriginalPortletId(),
430
431 journalContentSearchModelImpl.getOriginalArticleId()
432 };
433
434 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args);
435 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args);
436 }
437 }
438
439
445 public JournalContentSearch create(long contentSearchId) {
446 JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
447
448 journalContentSearch.setNew(true);
449 journalContentSearch.setPrimaryKey(contentSearchId);
450
451 return journalContentSearch;
452 }
453
454
462 public JournalContentSearch remove(long contentSearchId)
463 throws NoSuchContentSearchException, SystemException {
464 return remove(Long.valueOf(contentSearchId));
465 }
466
467
475 @Override
476 public JournalContentSearch remove(Serializable primaryKey)
477 throws NoSuchContentSearchException, SystemException {
478 Session session = null;
479
480 try {
481 session = openSession();
482
483 JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
484 primaryKey);
485
486 if (journalContentSearch == null) {
487 if (_log.isWarnEnabled()) {
488 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
489 }
490
491 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
492 primaryKey);
493 }
494
495 return remove(journalContentSearch);
496 }
497 catch (NoSuchContentSearchException nsee) {
498 throw nsee;
499 }
500 catch (Exception e) {
501 throw processException(e);
502 }
503 finally {
504 closeSession(session);
505 }
506 }
507
508 @Override
509 protected JournalContentSearch removeImpl(
510 JournalContentSearch journalContentSearch) throws SystemException {
511 journalContentSearch = toUnwrappedModel(journalContentSearch);
512
513 Session session = null;
514
515 try {
516 session = openSession();
517
518 BatchSessionUtil.delete(session, journalContentSearch);
519 }
520 catch (Exception e) {
521 throw processException(e);
522 }
523 finally {
524 closeSession(session);
525 }
526
527 clearCache(journalContentSearch);
528
529 return journalContentSearch;
530 }
531
532 @Override
533 public JournalContentSearch updateImpl(
534 com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch,
535 boolean merge) throws SystemException {
536 journalContentSearch = toUnwrappedModel(journalContentSearch);
537
538 boolean isNew = journalContentSearch.isNew();
539
540 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
541
542 Session session = null;
543
544 try {
545 session = openSession();
546
547 BatchSessionUtil.update(session, journalContentSearch, merge);
548
549 journalContentSearch.setNew(false);
550 }
551 catch (Exception e) {
552 throw processException(e);
553 }
554 finally {
555 closeSession(session);
556 }
557
558 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
559
560 if (isNew || !JournalContentSearchModelImpl.COLUMN_BITMASK_ENABLED) {
561 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
562 }
563
564 else {
565 if ((journalContentSearchModelImpl.getColumnBitmask() &
566 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID.getColumnBitmask()) != 0) {
567 Object[] args = new Object[] {
568 journalContentSearchModelImpl.getOriginalArticleId()
569 };
570
571 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
572 args);
573 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
574 args);
575
576 args = new Object[] { journalContentSearchModelImpl.getArticleId() };
577
578 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
579 args);
580 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
581 args);
582 }
583
584 if ((journalContentSearchModelImpl.getColumnBitmask() &
585 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
586 Object[] args = new Object[] {
587 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
588 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout())
589 };
590
591 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
592 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
593 args);
594
595 args = new Object[] {
596 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
597 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout())
598 };
599
600 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
601 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
602 args);
603 }
604
605 if ((journalContentSearchModelImpl.getColumnBitmask() &
606 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
607 Object[] args = new Object[] {
608 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
609
610 journalContentSearchModelImpl.getOriginalArticleId()
611 };
612
613 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
614 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
615 args);
616
617 args = new Object[] {
618 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
619
620 journalContentSearchModelImpl.getArticleId()
621 };
622
623 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
624 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
625 args);
626 }
627
628 if ((journalContentSearchModelImpl.getColumnBitmask() &
629 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L.getColumnBitmask()) != 0) {
630 Object[] args = new Object[] {
631 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
632 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
633 Long.valueOf(journalContentSearchModelImpl.getOriginalLayoutId())
634 };
635
636 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
637 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
638 args);
639
640 args = new Object[] {
641 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
642 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout()),
643 Long.valueOf(journalContentSearchModelImpl.getLayoutId())
644 };
645
646 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
647 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
648 args);
649 }
650
651 if ((journalContentSearchModelImpl.getColumnBitmask() &
652 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A.getColumnBitmask()) != 0) {
653 Object[] args = new Object[] {
654 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
655 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
656
657 journalContentSearchModelImpl.getOriginalArticleId()
658 };
659
660 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
661 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
662 args);
663
664 args = new Object[] {
665 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
666 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout()),
667
668 journalContentSearchModelImpl.getArticleId()
669 };
670
671 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
672 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
673 args);
674 }
675
676 if ((journalContentSearchModelImpl.getColumnBitmask() &
677 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P.getColumnBitmask()) != 0) {
678 Object[] args = new Object[] {
679 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
680 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
681 Long.valueOf(journalContentSearchModelImpl.getOriginalLayoutId()),
682
683 journalContentSearchModelImpl.getOriginalPortletId()
684 };
685
686 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
687 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
688 args);
689
690 args = new Object[] {
691 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
692 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout()),
693 Long.valueOf(journalContentSearchModelImpl.getLayoutId()),
694
695 journalContentSearchModelImpl.getPortletId()
696 };
697
698 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
699 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
700 args);
701 }
702 }
703
704 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
705 JournalContentSearchImpl.class,
706 journalContentSearch.getPrimaryKey(), journalContentSearch);
707
708 clearUniqueFindersCache(journalContentSearch);
709 cacheUniqueFindersCache(journalContentSearch);
710
711 return journalContentSearch;
712 }
713
714 protected JournalContentSearch toUnwrappedModel(
715 JournalContentSearch journalContentSearch) {
716 if (journalContentSearch instanceof JournalContentSearchImpl) {
717 return journalContentSearch;
718 }
719
720 JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
721
722 journalContentSearchImpl.setNew(journalContentSearch.isNew());
723 journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
724
725 journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
726 journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
727 journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
728 journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
729 journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
730 journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
731 journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
732
733 return journalContentSearchImpl;
734 }
735
736
744 @Override
745 public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
746 throws NoSuchModelException, SystemException {
747 return findByPrimaryKey(((Long)primaryKey).longValue());
748 }
749
750
758 public JournalContentSearch findByPrimaryKey(long contentSearchId)
759 throws NoSuchContentSearchException, SystemException {
760 JournalContentSearch journalContentSearch = fetchByPrimaryKey(contentSearchId);
761
762 if (journalContentSearch == null) {
763 if (_log.isWarnEnabled()) {
764 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contentSearchId);
765 }
766
767 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
768 contentSearchId);
769 }
770
771 return journalContentSearch;
772 }
773
774
781 @Override
782 public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey)
783 throws SystemException {
784 return fetchByPrimaryKey(((Long)primaryKey).longValue());
785 }
786
787
794 public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
795 throws SystemException {
796 JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
797 JournalContentSearchImpl.class, contentSearchId);
798
799 if (journalContentSearch == _nullJournalContentSearch) {
800 return null;
801 }
802
803 if (journalContentSearch == null) {
804 Session session = null;
805
806 boolean hasException = false;
807
808 try {
809 session = openSession();
810
811 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
812 Long.valueOf(contentSearchId));
813 }
814 catch (Exception e) {
815 hasException = true;
816
817 throw processException(e);
818 }
819 finally {
820 if (journalContentSearch != null) {
821 cacheResult(journalContentSearch);
822 }
823 else if (!hasException) {
824 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
825 JournalContentSearchImpl.class, contentSearchId,
826 _nullJournalContentSearch);
827 }
828
829 closeSession(session);
830 }
831 }
832
833 return journalContentSearch;
834 }
835
836
843 public List<JournalContentSearch> findByArticleId(String articleId)
844 throws SystemException {
845 return findByArticleId(articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
846 null);
847 }
848
849
862 public List<JournalContentSearch> findByArticleId(String articleId,
863 int start, int end) throws SystemException {
864 return findByArticleId(articleId, start, end, null);
865 }
866
867
881 public List<JournalContentSearch> findByArticleId(String articleId,
882 int start, int end, OrderByComparator orderByComparator)
883 throws SystemException {
884 FinderPath finderPath = null;
885 Object[] finderArgs = null;
886
887 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
888 (orderByComparator == null)) {
889 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID;
890 finderArgs = new Object[] { articleId };
891 }
892 else {
893 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ARTICLEID;
894 finderArgs = new Object[] { articleId, start, end, orderByComparator };
895 }
896
897 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
898 finderArgs, this);
899
900 if ((list != null) && !list.isEmpty()) {
901 for (JournalContentSearch journalContentSearch : list) {
902 if (!Validator.equals(articleId,
903 journalContentSearch.getArticleId())) {
904 list = null;
905
906 break;
907 }
908 }
909 }
910
911 if (list == null) {
912 StringBundler query = null;
913
914 if (orderByComparator != null) {
915 query = new StringBundler(3 +
916 (orderByComparator.getOrderByFields().length * 3));
917 }
918 else {
919 query = new StringBundler(2);
920 }
921
922 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
923
924 if (articleId == null) {
925 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
926 }
927 else {
928 if (articleId.equals(StringPool.BLANK)) {
929 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
930 }
931 else {
932 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
933 }
934 }
935
936 if (orderByComparator != null) {
937 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
938 orderByComparator);
939 }
940
941 String sql = query.toString();
942
943 Session session = null;
944
945 try {
946 session = openSession();
947
948 Query q = session.createQuery(sql);
949
950 QueryPos qPos = QueryPos.getInstance(q);
951
952 if (articleId != null) {
953 qPos.add(articleId);
954 }
955
956 list = (List<JournalContentSearch>)QueryUtil.list(q,
957 getDialect(), start, end);
958 }
959 catch (Exception e) {
960 throw processException(e);
961 }
962 finally {
963 if (list == null) {
964 FinderCacheUtil.removeResult(finderPath, finderArgs);
965 }
966 else {
967 cacheResult(list);
968
969 FinderCacheUtil.putResult(finderPath, finderArgs, list);
970 }
971
972 closeSession(session);
973 }
974 }
975
976 return list;
977 }
978
979
988 public JournalContentSearch findByArticleId_First(String articleId,
989 OrderByComparator orderByComparator)
990 throws NoSuchContentSearchException, SystemException {
991 JournalContentSearch journalContentSearch = fetchByArticleId_First(articleId,
992 orderByComparator);
993
994 if (journalContentSearch != null) {
995 return journalContentSearch;
996 }
997
998 StringBundler msg = new StringBundler(4);
999
1000 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1001
1002 msg.append("articleId=");
1003 msg.append(articleId);
1004
1005 msg.append(StringPool.CLOSE_CURLY_BRACE);
1006
1007 throw new NoSuchContentSearchException(msg.toString());
1008 }
1009
1010
1018 public JournalContentSearch fetchByArticleId_First(String articleId,
1019 OrderByComparator orderByComparator) throws SystemException {
1020 List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
1021 orderByComparator);
1022
1023 if (!list.isEmpty()) {
1024 return list.get(0);
1025 }
1026
1027 return null;
1028 }
1029
1030
1039 public JournalContentSearch findByArticleId_Last(String articleId,
1040 OrderByComparator orderByComparator)
1041 throws NoSuchContentSearchException, SystemException {
1042 JournalContentSearch journalContentSearch = fetchByArticleId_Last(articleId,
1043 orderByComparator);
1044
1045 if (journalContentSearch != null) {
1046 return journalContentSearch;
1047 }
1048
1049 StringBundler msg = new StringBundler(4);
1050
1051 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1052
1053 msg.append("articleId=");
1054 msg.append(articleId);
1055
1056 msg.append(StringPool.CLOSE_CURLY_BRACE);
1057
1058 throw new NoSuchContentSearchException(msg.toString());
1059 }
1060
1061
1069 public JournalContentSearch fetchByArticleId_Last(String articleId,
1070 OrderByComparator orderByComparator) throws SystemException {
1071 int count = countByArticleId(articleId);
1072
1073 List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
1074 count, orderByComparator);
1075
1076 if (!list.isEmpty()) {
1077 return list.get(0);
1078 }
1079
1080 return null;
1081 }
1082
1083
1093 public JournalContentSearch[] findByArticleId_PrevAndNext(
1094 long contentSearchId, String articleId,
1095 OrderByComparator orderByComparator)
1096 throws NoSuchContentSearchException, SystemException {
1097 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1098
1099 Session session = null;
1100
1101 try {
1102 session = openSession();
1103
1104 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1105
1106 array[0] = getByArticleId_PrevAndNext(session,
1107 journalContentSearch, articleId, orderByComparator, true);
1108
1109 array[1] = journalContentSearch;
1110
1111 array[2] = getByArticleId_PrevAndNext(session,
1112 journalContentSearch, articleId, orderByComparator, false);
1113
1114 return array;
1115 }
1116 catch (Exception e) {
1117 throw processException(e);
1118 }
1119 finally {
1120 closeSession(session);
1121 }
1122 }
1123
1124 protected JournalContentSearch getByArticleId_PrevAndNext(Session session,
1125 JournalContentSearch journalContentSearch, String articleId,
1126 OrderByComparator orderByComparator, boolean previous) {
1127 StringBundler query = null;
1128
1129 if (orderByComparator != null) {
1130 query = new StringBundler(6 +
1131 (orderByComparator.getOrderByFields().length * 6));
1132 }
1133 else {
1134 query = new StringBundler(3);
1135 }
1136
1137 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1138
1139 if (articleId == null) {
1140 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
1141 }
1142 else {
1143 if (articleId.equals(StringPool.BLANK)) {
1144 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
1145 }
1146 else {
1147 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
1148 }
1149 }
1150
1151 if (orderByComparator != null) {
1152 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1153
1154 if (orderByConditionFields.length > 0) {
1155 query.append(WHERE_AND);
1156 }
1157
1158 for (int i = 0; i < orderByConditionFields.length; i++) {
1159 query.append(_ORDER_BY_ENTITY_ALIAS);
1160 query.append(orderByConditionFields[i]);
1161
1162 if ((i + 1) < orderByConditionFields.length) {
1163 if (orderByComparator.isAscending() ^ previous) {
1164 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1165 }
1166 else {
1167 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1168 }
1169 }
1170 else {
1171 if (orderByComparator.isAscending() ^ previous) {
1172 query.append(WHERE_GREATER_THAN);
1173 }
1174 else {
1175 query.append(WHERE_LESSER_THAN);
1176 }
1177 }
1178 }
1179
1180 query.append(ORDER_BY_CLAUSE);
1181
1182 String[] orderByFields = orderByComparator.getOrderByFields();
1183
1184 for (int i = 0; i < orderByFields.length; i++) {
1185 query.append(_ORDER_BY_ENTITY_ALIAS);
1186 query.append(orderByFields[i]);
1187
1188 if ((i + 1) < orderByFields.length) {
1189 if (orderByComparator.isAscending() ^ previous) {
1190 query.append(ORDER_BY_ASC_HAS_NEXT);
1191 }
1192 else {
1193 query.append(ORDER_BY_DESC_HAS_NEXT);
1194 }
1195 }
1196 else {
1197 if (orderByComparator.isAscending() ^ previous) {
1198 query.append(ORDER_BY_ASC);
1199 }
1200 else {
1201 query.append(ORDER_BY_DESC);
1202 }
1203 }
1204 }
1205 }
1206
1207 String sql = query.toString();
1208
1209 Query q = session.createQuery(sql);
1210
1211 q.setFirstResult(0);
1212 q.setMaxResults(2);
1213
1214 QueryPos qPos = QueryPos.getInstance(q);
1215
1216 if (articleId != null) {
1217 qPos.add(articleId);
1218 }
1219
1220 if (orderByComparator != null) {
1221 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1222
1223 for (Object value : values) {
1224 qPos.add(value);
1225 }
1226 }
1227
1228 List<JournalContentSearch> list = q.list();
1229
1230 if (list.size() == 2) {
1231 return list.get(1);
1232 }
1233 else {
1234 return null;
1235 }
1236 }
1237
1238
1246 public List<JournalContentSearch> findByG_P(long groupId,
1247 boolean privateLayout) throws SystemException {
1248 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1249 QueryUtil.ALL_POS, null);
1250 }
1251
1252
1266 public List<JournalContentSearch> findByG_P(long groupId,
1267 boolean privateLayout, int start, int end) throws SystemException {
1268 return findByG_P(groupId, privateLayout, start, end, null);
1269 }
1270
1271
1286 public List<JournalContentSearch> findByG_P(long groupId,
1287 boolean privateLayout, int start, int end,
1288 OrderByComparator orderByComparator) throws SystemException {
1289 FinderPath finderPath = null;
1290 Object[] finderArgs = null;
1291
1292 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1293 (orderByComparator == null)) {
1294 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1295 finderArgs = new Object[] { groupId, privateLayout };
1296 }
1297 else {
1298 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1299 finderArgs = new Object[] {
1300 groupId, privateLayout,
1301
1302 start, end, orderByComparator
1303 };
1304 }
1305
1306 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1307 finderArgs, this);
1308
1309 if ((list != null) && !list.isEmpty()) {
1310 for (JournalContentSearch journalContentSearch : list) {
1311 if ((groupId != journalContentSearch.getGroupId()) ||
1312 (privateLayout != journalContentSearch.getPrivateLayout())) {
1313 list = null;
1314
1315 break;
1316 }
1317 }
1318 }
1319
1320 if (list == null) {
1321 StringBundler query = null;
1322
1323 if (orderByComparator != null) {
1324 query = new StringBundler(4 +
1325 (orderByComparator.getOrderByFields().length * 3));
1326 }
1327 else {
1328 query = new StringBundler(3);
1329 }
1330
1331 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1332
1333 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1334
1335 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1336
1337 if (orderByComparator != null) {
1338 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1339 orderByComparator);
1340 }
1341
1342 String sql = query.toString();
1343
1344 Session session = null;
1345
1346 try {
1347 session = openSession();
1348
1349 Query q = session.createQuery(sql);
1350
1351 QueryPos qPos = QueryPos.getInstance(q);
1352
1353 qPos.add(groupId);
1354
1355 qPos.add(privateLayout);
1356
1357 list = (List<JournalContentSearch>)QueryUtil.list(q,
1358 getDialect(), start, end);
1359 }
1360 catch (Exception e) {
1361 throw processException(e);
1362 }
1363 finally {
1364 if (list == null) {
1365 FinderCacheUtil.removeResult(finderPath, finderArgs);
1366 }
1367 else {
1368 cacheResult(list);
1369
1370 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1371 }
1372
1373 closeSession(session);
1374 }
1375 }
1376
1377 return list;
1378 }
1379
1380
1390 public JournalContentSearch findByG_P_First(long groupId,
1391 boolean privateLayout, OrderByComparator orderByComparator)
1392 throws NoSuchContentSearchException, SystemException {
1393 JournalContentSearch journalContentSearch = fetchByG_P_First(groupId,
1394 privateLayout, orderByComparator);
1395
1396 if (journalContentSearch != null) {
1397 return journalContentSearch;
1398 }
1399
1400 StringBundler msg = new StringBundler(6);
1401
1402 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1403
1404 msg.append("groupId=");
1405 msg.append(groupId);
1406
1407 msg.append(", privateLayout=");
1408 msg.append(privateLayout);
1409
1410 msg.append(StringPool.CLOSE_CURLY_BRACE);
1411
1412 throw new NoSuchContentSearchException(msg.toString());
1413 }
1414
1415
1424 public JournalContentSearch fetchByG_P_First(long groupId,
1425 boolean privateLayout, OrderByComparator orderByComparator)
1426 throws SystemException {
1427 List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
1428 1, orderByComparator);
1429
1430 if (!list.isEmpty()) {
1431 return list.get(0);
1432 }
1433
1434 return null;
1435 }
1436
1437
1447 public JournalContentSearch findByG_P_Last(long groupId,
1448 boolean privateLayout, OrderByComparator orderByComparator)
1449 throws NoSuchContentSearchException, SystemException {
1450 JournalContentSearch journalContentSearch = fetchByG_P_Last(groupId,
1451 privateLayout, orderByComparator);
1452
1453 if (journalContentSearch != null) {
1454 return journalContentSearch;
1455 }
1456
1457 StringBundler msg = new StringBundler(6);
1458
1459 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1460
1461 msg.append("groupId=");
1462 msg.append(groupId);
1463
1464 msg.append(", privateLayout=");
1465 msg.append(privateLayout);
1466
1467 msg.append(StringPool.CLOSE_CURLY_BRACE);
1468
1469 throw new NoSuchContentSearchException(msg.toString());
1470 }
1471
1472
1481 public JournalContentSearch fetchByG_P_Last(long groupId,
1482 boolean privateLayout, OrderByComparator orderByComparator)
1483 throws SystemException {
1484 int count = countByG_P(groupId, privateLayout);
1485
1486 List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
1487 count - 1, count, orderByComparator);
1488
1489 if (!list.isEmpty()) {
1490 return list.get(0);
1491 }
1492
1493 return null;
1494 }
1495
1496
1507 public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
1508 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1509 throws NoSuchContentSearchException, SystemException {
1510 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1511
1512 Session session = null;
1513
1514 try {
1515 session = openSession();
1516
1517 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1518
1519 array[0] = getByG_P_PrevAndNext(session, journalContentSearch,
1520 groupId, privateLayout, orderByComparator, true);
1521
1522 array[1] = journalContentSearch;
1523
1524 array[2] = getByG_P_PrevAndNext(session, journalContentSearch,
1525 groupId, privateLayout, orderByComparator, false);
1526
1527 return array;
1528 }
1529 catch (Exception e) {
1530 throw processException(e);
1531 }
1532 finally {
1533 closeSession(session);
1534 }
1535 }
1536
1537 protected JournalContentSearch getByG_P_PrevAndNext(Session session,
1538 JournalContentSearch journalContentSearch, long groupId,
1539 boolean privateLayout, OrderByComparator orderByComparator,
1540 boolean previous) {
1541 StringBundler query = null;
1542
1543 if (orderByComparator != null) {
1544 query = new StringBundler(6 +
1545 (orderByComparator.getOrderByFields().length * 6));
1546 }
1547 else {
1548 query = new StringBundler(3);
1549 }
1550
1551 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1552
1553 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1554
1555 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1556
1557 if (orderByComparator != null) {
1558 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1559
1560 if (orderByConditionFields.length > 0) {
1561 query.append(WHERE_AND);
1562 }
1563
1564 for (int i = 0; i < orderByConditionFields.length; i++) {
1565 query.append(_ORDER_BY_ENTITY_ALIAS);
1566 query.append(orderByConditionFields[i]);
1567
1568 if ((i + 1) < orderByConditionFields.length) {
1569 if (orderByComparator.isAscending() ^ previous) {
1570 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1571 }
1572 else {
1573 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1574 }
1575 }
1576 else {
1577 if (orderByComparator.isAscending() ^ previous) {
1578 query.append(WHERE_GREATER_THAN);
1579 }
1580 else {
1581 query.append(WHERE_LESSER_THAN);
1582 }
1583 }
1584 }
1585
1586 query.append(ORDER_BY_CLAUSE);
1587
1588 String[] orderByFields = orderByComparator.getOrderByFields();
1589
1590 for (int i = 0; i < orderByFields.length; i++) {
1591 query.append(_ORDER_BY_ENTITY_ALIAS);
1592 query.append(orderByFields[i]);
1593
1594 if ((i + 1) < orderByFields.length) {
1595 if (orderByComparator.isAscending() ^ previous) {
1596 query.append(ORDER_BY_ASC_HAS_NEXT);
1597 }
1598 else {
1599 query.append(ORDER_BY_DESC_HAS_NEXT);
1600 }
1601 }
1602 else {
1603 if (orderByComparator.isAscending() ^ previous) {
1604 query.append(ORDER_BY_ASC);
1605 }
1606 else {
1607 query.append(ORDER_BY_DESC);
1608 }
1609 }
1610 }
1611 }
1612
1613 String sql = query.toString();
1614
1615 Query q = session.createQuery(sql);
1616
1617 q.setFirstResult(0);
1618 q.setMaxResults(2);
1619
1620 QueryPos qPos = QueryPos.getInstance(q);
1621
1622 qPos.add(groupId);
1623
1624 qPos.add(privateLayout);
1625
1626 if (orderByComparator != null) {
1627 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1628
1629 for (Object value : values) {
1630 qPos.add(value);
1631 }
1632 }
1633
1634 List<JournalContentSearch> list = q.list();
1635
1636 if (list.size() == 2) {
1637 return list.get(1);
1638 }
1639 else {
1640 return null;
1641 }
1642 }
1643
1644
1652 public List<JournalContentSearch> findByG_A(long groupId, String articleId)
1653 throws SystemException {
1654 return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
1655 QueryUtil.ALL_POS, null);
1656 }
1657
1658
1672 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1673 int start, int end) throws SystemException {
1674 return findByG_A(groupId, articleId, start, end, null);
1675 }
1676
1677
1692 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1693 int start, int end, OrderByComparator orderByComparator)
1694 throws SystemException {
1695 FinderPath finderPath = null;
1696 Object[] finderArgs = null;
1697
1698 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1699 (orderByComparator == null)) {
1700 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
1701 finderArgs = new Object[] { groupId, articleId };
1702 }
1703 else {
1704 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
1705 finderArgs = new Object[] {
1706 groupId, articleId,
1707
1708 start, end, orderByComparator
1709 };
1710 }
1711
1712 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1713 finderArgs, this);
1714
1715 if ((list != null) && !list.isEmpty()) {
1716 for (JournalContentSearch journalContentSearch : list) {
1717 if ((groupId != journalContentSearch.getGroupId()) ||
1718 !Validator.equals(articleId,
1719 journalContentSearch.getArticleId())) {
1720 list = null;
1721
1722 break;
1723 }
1724 }
1725 }
1726
1727 if (list == null) {
1728 StringBundler query = null;
1729
1730 if (orderByComparator != null) {
1731 query = new StringBundler(4 +
1732 (orderByComparator.getOrderByFields().length * 3));
1733 }
1734 else {
1735 query = new StringBundler(3);
1736 }
1737
1738 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1739
1740 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1741
1742 if (articleId == null) {
1743 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1744 }
1745 else {
1746 if (articleId.equals(StringPool.BLANK)) {
1747 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1748 }
1749 else {
1750 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1751 }
1752 }
1753
1754 if (orderByComparator != null) {
1755 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1756 orderByComparator);
1757 }
1758
1759 String sql = query.toString();
1760
1761 Session session = null;
1762
1763 try {
1764 session = openSession();
1765
1766 Query q = session.createQuery(sql);
1767
1768 QueryPos qPos = QueryPos.getInstance(q);
1769
1770 qPos.add(groupId);
1771
1772 if (articleId != null) {
1773 qPos.add(articleId);
1774 }
1775
1776 list = (List<JournalContentSearch>)QueryUtil.list(q,
1777 getDialect(), start, end);
1778 }
1779 catch (Exception e) {
1780 throw processException(e);
1781 }
1782 finally {
1783 if (list == null) {
1784 FinderCacheUtil.removeResult(finderPath, finderArgs);
1785 }
1786 else {
1787 cacheResult(list);
1788
1789 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1790 }
1791
1792 closeSession(session);
1793 }
1794 }
1795
1796 return list;
1797 }
1798
1799
1809 public JournalContentSearch findByG_A_First(long groupId, String articleId,
1810 OrderByComparator orderByComparator)
1811 throws NoSuchContentSearchException, SystemException {
1812 JournalContentSearch journalContentSearch = fetchByG_A_First(groupId,
1813 articleId, orderByComparator);
1814
1815 if (journalContentSearch != null) {
1816 return journalContentSearch;
1817 }
1818
1819 StringBundler msg = new StringBundler(6);
1820
1821 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1822
1823 msg.append("groupId=");
1824 msg.append(groupId);
1825
1826 msg.append(", articleId=");
1827 msg.append(articleId);
1828
1829 msg.append(StringPool.CLOSE_CURLY_BRACE);
1830
1831 throw new NoSuchContentSearchException(msg.toString());
1832 }
1833
1834
1843 public JournalContentSearch fetchByG_A_First(long groupId,
1844 String articleId, OrderByComparator orderByComparator)
1845 throws SystemException {
1846 List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1847 orderByComparator);
1848
1849 if (!list.isEmpty()) {
1850 return list.get(0);
1851 }
1852
1853 return null;
1854 }
1855
1856
1866 public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1867 OrderByComparator orderByComparator)
1868 throws NoSuchContentSearchException, SystemException {
1869 JournalContentSearch journalContentSearch = fetchByG_A_Last(groupId,
1870 articleId, orderByComparator);
1871
1872 if (journalContentSearch != null) {
1873 return journalContentSearch;
1874 }
1875
1876 StringBundler msg = new StringBundler(6);
1877
1878 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1879
1880 msg.append("groupId=");
1881 msg.append(groupId);
1882
1883 msg.append(", articleId=");
1884 msg.append(articleId);
1885
1886 msg.append(StringPool.CLOSE_CURLY_BRACE);
1887
1888 throw new NoSuchContentSearchException(msg.toString());
1889 }
1890
1891
1900 public JournalContentSearch fetchByG_A_Last(long groupId, String articleId,
1901 OrderByComparator orderByComparator) throws SystemException {
1902 int count = countByG_A(groupId, articleId);
1903
1904 List<JournalContentSearch> list = findByG_A(groupId, articleId,
1905 count - 1, count, orderByComparator);
1906
1907 if (!list.isEmpty()) {
1908 return list.get(0);
1909 }
1910
1911 return null;
1912 }
1913
1914
1925 public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
1926 long groupId, String articleId, OrderByComparator orderByComparator)
1927 throws NoSuchContentSearchException, SystemException {
1928 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1929
1930 Session session = null;
1931
1932 try {
1933 session = openSession();
1934
1935 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1936
1937 array[0] = getByG_A_PrevAndNext(session, journalContentSearch,
1938 groupId, articleId, orderByComparator, true);
1939
1940 array[1] = journalContentSearch;
1941
1942 array[2] = getByG_A_PrevAndNext(session, journalContentSearch,
1943 groupId, articleId, orderByComparator, false);
1944
1945 return array;
1946 }
1947 catch (Exception e) {
1948 throw processException(e);
1949 }
1950 finally {
1951 closeSession(session);
1952 }
1953 }
1954
1955 protected JournalContentSearch getByG_A_PrevAndNext(Session session,
1956 JournalContentSearch journalContentSearch, long groupId,
1957 String articleId, OrderByComparator orderByComparator, boolean previous) {
1958 StringBundler query = null;
1959
1960 if (orderByComparator != null) {
1961 query = new StringBundler(6 +
1962 (orderByComparator.getOrderByFields().length * 6));
1963 }
1964 else {
1965 query = new StringBundler(3);
1966 }
1967
1968 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1969
1970 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1971
1972 if (articleId == null) {
1973 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1974 }
1975 else {
1976 if (articleId.equals(StringPool.BLANK)) {
1977 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1978 }
1979 else {
1980 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1981 }
1982 }
1983
1984 if (orderByComparator != null) {
1985 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1986
1987 if (orderByConditionFields.length > 0) {
1988 query.append(WHERE_AND);
1989 }
1990
1991 for (int i = 0; i < orderByConditionFields.length; i++) {
1992 query.append(_ORDER_BY_ENTITY_ALIAS);
1993 query.append(orderByConditionFields[i]);
1994
1995 if ((i + 1) < orderByConditionFields.length) {
1996 if (orderByComparator.isAscending() ^ previous) {
1997 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1998 }
1999 else {
2000 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2001 }
2002 }
2003 else {
2004 if (orderByComparator.isAscending() ^ previous) {
2005 query.append(WHERE_GREATER_THAN);
2006 }
2007 else {
2008 query.append(WHERE_LESSER_THAN);
2009 }
2010 }
2011 }
2012
2013 query.append(ORDER_BY_CLAUSE);
2014
2015 String[] orderByFields = orderByComparator.getOrderByFields();
2016
2017 for (int i = 0; i < orderByFields.length; i++) {
2018 query.append(_ORDER_BY_ENTITY_ALIAS);
2019 query.append(orderByFields[i]);
2020
2021 if ((i + 1) < orderByFields.length) {
2022 if (orderByComparator.isAscending() ^ previous) {
2023 query.append(ORDER_BY_ASC_HAS_NEXT);
2024 }
2025 else {
2026 query.append(ORDER_BY_DESC_HAS_NEXT);
2027 }
2028 }
2029 else {
2030 if (orderByComparator.isAscending() ^ previous) {
2031 query.append(ORDER_BY_ASC);
2032 }
2033 else {
2034 query.append(ORDER_BY_DESC);
2035 }
2036 }
2037 }
2038 }
2039
2040 String sql = query.toString();
2041
2042 Query q = session.createQuery(sql);
2043
2044 q.setFirstResult(0);
2045 q.setMaxResults(2);
2046
2047 QueryPos qPos = QueryPos.getInstance(q);
2048
2049 qPos.add(groupId);
2050
2051 if (articleId != null) {
2052 qPos.add(articleId);
2053 }
2054
2055 if (orderByComparator != null) {
2056 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2057
2058 for (Object value : values) {
2059 qPos.add(value);
2060 }
2061 }
2062
2063 List<JournalContentSearch> list = q.list();
2064
2065 if (list.size() == 2) {
2066 return list.get(1);
2067 }
2068 else {
2069 return null;
2070 }
2071 }
2072
2073
2082 public List<JournalContentSearch> findByG_P_L(long groupId,
2083 boolean privateLayout, long layoutId) throws SystemException {
2084 return findByG_P_L(groupId, privateLayout, layoutId, QueryUtil.ALL_POS,
2085 QueryUtil.ALL_POS, null);
2086 }
2087
2088
2103 public List<JournalContentSearch> findByG_P_L(long groupId,
2104 boolean privateLayout, long layoutId, int start, int end)
2105 throws SystemException {
2106 return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
2107 }
2108
2109
2125 public List<JournalContentSearch> findByG_P_L(long groupId,
2126 boolean privateLayout, long layoutId, int start, int end,
2127 OrderByComparator orderByComparator) throws SystemException {
2128 FinderPath finderPath = null;
2129 Object[] finderArgs = null;
2130
2131 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2132 (orderByComparator == null)) {
2133 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L;
2134 finderArgs = new Object[] { groupId, privateLayout, layoutId };
2135 }
2136 else {
2137 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L;
2138 finderArgs = new Object[] {
2139 groupId, privateLayout, layoutId,
2140
2141 start, end, orderByComparator
2142 };
2143 }
2144
2145 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2146 finderArgs, this);
2147
2148 if ((list != null) && !list.isEmpty()) {
2149 for (JournalContentSearch journalContentSearch : list) {
2150 if ((groupId != journalContentSearch.getGroupId()) ||
2151 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2152 (layoutId != journalContentSearch.getLayoutId())) {
2153 list = null;
2154
2155 break;
2156 }
2157 }
2158 }
2159
2160 if (list == null) {
2161 StringBundler query = null;
2162
2163 if (orderByComparator != null) {
2164 query = new StringBundler(5 +
2165 (orderByComparator.getOrderByFields().length * 3));
2166 }
2167 else {
2168 query = new StringBundler(4);
2169 }
2170
2171 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2172
2173 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2174
2175 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2176
2177 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2178
2179 if (orderByComparator != null) {
2180 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2181 orderByComparator);
2182 }
2183
2184 String sql = query.toString();
2185
2186 Session session = null;
2187
2188 try {
2189 session = openSession();
2190
2191 Query q = session.createQuery(sql);
2192
2193 QueryPos qPos = QueryPos.getInstance(q);
2194
2195 qPos.add(groupId);
2196
2197 qPos.add(privateLayout);
2198
2199 qPos.add(layoutId);
2200
2201 list = (List<JournalContentSearch>)QueryUtil.list(q,
2202 getDialect(), start, end);
2203 }
2204 catch (Exception e) {
2205 throw processException(e);
2206 }
2207 finally {
2208 if (list == null) {
2209 FinderCacheUtil.removeResult(finderPath, finderArgs);
2210 }
2211 else {
2212 cacheResult(list);
2213
2214 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2215 }
2216
2217 closeSession(session);
2218 }
2219 }
2220
2221 return list;
2222 }
2223
2224
2235 public JournalContentSearch findByG_P_L_First(long groupId,
2236 boolean privateLayout, long layoutId,
2237 OrderByComparator orderByComparator)
2238 throws NoSuchContentSearchException, SystemException {
2239 JournalContentSearch journalContentSearch = fetchByG_P_L_First(groupId,
2240 privateLayout, layoutId, orderByComparator);
2241
2242 if (journalContentSearch != null) {
2243 return journalContentSearch;
2244 }
2245
2246 StringBundler msg = new StringBundler(8);
2247
2248 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2249
2250 msg.append("groupId=");
2251 msg.append(groupId);
2252
2253 msg.append(", privateLayout=");
2254 msg.append(privateLayout);
2255
2256 msg.append(", layoutId=");
2257 msg.append(layoutId);
2258
2259 msg.append(StringPool.CLOSE_CURLY_BRACE);
2260
2261 throw new NoSuchContentSearchException(msg.toString());
2262 }
2263
2264
2274 public JournalContentSearch fetchByG_P_L_First(long groupId,
2275 boolean privateLayout, long layoutId,
2276 OrderByComparator orderByComparator) throws SystemException {
2277 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2278 layoutId, 0, 1, orderByComparator);
2279
2280 if (!list.isEmpty()) {
2281 return list.get(0);
2282 }
2283
2284 return null;
2285 }
2286
2287
2298 public JournalContentSearch findByG_P_L_Last(long groupId,
2299 boolean privateLayout, long layoutId,
2300 OrderByComparator orderByComparator)
2301 throws NoSuchContentSearchException, SystemException {
2302 JournalContentSearch journalContentSearch = fetchByG_P_L_Last(groupId,
2303 privateLayout, layoutId, orderByComparator);
2304
2305 if (journalContentSearch != null) {
2306 return journalContentSearch;
2307 }
2308
2309 StringBundler msg = new StringBundler(8);
2310
2311 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2312
2313 msg.append("groupId=");
2314 msg.append(groupId);
2315
2316 msg.append(", privateLayout=");
2317 msg.append(privateLayout);
2318
2319 msg.append(", layoutId=");
2320 msg.append(layoutId);
2321
2322 msg.append(StringPool.CLOSE_CURLY_BRACE);
2323
2324 throw new NoSuchContentSearchException(msg.toString());
2325 }
2326
2327
2337 public JournalContentSearch fetchByG_P_L_Last(long groupId,
2338 boolean privateLayout, long layoutId,
2339 OrderByComparator orderByComparator) throws SystemException {
2340 int count = countByG_P_L(groupId, privateLayout, layoutId);
2341
2342 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2343 layoutId, count - 1, count, orderByComparator);
2344
2345 if (!list.isEmpty()) {
2346 return list.get(0);
2347 }
2348
2349 return null;
2350 }
2351
2352
2364 public JournalContentSearch[] findByG_P_L_PrevAndNext(
2365 long contentSearchId, long groupId, boolean privateLayout,
2366 long layoutId, OrderByComparator orderByComparator)
2367 throws NoSuchContentSearchException, SystemException {
2368 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2369
2370 Session session = null;
2371
2372 try {
2373 session = openSession();
2374
2375 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2376
2377 array[0] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2378 groupId, privateLayout, layoutId, orderByComparator, true);
2379
2380 array[1] = journalContentSearch;
2381
2382 array[2] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2383 groupId, privateLayout, layoutId, orderByComparator, false);
2384
2385 return array;
2386 }
2387 catch (Exception e) {
2388 throw processException(e);
2389 }
2390 finally {
2391 closeSession(session);
2392 }
2393 }
2394
2395 protected JournalContentSearch getByG_P_L_PrevAndNext(Session session,
2396 JournalContentSearch journalContentSearch, long groupId,
2397 boolean privateLayout, long layoutId,
2398 OrderByComparator orderByComparator, boolean previous) {
2399 StringBundler query = null;
2400
2401 if (orderByComparator != null) {
2402 query = new StringBundler(6 +
2403 (orderByComparator.getOrderByFields().length * 6));
2404 }
2405 else {
2406 query = new StringBundler(3);
2407 }
2408
2409 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2410
2411 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2412
2413 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2414
2415 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2416
2417 if (orderByComparator != null) {
2418 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2419
2420 if (orderByConditionFields.length > 0) {
2421 query.append(WHERE_AND);
2422 }
2423
2424 for (int i = 0; i < orderByConditionFields.length; i++) {
2425 query.append(_ORDER_BY_ENTITY_ALIAS);
2426 query.append(orderByConditionFields[i]);
2427
2428 if ((i + 1) < orderByConditionFields.length) {
2429 if (orderByComparator.isAscending() ^ previous) {
2430 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2431 }
2432 else {
2433 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2434 }
2435 }
2436 else {
2437 if (orderByComparator.isAscending() ^ previous) {
2438 query.append(WHERE_GREATER_THAN);
2439 }
2440 else {
2441 query.append(WHERE_LESSER_THAN);
2442 }
2443 }
2444 }
2445
2446 query.append(ORDER_BY_CLAUSE);
2447
2448 String[] orderByFields = orderByComparator.getOrderByFields();
2449
2450 for (int i = 0; i < orderByFields.length; i++) {
2451 query.append(_ORDER_BY_ENTITY_ALIAS);
2452 query.append(orderByFields[i]);
2453
2454 if ((i + 1) < orderByFields.length) {
2455 if (orderByComparator.isAscending() ^ previous) {
2456 query.append(ORDER_BY_ASC_HAS_NEXT);
2457 }
2458 else {
2459 query.append(ORDER_BY_DESC_HAS_NEXT);
2460 }
2461 }
2462 else {
2463 if (orderByComparator.isAscending() ^ previous) {
2464 query.append(ORDER_BY_ASC);
2465 }
2466 else {
2467 query.append(ORDER_BY_DESC);
2468 }
2469 }
2470 }
2471 }
2472
2473 String sql = query.toString();
2474
2475 Query q = session.createQuery(sql);
2476
2477 q.setFirstResult(0);
2478 q.setMaxResults(2);
2479
2480 QueryPos qPos = QueryPos.getInstance(q);
2481
2482 qPos.add(groupId);
2483
2484 qPos.add(privateLayout);
2485
2486 qPos.add(layoutId);
2487
2488 if (orderByComparator != null) {
2489 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2490
2491 for (Object value : values) {
2492 qPos.add(value);
2493 }
2494 }
2495
2496 List<JournalContentSearch> list = q.list();
2497
2498 if (list.size() == 2) {
2499 return list.get(1);
2500 }
2501 else {
2502 return null;
2503 }
2504 }
2505
2506
2515 public List<JournalContentSearch> findByG_P_A(long groupId,
2516 boolean privateLayout, String articleId) throws SystemException {
2517 return findByG_P_A(groupId, privateLayout, articleId,
2518 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2519 }
2520
2521
2536 public List<JournalContentSearch> findByG_P_A(long groupId,
2537 boolean privateLayout, String articleId, int start, int end)
2538 throws SystemException {
2539 return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
2540 }
2541
2542
2558 public List<JournalContentSearch> findByG_P_A(long groupId,
2559 boolean privateLayout, String articleId, int start, int end,
2560 OrderByComparator orderByComparator) throws SystemException {
2561 FinderPath finderPath = null;
2562 Object[] finderArgs = null;
2563
2564 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2565 (orderByComparator == null)) {
2566 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A;
2567 finderArgs = new Object[] { groupId, privateLayout, articleId };
2568 }
2569 else {
2570 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_A;
2571 finderArgs = new Object[] {
2572 groupId, privateLayout, articleId,
2573
2574 start, end, orderByComparator
2575 };
2576 }
2577
2578 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2579 finderArgs, this);
2580
2581 if ((list != null) && !list.isEmpty()) {
2582 for (JournalContentSearch journalContentSearch : list) {
2583 if ((groupId != journalContentSearch.getGroupId()) ||
2584 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2585 !Validator.equals(articleId,
2586 journalContentSearch.getArticleId())) {
2587 list = null;
2588
2589 break;
2590 }
2591 }
2592 }
2593
2594 if (list == null) {
2595 StringBundler query = null;
2596
2597 if (orderByComparator != null) {
2598 query = new StringBundler(5 +
2599 (orderByComparator.getOrderByFields().length * 3));
2600 }
2601 else {
2602 query = new StringBundler(4);
2603 }
2604
2605 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2606
2607 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2608
2609 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2610
2611 if (articleId == null) {
2612 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2613 }
2614 else {
2615 if (articleId.equals(StringPool.BLANK)) {
2616 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2617 }
2618 else {
2619 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2620 }
2621 }
2622
2623 if (orderByComparator != null) {
2624 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2625 orderByComparator);
2626 }
2627
2628 String sql = query.toString();
2629
2630 Session session = null;
2631
2632 try {
2633 session = openSession();
2634
2635 Query q = session.createQuery(sql);
2636
2637 QueryPos qPos = QueryPos.getInstance(q);
2638
2639 qPos.add(groupId);
2640
2641 qPos.add(privateLayout);
2642
2643 if (articleId != null) {
2644 qPos.add(articleId);
2645 }
2646
2647 list = (List<JournalContentSearch>)QueryUtil.list(q,
2648 getDialect(), start, end);
2649 }
2650 catch (Exception e) {
2651 throw processException(e);
2652 }
2653 finally {
2654 if (list == null) {
2655 FinderCacheUtil.removeResult(finderPath, finderArgs);
2656 }
2657 else {
2658 cacheResult(list);
2659
2660 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2661 }
2662
2663 closeSession(session);
2664 }
2665 }
2666
2667 return list;
2668 }
2669
2670
2681 public JournalContentSearch findByG_P_A_First(long groupId,
2682 boolean privateLayout, String articleId,
2683 OrderByComparator orderByComparator)
2684 throws NoSuchContentSearchException, SystemException {
2685 JournalContentSearch journalContentSearch = fetchByG_P_A_First(groupId,
2686 privateLayout, articleId, orderByComparator);
2687
2688 if (journalContentSearch != null) {
2689 return journalContentSearch;
2690 }
2691
2692 StringBundler msg = new StringBundler(8);
2693
2694 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2695
2696 msg.append("groupId=");
2697 msg.append(groupId);
2698
2699 msg.append(", privateLayout=");
2700 msg.append(privateLayout);
2701
2702 msg.append(", articleId=");
2703 msg.append(articleId);
2704
2705 msg.append(StringPool.CLOSE_CURLY_BRACE);
2706
2707 throw new NoSuchContentSearchException(msg.toString());
2708 }
2709
2710
2720 public JournalContentSearch fetchByG_P_A_First(long groupId,
2721 boolean privateLayout, String articleId,
2722 OrderByComparator orderByComparator) throws SystemException {
2723 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2724 articleId, 0, 1, orderByComparator);
2725
2726 if (!list.isEmpty()) {
2727 return list.get(0);
2728 }
2729
2730 return null;
2731 }
2732
2733
2744 public JournalContentSearch findByG_P_A_Last(long groupId,
2745 boolean privateLayout, String articleId,
2746 OrderByComparator orderByComparator)
2747 throws NoSuchContentSearchException, SystemException {
2748 JournalContentSearch journalContentSearch = fetchByG_P_A_Last(groupId,
2749 privateLayout, articleId, orderByComparator);
2750
2751 if (journalContentSearch != null) {
2752 return journalContentSearch;
2753 }
2754
2755 StringBundler msg = new StringBundler(8);
2756
2757 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2758
2759 msg.append("groupId=");
2760 msg.append(groupId);
2761
2762 msg.append(", privateLayout=");
2763 msg.append(privateLayout);
2764
2765 msg.append(", articleId=");
2766 msg.append(articleId);
2767
2768 msg.append(StringPool.CLOSE_CURLY_BRACE);
2769
2770 throw new NoSuchContentSearchException(msg.toString());
2771 }
2772
2773
2783 public JournalContentSearch fetchByG_P_A_Last(long groupId,
2784 boolean privateLayout, String articleId,
2785 OrderByComparator orderByComparator) throws SystemException {
2786 int count = countByG_P_A(groupId, privateLayout, articleId);
2787
2788 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2789 articleId, count - 1, count, orderByComparator);
2790
2791 if (!list.isEmpty()) {
2792 return list.get(0);
2793 }
2794
2795 return null;
2796 }
2797
2798
2810 public JournalContentSearch[] findByG_P_A_PrevAndNext(
2811 long contentSearchId, long groupId, boolean privateLayout,
2812 String articleId, OrderByComparator orderByComparator)
2813 throws NoSuchContentSearchException, SystemException {
2814 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2815
2816 Session session = null;
2817
2818 try {
2819 session = openSession();
2820
2821 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2822
2823 array[0] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2824 groupId, privateLayout, articleId, orderByComparator, true);
2825
2826 array[1] = journalContentSearch;
2827
2828 array[2] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2829 groupId, privateLayout, articleId, orderByComparator, false);
2830
2831 return array;
2832 }
2833 catch (Exception e) {
2834 throw processException(e);
2835 }
2836 finally {
2837 closeSession(session);
2838 }
2839 }
2840
2841 protected JournalContentSearch getByG_P_A_PrevAndNext(Session session,
2842 JournalContentSearch journalContentSearch, long groupId,
2843 boolean privateLayout, String articleId,
2844 OrderByComparator orderByComparator, boolean previous) {
2845 StringBundler query = null;
2846
2847 if (orderByComparator != null) {
2848 query = new StringBundler(6 +
2849 (orderByComparator.getOrderByFields().length * 6));
2850 }
2851 else {
2852 query = new StringBundler(3);
2853 }
2854
2855 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2856
2857 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2858
2859 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2860
2861 if (articleId == null) {
2862 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2863 }
2864 else {
2865 if (articleId.equals(StringPool.BLANK)) {
2866 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2867 }
2868 else {
2869 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2870 }
2871 }
2872
2873 if (orderByComparator != null) {
2874 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2875
2876 if (orderByConditionFields.length > 0) {
2877 query.append(WHERE_AND);
2878 }
2879
2880 for (int i = 0; i < orderByConditionFields.length; i++) {
2881 query.append(_ORDER_BY_ENTITY_ALIAS);
2882 query.append(orderByConditionFields[i]);
2883
2884 if ((i + 1) < orderByConditionFields.length) {
2885 if (orderByComparator.isAscending() ^ previous) {
2886 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2887 }
2888 else {
2889 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2890 }
2891 }
2892 else {
2893 if (orderByComparator.isAscending() ^ previous) {
2894 query.append(WHERE_GREATER_THAN);
2895 }
2896 else {
2897 query.append(WHERE_LESSER_THAN);
2898 }
2899 }
2900 }
2901
2902 query.append(ORDER_BY_CLAUSE);
2903
2904 String[] orderByFields = orderByComparator.getOrderByFields();
2905
2906 for (int i = 0; i < orderByFields.length; i++) {
2907 query.append(_ORDER_BY_ENTITY_ALIAS);
2908 query.append(orderByFields[i]);
2909
2910 if ((i + 1) < orderByFields.length) {
2911 if (orderByComparator.isAscending() ^ previous) {
2912 query.append(ORDER_BY_ASC_HAS_NEXT);
2913 }
2914 else {
2915 query.append(ORDER_BY_DESC_HAS_NEXT);
2916 }
2917 }
2918 else {
2919 if (orderByComparator.isAscending() ^ previous) {
2920 query.append(ORDER_BY_ASC);
2921 }
2922 else {
2923 query.append(ORDER_BY_DESC);
2924 }
2925 }
2926 }
2927 }
2928
2929 String sql = query.toString();
2930
2931 Query q = session.createQuery(sql);
2932
2933 q.setFirstResult(0);
2934 q.setMaxResults(2);
2935
2936 QueryPos qPos = QueryPos.getInstance(q);
2937
2938 qPos.add(groupId);
2939
2940 qPos.add(privateLayout);
2941
2942 if (articleId != null) {
2943 qPos.add(articleId);
2944 }
2945
2946 if (orderByComparator != null) {
2947 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2948
2949 for (Object value : values) {
2950 qPos.add(value);
2951 }
2952 }
2953
2954 List<JournalContentSearch> list = q.list();
2955
2956 if (list.size() == 2) {
2957 return list.get(1);
2958 }
2959 else {
2960 return null;
2961 }
2962 }
2963
2964
2974 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2975 boolean privateLayout, long layoutId, String portletId)
2976 throws SystemException {
2977 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
2978 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2979 }
2980
2981
2997 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2998 boolean privateLayout, long layoutId, String portletId, int start,
2999 int end) throws SystemException {
3000 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
3001 start, end, null);
3002 }
3003
3004
3021 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3022 boolean privateLayout, long layoutId, String portletId, int start,
3023 int end, OrderByComparator orderByComparator) throws SystemException {
3024 FinderPath finderPath = null;
3025 Object[] finderArgs = null;
3026
3027 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3028 (orderByComparator == null)) {
3029 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P;
3030 finderArgs = new Object[] {
3031 groupId, privateLayout, layoutId, portletId
3032 };
3033 }
3034 else {
3035 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L_P;
3036 finderArgs = new Object[] {
3037 groupId, privateLayout, layoutId, portletId,
3038
3039 start, end, orderByComparator
3040 };
3041 }
3042
3043 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
3044 finderArgs, this);
3045
3046 if ((list != null) && !list.isEmpty()) {
3047 for (JournalContentSearch journalContentSearch : list) {
3048 if ((groupId != journalContentSearch.getGroupId()) ||
3049 (privateLayout != journalContentSearch.getPrivateLayout()) ||
3050 (layoutId != journalContentSearch.getLayoutId()) ||
3051 !Validator.equals(portletId,
3052 journalContentSearch.getPortletId())) {
3053 list = null;
3054
3055 break;
3056 }
3057 }
3058 }
3059
3060 if (list == null) {
3061 StringBundler query = null;
3062
3063 if (orderByComparator != null) {
3064 query = new StringBundler(6 +
3065 (orderByComparator.getOrderByFields().length * 3));
3066 }
3067 else {
3068 query = new StringBundler(5);
3069 }
3070
3071 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3072
3073 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3074
3075 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3076
3077 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3078
3079 if (portletId == null) {
3080 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3081 }
3082 else {
3083 if (portletId.equals(StringPool.BLANK)) {
3084 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3085 }
3086 else {
3087 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3088 }
3089 }
3090
3091 if (orderByComparator != null) {
3092 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3093 orderByComparator);
3094 }
3095
3096 String sql = query.toString();
3097
3098 Session session = null;
3099
3100 try {
3101 session = openSession();
3102
3103 Query q = session.createQuery(sql);
3104
3105 QueryPos qPos = QueryPos.getInstance(q);
3106
3107 qPos.add(groupId);
3108
3109 qPos.add(privateLayout);
3110
3111 qPos.add(layoutId);
3112
3113 if (portletId != null) {
3114 qPos.add(portletId);
3115 }
3116
3117 list = (List<JournalContentSearch>)QueryUtil.list(q,
3118 getDialect(), start, end);
3119 }
3120 catch (Exception e) {
3121 throw processException(e);
3122 }
3123 finally {
3124 if (list == null) {
3125 FinderCacheUtil.removeResult(finderPath, finderArgs);
3126 }
3127 else {
3128 cacheResult(list);
3129
3130 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3131 }
3132
3133 closeSession(session);
3134 }
3135 }
3136
3137 return list;
3138 }
3139
3140
3152 public JournalContentSearch findByG_P_L_P_First(long groupId,
3153 boolean privateLayout, long layoutId, String portletId,
3154 OrderByComparator orderByComparator)
3155 throws NoSuchContentSearchException, SystemException {
3156 JournalContentSearch journalContentSearch = fetchByG_P_L_P_First(groupId,
3157 privateLayout, layoutId, portletId, orderByComparator);
3158
3159 if (journalContentSearch != null) {
3160 return journalContentSearch;
3161 }
3162
3163 StringBundler msg = new StringBundler(10);
3164
3165 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3166
3167 msg.append("groupId=");
3168 msg.append(groupId);
3169
3170 msg.append(", privateLayout=");
3171 msg.append(privateLayout);
3172
3173 msg.append(", layoutId=");
3174 msg.append(layoutId);
3175
3176 msg.append(", portletId=");
3177 msg.append(portletId);
3178
3179 msg.append(StringPool.CLOSE_CURLY_BRACE);
3180
3181 throw new NoSuchContentSearchException(msg.toString());
3182 }
3183
3184
3195 public JournalContentSearch fetchByG_P_L_P_First(long groupId,
3196 boolean privateLayout, long layoutId, String portletId,
3197 OrderByComparator orderByComparator) throws SystemException {
3198 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3199 layoutId, portletId, 0, 1, orderByComparator);
3200
3201 if (!list.isEmpty()) {
3202 return list.get(0);
3203 }
3204
3205 return null;
3206 }
3207
3208
3220 public JournalContentSearch findByG_P_L_P_Last(long groupId,
3221 boolean privateLayout, long layoutId, String portletId,
3222 OrderByComparator orderByComparator)
3223 throws NoSuchContentSearchException, SystemException {
3224 JournalContentSearch journalContentSearch = fetchByG_P_L_P_Last(groupId,
3225 privateLayout, layoutId, portletId, orderByComparator);
3226
3227 if (journalContentSearch != null) {
3228 return journalContentSearch;
3229 }
3230
3231 StringBundler msg = new StringBundler(10);
3232
3233 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3234
3235 msg.append("groupId=");
3236 msg.append(groupId);
3237
3238 msg.append(", privateLayout=");
3239 msg.append(privateLayout);
3240
3241 msg.append(", layoutId=");
3242 msg.append(layoutId);
3243
3244 msg.append(", portletId=");
3245 msg.append(portletId);
3246
3247 msg.append(StringPool.CLOSE_CURLY_BRACE);
3248
3249 throw new NoSuchContentSearchException(msg.toString());
3250 }
3251
3252
3263 public JournalContentSearch fetchByG_P_L_P_Last(long groupId,
3264 boolean privateLayout, long layoutId, String portletId,
3265 OrderByComparator orderByComparator) throws SystemException {
3266 int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
3267
3268 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3269 layoutId, portletId, count - 1, count, orderByComparator);
3270
3271 if (!list.isEmpty()) {
3272 return list.get(0);
3273 }
3274
3275 return null;
3276 }
3277
3278
3291 public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
3292 long contentSearchId, long groupId, boolean privateLayout,
3293 long layoutId, String portletId, OrderByComparator orderByComparator)
3294 throws NoSuchContentSearchException, SystemException {
3295 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
3296
3297 Session session = null;
3298
3299 try {
3300 session = openSession();
3301
3302 JournalContentSearch[] array = new JournalContentSearchImpl[3];
3303
3304 array[0] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3305 groupId, privateLayout, layoutId, portletId,
3306 orderByComparator, true);
3307
3308 array[1] = journalContentSearch;
3309
3310 array[2] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3311 groupId, privateLayout, layoutId, portletId,
3312 orderByComparator, false);
3313
3314 return array;
3315 }
3316 catch (Exception e) {
3317 throw processException(e);
3318 }
3319 finally {
3320 closeSession(session);
3321 }
3322 }
3323
3324 protected JournalContentSearch getByG_P_L_P_PrevAndNext(Session session,
3325 JournalContentSearch journalContentSearch, long groupId,
3326 boolean privateLayout, long layoutId, String portletId,
3327 OrderByComparator orderByComparator, boolean previous) {
3328 StringBundler query = null;
3329
3330 if (orderByComparator != null) {
3331 query = new StringBundler(6 +
3332 (orderByComparator.getOrderByFields().length * 6));
3333 }
3334 else {
3335 query = new StringBundler(3);
3336 }
3337
3338 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3339
3340 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3341
3342 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3343
3344 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3345
3346 if (portletId == null) {
3347 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3348 }
3349 else {
3350 if (portletId.equals(StringPool.BLANK)) {
3351 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3352 }
3353 else {
3354 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3355 }
3356 }
3357
3358 if (orderByComparator != null) {
3359 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3360
3361 if (orderByConditionFields.length > 0) {
3362 query.append(WHERE_AND);
3363 }
3364
3365 for (int i = 0; i < orderByConditionFields.length; i++) {
3366 query.append(_ORDER_BY_ENTITY_ALIAS);
3367 query.append(orderByConditionFields[i]);
3368
3369 if ((i + 1) < orderByConditionFields.length) {
3370 if (orderByComparator.isAscending() ^ previous) {
3371 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3372 }
3373 else {
3374 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3375 }
3376 }
3377 else {
3378 if (orderByComparator.isAscending() ^ previous) {
3379 query.append(WHERE_GREATER_THAN);
3380 }
3381 else {
3382 query.append(WHERE_LESSER_THAN);
3383 }
3384 }
3385 }
3386
3387 query.append(ORDER_BY_CLAUSE);
3388
3389 String[] orderByFields = orderByComparator.getOrderByFields();
3390
3391 for (int i = 0; i < orderByFields.length; i++) {
3392 query.append(_ORDER_BY_ENTITY_ALIAS);
3393 query.append(orderByFields[i]);
3394
3395 if ((i + 1) < orderByFields.length) {
3396 if (orderByComparator.isAscending() ^ previous) {
3397 query.append(ORDER_BY_ASC_HAS_NEXT);
3398 }
3399 else {
3400 query.append(ORDER_BY_DESC_HAS_NEXT);
3401 }
3402 }
3403 else {
3404 if (orderByComparator.isAscending() ^ previous) {
3405 query.append(ORDER_BY_ASC);
3406 }
3407 else {
3408 query.append(ORDER_BY_DESC);
3409 }
3410 }
3411 }
3412 }
3413
3414 String sql = query.toString();
3415
3416 Query q = session.createQuery(sql);
3417
3418 q.setFirstResult(0);
3419 q.setMaxResults(2);
3420
3421 QueryPos qPos = QueryPos.getInstance(q);
3422
3423 qPos.add(groupId);
3424
3425 qPos.add(privateLayout);
3426
3427 qPos.add(layoutId);
3428
3429 if (portletId != null) {
3430 qPos.add(portletId);
3431 }
3432
3433 if (orderByComparator != null) {
3434 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
3435
3436 for (Object value : values) {
3437 qPos.add(value);
3438 }
3439 }
3440
3441 List<JournalContentSearch> list = q.list();
3442
3443 if (list.size() == 2) {
3444 return list.get(1);
3445 }
3446 else {
3447 return null;
3448 }
3449 }
3450
3451
3463 public JournalContentSearch findByG_P_L_P_A(long groupId,
3464 boolean privateLayout, long layoutId, String portletId, String articleId)
3465 throws NoSuchContentSearchException, SystemException {
3466 JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
3467 privateLayout, layoutId, portletId, articleId);
3468
3469 if (journalContentSearch == null) {
3470 StringBundler msg = new StringBundler(12);
3471
3472 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3473
3474 msg.append("groupId=");
3475 msg.append(groupId);
3476
3477 msg.append(", privateLayout=");
3478 msg.append(privateLayout);
3479
3480 msg.append(", layoutId=");
3481 msg.append(layoutId);
3482
3483 msg.append(", portletId=");
3484 msg.append(portletId);
3485
3486 msg.append(", articleId=");
3487 msg.append(articleId);
3488
3489 msg.append(StringPool.CLOSE_CURLY_BRACE);
3490
3491 if (_log.isWarnEnabled()) {
3492 _log.warn(msg.toString());
3493 }
3494
3495 throw new NoSuchContentSearchException(msg.toString());
3496 }
3497
3498 return journalContentSearch;
3499 }
3500
3501
3512 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
3513 boolean privateLayout, long layoutId, String portletId, String articleId)
3514 throws SystemException {
3515 return fetchByG_P_L_P_A(groupId, privateLayout, layoutId, portletId,
3516 articleId, true);
3517 }
3518
3519
3531 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
3532 boolean privateLayout, long layoutId, String portletId,
3533 String articleId, boolean retrieveFromCache) throws SystemException {
3534 Object[] finderArgs = new Object[] {
3535 groupId, privateLayout, layoutId, portletId, articleId
3536 };
3537
3538 Object result = null;
3539
3540 if (retrieveFromCache) {
3541 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3542 finderArgs, this);
3543 }
3544
3545 if (result instanceof JournalContentSearch) {
3546 JournalContentSearch journalContentSearch = (JournalContentSearch)result;
3547
3548 if ((groupId != journalContentSearch.getGroupId()) ||
3549 (privateLayout != journalContentSearch.getPrivateLayout()) ||
3550 (layoutId != journalContentSearch.getLayoutId()) ||
3551 !Validator.equals(portletId,
3552 journalContentSearch.getPortletId()) ||
3553 !Validator.equals(articleId,
3554 journalContentSearch.getArticleId())) {
3555 result = null;
3556 }
3557 }
3558
3559 if (result == null) {
3560 StringBundler query = new StringBundler(6);
3561
3562 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3563
3564 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
3565
3566 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
3567
3568 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
3569
3570 if (portletId == null) {
3571 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
3572 }
3573 else {
3574 if (portletId.equals(StringPool.BLANK)) {
3575 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
3576 }
3577 else {
3578 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
3579 }
3580 }
3581
3582 if (articleId == null) {
3583 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
3584 }
3585 else {
3586 if (articleId.equals(StringPool.BLANK)) {
3587 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
3588 }
3589 else {
3590 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
3591 }
3592 }
3593
3594 String sql = query.toString();
3595
3596 Session session = null;
3597
3598 try {
3599 session = openSession();
3600
3601 Query q = session.createQuery(sql);
3602
3603 QueryPos qPos = QueryPos.getInstance(q);
3604
3605 qPos.add(groupId);
3606
3607 qPos.add(privateLayout);
3608
3609 qPos.add(layoutId);
3610
3611 if (portletId != null) {
3612 qPos.add(portletId);
3613 }
3614
3615 if (articleId != null) {
3616 qPos.add(articleId);
3617 }
3618
3619 List<JournalContentSearch> list = q.list();
3620
3621 result = list;
3622
3623 JournalContentSearch journalContentSearch = null;
3624
3625 if (list.isEmpty()) {
3626 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3627 finderArgs, list);
3628 }
3629 else {
3630 journalContentSearch = list.get(0);
3631
3632 cacheResult(journalContentSearch);
3633
3634 if ((journalContentSearch.getGroupId() != groupId) ||
3635 (journalContentSearch.getPrivateLayout() != privateLayout) ||
3636 (journalContentSearch.getLayoutId() != layoutId) ||
3637 (journalContentSearch.getPortletId() == null) ||
3638 !journalContentSearch.getPortletId()
3639 .equals(portletId) ||
3640 (journalContentSearch.getArticleId() == null) ||
3641 !journalContentSearch.getArticleId()
3642 .equals(articleId)) {
3643 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3644 finderArgs, journalContentSearch);
3645 }
3646 }
3647
3648 return journalContentSearch;
3649 }
3650 catch (Exception e) {
3651 throw processException(e);
3652 }
3653 finally {
3654 if (result == null) {
3655 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3656 finderArgs);
3657 }
3658
3659 closeSession(session);
3660 }
3661 }
3662 else {
3663 if (result instanceof List<?>) {
3664 return null;
3665 }
3666 else {
3667 return (JournalContentSearch)result;
3668 }
3669 }
3670 }
3671
3672
3678 public List<JournalContentSearch> findAll() throws SystemException {
3679 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3680 }
3681
3682
3694 public List<JournalContentSearch> findAll(int start, int end)
3695 throws SystemException {
3696 return findAll(start, end, null);
3697 }
3698
3699
3712 public List<JournalContentSearch> findAll(int start, int end,
3713 OrderByComparator orderByComparator) throws SystemException {
3714 FinderPath finderPath = null;
3715 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3716
3717 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3718 (orderByComparator == null)) {
3719 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3720 finderArgs = FINDER_ARGS_EMPTY;
3721 }
3722 else {
3723 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3724 finderArgs = new Object[] { start, end, orderByComparator };
3725 }
3726
3727 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
3728 finderArgs, this);
3729
3730 if (list == null) {
3731 StringBundler query = null;
3732 String sql = null;
3733
3734 if (orderByComparator != null) {
3735 query = new StringBundler(2 +
3736 (orderByComparator.getOrderByFields().length * 3));
3737
3738 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
3739
3740 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3741 orderByComparator);
3742
3743 sql = query.toString();
3744 }
3745 else {
3746 sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
3747 }
3748
3749 Session session = null;
3750
3751 try {
3752 session = openSession();
3753
3754 Query q = session.createQuery(sql);
3755
3756 if (orderByComparator == null) {
3757 list = (List<JournalContentSearch>)QueryUtil.list(q,
3758 getDialect(), start, end, false);
3759
3760 Collections.sort(list);
3761 }
3762 else {
3763 list = (List<JournalContentSearch>)QueryUtil.list(q,
3764 getDialect(), start, end);
3765 }
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
3793 public void removeByArticleId(String articleId) throws SystemException {
3794 for (JournalContentSearch journalContentSearch : findByArticleId(
3795 articleId)) {
3796 remove(journalContentSearch);
3797 }
3798 }
3799
3800
3807 public void removeByG_P(long groupId, boolean privateLayout)
3808 throws SystemException {
3809 for (JournalContentSearch journalContentSearch : findByG_P(groupId,
3810 privateLayout)) {
3811 remove(journalContentSearch);
3812 }
3813 }
3814
3815
3822 public void removeByG_A(long groupId, String articleId)
3823 throws SystemException {
3824 for (JournalContentSearch journalContentSearch : findByG_A(groupId,
3825 articleId)) {
3826 remove(journalContentSearch);
3827 }
3828 }
3829
3830
3838 public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
3839 throws SystemException {
3840 for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
3841 privateLayout, layoutId)) {
3842 remove(journalContentSearch);
3843 }
3844 }
3845
3846
3854 public void removeByG_P_A(long groupId, boolean privateLayout,
3855 String articleId) throws SystemException {
3856 for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
3857 privateLayout, articleId)) {
3858 remove(journalContentSearch);
3859 }
3860 }
3861
3862
3871 public void removeByG_P_L_P(long groupId, boolean privateLayout,
3872 long layoutId, String portletId) throws SystemException {
3873 for (JournalContentSearch journalContentSearch : findByG_P_L_P(
3874 groupId, privateLayout, layoutId, portletId)) {
3875 remove(journalContentSearch);
3876 }
3877 }
3878
3879
3890 public JournalContentSearch removeByG_P_L_P_A(long groupId,
3891 boolean privateLayout, long layoutId, String portletId, String articleId)
3892 throws NoSuchContentSearchException, SystemException {
3893 JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
3894 privateLayout, layoutId, portletId, articleId);
3895
3896 return remove(journalContentSearch);
3897 }
3898
3899
3904 public void removeAll() throws SystemException {
3905 for (JournalContentSearch journalContentSearch : findAll()) {
3906 remove(journalContentSearch);
3907 }
3908 }
3909
3910
3917 public int countByArticleId(String articleId) throws SystemException {
3918 Object[] finderArgs = new Object[] { articleId };
3919
3920 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3921 finderArgs, this);
3922
3923 if (count == null) {
3924 StringBundler query = new StringBundler(2);
3925
3926 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3927
3928 if (articleId == null) {
3929 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
3930 }
3931 else {
3932 if (articleId.equals(StringPool.BLANK)) {
3933 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
3934 }
3935 else {
3936 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
3937 }
3938 }
3939
3940 String sql = query.toString();
3941
3942 Session session = null;
3943
3944 try {
3945 session = openSession();
3946
3947 Query q = session.createQuery(sql);
3948
3949 QueryPos qPos = QueryPos.getInstance(q);
3950
3951 if (articleId != null) {
3952 qPos.add(articleId);
3953 }
3954
3955 count = (Long)q.uniqueResult();
3956 }
3957 catch (Exception e) {
3958 throw processException(e);
3959 }
3960 finally {
3961 if (count == null) {
3962 count = Long.valueOf(0);
3963 }
3964
3965 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3966 finderArgs, count);
3967
3968 closeSession(session);
3969 }
3970 }
3971
3972 return count.intValue();
3973 }
3974
3975
3983 public int countByG_P(long groupId, boolean privateLayout)
3984 throws SystemException {
3985 Object[] finderArgs = new Object[] { groupId, privateLayout };
3986
3987 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
3988 finderArgs, this);
3989
3990 if (count == null) {
3991 StringBundler query = new StringBundler(3);
3992
3993 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3994
3995 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3996
3997 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
3998
3999 String sql = query.toString();
4000
4001 Session session = null;
4002
4003 try {
4004 session = openSession();
4005
4006 Query q = session.createQuery(sql);
4007
4008 QueryPos qPos = QueryPos.getInstance(q);
4009
4010 qPos.add(groupId);
4011
4012 qPos.add(privateLayout);
4013
4014 count = (Long)q.uniqueResult();
4015 }
4016 catch (Exception e) {
4017 throw processException(e);
4018 }
4019 finally {
4020 if (count == null) {
4021 count = Long.valueOf(0);
4022 }
4023
4024 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
4025 count);
4026
4027 closeSession(session);
4028 }
4029 }
4030
4031 return count.intValue();
4032 }
4033
4034
4042 public int countByG_A(long groupId, String articleId)
4043 throws SystemException {
4044 Object[] finderArgs = new Object[] { groupId, articleId };
4045
4046 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
4047 finderArgs, this);
4048
4049 if (count == null) {
4050 StringBundler query = new StringBundler(3);
4051
4052 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4053
4054 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4055
4056 if (articleId == null) {
4057 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4058 }
4059 else {
4060 if (articleId.equals(StringPool.BLANK)) {
4061 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4062 }
4063 else {
4064 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4065 }
4066 }
4067
4068 String sql = query.toString();
4069
4070 Session session = null;
4071
4072 try {
4073 session = openSession();
4074
4075 Query q = session.createQuery(sql);
4076
4077 QueryPos qPos = QueryPos.getInstance(q);
4078
4079 qPos.add(groupId);
4080
4081 if (articleId != null) {
4082 qPos.add(articleId);
4083 }
4084
4085 count = (Long)q.uniqueResult();
4086 }
4087 catch (Exception e) {
4088 throw processException(e);
4089 }
4090 finally {
4091 if (count == null) {
4092 count = Long.valueOf(0);
4093 }
4094
4095 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
4096 count);
4097
4098 closeSession(session);
4099 }
4100 }
4101
4102 return count.intValue();
4103 }
4104
4105
4114 public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
4115 throws SystemException {
4116 Object[] finderArgs = new Object[] { groupId, privateLayout, layoutId };
4117
4118 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L,
4119 finderArgs, this);
4120
4121 if (count == null) {
4122 StringBundler query = new StringBundler(4);
4123
4124 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4125
4126 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
4127
4128 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
4129
4130 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
4131
4132 String sql = query.toString();
4133
4134 Session session = null;
4135
4136 try {
4137 session = openSession();
4138
4139 Query q = session.createQuery(sql);
4140
4141 QueryPos qPos = QueryPos.getInstance(q);
4142
4143 qPos.add(groupId);
4144
4145 qPos.add(privateLayout);
4146
4147 qPos.add(layoutId);
4148
4149 count = (Long)q.uniqueResult();
4150 }
4151 catch (Exception e) {
4152 throw processException(e);
4153 }
4154 finally {
4155 if (count == null) {
4156 count = Long.valueOf(0);
4157 }
4158
4159 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L,
4160 finderArgs, count);
4161
4162 closeSession(session);
4163 }
4164 }
4165
4166 return count.intValue();
4167 }
4168
4169
4178 public int countByG_P_A(long groupId, boolean privateLayout,
4179 String articleId) throws SystemException {
4180 Object[] finderArgs = new Object[] { groupId, privateLayout, articleId };
4181
4182 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_A,
4183 finderArgs, this);
4184
4185 if (count == null) {
4186 StringBundler query = new StringBundler(4);
4187
4188 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4189
4190 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
4191
4192 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
4193
4194 if (articleId == null) {
4195 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
4196 }
4197 else {
4198 if (articleId.equals(StringPool.BLANK)) {
4199 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
4200 }
4201 else {
4202 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
4203 }
4204 }
4205
4206 String sql = query.toString();
4207
4208 Session session = null;
4209
4210 try {
4211 session = openSession();
4212
4213 Query q = session.createQuery(sql);
4214
4215 QueryPos qPos = QueryPos.getInstance(q);
4216
4217 qPos.add(groupId);
4218
4219 qPos.add(privateLayout);
4220
4221 if (articleId != null) {
4222 qPos.add(articleId);
4223 }
4224
4225 count = (Long)q.uniqueResult();
4226 }
4227 catch (Exception e) {
4228 throw processException(e);
4229 }
4230 finally {
4231 if (count == null) {
4232 count = Long.valueOf(0);
4233 }
4234
4235 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_A,
4236 finderArgs, count);
4237
4238 closeSession(session);
4239 }
4240 }
4241
4242 return count.intValue();
4243 }
4244
4245
4255 public int countByG_P_L_P(long groupId, boolean privateLayout,
4256 long layoutId, String portletId) throws SystemException {
4257 Object[] finderArgs = new Object[] {
4258 groupId, privateLayout, layoutId, portletId
4259 };
4260
4261 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P,
4262 finderArgs, this);
4263
4264 if (count == null) {
4265 StringBundler query = new StringBundler(5);
4266
4267 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4268
4269 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
4270
4271 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
4272
4273 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
4274
4275 if (portletId == null) {
4276 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
4277 }
4278 else {
4279 if (portletId.equals(StringPool.BLANK)) {
4280 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
4281 }
4282 else {
4283 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
4284 }
4285 }
4286
4287 String sql = query.toString();
4288
4289 Session session = null;
4290
4291 try {
4292 session = openSession();
4293
4294 Query q = session.createQuery(sql);
4295
4296 QueryPos qPos = QueryPos.getInstance(q);
4297
4298 qPos.add(groupId);
4299
4300 qPos.add(privateLayout);
4301
4302 qPos.add(layoutId);
4303
4304 if (portletId != null) {
4305 qPos.add(portletId);
4306 }
4307
4308 count = (Long)q.uniqueResult();
4309 }
4310 catch (Exception e) {
4311 throw processException(e);
4312 }
4313 finally {
4314 if (count == null) {
4315 count = Long.valueOf(0);
4316 }
4317
4318 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P,
4319 finderArgs, count);
4320
4321 closeSession(session);
4322 }
4323 }
4324
4325 return count.intValue();
4326 }
4327
4328
4339 public int countByG_P_L_P_A(long groupId, boolean privateLayout,
4340 long layoutId, String portletId, String articleId)
4341 throws SystemException {
4342 Object[] finderArgs = new Object[] {
4343 groupId, privateLayout, layoutId, portletId, articleId
4344 };
4345
4346 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
4347 finderArgs, this);
4348
4349 if (count == null) {
4350 StringBundler query = new StringBundler(6);
4351
4352 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4353
4354 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
4355
4356 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
4357
4358 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
4359
4360 if (portletId == null) {
4361 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
4362 }
4363 else {
4364 if (portletId.equals(StringPool.BLANK)) {
4365 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
4366 }
4367 else {
4368 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
4369 }
4370 }
4371
4372 if (articleId == null) {
4373 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
4374 }
4375 else {
4376 if (articleId.equals(StringPool.BLANK)) {
4377 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
4378 }
4379 else {
4380 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
4381 }
4382 }
4383
4384 String sql = query.toString();
4385
4386 Session session = null;
4387
4388 try {
4389 session = openSession();
4390
4391 Query q = session.createQuery(sql);
4392
4393 QueryPos qPos = QueryPos.getInstance(q);
4394
4395 qPos.add(groupId);
4396
4397 qPos.add(privateLayout);
4398
4399 qPos.add(layoutId);
4400
4401 if (portletId != null) {
4402 qPos.add(portletId);
4403 }
4404
4405 if (articleId != null) {
4406 qPos.add(articleId);
4407 }
4408
4409 count = (Long)q.uniqueResult();
4410 }
4411 catch (Exception e) {
4412 throw processException(e);
4413 }
4414 finally {
4415 if (count == null) {
4416 count = Long.valueOf(0);
4417 }
4418
4419 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
4420 finderArgs, count);
4421
4422 closeSession(session);
4423 }
4424 }
4425
4426 return count.intValue();
4427 }
4428
4429
4435 public int countAll() throws SystemException {
4436 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4437 FINDER_ARGS_EMPTY, this);
4438
4439 if (count == null) {
4440 Session session = null;
4441
4442 try {
4443 session = openSession();
4444
4445 Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
4446
4447 count = (Long)q.uniqueResult();
4448 }
4449 catch (Exception e) {
4450 throw processException(e);
4451 }
4452 finally {
4453 if (count == null) {
4454 count = Long.valueOf(0);
4455 }
4456
4457 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4458 FINDER_ARGS_EMPTY, count);
4459
4460 closeSession(session);
4461 }
4462 }
4463
4464 return count.intValue();
4465 }
4466
4467
4470 public void afterPropertiesSet() {
4471 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4472 com.liferay.portal.util.PropsUtil.get(
4473 "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch")));
4474
4475 if (listenerClassNames.length > 0) {
4476 try {
4477 List<ModelListener<JournalContentSearch>> listenersList = new ArrayList<ModelListener<JournalContentSearch>>();
4478
4479 for (String listenerClassName : listenerClassNames) {
4480 Class<?> clazz = getClass();
4481
4482 listenersList.add((ModelListener<JournalContentSearch>)InstanceFactory.newInstance(
4483 clazz.getClassLoader(), listenerClassName));
4484 }
4485
4486 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4487 }
4488 catch (Exception e) {
4489 _log.error(e);
4490 }
4491 }
4492 }
4493
4494 public void destroy() {
4495 EntityCacheUtil.removeCache(JournalContentSearchImpl.class.getName());
4496 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4497 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4498 }
4499
4500 @BeanReference(type = JournalArticlePersistence.class)
4501 protected JournalArticlePersistence journalArticlePersistence;
4502 @BeanReference(type = JournalArticleImagePersistence.class)
4503 protected JournalArticleImagePersistence journalArticleImagePersistence;
4504 @BeanReference(type = JournalArticleResourcePersistence.class)
4505 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
4506 @BeanReference(type = JournalContentSearchPersistence.class)
4507 protected JournalContentSearchPersistence journalContentSearchPersistence;
4508 @BeanReference(type = JournalFeedPersistence.class)
4509 protected JournalFeedPersistence journalFeedPersistence;
4510 @BeanReference(type = JournalStructurePersistence.class)
4511 protected JournalStructurePersistence journalStructurePersistence;
4512 @BeanReference(type = JournalTemplatePersistence.class)
4513 protected JournalTemplatePersistence journalTemplatePersistence;
4514 @BeanReference(type = GroupPersistence.class)
4515 protected GroupPersistence groupPersistence;
4516 @BeanReference(type = LayoutPersistence.class)
4517 protected LayoutPersistence layoutPersistence;
4518 @BeanReference(type = PortletPreferencesPersistence.class)
4519 protected PortletPreferencesPersistence portletPreferencesPersistence;
4520 @BeanReference(type = ResourcePersistence.class)
4521 protected ResourcePersistence resourcePersistence;
4522 @BeanReference(type = UserPersistence.class)
4523 protected UserPersistence userPersistence;
4524 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
4525 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
4526 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
4527 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
4528 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4529 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4530 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
4531 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4532 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
4533 private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4534 private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4535 private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4536 private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
4537 private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4538 private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4539 private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
4540 private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4541 private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4542 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4543 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4544 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
4545 private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4546 private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4547 private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4548 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
4549 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
4550 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?)";
4551 private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4552 private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4553 private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4554 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
4555 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
4556 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?) AND ";
4557 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4558 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4559 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
4560 private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
4561 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
4562 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
4563 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4564 private static Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
4565 private static JournalContentSearch _nullJournalContentSearch = new JournalContentSearchImpl() {
4566 @Override
4567 public Object clone() {
4568 return this;
4569 }
4570
4571 @Override
4572 public CacheModel<JournalContentSearch> toCacheModel() {
4573 return _nullJournalContentSearchCacheModel;
4574 }
4575 };
4576
4577 private static CacheModel<JournalContentSearch> _nullJournalContentSearchCacheModel =
4578 new CacheModel<JournalContentSearch>() {
4579 public JournalContentSearch toEntityModel() {
4580 return _nullJournalContentSearch;
4581 }
4582 };
4583 }