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 clearUniqueFindersCache(
365 JournalContentSearch journalContentSearch) {
366 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
367 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
378
384 public JournalContentSearch create(long contentSearchId) {
385 JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
386
387 journalContentSearch.setNew(true);
388 journalContentSearch.setPrimaryKey(contentSearchId);
389
390 return journalContentSearch;
391 }
392
393
401 public JournalContentSearch remove(long contentSearchId)
402 throws NoSuchContentSearchException, SystemException {
403 return remove(Long.valueOf(contentSearchId));
404 }
405
406
414 @Override
415 public JournalContentSearch remove(Serializable primaryKey)
416 throws NoSuchContentSearchException, SystemException {
417 Session session = null;
418
419 try {
420 session = openSession();
421
422 JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
423 primaryKey);
424
425 if (journalContentSearch == null) {
426 if (_log.isWarnEnabled()) {
427 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
428 }
429
430 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
431 primaryKey);
432 }
433
434 return remove(journalContentSearch);
435 }
436 catch (NoSuchContentSearchException nsee) {
437 throw nsee;
438 }
439 catch (Exception e) {
440 throw processException(e);
441 }
442 finally {
443 closeSession(session);
444 }
445 }
446
447 @Override
448 protected JournalContentSearch removeImpl(
449 JournalContentSearch journalContentSearch) throws SystemException {
450 journalContentSearch = toUnwrappedModel(journalContentSearch);
451
452 Session session = null;
453
454 try {
455 session = openSession();
456
457 BatchSessionUtil.delete(session, journalContentSearch);
458 }
459 catch (Exception e) {
460 throw processException(e);
461 }
462 finally {
463 closeSession(session);
464 }
465
466 clearCache(journalContentSearch);
467
468 return journalContentSearch;
469 }
470
471 @Override
472 public JournalContentSearch updateImpl(
473 com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch,
474 boolean merge) throws SystemException {
475 journalContentSearch = toUnwrappedModel(journalContentSearch);
476
477 boolean isNew = journalContentSearch.isNew();
478
479 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
480
481 Session session = null;
482
483 try {
484 session = openSession();
485
486 BatchSessionUtil.update(session, journalContentSearch, merge);
487
488 journalContentSearch.setNew(false);
489 }
490 catch (Exception e) {
491 throw processException(e);
492 }
493 finally {
494 closeSession(session);
495 }
496
497 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
498
499 if (isNew || !JournalContentSearchModelImpl.COLUMN_BITMASK_ENABLED) {
500 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
501 }
502
503 else {
504 if ((journalContentSearchModelImpl.getColumnBitmask() &
505 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID.getColumnBitmask()) != 0) {
506 Object[] args = new Object[] {
507 journalContentSearchModelImpl.getOriginalArticleId()
508 };
509
510 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
511 args);
512 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
513 args);
514
515 args = new Object[] { journalContentSearchModelImpl.getArticleId() };
516
517 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
518 args);
519 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
520 args);
521 }
522
523 if ((journalContentSearchModelImpl.getColumnBitmask() &
524 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
525 Object[] args = new Object[] {
526 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
527 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout())
528 };
529
530 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
531 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
532 args);
533
534 args = new Object[] {
535 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
536 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout())
537 };
538
539 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
540 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
541 args);
542 }
543
544 if ((journalContentSearchModelImpl.getColumnBitmask() &
545 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
546 Object[] args = new Object[] {
547 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
548
549 journalContentSearchModelImpl.getOriginalArticleId()
550 };
551
552 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
553 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
554 args);
555
556 args = new Object[] {
557 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
558
559 journalContentSearchModelImpl.getArticleId()
560 };
561
562 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
563 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
564 args);
565 }
566
567 if ((journalContentSearchModelImpl.getColumnBitmask() &
568 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L.getColumnBitmask()) != 0) {
569 Object[] args = new Object[] {
570 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
571 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
572 Long.valueOf(journalContentSearchModelImpl.getOriginalLayoutId())
573 };
574
575 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
576 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
577 args);
578
579 args = new Object[] {
580 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
581 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout()),
582 Long.valueOf(journalContentSearchModelImpl.getLayoutId())
583 };
584
585 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
586 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
587 args);
588 }
589
590 if ((journalContentSearchModelImpl.getColumnBitmask() &
591 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A.getColumnBitmask()) != 0) {
592 Object[] args = new Object[] {
593 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
594 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
595
596 journalContentSearchModelImpl.getOriginalArticleId()
597 };
598
599 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
600 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
601 args);
602
603 args = new Object[] {
604 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
605 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout()),
606
607 journalContentSearchModelImpl.getArticleId()
608 };
609
610 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
611 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
612 args);
613 }
614
615 if ((journalContentSearchModelImpl.getColumnBitmask() &
616 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P.getColumnBitmask()) != 0) {
617 Object[] args = new Object[] {
618 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
619 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
620 Long.valueOf(journalContentSearchModelImpl.getOriginalLayoutId()),
621
622 journalContentSearchModelImpl.getOriginalPortletId()
623 };
624
625 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
626 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
627 args);
628
629 args = new Object[] {
630 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
631 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout()),
632 Long.valueOf(journalContentSearchModelImpl.getLayoutId()),
633
634 journalContentSearchModelImpl.getPortletId()
635 };
636
637 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
638 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
639 args);
640 }
641 }
642
643 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
644 JournalContentSearchImpl.class,
645 journalContentSearch.getPrimaryKey(), journalContentSearch);
646
647 if (isNew) {
648 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
649 new Object[] {
650 Long.valueOf(journalContentSearch.getGroupId()),
651 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
652 Long.valueOf(journalContentSearch.getLayoutId()),
653
654 journalContentSearch.getPortletId(),
655
656 journalContentSearch.getArticleId()
657 }, journalContentSearch);
658 }
659 else {
660 if ((journalContentSearchModelImpl.getColumnBitmask() &
661 FINDER_PATH_FETCH_BY_G_P_L_P_A.getColumnBitmask()) != 0) {
662 Object[] args = new Object[] {
663 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
664 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
665 Long.valueOf(journalContentSearchModelImpl.getOriginalLayoutId()),
666
667 journalContentSearchModelImpl.getOriginalPortletId(),
668
669 journalContentSearchModelImpl.getOriginalArticleId()
670 };
671
672 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
673 args);
674
675 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
676 args);
677
678 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
679 new Object[] {
680 Long.valueOf(journalContentSearch.getGroupId()),
681 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
682 Long.valueOf(journalContentSearch.getLayoutId()),
683
684 journalContentSearch.getPortletId(),
685
686 journalContentSearch.getArticleId()
687 }, journalContentSearch);
688 }
689 }
690
691 return journalContentSearch;
692 }
693
694 protected JournalContentSearch toUnwrappedModel(
695 JournalContentSearch journalContentSearch) {
696 if (journalContentSearch instanceof JournalContentSearchImpl) {
697 return journalContentSearch;
698 }
699
700 JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
701
702 journalContentSearchImpl.setNew(journalContentSearch.isNew());
703 journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
704
705 journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
706 journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
707 journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
708 journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
709 journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
710 journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
711 journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
712
713 return journalContentSearchImpl;
714 }
715
716
724 @Override
725 public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
726 throws NoSuchModelException, SystemException {
727 return findByPrimaryKey(((Long)primaryKey).longValue());
728 }
729
730
738 public JournalContentSearch findByPrimaryKey(long contentSearchId)
739 throws NoSuchContentSearchException, SystemException {
740 JournalContentSearch journalContentSearch = fetchByPrimaryKey(contentSearchId);
741
742 if (journalContentSearch == null) {
743 if (_log.isWarnEnabled()) {
744 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contentSearchId);
745 }
746
747 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
748 contentSearchId);
749 }
750
751 return journalContentSearch;
752 }
753
754
761 @Override
762 public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey)
763 throws SystemException {
764 return fetchByPrimaryKey(((Long)primaryKey).longValue());
765 }
766
767
774 public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
775 throws SystemException {
776 JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
777 JournalContentSearchImpl.class, contentSearchId);
778
779 if (journalContentSearch == _nullJournalContentSearch) {
780 return null;
781 }
782
783 if (journalContentSearch == null) {
784 Session session = null;
785
786 boolean hasException = false;
787
788 try {
789 session = openSession();
790
791 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
792 Long.valueOf(contentSearchId));
793 }
794 catch (Exception e) {
795 hasException = true;
796
797 throw processException(e);
798 }
799 finally {
800 if (journalContentSearch != null) {
801 cacheResult(journalContentSearch);
802 }
803 else if (!hasException) {
804 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
805 JournalContentSearchImpl.class, contentSearchId,
806 _nullJournalContentSearch);
807 }
808
809 closeSession(session);
810 }
811 }
812
813 return journalContentSearch;
814 }
815
816
823 public List<JournalContentSearch> findByArticleId(String articleId)
824 throws SystemException {
825 return findByArticleId(articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
826 null);
827 }
828
829
842 public List<JournalContentSearch> findByArticleId(String articleId,
843 int start, int end) throws SystemException {
844 return findByArticleId(articleId, start, end, null);
845 }
846
847
861 public List<JournalContentSearch> findByArticleId(String articleId,
862 int start, int end, OrderByComparator orderByComparator)
863 throws SystemException {
864 FinderPath finderPath = null;
865 Object[] finderArgs = null;
866
867 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
868 (orderByComparator == null)) {
869 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID;
870 finderArgs = new Object[] { articleId };
871 }
872 else {
873 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ARTICLEID;
874 finderArgs = new Object[] { articleId, start, end, orderByComparator };
875 }
876
877 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
878 finderArgs, this);
879
880 if ((list != null) && !list.isEmpty()) {
881 for (JournalContentSearch journalContentSearch : list) {
882 if (!Validator.equals(articleId,
883 journalContentSearch.getArticleId())) {
884 list = null;
885
886 break;
887 }
888 }
889 }
890
891 if (list == null) {
892 StringBundler query = null;
893
894 if (orderByComparator != null) {
895 query = new StringBundler(3 +
896 (orderByComparator.getOrderByFields().length * 3));
897 }
898 else {
899 query = new StringBundler(2);
900 }
901
902 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
903
904 if (articleId == null) {
905 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
906 }
907 else {
908 if (articleId.equals(StringPool.BLANK)) {
909 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
910 }
911 else {
912 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
913 }
914 }
915
916 if (orderByComparator != null) {
917 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
918 orderByComparator);
919 }
920
921 String sql = query.toString();
922
923 Session session = null;
924
925 try {
926 session = openSession();
927
928 Query q = session.createQuery(sql);
929
930 QueryPos qPos = QueryPos.getInstance(q);
931
932 if (articleId != null) {
933 qPos.add(articleId);
934 }
935
936 list = (List<JournalContentSearch>)QueryUtil.list(q,
937 getDialect(), start, end);
938 }
939 catch (Exception e) {
940 throw processException(e);
941 }
942 finally {
943 if (list == null) {
944 FinderCacheUtil.removeResult(finderPath, finderArgs);
945 }
946 else {
947 cacheResult(list);
948
949 FinderCacheUtil.putResult(finderPath, finderArgs, list);
950 }
951
952 closeSession(session);
953 }
954 }
955
956 return list;
957 }
958
959
968 public JournalContentSearch findByArticleId_First(String articleId,
969 OrderByComparator orderByComparator)
970 throws NoSuchContentSearchException, SystemException {
971 JournalContentSearch journalContentSearch = fetchByArticleId_First(articleId,
972 orderByComparator);
973
974 if (journalContentSearch != null) {
975 return journalContentSearch;
976 }
977
978 StringBundler msg = new StringBundler(4);
979
980 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
981
982 msg.append("articleId=");
983 msg.append(articleId);
984
985 msg.append(StringPool.CLOSE_CURLY_BRACE);
986
987 throw new NoSuchContentSearchException(msg.toString());
988 }
989
990
998 public JournalContentSearch fetchByArticleId_First(String articleId,
999 OrderByComparator orderByComparator) throws SystemException {
1000 List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
1001 orderByComparator);
1002
1003 if (!list.isEmpty()) {
1004 return list.get(0);
1005 }
1006
1007 return null;
1008 }
1009
1010
1019 public JournalContentSearch findByArticleId_Last(String articleId,
1020 OrderByComparator orderByComparator)
1021 throws NoSuchContentSearchException, SystemException {
1022 JournalContentSearch journalContentSearch = fetchByArticleId_Last(articleId,
1023 orderByComparator);
1024
1025 if (journalContentSearch != null) {
1026 return journalContentSearch;
1027 }
1028
1029 StringBundler msg = new StringBundler(4);
1030
1031 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1032
1033 msg.append("articleId=");
1034 msg.append(articleId);
1035
1036 msg.append(StringPool.CLOSE_CURLY_BRACE);
1037
1038 throw new NoSuchContentSearchException(msg.toString());
1039 }
1040
1041
1049 public JournalContentSearch fetchByArticleId_Last(String articleId,
1050 OrderByComparator orderByComparator) throws SystemException {
1051 int count = countByArticleId(articleId);
1052
1053 List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
1054 count, orderByComparator);
1055
1056 if (!list.isEmpty()) {
1057 return list.get(0);
1058 }
1059
1060 return null;
1061 }
1062
1063
1073 public JournalContentSearch[] findByArticleId_PrevAndNext(
1074 long contentSearchId, String articleId,
1075 OrderByComparator orderByComparator)
1076 throws NoSuchContentSearchException, SystemException {
1077 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1078
1079 Session session = null;
1080
1081 try {
1082 session = openSession();
1083
1084 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1085
1086 array[0] = getByArticleId_PrevAndNext(session,
1087 journalContentSearch, articleId, orderByComparator, true);
1088
1089 array[1] = journalContentSearch;
1090
1091 array[2] = getByArticleId_PrevAndNext(session,
1092 journalContentSearch, articleId, orderByComparator, false);
1093
1094 return array;
1095 }
1096 catch (Exception e) {
1097 throw processException(e);
1098 }
1099 finally {
1100 closeSession(session);
1101 }
1102 }
1103
1104 protected JournalContentSearch getByArticleId_PrevAndNext(Session session,
1105 JournalContentSearch journalContentSearch, String articleId,
1106 OrderByComparator orderByComparator, boolean previous) {
1107 StringBundler query = null;
1108
1109 if (orderByComparator != null) {
1110 query = new StringBundler(6 +
1111 (orderByComparator.getOrderByFields().length * 6));
1112 }
1113 else {
1114 query = new StringBundler(3);
1115 }
1116
1117 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1118
1119 if (articleId == null) {
1120 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
1121 }
1122 else {
1123 if (articleId.equals(StringPool.BLANK)) {
1124 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
1125 }
1126 else {
1127 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
1128 }
1129 }
1130
1131 if (orderByComparator != null) {
1132 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1133
1134 if (orderByConditionFields.length > 0) {
1135 query.append(WHERE_AND);
1136 }
1137
1138 for (int i = 0; i < orderByConditionFields.length; i++) {
1139 query.append(_ORDER_BY_ENTITY_ALIAS);
1140 query.append(orderByConditionFields[i]);
1141
1142 if ((i + 1) < orderByConditionFields.length) {
1143 if (orderByComparator.isAscending() ^ previous) {
1144 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1145 }
1146 else {
1147 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1148 }
1149 }
1150 else {
1151 if (orderByComparator.isAscending() ^ previous) {
1152 query.append(WHERE_GREATER_THAN);
1153 }
1154 else {
1155 query.append(WHERE_LESSER_THAN);
1156 }
1157 }
1158 }
1159
1160 query.append(ORDER_BY_CLAUSE);
1161
1162 String[] orderByFields = orderByComparator.getOrderByFields();
1163
1164 for (int i = 0; i < orderByFields.length; i++) {
1165 query.append(_ORDER_BY_ENTITY_ALIAS);
1166 query.append(orderByFields[i]);
1167
1168 if ((i + 1) < orderByFields.length) {
1169 if (orderByComparator.isAscending() ^ previous) {
1170 query.append(ORDER_BY_ASC_HAS_NEXT);
1171 }
1172 else {
1173 query.append(ORDER_BY_DESC_HAS_NEXT);
1174 }
1175 }
1176 else {
1177 if (orderByComparator.isAscending() ^ previous) {
1178 query.append(ORDER_BY_ASC);
1179 }
1180 else {
1181 query.append(ORDER_BY_DESC);
1182 }
1183 }
1184 }
1185 }
1186
1187 String sql = query.toString();
1188
1189 Query q = session.createQuery(sql);
1190
1191 q.setFirstResult(0);
1192 q.setMaxResults(2);
1193
1194 QueryPos qPos = QueryPos.getInstance(q);
1195
1196 if (articleId != null) {
1197 qPos.add(articleId);
1198 }
1199
1200 if (orderByComparator != null) {
1201 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1202
1203 for (Object value : values) {
1204 qPos.add(value);
1205 }
1206 }
1207
1208 List<JournalContentSearch> list = q.list();
1209
1210 if (list.size() == 2) {
1211 return list.get(1);
1212 }
1213 else {
1214 return null;
1215 }
1216 }
1217
1218
1226 public List<JournalContentSearch> findByG_P(long groupId,
1227 boolean privateLayout) throws SystemException {
1228 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1229 QueryUtil.ALL_POS, null);
1230 }
1231
1232
1246 public List<JournalContentSearch> findByG_P(long groupId,
1247 boolean privateLayout, int start, int end) throws SystemException {
1248 return findByG_P(groupId, privateLayout, start, end, null);
1249 }
1250
1251
1266 public List<JournalContentSearch> findByG_P(long groupId,
1267 boolean privateLayout, int start, int end,
1268 OrderByComparator orderByComparator) throws SystemException {
1269 FinderPath finderPath = null;
1270 Object[] finderArgs = null;
1271
1272 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1273 (orderByComparator == null)) {
1274 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1275 finderArgs = new Object[] { groupId, privateLayout };
1276 }
1277 else {
1278 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1279 finderArgs = new Object[] {
1280 groupId, privateLayout,
1281
1282 start, end, orderByComparator
1283 };
1284 }
1285
1286 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1287 finderArgs, this);
1288
1289 if ((list != null) && !list.isEmpty()) {
1290 for (JournalContentSearch journalContentSearch : list) {
1291 if ((groupId != journalContentSearch.getGroupId()) ||
1292 (privateLayout != journalContentSearch.getPrivateLayout())) {
1293 list = null;
1294
1295 break;
1296 }
1297 }
1298 }
1299
1300 if (list == null) {
1301 StringBundler query = null;
1302
1303 if (orderByComparator != null) {
1304 query = new StringBundler(4 +
1305 (orderByComparator.getOrderByFields().length * 3));
1306 }
1307 else {
1308 query = new StringBundler(3);
1309 }
1310
1311 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1312
1313 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1314
1315 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1316
1317 if (orderByComparator != null) {
1318 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1319 orderByComparator);
1320 }
1321
1322 String sql = query.toString();
1323
1324 Session session = null;
1325
1326 try {
1327 session = openSession();
1328
1329 Query q = session.createQuery(sql);
1330
1331 QueryPos qPos = QueryPos.getInstance(q);
1332
1333 qPos.add(groupId);
1334
1335 qPos.add(privateLayout);
1336
1337 list = (List<JournalContentSearch>)QueryUtil.list(q,
1338 getDialect(), start, end);
1339 }
1340 catch (Exception e) {
1341 throw processException(e);
1342 }
1343 finally {
1344 if (list == null) {
1345 FinderCacheUtil.removeResult(finderPath, finderArgs);
1346 }
1347 else {
1348 cacheResult(list);
1349
1350 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1351 }
1352
1353 closeSession(session);
1354 }
1355 }
1356
1357 return list;
1358 }
1359
1360
1370 public JournalContentSearch findByG_P_First(long groupId,
1371 boolean privateLayout, OrderByComparator orderByComparator)
1372 throws NoSuchContentSearchException, SystemException {
1373 JournalContentSearch journalContentSearch = fetchByG_P_First(groupId,
1374 privateLayout, orderByComparator);
1375
1376 if (journalContentSearch != null) {
1377 return journalContentSearch;
1378 }
1379
1380 StringBundler msg = new StringBundler(6);
1381
1382 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1383
1384 msg.append("groupId=");
1385 msg.append(groupId);
1386
1387 msg.append(", privateLayout=");
1388 msg.append(privateLayout);
1389
1390 msg.append(StringPool.CLOSE_CURLY_BRACE);
1391
1392 throw new NoSuchContentSearchException(msg.toString());
1393 }
1394
1395
1404 public JournalContentSearch fetchByG_P_First(long groupId,
1405 boolean privateLayout, OrderByComparator orderByComparator)
1406 throws SystemException {
1407 List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
1408 1, orderByComparator);
1409
1410 if (!list.isEmpty()) {
1411 return list.get(0);
1412 }
1413
1414 return null;
1415 }
1416
1417
1427 public JournalContentSearch findByG_P_Last(long groupId,
1428 boolean privateLayout, OrderByComparator orderByComparator)
1429 throws NoSuchContentSearchException, SystemException {
1430 JournalContentSearch journalContentSearch = fetchByG_P_Last(groupId,
1431 privateLayout, orderByComparator);
1432
1433 if (journalContentSearch != null) {
1434 return journalContentSearch;
1435 }
1436
1437 StringBundler msg = new StringBundler(6);
1438
1439 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1440
1441 msg.append("groupId=");
1442 msg.append(groupId);
1443
1444 msg.append(", privateLayout=");
1445 msg.append(privateLayout);
1446
1447 msg.append(StringPool.CLOSE_CURLY_BRACE);
1448
1449 throw new NoSuchContentSearchException(msg.toString());
1450 }
1451
1452
1461 public JournalContentSearch fetchByG_P_Last(long groupId,
1462 boolean privateLayout, OrderByComparator orderByComparator)
1463 throws SystemException {
1464 int count = countByG_P(groupId, privateLayout);
1465
1466 List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
1467 count - 1, count, orderByComparator);
1468
1469 if (!list.isEmpty()) {
1470 return list.get(0);
1471 }
1472
1473 return null;
1474 }
1475
1476
1487 public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
1488 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1489 throws NoSuchContentSearchException, SystemException {
1490 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1491
1492 Session session = null;
1493
1494 try {
1495 session = openSession();
1496
1497 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1498
1499 array[0] = getByG_P_PrevAndNext(session, journalContentSearch,
1500 groupId, privateLayout, orderByComparator, true);
1501
1502 array[1] = journalContentSearch;
1503
1504 array[2] = getByG_P_PrevAndNext(session, journalContentSearch,
1505 groupId, privateLayout, orderByComparator, false);
1506
1507 return array;
1508 }
1509 catch (Exception e) {
1510 throw processException(e);
1511 }
1512 finally {
1513 closeSession(session);
1514 }
1515 }
1516
1517 protected JournalContentSearch getByG_P_PrevAndNext(Session session,
1518 JournalContentSearch journalContentSearch, long groupId,
1519 boolean privateLayout, OrderByComparator orderByComparator,
1520 boolean previous) {
1521 StringBundler query = null;
1522
1523 if (orderByComparator != null) {
1524 query = new StringBundler(6 +
1525 (orderByComparator.getOrderByFields().length * 6));
1526 }
1527 else {
1528 query = new StringBundler(3);
1529 }
1530
1531 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1532
1533 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1534
1535 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1536
1537 if (orderByComparator != null) {
1538 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1539
1540 if (orderByConditionFields.length > 0) {
1541 query.append(WHERE_AND);
1542 }
1543
1544 for (int i = 0; i < orderByConditionFields.length; i++) {
1545 query.append(_ORDER_BY_ENTITY_ALIAS);
1546 query.append(orderByConditionFields[i]);
1547
1548 if ((i + 1) < orderByConditionFields.length) {
1549 if (orderByComparator.isAscending() ^ previous) {
1550 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1551 }
1552 else {
1553 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1554 }
1555 }
1556 else {
1557 if (orderByComparator.isAscending() ^ previous) {
1558 query.append(WHERE_GREATER_THAN);
1559 }
1560 else {
1561 query.append(WHERE_LESSER_THAN);
1562 }
1563 }
1564 }
1565
1566 query.append(ORDER_BY_CLAUSE);
1567
1568 String[] orderByFields = orderByComparator.getOrderByFields();
1569
1570 for (int i = 0; i < orderByFields.length; i++) {
1571 query.append(_ORDER_BY_ENTITY_ALIAS);
1572 query.append(orderByFields[i]);
1573
1574 if ((i + 1) < orderByFields.length) {
1575 if (orderByComparator.isAscending() ^ previous) {
1576 query.append(ORDER_BY_ASC_HAS_NEXT);
1577 }
1578 else {
1579 query.append(ORDER_BY_DESC_HAS_NEXT);
1580 }
1581 }
1582 else {
1583 if (orderByComparator.isAscending() ^ previous) {
1584 query.append(ORDER_BY_ASC);
1585 }
1586 else {
1587 query.append(ORDER_BY_DESC);
1588 }
1589 }
1590 }
1591 }
1592
1593 String sql = query.toString();
1594
1595 Query q = session.createQuery(sql);
1596
1597 q.setFirstResult(0);
1598 q.setMaxResults(2);
1599
1600 QueryPos qPos = QueryPos.getInstance(q);
1601
1602 qPos.add(groupId);
1603
1604 qPos.add(privateLayout);
1605
1606 if (orderByComparator != null) {
1607 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1608
1609 for (Object value : values) {
1610 qPos.add(value);
1611 }
1612 }
1613
1614 List<JournalContentSearch> list = q.list();
1615
1616 if (list.size() == 2) {
1617 return list.get(1);
1618 }
1619 else {
1620 return null;
1621 }
1622 }
1623
1624
1632 public List<JournalContentSearch> findByG_A(long groupId, String articleId)
1633 throws SystemException {
1634 return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
1635 QueryUtil.ALL_POS, null);
1636 }
1637
1638
1652 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1653 int start, int end) throws SystemException {
1654 return findByG_A(groupId, articleId, start, end, null);
1655 }
1656
1657
1672 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1673 int start, int end, OrderByComparator orderByComparator)
1674 throws SystemException {
1675 FinderPath finderPath = null;
1676 Object[] finderArgs = null;
1677
1678 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1679 (orderByComparator == null)) {
1680 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
1681 finderArgs = new Object[] { groupId, articleId };
1682 }
1683 else {
1684 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
1685 finderArgs = new Object[] {
1686 groupId, articleId,
1687
1688 start, end, orderByComparator
1689 };
1690 }
1691
1692 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1693 finderArgs, this);
1694
1695 if ((list != null) && !list.isEmpty()) {
1696 for (JournalContentSearch journalContentSearch : list) {
1697 if ((groupId != journalContentSearch.getGroupId()) ||
1698 !Validator.equals(articleId,
1699 journalContentSearch.getArticleId())) {
1700 list = null;
1701
1702 break;
1703 }
1704 }
1705 }
1706
1707 if (list == null) {
1708 StringBundler query = null;
1709
1710 if (orderByComparator != null) {
1711 query = new StringBundler(4 +
1712 (orderByComparator.getOrderByFields().length * 3));
1713 }
1714 else {
1715 query = new StringBundler(3);
1716 }
1717
1718 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1719
1720 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1721
1722 if (articleId == null) {
1723 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1724 }
1725 else {
1726 if (articleId.equals(StringPool.BLANK)) {
1727 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1728 }
1729 else {
1730 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1731 }
1732 }
1733
1734 if (orderByComparator != null) {
1735 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1736 orderByComparator);
1737 }
1738
1739 String sql = query.toString();
1740
1741 Session session = null;
1742
1743 try {
1744 session = openSession();
1745
1746 Query q = session.createQuery(sql);
1747
1748 QueryPos qPos = QueryPos.getInstance(q);
1749
1750 qPos.add(groupId);
1751
1752 if (articleId != null) {
1753 qPos.add(articleId);
1754 }
1755
1756 list = (List<JournalContentSearch>)QueryUtil.list(q,
1757 getDialect(), start, end);
1758 }
1759 catch (Exception e) {
1760 throw processException(e);
1761 }
1762 finally {
1763 if (list == null) {
1764 FinderCacheUtil.removeResult(finderPath, finderArgs);
1765 }
1766 else {
1767 cacheResult(list);
1768
1769 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1770 }
1771
1772 closeSession(session);
1773 }
1774 }
1775
1776 return list;
1777 }
1778
1779
1789 public JournalContentSearch findByG_A_First(long groupId, String articleId,
1790 OrderByComparator orderByComparator)
1791 throws NoSuchContentSearchException, SystemException {
1792 JournalContentSearch journalContentSearch = fetchByG_A_First(groupId,
1793 articleId, orderByComparator);
1794
1795 if (journalContentSearch != null) {
1796 return journalContentSearch;
1797 }
1798
1799 StringBundler msg = new StringBundler(6);
1800
1801 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1802
1803 msg.append("groupId=");
1804 msg.append(groupId);
1805
1806 msg.append(", articleId=");
1807 msg.append(articleId);
1808
1809 msg.append(StringPool.CLOSE_CURLY_BRACE);
1810
1811 throw new NoSuchContentSearchException(msg.toString());
1812 }
1813
1814
1823 public JournalContentSearch fetchByG_A_First(long groupId,
1824 String articleId, OrderByComparator orderByComparator)
1825 throws SystemException {
1826 List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1827 orderByComparator);
1828
1829 if (!list.isEmpty()) {
1830 return list.get(0);
1831 }
1832
1833 return null;
1834 }
1835
1836
1846 public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1847 OrderByComparator orderByComparator)
1848 throws NoSuchContentSearchException, SystemException {
1849 JournalContentSearch journalContentSearch = fetchByG_A_Last(groupId,
1850 articleId, orderByComparator);
1851
1852 if (journalContentSearch != null) {
1853 return journalContentSearch;
1854 }
1855
1856 StringBundler msg = new StringBundler(6);
1857
1858 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1859
1860 msg.append("groupId=");
1861 msg.append(groupId);
1862
1863 msg.append(", articleId=");
1864 msg.append(articleId);
1865
1866 msg.append(StringPool.CLOSE_CURLY_BRACE);
1867
1868 throw new NoSuchContentSearchException(msg.toString());
1869 }
1870
1871
1880 public JournalContentSearch fetchByG_A_Last(long groupId, String articleId,
1881 OrderByComparator orderByComparator) throws SystemException {
1882 int count = countByG_A(groupId, articleId);
1883
1884 List<JournalContentSearch> list = findByG_A(groupId, articleId,
1885 count - 1, count, orderByComparator);
1886
1887 if (!list.isEmpty()) {
1888 return list.get(0);
1889 }
1890
1891 return null;
1892 }
1893
1894
1905 public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
1906 long groupId, String articleId, OrderByComparator orderByComparator)
1907 throws NoSuchContentSearchException, SystemException {
1908 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1909
1910 Session session = null;
1911
1912 try {
1913 session = openSession();
1914
1915 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1916
1917 array[0] = getByG_A_PrevAndNext(session, journalContentSearch,
1918 groupId, articleId, orderByComparator, true);
1919
1920 array[1] = journalContentSearch;
1921
1922 array[2] = getByG_A_PrevAndNext(session, journalContentSearch,
1923 groupId, articleId, orderByComparator, false);
1924
1925 return array;
1926 }
1927 catch (Exception e) {
1928 throw processException(e);
1929 }
1930 finally {
1931 closeSession(session);
1932 }
1933 }
1934
1935 protected JournalContentSearch getByG_A_PrevAndNext(Session session,
1936 JournalContentSearch journalContentSearch, long groupId,
1937 String articleId, OrderByComparator orderByComparator, boolean previous) {
1938 StringBundler query = null;
1939
1940 if (orderByComparator != null) {
1941 query = new StringBundler(6 +
1942 (orderByComparator.getOrderByFields().length * 6));
1943 }
1944 else {
1945 query = new StringBundler(3);
1946 }
1947
1948 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1949
1950 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1951
1952 if (articleId == null) {
1953 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1954 }
1955 else {
1956 if (articleId.equals(StringPool.BLANK)) {
1957 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1958 }
1959 else {
1960 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1961 }
1962 }
1963
1964 if (orderByComparator != null) {
1965 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1966
1967 if (orderByConditionFields.length > 0) {
1968 query.append(WHERE_AND);
1969 }
1970
1971 for (int i = 0; i < orderByConditionFields.length; i++) {
1972 query.append(_ORDER_BY_ENTITY_ALIAS);
1973 query.append(orderByConditionFields[i]);
1974
1975 if ((i + 1) < orderByConditionFields.length) {
1976 if (orderByComparator.isAscending() ^ previous) {
1977 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1978 }
1979 else {
1980 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1981 }
1982 }
1983 else {
1984 if (orderByComparator.isAscending() ^ previous) {
1985 query.append(WHERE_GREATER_THAN);
1986 }
1987 else {
1988 query.append(WHERE_LESSER_THAN);
1989 }
1990 }
1991 }
1992
1993 query.append(ORDER_BY_CLAUSE);
1994
1995 String[] orderByFields = orderByComparator.getOrderByFields();
1996
1997 for (int i = 0; i < orderByFields.length; i++) {
1998 query.append(_ORDER_BY_ENTITY_ALIAS);
1999 query.append(orderByFields[i]);
2000
2001 if ((i + 1) < orderByFields.length) {
2002 if (orderByComparator.isAscending() ^ previous) {
2003 query.append(ORDER_BY_ASC_HAS_NEXT);
2004 }
2005 else {
2006 query.append(ORDER_BY_DESC_HAS_NEXT);
2007 }
2008 }
2009 else {
2010 if (orderByComparator.isAscending() ^ previous) {
2011 query.append(ORDER_BY_ASC);
2012 }
2013 else {
2014 query.append(ORDER_BY_DESC);
2015 }
2016 }
2017 }
2018 }
2019
2020 String sql = query.toString();
2021
2022 Query q = session.createQuery(sql);
2023
2024 q.setFirstResult(0);
2025 q.setMaxResults(2);
2026
2027 QueryPos qPos = QueryPos.getInstance(q);
2028
2029 qPos.add(groupId);
2030
2031 if (articleId != null) {
2032 qPos.add(articleId);
2033 }
2034
2035 if (orderByComparator != null) {
2036 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2037
2038 for (Object value : values) {
2039 qPos.add(value);
2040 }
2041 }
2042
2043 List<JournalContentSearch> list = q.list();
2044
2045 if (list.size() == 2) {
2046 return list.get(1);
2047 }
2048 else {
2049 return null;
2050 }
2051 }
2052
2053
2062 public List<JournalContentSearch> findByG_P_L(long groupId,
2063 boolean privateLayout, long layoutId) throws SystemException {
2064 return findByG_P_L(groupId, privateLayout, layoutId, QueryUtil.ALL_POS,
2065 QueryUtil.ALL_POS, null);
2066 }
2067
2068
2083 public List<JournalContentSearch> findByG_P_L(long groupId,
2084 boolean privateLayout, long layoutId, int start, int end)
2085 throws SystemException {
2086 return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
2087 }
2088
2089
2105 public List<JournalContentSearch> findByG_P_L(long groupId,
2106 boolean privateLayout, long layoutId, int start, int end,
2107 OrderByComparator orderByComparator) throws SystemException {
2108 FinderPath finderPath = null;
2109 Object[] finderArgs = null;
2110
2111 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2112 (orderByComparator == null)) {
2113 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L;
2114 finderArgs = new Object[] { groupId, privateLayout, layoutId };
2115 }
2116 else {
2117 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L;
2118 finderArgs = new Object[] {
2119 groupId, privateLayout, layoutId,
2120
2121 start, end, orderByComparator
2122 };
2123 }
2124
2125 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2126 finderArgs, this);
2127
2128 if ((list != null) && !list.isEmpty()) {
2129 for (JournalContentSearch journalContentSearch : list) {
2130 if ((groupId != journalContentSearch.getGroupId()) ||
2131 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2132 (layoutId != journalContentSearch.getLayoutId())) {
2133 list = null;
2134
2135 break;
2136 }
2137 }
2138 }
2139
2140 if (list == null) {
2141 StringBundler query = null;
2142
2143 if (orderByComparator != null) {
2144 query = new StringBundler(5 +
2145 (orderByComparator.getOrderByFields().length * 3));
2146 }
2147 else {
2148 query = new StringBundler(4);
2149 }
2150
2151 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2152
2153 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2154
2155 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2156
2157 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2158
2159 if (orderByComparator != null) {
2160 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2161 orderByComparator);
2162 }
2163
2164 String sql = query.toString();
2165
2166 Session session = null;
2167
2168 try {
2169 session = openSession();
2170
2171 Query q = session.createQuery(sql);
2172
2173 QueryPos qPos = QueryPos.getInstance(q);
2174
2175 qPos.add(groupId);
2176
2177 qPos.add(privateLayout);
2178
2179 qPos.add(layoutId);
2180
2181 list = (List<JournalContentSearch>)QueryUtil.list(q,
2182 getDialect(), start, end);
2183 }
2184 catch (Exception e) {
2185 throw processException(e);
2186 }
2187 finally {
2188 if (list == null) {
2189 FinderCacheUtil.removeResult(finderPath, finderArgs);
2190 }
2191 else {
2192 cacheResult(list);
2193
2194 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2195 }
2196
2197 closeSession(session);
2198 }
2199 }
2200
2201 return list;
2202 }
2203
2204
2215 public JournalContentSearch findByG_P_L_First(long groupId,
2216 boolean privateLayout, long layoutId,
2217 OrderByComparator orderByComparator)
2218 throws NoSuchContentSearchException, SystemException {
2219 JournalContentSearch journalContentSearch = fetchByG_P_L_First(groupId,
2220 privateLayout, layoutId, orderByComparator);
2221
2222 if (journalContentSearch != null) {
2223 return journalContentSearch;
2224 }
2225
2226 StringBundler msg = new StringBundler(8);
2227
2228 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2229
2230 msg.append("groupId=");
2231 msg.append(groupId);
2232
2233 msg.append(", privateLayout=");
2234 msg.append(privateLayout);
2235
2236 msg.append(", layoutId=");
2237 msg.append(layoutId);
2238
2239 msg.append(StringPool.CLOSE_CURLY_BRACE);
2240
2241 throw new NoSuchContentSearchException(msg.toString());
2242 }
2243
2244
2254 public JournalContentSearch fetchByG_P_L_First(long groupId,
2255 boolean privateLayout, long layoutId,
2256 OrderByComparator orderByComparator) throws SystemException {
2257 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2258 layoutId, 0, 1, orderByComparator);
2259
2260 if (!list.isEmpty()) {
2261 return list.get(0);
2262 }
2263
2264 return null;
2265 }
2266
2267
2278 public JournalContentSearch findByG_P_L_Last(long groupId,
2279 boolean privateLayout, long layoutId,
2280 OrderByComparator orderByComparator)
2281 throws NoSuchContentSearchException, SystemException {
2282 JournalContentSearch journalContentSearch = fetchByG_P_L_Last(groupId,
2283 privateLayout, layoutId, orderByComparator);
2284
2285 if (journalContentSearch != null) {
2286 return journalContentSearch;
2287 }
2288
2289 StringBundler msg = new StringBundler(8);
2290
2291 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2292
2293 msg.append("groupId=");
2294 msg.append(groupId);
2295
2296 msg.append(", privateLayout=");
2297 msg.append(privateLayout);
2298
2299 msg.append(", layoutId=");
2300 msg.append(layoutId);
2301
2302 msg.append(StringPool.CLOSE_CURLY_BRACE);
2303
2304 throw new NoSuchContentSearchException(msg.toString());
2305 }
2306
2307
2317 public JournalContentSearch fetchByG_P_L_Last(long groupId,
2318 boolean privateLayout, long layoutId,
2319 OrderByComparator orderByComparator) throws SystemException {
2320 int count = countByG_P_L(groupId, privateLayout, layoutId);
2321
2322 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2323 layoutId, count - 1, count, orderByComparator);
2324
2325 if (!list.isEmpty()) {
2326 return list.get(0);
2327 }
2328
2329 return null;
2330 }
2331
2332
2344 public JournalContentSearch[] findByG_P_L_PrevAndNext(
2345 long contentSearchId, long groupId, boolean privateLayout,
2346 long layoutId, OrderByComparator orderByComparator)
2347 throws NoSuchContentSearchException, SystemException {
2348 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2349
2350 Session session = null;
2351
2352 try {
2353 session = openSession();
2354
2355 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2356
2357 array[0] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2358 groupId, privateLayout, layoutId, orderByComparator, true);
2359
2360 array[1] = journalContentSearch;
2361
2362 array[2] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2363 groupId, privateLayout, layoutId, orderByComparator, false);
2364
2365 return array;
2366 }
2367 catch (Exception e) {
2368 throw processException(e);
2369 }
2370 finally {
2371 closeSession(session);
2372 }
2373 }
2374
2375 protected JournalContentSearch getByG_P_L_PrevAndNext(Session session,
2376 JournalContentSearch journalContentSearch, long groupId,
2377 boolean privateLayout, long layoutId,
2378 OrderByComparator orderByComparator, boolean previous) {
2379 StringBundler query = null;
2380
2381 if (orderByComparator != null) {
2382 query = new StringBundler(6 +
2383 (orderByComparator.getOrderByFields().length * 6));
2384 }
2385 else {
2386 query = new StringBundler(3);
2387 }
2388
2389 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2390
2391 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2392
2393 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2394
2395 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2396
2397 if (orderByComparator != null) {
2398 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2399
2400 if (orderByConditionFields.length > 0) {
2401 query.append(WHERE_AND);
2402 }
2403
2404 for (int i = 0; i < orderByConditionFields.length; i++) {
2405 query.append(_ORDER_BY_ENTITY_ALIAS);
2406 query.append(orderByConditionFields[i]);
2407
2408 if ((i + 1) < orderByConditionFields.length) {
2409 if (orderByComparator.isAscending() ^ previous) {
2410 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2411 }
2412 else {
2413 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2414 }
2415 }
2416 else {
2417 if (orderByComparator.isAscending() ^ previous) {
2418 query.append(WHERE_GREATER_THAN);
2419 }
2420 else {
2421 query.append(WHERE_LESSER_THAN);
2422 }
2423 }
2424 }
2425
2426 query.append(ORDER_BY_CLAUSE);
2427
2428 String[] orderByFields = orderByComparator.getOrderByFields();
2429
2430 for (int i = 0; i < orderByFields.length; i++) {
2431 query.append(_ORDER_BY_ENTITY_ALIAS);
2432 query.append(orderByFields[i]);
2433
2434 if ((i + 1) < orderByFields.length) {
2435 if (orderByComparator.isAscending() ^ previous) {
2436 query.append(ORDER_BY_ASC_HAS_NEXT);
2437 }
2438 else {
2439 query.append(ORDER_BY_DESC_HAS_NEXT);
2440 }
2441 }
2442 else {
2443 if (orderByComparator.isAscending() ^ previous) {
2444 query.append(ORDER_BY_ASC);
2445 }
2446 else {
2447 query.append(ORDER_BY_DESC);
2448 }
2449 }
2450 }
2451 }
2452
2453 String sql = query.toString();
2454
2455 Query q = session.createQuery(sql);
2456
2457 q.setFirstResult(0);
2458 q.setMaxResults(2);
2459
2460 QueryPos qPos = QueryPos.getInstance(q);
2461
2462 qPos.add(groupId);
2463
2464 qPos.add(privateLayout);
2465
2466 qPos.add(layoutId);
2467
2468 if (orderByComparator != null) {
2469 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2470
2471 for (Object value : values) {
2472 qPos.add(value);
2473 }
2474 }
2475
2476 List<JournalContentSearch> list = q.list();
2477
2478 if (list.size() == 2) {
2479 return list.get(1);
2480 }
2481 else {
2482 return null;
2483 }
2484 }
2485
2486
2495 public List<JournalContentSearch> findByG_P_A(long groupId,
2496 boolean privateLayout, String articleId) throws SystemException {
2497 return findByG_P_A(groupId, privateLayout, articleId,
2498 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2499 }
2500
2501
2516 public List<JournalContentSearch> findByG_P_A(long groupId,
2517 boolean privateLayout, String articleId, int start, int end)
2518 throws SystemException {
2519 return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
2520 }
2521
2522
2538 public List<JournalContentSearch> findByG_P_A(long groupId,
2539 boolean privateLayout, String articleId, int start, int end,
2540 OrderByComparator orderByComparator) throws SystemException {
2541 FinderPath finderPath = null;
2542 Object[] finderArgs = null;
2543
2544 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2545 (orderByComparator == null)) {
2546 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A;
2547 finderArgs = new Object[] { groupId, privateLayout, articleId };
2548 }
2549 else {
2550 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_A;
2551 finderArgs = new Object[] {
2552 groupId, privateLayout, articleId,
2553
2554 start, end, orderByComparator
2555 };
2556 }
2557
2558 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2559 finderArgs, this);
2560
2561 if ((list != null) && !list.isEmpty()) {
2562 for (JournalContentSearch journalContentSearch : list) {
2563 if ((groupId != journalContentSearch.getGroupId()) ||
2564 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2565 !Validator.equals(articleId,
2566 journalContentSearch.getArticleId())) {
2567 list = null;
2568
2569 break;
2570 }
2571 }
2572 }
2573
2574 if (list == null) {
2575 StringBundler query = null;
2576
2577 if (orderByComparator != null) {
2578 query = new StringBundler(5 +
2579 (orderByComparator.getOrderByFields().length * 3));
2580 }
2581 else {
2582 query = new StringBundler(4);
2583 }
2584
2585 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2586
2587 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2588
2589 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2590
2591 if (articleId == null) {
2592 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2593 }
2594 else {
2595 if (articleId.equals(StringPool.BLANK)) {
2596 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2597 }
2598 else {
2599 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2600 }
2601 }
2602
2603 if (orderByComparator != null) {
2604 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2605 orderByComparator);
2606 }
2607
2608 String sql = query.toString();
2609
2610 Session session = null;
2611
2612 try {
2613 session = openSession();
2614
2615 Query q = session.createQuery(sql);
2616
2617 QueryPos qPos = QueryPos.getInstance(q);
2618
2619 qPos.add(groupId);
2620
2621 qPos.add(privateLayout);
2622
2623 if (articleId != null) {
2624 qPos.add(articleId);
2625 }
2626
2627 list = (List<JournalContentSearch>)QueryUtil.list(q,
2628 getDialect(), start, end);
2629 }
2630 catch (Exception e) {
2631 throw processException(e);
2632 }
2633 finally {
2634 if (list == null) {
2635 FinderCacheUtil.removeResult(finderPath, finderArgs);
2636 }
2637 else {
2638 cacheResult(list);
2639
2640 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2641 }
2642
2643 closeSession(session);
2644 }
2645 }
2646
2647 return list;
2648 }
2649
2650
2661 public JournalContentSearch findByG_P_A_First(long groupId,
2662 boolean privateLayout, String articleId,
2663 OrderByComparator orderByComparator)
2664 throws NoSuchContentSearchException, SystemException {
2665 JournalContentSearch journalContentSearch = fetchByG_P_A_First(groupId,
2666 privateLayout, articleId, orderByComparator);
2667
2668 if (journalContentSearch != null) {
2669 return journalContentSearch;
2670 }
2671
2672 StringBundler msg = new StringBundler(8);
2673
2674 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2675
2676 msg.append("groupId=");
2677 msg.append(groupId);
2678
2679 msg.append(", privateLayout=");
2680 msg.append(privateLayout);
2681
2682 msg.append(", articleId=");
2683 msg.append(articleId);
2684
2685 msg.append(StringPool.CLOSE_CURLY_BRACE);
2686
2687 throw new NoSuchContentSearchException(msg.toString());
2688 }
2689
2690
2700 public JournalContentSearch fetchByG_P_A_First(long groupId,
2701 boolean privateLayout, String articleId,
2702 OrderByComparator orderByComparator) throws SystemException {
2703 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2704 articleId, 0, 1, orderByComparator);
2705
2706 if (!list.isEmpty()) {
2707 return list.get(0);
2708 }
2709
2710 return null;
2711 }
2712
2713
2724 public JournalContentSearch findByG_P_A_Last(long groupId,
2725 boolean privateLayout, String articleId,
2726 OrderByComparator orderByComparator)
2727 throws NoSuchContentSearchException, SystemException {
2728 JournalContentSearch journalContentSearch = fetchByG_P_A_Last(groupId,
2729 privateLayout, articleId, orderByComparator);
2730
2731 if (journalContentSearch != null) {
2732 return journalContentSearch;
2733 }
2734
2735 StringBundler msg = new StringBundler(8);
2736
2737 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2738
2739 msg.append("groupId=");
2740 msg.append(groupId);
2741
2742 msg.append(", privateLayout=");
2743 msg.append(privateLayout);
2744
2745 msg.append(", articleId=");
2746 msg.append(articleId);
2747
2748 msg.append(StringPool.CLOSE_CURLY_BRACE);
2749
2750 throw new NoSuchContentSearchException(msg.toString());
2751 }
2752
2753
2763 public JournalContentSearch fetchByG_P_A_Last(long groupId,
2764 boolean privateLayout, String articleId,
2765 OrderByComparator orderByComparator) throws SystemException {
2766 int count = countByG_P_A(groupId, privateLayout, articleId);
2767
2768 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2769 articleId, count - 1, count, orderByComparator);
2770
2771 if (!list.isEmpty()) {
2772 return list.get(0);
2773 }
2774
2775 return null;
2776 }
2777
2778
2790 public JournalContentSearch[] findByG_P_A_PrevAndNext(
2791 long contentSearchId, long groupId, boolean privateLayout,
2792 String articleId, OrderByComparator orderByComparator)
2793 throws NoSuchContentSearchException, SystemException {
2794 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2795
2796 Session session = null;
2797
2798 try {
2799 session = openSession();
2800
2801 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2802
2803 array[0] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2804 groupId, privateLayout, articleId, orderByComparator, true);
2805
2806 array[1] = journalContentSearch;
2807
2808 array[2] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2809 groupId, privateLayout, articleId, orderByComparator, false);
2810
2811 return array;
2812 }
2813 catch (Exception e) {
2814 throw processException(e);
2815 }
2816 finally {
2817 closeSession(session);
2818 }
2819 }
2820
2821 protected JournalContentSearch getByG_P_A_PrevAndNext(Session session,
2822 JournalContentSearch journalContentSearch, long groupId,
2823 boolean privateLayout, String articleId,
2824 OrderByComparator orderByComparator, boolean previous) {
2825 StringBundler query = null;
2826
2827 if (orderByComparator != null) {
2828 query = new StringBundler(6 +
2829 (orderByComparator.getOrderByFields().length * 6));
2830 }
2831 else {
2832 query = new StringBundler(3);
2833 }
2834
2835 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2836
2837 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2838
2839 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2840
2841 if (articleId == null) {
2842 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2843 }
2844 else {
2845 if (articleId.equals(StringPool.BLANK)) {
2846 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2847 }
2848 else {
2849 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2850 }
2851 }
2852
2853 if (orderByComparator != null) {
2854 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2855
2856 if (orderByConditionFields.length > 0) {
2857 query.append(WHERE_AND);
2858 }
2859
2860 for (int i = 0; i < orderByConditionFields.length; i++) {
2861 query.append(_ORDER_BY_ENTITY_ALIAS);
2862 query.append(orderByConditionFields[i]);
2863
2864 if ((i + 1) < orderByConditionFields.length) {
2865 if (orderByComparator.isAscending() ^ previous) {
2866 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2867 }
2868 else {
2869 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2870 }
2871 }
2872 else {
2873 if (orderByComparator.isAscending() ^ previous) {
2874 query.append(WHERE_GREATER_THAN);
2875 }
2876 else {
2877 query.append(WHERE_LESSER_THAN);
2878 }
2879 }
2880 }
2881
2882 query.append(ORDER_BY_CLAUSE);
2883
2884 String[] orderByFields = orderByComparator.getOrderByFields();
2885
2886 for (int i = 0; i < orderByFields.length; i++) {
2887 query.append(_ORDER_BY_ENTITY_ALIAS);
2888 query.append(orderByFields[i]);
2889
2890 if ((i + 1) < orderByFields.length) {
2891 if (orderByComparator.isAscending() ^ previous) {
2892 query.append(ORDER_BY_ASC_HAS_NEXT);
2893 }
2894 else {
2895 query.append(ORDER_BY_DESC_HAS_NEXT);
2896 }
2897 }
2898 else {
2899 if (orderByComparator.isAscending() ^ previous) {
2900 query.append(ORDER_BY_ASC);
2901 }
2902 else {
2903 query.append(ORDER_BY_DESC);
2904 }
2905 }
2906 }
2907 }
2908
2909 String sql = query.toString();
2910
2911 Query q = session.createQuery(sql);
2912
2913 q.setFirstResult(0);
2914 q.setMaxResults(2);
2915
2916 QueryPos qPos = QueryPos.getInstance(q);
2917
2918 qPos.add(groupId);
2919
2920 qPos.add(privateLayout);
2921
2922 if (articleId != null) {
2923 qPos.add(articleId);
2924 }
2925
2926 if (orderByComparator != null) {
2927 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2928
2929 for (Object value : values) {
2930 qPos.add(value);
2931 }
2932 }
2933
2934 List<JournalContentSearch> list = q.list();
2935
2936 if (list.size() == 2) {
2937 return list.get(1);
2938 }
2939 else {
2940 return null;
2941 }
2942 }
2943
2944
2954 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2955 boolean privateLayout, long layoutId, String portletId)
2956 throws SystemException {
2957 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
2958 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2959 }
2960
2961
2977 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2978 boolean privateLayout, long layoutId, String portletId, int start,
2979 int end) throws SystemException {
2980 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
2981 start, end, null);
2982 }
2983
2984
3001 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3002 boolean privateLayout, long layoutId, String portletId, int start,
3003 int end, OrderByComparator orderByComparator) throws SystemException {
3004 FinderPath finderPath = null;
3005 Object[] finderArgs = null;
3006
3007 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3008 (orderByComparator == null)) {
3009 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P;
3010 finderArgs = new Object[] {
3011 groupId, privateLayout, layoutId, portletId
3012 };
3013 }
3014 else {
3015 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L_P;
3016 finderArgs = new Object[] {
3017 groupId, privateLayout, layoutId, portletId,
3018
3019 start, end, orderByComparator
3020 };
3021 }
3022
3023 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
3024 finderArgs, this);
3025
3026 if ((list != null) && !list.isEmpty()) {
3027 for (JournalContentSearch journalContentSearch : list) {
3028 if ((groupId != journalContentSearch.getGroupId()) ||
3029 (privateLayout != journalContentSearch.getPrivateLayout()) ||
3030 (layoutId != journalContentSearch.getLayoutId()) ||
3031 !Validator.equals(portletId,
3032 journalContentSearch.getPortletId())) {
3033 list = null;
3034
3035 break;
3036 }
3037 }
3038 }
3039
3040 if (list == null) {
3041 StringBundler query = null;
3042
3043 if (orderByComparator != null) {
3044 query = new StringBundler(6 +
3045 (orderByComparator.getOrderByFields().length * 3));
3046 }
3047 else {
3048 query = new StringBundler(5);
3049 }
3050
3051 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3052
3053 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3054
3055 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3056
3057 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3058
3059 if (portletId == null) {
3060 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3061 }
3062 else {
3063 if (portletId.equals(StringPool.BLANK)) {
3064 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3065 }
3066 else {
3067 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3068 }
3069 }
3070
3071 if (orderByComparator != null) {
3072 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3073 orderByComparator);
3074 }
3075
3076 String sql = query.toString();
3077
3078 Session session = null;
3079
3080 try {
3081 session = openSession();
3082
3083 Query q = session.createQuery(sql);
3084
3085 QueryPos qPos = QueryPos.getInstance(q);
3086
3087 qPos.add(groupId);
3088
3089 qPos.add(privateLayout);
3090
3091 qPos.add(layoutId);
3092
3093 if (portletId != null) {
3094 qPos.add(portletId);
3095 }
3096
3097 list = (List<JournalContentSearch>)QueryUtil.list(q,
3098 getDialect(), start, end);
3099 }
3100 catch (Exception e) {
3101 throw processException(e);
3102 }
3103 finally {
3104 if (list == null) {
3105 FinderCacheUtil.removeResult(finderPath, finderArgs);
3106 }
3107 else {
3108 cacheResult(list);
3109
3110 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3111 }
3112
3113 closeSession(session);
3114 }
3115 }
3116
3117 return list;
3118 }
3119
3120
3132 public JournalContentSearch findByG_P_L_P_First(long groupId,
3133 boolean privateLayout, long layoutId, String portletId,
3134 OrderByComparator orderByComparator)
3135 throws NoSuchContentSearchException, SystemException {
3136 JournalContentSearch journalContentSearch = fetchByG_P_L_P_First(groupId,
3137 privateLayout, layoutId, portletId, orderByComparator);
3138
3139 if (journalContentSearch != null) {
3140 return journalContentSearch;
3141 }
3142
3143 StringBundler msg = new StringBundler(10);
3144
3145 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3146
3147 msg.append("groupId=");
3148 msg.append(groupId);
3149
3150 msg.append(", privateLayout=");
3151 msg.append(privateLayout);
3152
3153 msg.append(", layoutId=");
3154 msg.append(layoutId);
3155
3156 msg.append(", portletId=");
3157 msg.append(portletId);
3158
3159 msg.append(StringPool.CLOSE_CURLY_BRACE);
3160
3161 throw new NoSuchContentSearchException(msg.toString());
3162 }
3163
3164
3175 public JournalContentSearch fetchByG_P_L_P_First(long groupId,
3176 boolean privateLayout, long layoutId, String portletId,
3177 OrderByComparator orderByComparator) throws SystemException {
3178 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3179 layoutId, portletId, 0, 1, orderByComparator);
3180
3181 if (!list.isEmpty()) {
3182 return list.get(0);
3183 }
3184
3185 return null;
3186 }
3187
3188
3200 public JournalContentSearch findByG_P_L_P_Last(long groupId,
3201 boolean privateLayout, long layoutId, String portletId,
3202 OrderByComparator orderByComparator)
3203 throws NoSuchContentSearchException, SystemException {
3204 JournalContentSearch journalContentSearch = fetchByG_P_L_P_Last(groupId,
3205 privateLayout, layoutId, portletId, orderByComparator);
3206
3207 if (journalContentSearch != null) {
3208 return journalContentSearch;
3209 }
3210
3211 StringBundler msg = new StringBundler(10);
3212
3213 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3214
3215 msg.append("groupId=");
3216 msg.append(groupId);
3217
3218 msg.append(", privateLayout=");
3219 msg.append(privateLayout);
3220
3221 msg.append(", layoutId=");
3222 msg.append(layoutId);
3223
3224 msg.append(", portletId=");
3225 msg.append(portletId);
3226
3227 msg.append(StringPool.CLOSE_CURLY_BRACE);
3228
3229 throw new NoSuchContentSearchException(msg.toString());
3230 }
3231
3232
3243 public JournalContentSearch fetchByG_P_L_P_Last(long groupId,
3244 boolean privateLayout, long layoutId, String portletId,
3245 OrderByComparator orderByComparator) throws SystemException {
3246 int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
3247
3248 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3249 layoutId, portletId, count - 1, count, orderByComparator);
3250
3251 if (!list.isEmpty()) {
3252 return list.get(0);
3253 }
3254
3255 return null;
3256 }
3257
3258
3271 public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
3272 long contentSearchId, long groupId, boolean privateLayout,
3273 long layoutId, String portletId, OrderByComparator orderByComparator)
3274 throws NoSuchContentSearchException, SystemException {
3275 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
3276
3277 Session session = null;
3278
3279 try {
3280 session = openSession();
3281
3282 JournalContentSearch[] array = new JournalContentSearchImpl[3];
3283
3284 array[0] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3285 groupId, privateLayout, layoutId, portletId,
3286 orderByComparator, true);
3287
3288 array[1] = journalContentSearch;
3289
3290 array[2] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3291 groupId, privateLayout, layoutId, portletId,
3292 orderByComparator, false);
3293
3294 return array;
3295 }
3296 catch (Exception e) {
3297 throw processException(e);
3298 }
3299 finally {
3300 closeSession(session);
3301 }
3302 }
3303
3304 protected JournalContentSearch getByG_P_L_P_PrevAndNext(Session session,
3305 JournalContentSearch journalContentSearch, long groupId,
3306 boolean privateLayout, long layoutId, String portletId,
3307 OrderByComparator orderByComparator, boolean previous) {
3308 StringBundler query = null;
3309
3310 if (orderByComparator != null) {
3311 query = new StringBundler(6 +
3312 (orderByComparator.getOrderByFields().length * 6));
3313 }
3314 else {
3315 query = new StringBundler(3);
3316 }
3317
3318 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3319
3320 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3321
3322 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3323
3324 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3325
3326 if (portletId == null) {
3327 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3328 }
3329 else {
3330 if (portletId.equals(StringPool.BLANK)) {
3331 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3332 }
3333 else {
3334 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3335 }
3336 }
3337
3338 if (orderByComparator != null) {
3339 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3340
3341 if (orderByConditionFields.length > 0) {
3342 query.append(WHERE_AND);
3343 }
3344
3345 for (int i = 0; i < orderByConditionFields.length; i++) {
3346 query.append(_ORDER_BY_ENTITY_ALIAS);
3347 query.append(orderByConditionFields[i]);
3348
3349 if ((i + 1) < orderByConditionFields.length) {
3350 if (orderByComparator.isAscending() ^ previous) {
3351 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3352 }
3353 else {
3354 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3355 }
3356 }
3357 else {
3358 if (orderByComparator.isAscending() ^ previous) {
3359 query.append(WHERE_GREATER_THAN);
3360 }
3361 else {
3362 query.append(WHERE_LESSER_THAN);
3363 }
3364 }
3365 }
3366
3367 query.append(ORDER_BY_CLAUSE);
3368
3369 String[] orderByFields = orderByComparator.getOrderByFields();
3370
3371 for (int i = 0; i < orderByFields.length; i++) {
3372 query.append(_ORDER_BY_ENTITY_ALIAS);
3373 query.append(orderByFields[i]);
3374
3375 if ((i + 1) < orderByFields.length) {
3376 if (orderByComparator.isAscending() ^ previous) {
3377 query.append(ORDER_BY_ASC_HAS_NEXT);
3378 }
3379 else {
3380 query.append(ORDER_BY_DESC_HAS_NEXT);
3381 }
3382 }
3383 else {
3384 if (orderByComparator.isAscending() ^ previous) {
3385 query.append(ORDER_BY_ASC);
3386 }
3387 else {
3388 query.append(ORDER_BY_DESC);
3389 }
3390 }
3391 }
3392 }
3393
3394 String sql = query.toString();
3395
3396 Query q = session.createQuery(sql);
3397
3398 q.setFirstResult(0);
3399 q.setMaxResults(2);
3400
3401 QueryPos qPos = QueryPos.getInstance(q);
3402
3403 qPos.add(groupId);
3404
3405 qPos.add(privateLayout);
3406
3407 qPos.add(layoutId);
3408
3409 if (portletId != null) {
3410 qPos.add(portletId);
3411 }
3412
3413 if (orderByComparator != null) {
3414 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
3415
3416 for (Object value : values) {
3417 qPos.add(value);
3418 }
3419 }
3420
3421 List<JournalContentSearch> list = q.list();
3422
3423 if (list.size() == 2) {
3424 return list.get(1);
3425 }
3426 else {
3427 return null;
3428 }
3429 }
3430
3431
3443 public JournalContentSearch findByG_P_L_P_A(long groupId,
3444 boolean privateLayout, long layoutId, String portletId, String articleId)
3445 throws NoSuchContentSearchException, SystemException {
3446 JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
3447 privateLayout, layoutId, portletId, articleId);
3448
3449 if (journalContentSearch == null) {
3450 StringBundler msg = new StringBundler(12);
3451
3452 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3453
3454 msg.append("groupId=");
3455 msg.append(groupId);
3456
3457 msg.append(", privateLayout=");
3458 msg.append(privateLayout);
3459
3460 msg.append(", layoutId=");
3461 msg.append(layoutId);
3462
3463 msg.append(", portletId=");
3464 msg.append(portletId);
3465
3466 msg.append(", articleId=");
3467 msg.append(articleId);
3468
3469 msg.append(StringPool.CLOSE_CURLY_BRACE);
3470
3471 if (_log.isWarnEnabled()) {
3472 _log.warn(msg.toString());
3473 }
3474
3475 throw new NoSuchContentSearchException(msg.toString());
3476 }
3477
3478 return journalContentSearch;
3479 }
3480
3481
3492 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
3493 boolean privateLayout, long layoutId, String portletId, String articleId)
3494 throws SystemException {
3495 return fetchByG_P_L_P_A(groupId, privateLayout, layoutId, portletId,
3496 articleId, true);
3497 }
3498
3499
3511 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
3512 boolean privateLayout, long layoutId, String portletId,
3513 String articleId, boolean retrieveFromCache) throws SystemException {
3514 Object[] finderArgs = new Object[] {
3515 groupId, privateLayout, layoutId, portletId, articleId
3516 };
3517
3518 Object result = null;
3519
3520 if (retrieveFromCache) {
3521 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3522 finderArgs, this);
3523 }
3524
3525 if (result instanceof JournalContentSearch) {
3526 JournalContentSearch journalContentSearch = (JournalContentSearch)result;
3527
3528 if ((groupId != journalContentSearch.getGroupId()) ||
3529 (privateLayout != journalContentSearch.getPrivateLayout()) ||
3530 (layoutId != journalContentSearch.getLayoutId()) ||
3531 !Validator.equals(portletId,
3532 journalContentSearch.getPortletId()) ||
3533 !Validator.equals(articleId,
3534 journalContentSearch.getArticleId())) {
3535 result = null;
3536 }
3537 }
3538
3539 if (result == null) {
3540 StringBundler query = new StringBundler(6);
3541
3542 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3543
3544 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
3545
3546 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
3547
3548 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
3549
3550 if (portletId == null) {
3551 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
3552 }
3553 else {
3554 if (portletId.equals(StringPool.BLANK)) {
3555 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
3556 }
3557 else {
3558 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
3559 }
3560 }
3561
3562 if (articleId == null) {
3563 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
3564 }
3565 else {
3566 if (articleId.equals(StringPool.BLANK)) {
3567 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
3568 }
3569 else {
3570 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
3571 }
3572 }
3573
3574 String sql = query.toString();
3575
3576 Session session = null;
3577
3578 try {
3579 session = openSession();
3580
3581 Query q = session.createQuery(sql);
3582
3583 QueryPos qPos = QueryPos.getInstance(q);
3584
3585 qPos.add(groupId);
3586
3587 qPos.add(privateLayout);
3588
3589 qPos.add(layoutId);
3590
3591 if (portletId != null) {
3592 qPos.add(portletId);
3593 }
3594
3595 if (articleId != null) {
3596 qPos.add(articleId);
3597 }
3598
3599 List<JournalContentSearch> list = q.list();
3600
3601 result = list;
3602
3603 JournalContentSearch journalContentSearch = null;
3604
3605 if (list.isEmpty()) {
3606 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3607 finderArgs, list);
3608 }
3609 else {
3610 journalContentSearch = list.get(0);
3611
3612 cacheResult(journalContentSearch);
3613
3614 if ((journalContentSearch.getGroupId() != groupId) ||
3615 (journalContentSearch.getPrivateLayout() != privateLayout) ||
3616 (journalContentSearch.getLayoutId() != layoutId) ||
3617 (journalContentSearch.getPortletId() == null) ||
3618 !journalContentSearch.getPortletId()
3619 .equals(portletId) ||
3620 (journalContentSearch.getArticleId() == null) ||
3621 !journalContentSearch.getArticleId()
3622 .equals(articleId)) {
3623 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3624 finderArgs, journalContentSearch);
3625 }
3626 }
3627
3628 return journalContentSearch;
3629 }
3630 catch (Exception e) {
3631 throw processException(e);
3632 }
3633 finally {
3634 if (result == null) {
3635 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3636 finderArgs);
3637 }
3638
3639 closeSession(session);
3640 }
3641 }
3642 else {
3643 if (result instanceof List<?>) {
3644 return null;
3645 }
3646 else {
3647 return (JournalContentSearch)result;
3648 }
3649 }
3650 }
3651
3652
3658 public List<JournalContentSearch> findAll() throws SystemException {
3659 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3660 }
3661
3662
3674 public List<JournalContentSearch> findAll(int start, int end)
3675 throws SystemException {
3676 return findAll(start, end, null);
3677 }
3678
3679
3692 public List<JournalContentSearch> findAll(int start, int end,
3693 OrderByComparator orderByComparator) throws SystemException {
3694 FinderPath finderPath = null;
3695 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3696
3697 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3698 (orderByComparator == null)) {
3699 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3700 finderArgs = FINDER_ARGS_EMPTY;
3701 }
3702 else {
3703 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3704 finderArgs = new Object[] { start, end, orderByComparator };
3705 }
3706
3707 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
3708 finderArgs, this);
3709
3710 if (list == null) {
3711 StringBundler query = null;
3712 String sql = null;
3713
3714 if (orderByComparator != null) {
3715 query = new StringBundler(2 +
3716 (orderByComparator.getOrderByFields().length * 3));
3717
3718 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
3719
3720 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3721 orderByComparator);
3722
3723 sql = query.toString();
3724 }
3725 else {
3726 sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
3727 }
3728
3729 Session session = null;
3730
3731 try {
3732 session = openSession();
3733
3734 Query q = session.createQuery(sql);
3735
3736 if (orderByComparator == null) {
3737 list = (List<JournalContentSearch>)QueryUtil.list(q,
3738 getDialect(), start, end, false);
3739
3740 Collections.sort(list);
3741 }
3742 else {
3743 list = (List<JournalContentSearch>)QueryUtil.list(q,
3744 getDialect(), start, end);
3745 }
3746 }
3747 catch (Exception e) {
3748 throw processException(e);
3749 }
3750 finally {
3751 if (list == null) {
3752 FinderCacheUtil.removeResult(finderPath, finderArgs);
3753 }
3754 else {
3755 cacheResult(list);
3756
3757 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3758 }
3759
3760 closeSession(session);
3761 }
3762 }
3763
3764 return list;
3765 }
3766
3767
3773 public void removeByArticleId(String articleId) throws SystemException {
3774 for (JournalContentSearch journalContentSearch : findByArticleId(
3775 articleId)) {
3776 remove(journalContentSearch);
3777 }
3778 }
3779
3780
3787 public void removeByG_P(long groupId, boolean privateLayout)
3788 throws SystemException {
3789 for (JournalContentSearch journalContentSearch : findByG_P(groupId,
3790 privateLayout)) {
3791 remove(journalContentSearch);
3792 }
3793 }
3794
3795
3802 public void removeByG_A(long groupId, String articleId)
3803 throws SystemException {
3804 for (JournalContentSearch journalContentSearch : findByG_A(groupId,
3805 articleId)) {
3806 remove(journalContentSearch);
3807 }
3808 }
3809
3810
3818 public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
3819 throws SystemException {
3820 for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
3821 privateLayout, layoutId)) {
3822 remove(journalContentSearch);
3823 }
3824 }
3825
3826
3834 public void removeByG_P_A(long groupId, boolean privateLayout,
3835 String articleId) throws SystemException {
3836 for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
3837 privateLayout, articleId)) {
3838 remove(journalContentSearch);
3839 }
3840 }
3841
3842
3851 public void removeByG_P_L_P(long groupId, boolean privateLayout,
3852 long layoutId, String portletId) throws SystemException {
3853 for (JournalContentSearch journalContentSearch : findByG_P_L_P(
3854 groupId, privateLayout, layoutId, portletId)) {
3855 remove(journalContentSearch);
3856 }
3857 }
3858
3859
3870 public JournalContentSearch removeByG_P_L_P_A(long groupId,
3871 boolean privateLayout, long layoutId, String portletId, String articleId)
3872 throws NoSuchContentSearchException, SystemException {
3873 JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
3874 privateLayout, layoutId, portletId, articleId);
3875
3876 return remove(journalContentSearch);
3877 }
3878
3879
3884 public void removeAll() throws SystemException {
3885 for (JournalContentSearch journalContentSearch : findAll()) {
3886 remove(journalContentSearch);
3887 }
3888 }
3889
3890
3897 public int countByArticleId(String articleId) throws SystemException {
3898 Object[] finderArgs = new Object[] { articleId };
3899
3900 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3901 finderArgs, this);
3902
3903 if (count == null) {
3904 StringBundler query = new StringBundler(2);
3905
3906 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3907
3908 if (articleId == null) {
3909 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
3910 }
3911 else {
3912 if (articleId.equals(StringPool.BLANK)) {
3913 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
3914 }
3915 else {
3916 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
3917 }
3918 }
3919
3920 String sql = query.toString();
3921
3922 Session session = null;
3923
3924 try {
3925 session = openSession();
3926
3927 Query q = session.createQuery(sql);
3928
3929 QueryPos qPos = QueryPos.getInstance(q);
3930
3931 if (articleId != null) {
3932 qPos.add(articleId);
3933 }
3934
3935 count = (Long)q.uniqueResult();
3936 }
3937 catch (Exception e) {
3938 throw processException(e);
3939 }
3940 finally {
3941 if (count == null) {
3942 count = Long.valueOf(0);
3943 }
3944
3945 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3946 finderArgs, count);
3947
3948 closeSession(session);
3949 }
3950 }
3951
3952 return count.intValue();
3953 }
3954
3955
3963 public int countByG_P(long groupId, boolean privateLayout)
3964 throws SystemException {
3965 Object[] finderArgs = new Object[] { groupId, privateLayout };
3966
3967 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
3968 finderArgs, this);
3969
3970 if (count == null) {
3971 StringBundler query = new StringBundler(3);
3972
3973 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3974
3975 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3976
3977 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
3978
3979 String sql = query.toString();
3980
3981 Session session = null;
3982
3983 try {
3984 session = openSession();
3985
3986 Query q = session.createQuery(sql);
3987
3988 QueryPos qPos = QueryPos.getInstance(q);
3989
3990 qPos.add(groupId);
3991
3992 qPos.add(privateLayout);
3993
3994 count = (Long)q.uniqueResult();
3995 }
3996 catch (Exception e) {
3997 throw processException(e);
3998 }
3999 finally {
4000 if (count == null) {
4001 count = Long.valueOf(0);
4002 }
4003
4004 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
4005 count);
4006
4007 closeSession(session);
4008 }
4009 }
4010
4011 return count.intValue();
4012 }
4013
4014
4022 public int countByG_A(long groupId, String articleId)
4023 throws SystemException {
4024 Object[] finderArgs = new Object[] { groupId, articleId };
4025
4026 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
4027 finderArgs, this);
4028
4029 if (count == null) {
4030 StringBundler query = new StringBundler(3);
4031
4032 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4033
4034 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4035
4036 if (articleId == null) {
4037 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4038 }
4039 else {
4040 if (articleId.equals(StringPool.BLANK)) {
4041 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4042 }
4043 else {
4044 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4045 }
4046 }
4047
4048 String sql = query.toString();
4049
4050 Session session = null;
4051
4052 try {
4053 session = openSession();
4054
4055 Query q = session.createQuery(sql);
4056
4057 QueryPos qPos = QueryPos.getInstance(q);
4058
4059 qPos.add(groupId);
4060
4061 if (articleId != null) {
4062 qPos.add(articleId);
4063 }
4064
4065 count = (Long)q.uniqueResult();
4066 }
4067 catch (Exception e) {
4068 throw processException(e);
4069 }
4070 finally {
4071 if (count == null) {
4072 count = Long.valueOf(0);
4073 }
4074
4075 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
4076 count);
4077
4078 closeSession(session);
4079 }
4080 }
4081
4082 return count.intValue();
4083 }
4084
4085
4094 public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
4095 throws SystemException {
4096 Object[] finderArgs = new Object[] { groupId, privateLayout, layoutId };
4097
4098 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L,
4099 finderArgs, this);
4100
4101 if (count == null) {
4102 StringBundler query = new StringBundler(4);
4103
4104 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4105
4106 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
4107
4108 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
4109
4110 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
4111
4112 String sql = query.toString();
4113
4114 Session session = null;
4115
4116 try {
4117 session = openSession();
4118
4119 Query q = session.createQuery(sql);
4120
4121 QueryPos qPos = QueryPos.getInstance(q);
4122
4123 qPos.add(groupId);
4124
4125 qPos.add(privateLayout);
4126
4127 qPos.add(layoutId);
4128
4129 count = (Long)q.uniqueResult();
4130 }
4131 catch (Exception e) {
4132 throw processException(e);
4133 }
4134 finally {
4135 if (count == null) {
4136 count = Long.valueOf(0);
4137 }
4138
4139 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L,
4140 finderArgs, count);
4141
4142 closeSession(session);
4143 }
4144 }
4145
4146 return count.intValue();
4147 }
4148
4149
4158 public int countByG_P_A(long groupId, boolean privateLayout,
4159 String articleId) throws SystemException {
4160 Object[] finderArgs = new Object[] { groupId, privateLayout, articleId };
4161
4162 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_A,
4163 finderArgs, this);
4164
4165 if (count == null) {
4166 StringBundler query = new StringBundler(4);
4167
4168 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4169
4170 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
4171
4172 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
4173
4174 if (articleId == null) {
4175 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
4176 }
4177 else {
4178 if (articleId.equals(StringPool.BLANK)) {
4179 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
4180 }
4181 else {
4182 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
4183 }
4184 }
4185
4186 String sql = query.toString();
4187
4188 Session session = null;
4189
4190 try {
4191 session = openSession();
4192
4193 Query q = session.createQuery(sql);
4194
4195 QueryPos qPos = QueryPos.getInstance(q);
4196
4197 qPos.add(groupId);
4198
4199 qPos.add(privateLayout);
4200
4201 if (articleId != null) {
4202 qPos.add(articleId);
4203 }
4204
4205 count = (Long)q.uniqueResult();
4206 }
4207 catch (Exception e) {
4208 throw processException(e);
4209 }
4210 finally {
4211 if (count == null) {
4212 count = Long.valueOf(0);
4213 }
4214
4215 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_A,
4216 finderArgs, count);
4217
4218 closeSession(session);
4219 }
4220 }
4221
4222 return count.intValue();
4223 }
4224
4225
4235 public int countByG_P_L_P(long groupId, boolean privateLayout,
4236 long layoutId, String portletId) throws SystemException {
4237 Object[] finderArgs = new Object[] {
4238 groupId, privateLayout, layoutId, portletId
4239 };
4240
4241 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P,
4242 finderArgs, this);
4243
4244 if (count == null) {
4245 StringBundler query = new StringBundler(5);
4246
4247 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4248
4249 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
4250
4251 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
4252
4253 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
4254
4255 if (portletId == null) {
4256 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
4257 }
4258 else {
4259 if (portletId.equals(StringPool.BLANK)) {
4260 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
4261 }
4262 else {
4263 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
4264 }
4265 }
4266
4267 String sql = query.toString();
4268
4269 Session session = null;
4270
4271 try {
4272 session = openSession();
4273
4274 Query q = session.createQuery(sql);
4275
4276 QueryPos qPos = QueryPos.getInstance(q);
4277
4278 qPos.add(groupId);
4279
4280 qPos.add(privateLayout);
4281
4282 qPos.add(layoutId);
4283
4284 if (portletId != null) {
4285 qPos.add(portletId);
4286 }
4287
4288 count = (Long)q.uniqueResult();
4289 }
4290 catch (Exception e) {
4291 throw processException(e);
4292 }
4293 finally {
4294 if (count == null) {
4295 count = Long.valueOf(0);
4296 }
4297
4298 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P,
4299 finderArgs, count);
4300
4301 closeSession(session);
4302 }
4303 }
4304
4305 return count.intValue();
4306 }
4307
4308
4319 public int countByG_P_L_P_A(long groupId, boolean privateLayout,
4320 long layoutId, String portletId, String articleId)
4321 throws SystemException {
4322 Object[] finderArgs = new Object[] {
4323 groupId, privateLayout, layoutId, portletId, articleId
4324 };
4325
4326 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
4327 finderArgs, this);
4328
4329 if (count == null) {
4330 StringBundler query = new StringBundler(6);
4331
4332 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4333
4334 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
4335
4336 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
4337
4338 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
4339
4340 if (portletId == null) {
4341 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
4342 }
4343 else {
4344 if (portletId.equals(StringPool.BLANK)) {
4345 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
4346 }
4347 else {
4348 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
4349 }
4350 }
4351
4352 if (articleId == null) {
4353 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
4354 }
4355 else {
4356 if (articleId.equals(StringPool.BLANK)) {
4357 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
4358 }
4359 else {
4360 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
4361 }
4362 }
4363
4364 String sql = query.toString();
4365
4366 Session session = null;
4367
4368 try {
4369 session = openSession();
4370
4371 Query q = session.createQuery(sql);
4372
4373 QueryPos qPos = QueryPos.getInstance(q);
4374
4375 qPos.add(groupId);
4376
4377 qPos.add(privateLayout);
4378
4379 qPos.add(layoutId);
4380
4381 if (portletId != null) {
4382 qPos.add(portletId);
4383 }
4384
4385 if (articleId != null) {
4386 qPos.add(articleId);
4387 }
4388
4389 count = (Long)q.uniqueResult();
4390 }
4391 catch (Exception e) {
4392 throw processException(e);
4393 }
4394 finally {
4395 if (count == null) {
4396 count = Long.valueOf(0);
4397 }
4398
4399 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
4400 finderArgs, count);
4401
4402 closeSession(session);
4403 }
4404 }
4405
4406 return count.intValue();
4407 }
4408
4409
4415 public int countAll() throws SystemException {
4416 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4417 FINDER_ARGS_EMPTY, this);
4418
4419 if (count == null) {
4420 Session session = null;
4421
4422 try {
4423 session = openSession();
4424
4425 Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
4426
4427 count = (Long)q.uniqueResult();
4428 }
4429 catch (Exception e) {
4430 throw processException(e);
4431 }
4432 finally {
4433 if (count == null) {
4434 count = Long.valueOf(0);
4435 }
4436
4437 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4438 FINDER_ARGS_EMPTY, count);
4439
4440 closeSession(session);
4441 }
4442 }
4443
4444 return count.intValue();
4445 }
4446
4447
4450 public void afterPropertiesSet() {
4451 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4452 com.liferay.portal.util.PropsUtil.get(
4453 "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch")));
4454
4455 if (listenerClassNames.length > 0) {
4456 try {
4457 List<ModelListener<JournalContentSearch>> listenersList = new ArrayList<ModelListener<JournalContentSearch>>();
4458
4459 for (String listenerClassName : listenerClassNames) {
4460 listenersList.add((ModelListener<JournalContentSearch>)InstanceFactory.newInstance(
4461 listenerClassName));
4462 }
4463
4464 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4465 }
4466 catch (Exception e) {
4467 _log.error(e);
4468 }
4469 }
4470 }
4471
4472 public void destroy() {
4473 EntityCacheUtil.removeCache(JournalContentSearchImpl.class.getName());
4474 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4475 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4476 }
4477
4478 @BeanReference(type = JournalArticlePersistence.class)
4479 protected JournalArticlePersistence journalArticlePersistence;
4480 @BeanReference(type = JournalArticleImagePersistence.class)
4481 protected JournalArticleImagePersistence journalArticleImagePersistence;
4482 @BeanReference(type = JournalArticleResourcePersistence.class)
4483 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
4484 @BeanReference(type = JournalContentSearchPersistence.class)
4485 protected JournalContentSearchPersistence journalContentSearchPersistence;
4486 @BeanReference(type = JournalFeedPersistence.class)
4487 protected JournalFeedPersistence journalFeedPersistence;
4488 @BeanReference(type = JournalStructurePersistence.class)
4489 protected JournalStructurePersistence journalStructurePersistence;
4490 @BeanReference(type = JournalTemplatePersistence.class)
4491 protected JournalTemplatePersistence journalTemplatePersistence;
4492 @BeanReference(type = GroupPersistence.class)
4493 protected GroupPersistence groupPersistence;
4494 @BeanReference(type = LayoutPersistence.class)
4495 protected LayoutPersistence layoutPersistence;
4496 @BeanReference(type = PortletPreferencesPersistence.class)
4497 protected PortletPreferencesPersistence portletPreferencesPersistence;
4498 @BeanReference(type = ResourcePersistence.class)
4499 protected ResourcePersistence resourcePersistence;
4500 @BeanReference(type = UserPersistence.class)
4501 protected UserPersistence userPersistence;
4502 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
4503 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
4504 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
4505 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
4506 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4507 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4508 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
4509 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4510 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
4511 private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4512 private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4513 private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4514 private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
4515 private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4516 private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4517 private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
4518 private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4519 private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4520 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4521 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4522 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
4523 private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4524 private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4525 private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4526 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
4527 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
4528 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?)";
4529 private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4530 private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4531 private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4532 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
4533 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
4534 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?) AND ";
4535 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4536 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4537 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
4538 private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
4539 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
4540 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
4541 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4542 private static Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
4543 private static JournalContentSearch _nullJournalContentSearch = new JournalContentSearchImpl() {
4544 @Override
4545 public Object clone() {
4546 return this;
4547 }
4548
4549 @Override
4550 public CacheModel<JournalContentSearch> toCacheModel() {
4551 return _nullJournalContentSearchCacheModel;
4552 }
4553 };
4554
4555 private static CacheModel<JournalContentSearch> _nullJournalContentSearchCacheModel =
4556 new CacheModel<JournalContentSearch>() {
4557 public JournalContentSearch toEntityModel() {
4558 return _nullJournalContentSearch;
4559 }
4560 };
4561 }