1
22
23 package com.liferay.portlet.journal.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.annotation.BeanReference;
27 import com.liferay.portal.kernel.cache.CacheRegistry;
28 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderPath;
32 import com.liferay.portal.kernel.dao.orm.Query;
33 import com.liferay.portal.kernel.dao.orm.QueryPos;
34 import com.liferay.portal.kernel.dao.orm.QueryUtil;
35 import com.liferay.portal.kernel.dao.orm.Session;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.StringPool;
41 import com.liferay.portal.kernel.util.StringUtil;
42 import com.liferay.portal.kernel.util.Validator;
43 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.journal.NoSuchTemplateException;
49 import com.liferay.portlet.journal.model.JournalTemplate;
50 import com.liferay.portlet.journal.model.impl.JournalTemplateImpl;
51 import com.liferay.portlet.journal.model.impl.JournalTemplateModelImpl;
52
53 import java.util.ArrayList;
54 import java.util.Collections;
55 import java.util.List;
56
57
63 public class JournalTemplatePersistenceImpl extends BasePersistenceImpl
64 implements JournalTemplatePersistence {
65 public static final String FINDER_CLASS_NAME_ENTITY = JournalTemplateImpl.class.getName();
66 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
67 ".List";
68 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
69 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
70 FINDER_CLASS_NAME_LIST, "findByUuid",
71 new String[] { String.class.getName() });
72 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
73 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
74 FINDER_CLASS_NAME_LIST, "findByUuid",
75 new String[] {
76 String.class.getName(),
77
78 "java.lang.Integer", "java.lang.Integer",
79 "com.liferay.portal.kernel.util.OrderByComparator"
80 });
81 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
82 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
83 FINDER_CLASS_NAME_LIST, "countByUuid",
84 new String[] { String.class.getName() });
85 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
86 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
87 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
88 new String[] { String.class.getName(), Long.class.getName() });
89 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
90 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
91 FINDER_CLASS_NAME_LIST, "countByUUID_G",
92 new String[] { String.class.getName(), Long.class.getName() });
93 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
94 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
95 FINDER_CLASS_NAME_LIST, "findByGroupId",
96 new String[] { Long.class.getName() });
97 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
98 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
99 FINDER_CLASS_NAME_LIST, "findByGroupId",
100 new String[] {
101 Long.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
107 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
108 FINDER_CLASS_NAME_LIST, "countByGroupId",
109 new String[] { Long.class.getName() });
110 public static final FinderPath FINDER_PATH_FIND_BY_TEMPLATEID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
111 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_LIST, "findByTemplateId",
113 new String[] { String.class.getName() });
114 public static final FinderPath FINDER_PATH_FIND_BY_OBC_TEMPLATEID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
115 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
116 FINDER_CLASS_NAME_LIST, "findByTemplateId",
117 new String[] {
118 String.class.getName(),
119
120 "java.lang.Integer", "java.lang.Integer",
121 "com.liferay.portal.kernel.util.OrderByComparator"
122 });
123 public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
124 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
125 FINDER_CLASS_NAME_LIST, "countByTemplateId",
126 new String[] { String.class.getName() });
127 public static final FinderPath FINDER_PATH_FETCH_BY_SMALLIMAGEID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
128 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
129 FINDER_CLASS_NAME_ENTITY, "fetchBySmallImageId",
130 new String[] { Long.class.getName() });
131 public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
132 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
133 FINDER_CLASS_NAME_LIST, "countBySmallImageId",
134 new String[] { Long.class.getName() });
135 public static final FinderPath FINDER_PATH_FETCH_BY_G_T = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
136 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
137 FINDER_CLASS_NAME_ENTITY, "fetchByG_T",
138 new String[] { Long.class.getName(), String.class.getName() });
139 public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
140 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
141 FINDER_CLASS_NAME_LIST, "countByG_T",
142 new String[] { Long.class.getName(), String.class.getName() });
143 public static final FinderPath FINDER_PATH_FIND_BY_G_S = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
144 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
145 FINDER_CLASS_NAME_LIST, "findByG_S",
146 new String[] { Long.class.getName(), String.class.getName() });
147 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_S = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
148 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
149 FINDER_CLASS_NAME_LIST, "findByG_S",
150 new String[] {
151 Long.class.getName(), String.class.getName(),
152
153 "java.lang.Integer", "java.lang.Integer",
154 "com.liferay.portal.kernel.util.OrderByComparator"
155 });
156 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
157 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
158 FINDER_CLASS_NAME_LIST, "countByG_S",
159 new String[] { Long.class.getName(), String.class.getName() });
160 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
161 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
162 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
163 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
164 JournalTemplateModelImpl.FINDER_CACHE_ENABLED,
165 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
166
167 public void cacheResult(JournalTemplate journalTemplate) {
168 EntityCacheUtil.putResult(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
169 JournalTemplateImpl.class, journalTemplate.getPrimaryKey(),
170 journalTemplate);
171
172 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
173 new Object[] {
174 journalTemplate.getUuid(),
175 new Long(journalTemplate.getGroupId())
176 }, journalTemplate);
177
178 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
179 new Object[] { new Long(journalTemplate.getSmallImageId()) },
180 journalTemplate);
181
182 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_T,
183 new Object[] {
184 new Long(journalTemplate.getGroupId()),
185
186 journalTemplate.getTemplateId()
187 }, journalTemplate);
188 }
189
190 public void cacheResult(List<JournalTemplate> journalTemplates) {
191 for (JournalTemplate journalTemplate : journalTemplates) {
192 if (EntityCacheUtil.getResult(
193 JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
194 JournalTemplateImpl.class,
195 journalTemplate.getPrimaryKey(), this) == null) {
196 cacheResult(journalTemplate);
197 }
198 }
199 }
200
201 public void clearCache() {
202 CacheRegistry.clear(JournalTemplateImpl.class.getName());
203 EntityCacheUtil.clearCache(JournalTemplateImpl.class.getName());
204 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
206 }
207
208 public JournalTemplate create(long id) {
209 JournalTemplate journalTemplate = new JournalTemplateImpl();
210
211 journalTemplate.setNew(true);
212 journalTemplate.setPrimaryKey(id);
213
214 String uuid = PortalUUIDUtil.generate();
215
216 journalTemplate.setUuid(uuid);
217
218 return journalTemplate;
219 }
220
221 public JournalTemplate remove(long id)
222 throws NoSuchTemplateException, SystemException {
223 Session session = null;
224
225 try {
226 session = openSession();
227
228 JournalTemplate journalTemplate = (JournalTemplate)session.get(JournalTemplateImpl.class,
229 new Long(id));
230
231 if (journalTemplate == null) {
232 if (_log.isWarnEnabled()) {
233 _log.warn("No JournalTemplate exists with the primary key " +
234 id);
235 }
236
237 throw new NoSuchTemplateException(
238 "No JournalTemplate exists with the primary key " + id);
239 }
240
241 return remove(journalTemplate);
242 }
243 catch (NoSuchTemplateException nsee) {
244 throw nsee;
245 }
246 catch (Exception e) {
247 throw processException(e);
248 }
249 finally {
250 closeSession(session);
251 }
252 }
253
254 public JournalTemplate remove(JournalTemplate journalTemplate)
255 throws SystemException {
256 for (ModelListener<JournalTemplate> listener : listeners) {
257 listener.onBeforeRemove(journalTemplate);
258 }
259
260 journalTemplate = removeImpl(journalTemplate);
261
262 for (ModelListener<JournalTemplate> listener : listeners) {
263 listener.onAfterRemove(journalTemplate);
264 }
265
266 return journalTemplate;
267 }
268
269 protected JournalTemplate removeImpl(JournalTemplate journalTemplate)
270 throws SystemException {
271 Session session = null;
272
273 try {
274 session = openSession();
275
276 if (journalTemplate.isCachedModel() ||
277 BatchSessionUtil.isEnabled()) {
278 Object staleObject = session.get(JournalTemplateImpl.class,
279 journalTemplate.getPrimaryKeyObj());
280
281 if (staleObject != null) {
282 session.evict(staleObject);
283 }
284 }
285
286 session.delete(journalTemplate);
287
288 session.flush();
289 }
290 catch (Exception e) {
291 throw processException(e);
292 }
293 finally {
294 closeSession(session);
295 }
296
297 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
298
299 JournalTemplateModelImpl journalTemplateModelImpl = (JournalTemplateModelImpl)journalTemplate;
300
301 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
302 new Object[] {
303 journalTemplateModelImpl.getOriginalUuid(),
304 new Long(journalTemplateModelImpl.getOriginalGroupId())
305 });
306
307 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
308 new Object[] {
309 new Long(journalTemplateModelImpl.getOriginalSmallImageId())
310 });
311
312 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_T,
313 new Object[] {
314 new Long(journalTemplateModelImpl.getOriginalGroupId()),
315
316 journalTemplateModelImpl.getOriginalTemplateId()
317 });
318
319 EntityCacheUtil.removeResult(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
320 JournalTemplateImpl.class, journalTemplate.getPrimaryKey());
321
322 return journalTemplate;
323 }
324
325
328 public JournalTemplate update(JournalTemplate journalTemplate)
329 throws SystemException {
330 if (_log.isWarnEnabled()) {
331 _log.warn(
332 "Using the deprecated update(JournalTemplate journalTemplate) method. Use update(JournalTemplate journalTemplate, boolean merge) instead.");
333 }
334
335 return update(journalTemplate, false);
336 }
337
338
351 public JournalTemplate update(JournalTemplate journalTemplate, boolean merge)
352 throws SystemException {
353 boolean isNew = journalTemplate.isNew();
354
355 for (ModelListener<JournalTemplate> listener : listeners) {
356 if (isNew) {
357 listener.onBeforeCreate(journalTemplate);
358 }
359 else {
360 listener.onBeforeUpdate(journalTemplate);
361 }
362 }
363
364 journalTemplate = updateImpl(journalTemplate, merge);
365
366 for (ModelListener<JournalTemplate> listener : listeners) {
367 if (isNew) {
368 listener.onAfterCreate(journalTemplate);
369 }
370 else {
371 listener.onAfterUpdate(journalTemplate);
372 }
373 }
374
375 return journalTemplate;
376 }
377
378 public JournalTemplate updateImpl(
379 com.liferay.portlet.journal.model.JournalTemplate journalTemplate,
380 boolean merge) throws SystemException {
381 boolean isNew = journalTemplate.isNew();
382
383 JournalTemplateModelImpl journalTemplateModelImpl = (JournalTemplateModelImpl)journalTemplate;
384
385 if (Validator.isNull(journalTemplate.getUuid())) {
386 String uuid = PortalUUIDUtil.generate();
387
388 journalTemplate.setUuid(uuid);
389 }
390
391 Session session = null;
392
393 try {
394 session = openSession();
395
396 BatchSessionUtil.update(session, journalTemplate, merge);
397
398 journalTemplate.setNew(false);
399 }
400 catch (Exception e) {
401 throw processException(e);
402 }
403 finally {
404 closeSession(session);
405 }
406
407 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
408
409 EntityCacheUtil.putResult(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
410 JournalTemplateImpl.class, journalTemplate.getPrimaryKey(),
411 journalTemplate);
412
413 if (!isNew &&
414 (!Validator.equals(journalTemplate.getUuid(),
415 journalTemplateModelImpl.getOriginalUuid()) ||
416 (journalTemplate.getGroupId() != journalTemplateModelImpl.getOriginalGroupId()))) {
417 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
418 new Object[] {
419 journalTemplateModelImpl.getOriginalUuid(),
420 new Long(journalTemplateModelImpl.getOriginalGroupId())
421 });
422 }
423
424 if (isNew ||
425 (!Validator.equals(journalTemplate.getUuid(),
426 journalTemplateModelImpl.getOriginalUuid()) ||
427 (journalTemplate.getGroupId() != journalTemplateModelImpl.getOriginalGroupId()))) {
428 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
429 new Object[] {
430 journalTemplate.getUuid(),
431 new Long(journalTemplate.getGroupId())
432 }, journalTemplate);
433 }
434
435 if (!isNew &&
436 (journalTemplate.getSmallImageId() != journalTemplateModelImpl.getOriginalSmallImageId())) {
437 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
438 new Object[] {
439 new Long(journalTemplateModelImpl.getOriginalSmallImageId())
440 });
441 }
442
443 if (isNew ||
444 (journalTemplate.getSmallImageId() != journalTemplateModelImpl.getOriginalSmallImageId())) {
445 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
446 new Object[] { new Long(journalTemplate.getSmallImageId()) },
447 journalTemplate);
448 }
449
450 if (!isNew &&
451 ((journalTemplate.getGroupId() != journalTemplateModelImpl.getOriginalGroupId()) ||
452 !Validator.equals(journalTemplate.getTemplateId(),
453 journalTemplateModelImpl.getOriginalTemplateId()))) {
454 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_T,
455 new Object[] {
456 new Long(journalTemplateModelImpl.getOriginalGroupId()),
457
458 journalTemplateModelImpl.getOriginalTemplateId()
459 });
460 }
461
462 if (isNew ||
463 ((journalTemplate.getGroupId() != journalTemplateModelImpl.getOriginalGroupId()) ||
464 !Validator.equals(journalTemplate.getTemplateId(),
465 journalTemplateModelImpl.getOriginalTemplateId()))) {
466 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_T,
467 new Object[] {
468 new Long(journalTemplate.getGroupId()),
469
470 journalTemplate.getTemplateId()
471 }, journalTemplate);
472 }
473
474 return journalTemplate;
475 }
476
477 public JournalTemplate findByPrimaryKey(long id)
478 throws NoSuchTemplateException, SystemException {
479 JournalTemplate journalTemplate = fetchByPrimaryKey(id);
480
481 if (journalTemplate == null) {
482 if (_log.isWarnEnabled()) {
483 _log.warn("No JournalTemplate exists with the primary key " +
484 id);
485 }
486
487 throw new NoSuchTemplateException(
488 "No JournalTemplate exists with the primary key " + id);
489 }
490
491 return journalTemplate;
492 }
493
494 public JournalTemplate fetchByPrimaryKey(long id) throws SystemException {
495 JournalTemplate journalTemplate = (JournalTemplate)EntityCacheUtil.getResult(JournalTemplateModelImpl.ENTITY_CACHE_ENABLED,
496 JournalTemplateImpl.class, id, this);
497
498 if (journalTemplate == null) {
499 Session session = null;
500
501 try {
502 session = openSession();
503
504 journalTemplate = (JournalTemplate)session.get(JournalTemplateImpl.class,
505 new Long(id));
506 }
507 catch (Exception e) {
508 throw processException(e);
509 }
510 finally {
511 if (journalTemplate != null) {
512 cacheResult(journalTemplate);
513 }
514
515 closeSession(session);
516 }
517 }
518
519 return journalTemplate;
520 }
521
522 public List<JournalTemplate> findByUuid(String uuid)
523 throws SystemException {
524 Object[] finderArgs = new Object[] { uuid };
525
526 List<JournalTemplate> list = (List<JournalTemplate>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
527 finderArgs, this);
528
529 if (list == null) {
530 Session session = null;
531
532 try {
533 session = openSession();
534
535 StringBuilder query = new StringBuilder();
536
537 query.append(
538 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
539
540 if (uuid == null) {
541 query.append("uuid_ IS NULL");
542 }
543 else {
544 query.append("uuid_ = ?");
545 }
546
547 query.append(" ");
548
549 query.append("ORDER BY ");
550
551 query.append("templateId ASC");
552
553 Query q = session.createQuery(query.toString());
554
555 QueryPos qPos = QueryPos.getInstance(q);
556
557 if (uuid != null) {
558 qPos.add(uuid);
559 }
560
561 list = q.list();
562 }
563 catch (Exception e) {
564 throw processException(e);
565 }
566 finally {
567 if (list == null) {
568 list = new ArrayList<JournalTemplate>();
569 }
570
571 cacheResult(list);
572
573 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
574 list);
575
576 closeSession(session);
577 }
578 }
579
580 return list;
581 }
582
583 public List<JournalTemplate> findByUuid(String uuid, int start, int end)
584 throws SystemException {
585 return findByUuid(uuid, start, end, null);
586 }
587
588 public List<JournalTemplate> findByUuid(String uuid, int start, int end,
589 OrderByComparator obc) throws SystemException {
590 Object[] finderArgs = new Object[] {
591 uuid,
592
593 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
594 };
595
596 List<JournalTemplate> list = (List<JournalTemplate>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
597 finderArgs, this);
598
599 if (list == null) {
600 Session session = null;
601
602 try {
603 session = openSession();
604
605 StringBuilder query = new StringBuilder();
606
607 query.append(
608 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
609
610 if (uuid == null) {
611 query.append("uuid_ IS NULL");
612 }
613 else {
614 query.append("uuid_ = ?");
615 }
616
617 query.append(" ");
618
619 if (obc != null) {
620 query.append("ORDER BY ");
621 query.append(obc.getOrderBy());
622 }
623
624 else {
625 query.append("ORDER BY ");
626
627 query.append("templateId ASC");
628 }
629
630 Query q = session.createQuery(query.toString());
631
632 QueryPos qPos = QueryPos.getInstance(q);
633
634 if (uuid != null) {
635 qPos.add(uuid);
636 }
637
638 list = (List<JournalTemplate>)QueryUtil.list(q, getDialect(),
639 start, end);
640 }
641 catch (Exception e) {
642 throw processException(e);
643 }
644 finally {
645 if (list == null) {
646 list = new ArrayList<JournalTemplate>();
647 }
648
649 cacheResult(list);
650
651 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
652 finderArgs, list);
653
654 closeSession(session);
655 }
656 }
657
658 return list;
659 }
660
661 public JournalTemplate findByUuid_First(String uuid, OrderByComparator obc)
662 throws NoSuchTemplateException, SystemException {
663 List<JournalTemplate> list = findByUuid(uuid, 0, 1, obc);
664
665 if (list.isEmpty()) {
666 StringBuilder msg = new StringBuilder();
667
668 msg.append("No JournalTemplate exists with the key {");
669
670 msg.append("uuid=" + uuid);
671
672 msg.append(StringPool.CLOSE_CURLY_BRACE);
673
674 throw new NoSuchTemplateException(msg.toString());
675 }
676 else {
677 return list.get(0);
678 }
679 }
680
681 public JournalTemplate findByUuid_Last(String uuid, OrderByComparator obc)
682 throws NoSuchTemplateException, SystemException {
683 int count = countByUuid(uuid);
684
685 List<JournalTemplate> list = findByUuid(uuid, count - 1, count, obc);
686
687 if (list.isEmpty()) {
688 StringBuilder msg = new StringBuilder();
689
690 msg.append("No JournalTemplate exists with the key {");
691
692 msg.append("uuid=" + uuid);
693
694 msg.append(StringPool.CLOSE_CURLY_BRACE);
695
696 throw new NoSuchTemplateException(msg.toString());
697 }
698 else {
699 return list.get(0);
700 }
701 }
702
703 public JournalTemplate[] findByUuid_PrevAndNext(long id, String uuid,
704 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
705 JournalTemplate journalTemplate = findByPrimaryKey(id);
706
707 int count = countByUuid(uuid);
708
709 Session session = null;
710
711 try {
712 session = openSession();
713
714 StringBuilder query = new StringBuilder();
715
716 query.append(
717 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
718
719 if (uuid == null) {
720 query.append("uuid_ IS NULL");
721 }
722 else {
723 query.append("uuid_ = ?");
724 }
725
726 query.append(" ");
727
728 if (obc != null) {
729 query.append("ORDER BY ");
730 query.append(obc.getOrderBy());
731 }
732
733 else {
734 query.append("ORDER BY ");
735
736 query.append("templateId ASC");
737 }
738
739 Query q = session.createQuery(query.toString());
740
741 QueryPos qPos = QueryPos.getInstance(q);
742
743 if (uuid != null) {
744 qPos.add(uuid);
745 }
746
747 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
748 journalTemplate);
749
750 JournalTemplate[] array = new JournalTemplateImpl[3];
751
752 array[0] = (JournalTemplate)objArray[0];
753 array[1] = (JournalTemplate)objArray[1];
754 array[2] = (JournalTemplate)objArray[2];
755
756 return array;
757 }
758 catch (Exception e) {
759 throw processException(e);
760 }
761 finally {
762 closeSession(session);
763 }
764 }
765
766 public JournalTemplate findByUUID_G(String uuid, long groupId)
767 throws NoSuchTemplateException, SystemException {
768 JournalTemplate journalTemplate = fetchByUUID_G(uuid, groupId);
769
770 if (journalTemplate == null) {
771 StringBuilder msg = new StringBuilder();
772
773 msg.append("No JournalTemplate exists with the key {");
774
775 msg.append("uuid=" + uuid);
776
777 msg.append(", ");
778 msg.append("groupId=" + groupId);
779
780 msg.append(StringPool.CLOSE_CURLY_BRACE);
781
782 if (_log.isWarnEnabled()) {
783 _log.warn(msg.toString());
784 }
785
786 throw new NoSuchTemplateException(msg.toString());
787 }
788
789 return journalTemplate;
790 }
791
792 public JournalTemplate fetchByUUID_G(String uuid, long groupId)
793 throws SystemException {
794 return fetchByUUID_G(uuid, groupId, true);
795 }
796
797 public JournalTemplate fetchByUUID_G(String uuid, long groupId,
798 boolean retrieveFromCache) throws SystemException {
799 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
800
801 Object result = null;
802
803 if (retrieveFromCache) {
804 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
805 finderArgs, this);
806 }
807
808 if (result == null) {
809 Session session = null;
810
811 try {
812 session = openSession();
813
814 StringBuilder query = new StringBuilder();
815
816 query.append(
817 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
818
819 if (uuid == null) {
820 query.append("uuid_ IS NULL");
821 }
822 else {
823 query.append("uuid_ = ?");
824 }
825
826 query.append(" AND ");
827
828 query.append("groupId = ?");
829
830 query.append(" ");
831
832 query.append("ORDER BY ");
833
834 query.append("templateId ASC");
835
836 Query q = session.createQuery(query.toString());
837
838 QueryPos qPos = QueryPos.getInstance(q);
839
840 if (uuid != null) {
841 qPos.add(uuid);
842 }
843
844 qPos.add(groupId);
845
846 List<JournalTemplate> list = q.list();
847
848 result = list;
849
850 JournalTemplate journalTemplate = null;
851
852 if (list.isEmpty()) {
853 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
854 finderArgs, list);
855 }
856 else {
857 journalTemplate = list.get(0);
858
859 cacheResult(journalTemplate);
860
861 if ((journalTemplate.getUuid() == null) ||
862 !journalTemplate.getUuid().equals(uuid) ||
863 (journalTemplate.getGroupId() != groupId)) {
864 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
865 finderArgs, journalTemplate);
866 }
867 }
868
869 return journalTemplate;
870 }
871 catch (Exception e) {
872 throw processException(e);
873 }
874 finally {
875 if (result == null) {
876 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
877 finderArgs, new ArrayList<JournalTemplate>());
878 }
879
880 closeSession(session);
881 }
882 }
883 else {
884 if (result instanceof List) {
885 return null;
886 }
887 else {
888 return (JournalTemplate)result;
889 }
890 }
891 }
892
893 public List<JournalTemplate> findByGroupId(long groupId)
894 throws SystemException {
895 Object[] finderArgs = new Object[] { new Long(groupId) };
896
897 List<JournalTemplate> list = (List<JournalTemplate>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
898 finderArgs, this);
899
900 if (list == null) {
901 Session session = null;
902
903 try {
904 session = openSession();
905
906 StringBuilder query = new StringBuilder();
907
908 query.append(
909 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
910
911 query.append("groupId = ?");
912
913 query.append(" ");
914
915 query.append("ORDER BY ");
916
917 query.append("templateId ASC");
918
919 Query q = session.createQuery(query.toString());
920
921 QueryPos qPos = QueryPos.getInstance(q);
922
923 qPos.add(groupId);
924
925 list = q.list();
926 }
927 catch (Exception e) {
928 throw processException(e);
929 }
930 finally {
931 if (list == null) {
932 list = new ArrayList<JournalTemplate>();
933 }
934
935 cacheResult(list);
936
937 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
938 finderArgs, list);
939
940 closeSession(session);
941 }
942 }
943
944 return list;
945 }
946
947 public List<JournalTemplate> findByGroupId(long groupId, int start, int end)
948 throws SystemException {
949 return findByGroupId(groupId, start, end, null);
950 }
951
952 public List<JournalTemplate> findByGroupId(long groupId, int start,
953 int end, OrderByComparator obc) throws SystemException {
954 Object[] finderArgs = new Object[] {
955 new Long(groupId),
956
957 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
958 };
959
960 List<JournalTemplate> list = (List<JournalTemplate>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
961 finderArgs, this);
962
963 if (list == null) {
964 Session session = null;
965
966 try {
967 session = openSession();
968
969 StringBuilder query = new StringBuilder();
970
971 query.append(
972 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
973
974 query.append("groupId = ?");
975
976 query.append(" ");
977
978 if (obc != null) {
979 query.append("ORDER BY ");
980 query.append(obc.getOrderBy());
981 }
982
983 else {
984 query.append("ORDER BY ");
985
986 query.append("templateId ASC");
987 }
988
989 Query q = session.createQuery(query.toString());
990
991 QueryPos qPos = QueryPos.getInstance(q);
992
993 qPos.add(groupId);
994
995 list = (List<JournalTemplate>)QueryUtil.list(q, getDialect(),
996 start, end);
997 }
998 catch (Exception e) {
999 throw processException(e);
1000 }
1001 finally {
1002 if (list == null) {
1003 list = new ArrayList<JournalTemplate>();
1004 }
1005
1006 cacheResult(list);
1007
1008 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1009 finderArgs, list);
1010
1011 closeSession(session);
1012 }
1013 }
1014
1015 return list;
1016 }
1017
1018 public JournalTemplate findByGroupId_First(long groupId,
1019 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1020 List<JournalTemplate> list = findByGroupId(groupId, 0, 1, obc);
1021
1022 if (list.isEmpty()) {
1023 StringBuilder msg = new StringBuilder();
1024
1025 msg.append("No JournalTemplate exists with the key {");
1026
1027 msg.append("groupId=" + groupId);
1028
1029 msg.append(StringPool.CLOSE_CURLY_BRACE);
1030
1031 throw new NoSuchTemplateException(msg.toString());
1032 }
1033 else {
1034 return list.get(0);
1035 }
1036 }
1037
1038 public JournalTemplate findByGroupId_Last(long groupId,
1039 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1040 int count = countByGroupId(groupId);
1041
1042 List<JournalTemplate> list = findByGroupId(groupId, count - 1, count,
1043 obc);
1044
1045 if (list.isEmpty()) {
1046 StringBuilder msg = new StringBuilder();
1047
1048 msg.append("No JournalTemplate exists with the key {");
1049
1050 msg.append("groupId=" + groupId);
1051
1052 msg.append(StringPool.CLOSE_CURLY_BRACE);
1053
1054 throw new NoSuchTemplateException(msg.toString());
1055 }
1056 else {
1057 return list.get(0);
1058 }
1059 }
1060
1061 public JournalTemplate[] findByGroupId_PrevAndNext(long id, long groupId,
1062 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1063 JournalTemplate journalTemplate = findByPrimaryKey(id);
1064
1065 int count = countByGroupId(groupId);
1066
1067 Session session = null;
1068
1069 try {
1070 session = openSession();
1071
1072 StringBuilder query = new StringBuilder();
1073
1074 query.append(
1075 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1076
1077 query.append("groupId = ?");
1078
1079 query.append(" ");
1080
1081 if (obc != null) {
1082 query.append("ORDER BY ");
1083 query.append(obc.getOrderBy());
1084 }
1085
1086 else {
1087 query.append("ORDER BY ");
1088
1089 query.append("templateId ASC");
1090 }
1091
1092 Query q = session.createQuery(query.toString());
1093
1094 QueryPos qPos = QueryPos.getInstance(q);
1095
1096 qPos.add(groupId);
1097
1098 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1099 journalTemplate);
1100
1101 JournalTemplate[] array = new JournalTemplateImpl[3];
1102
1103 array[0] = (JournalTemplate)objArray[0];
1104 array[1] = (JournalTemplate)objArray[1];
1105 array[2] = (JournalTemplate)objArray[2];
1106
1107 return array;
1108 }
1109 catch (Exception e) {
1110 throw processException(e);
1111 }
1112 finally {
1113 closeSession(session);
1114 }
1115 }
1116
1117 public List<JournalTemplate> findByTemplateId(String templateId)
1118 throws SystemException {
1119 Object[] finderArgs = new Object[] { templateId };
1120
1121 List<JournalTemplate> list = (List<JournalTemplate>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_TEMPLATEID,
1122 finderArgs, this);
1123
1124 if (list == null) {
1125 Session session = null;
1126
1127 try {
1128 session = openSession();
1129
1130 StringBuilder query = new StringBuilder();
1131
1132 query.append(
1133 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1134
1135 if (templateId == null) {
1136 query.append("templateId IS NULL");
1137 }
1138 else {
1139 query.append("templateId = ?");
1140 }
1141
1142 query.append(" ");
1143
1144 query.append("ORDER BY ");
1145
1146 query.append("templateId ASC");
1147
1148 Query q = session.createQuery(query.toString());
1149
1150 QueryPos qPos = QueryPos.getInstance(q);
1151
1152 if (templateId != null) {
1153 qPos.add(templateId);
1154 }
1155
1156 list = q.list();
1157 }
1158 catch (Exception e) {
1159 throw processException(e);
1160 }
1161 finally {
1162 if (list == null) {
1163 list = new ArrayList<JournalTemplate>();
1164 }
1165
1166 cacheResult(list);
1167
1168 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_TEMPLATEID,
1169 finderArgs, list);
1170
1171 closeSession(session);
1172 }
1173 }
1174
1175 return list;
1176 }
1177
1178 public List<JournalTemplate> findByTemplateId(String templateId, int start,
1179 int end) throws SystemException {
1180 return findByTemplateId(templateId, start, end, null);
1181 }
1182
1183 public List<JournalTemplate> findByTemplateId(String templateId, int start,
1184 int end, OrderByComparator obc) throws SystemException {
1185 Object[] finderArgs = new Object[] {
1186 templateId,
1187
1188 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1189 };
1190
1191 List<JournalTemplate> list = (List<JournalTemplate>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_TEMPLATEID,
1192 finderArgs, this);
1193
1194 if (list == null) {
1195 Session session = null;
1196
1197 try {
1198 session = openSession();
1199
1200 StringBuilder query = new StringBuilder();
1201
1202 query.append(
1203 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1204
1205 if (templateId == null) {
1206 query.append("templateId IS NULL");
1207 }
1208 else {
1209 query.append("templateId = ?");
1210 }
1211
1212 query.append(" ");
1213
1214 if (obc != null) {
1215 query.append("ORDER BY ");
1216 query.append(obc.getOrderBy());
1217 }
1218
1219 else {
1220 query.append("ORDER BY ");
1221
1222 query.append("templateId ASC");
1223 }
1224
1225 Query q = session.createQuery(query.toString());
1226
1227 QueryPos qPos = QueryPos.getInstance(q);
1228
1229 if (templateId != null) {
1230 qPos.add(templateId);
1231 }
1232
1233 list = (List<JournalTemplate>)QueryUtil.list(q, getDialect(),
1234 start, end);
1235 }
1236 catch (Exception e) {
1237 throw processException(e);
1238 }
1239 finally {
1240 if (list == null) {
1241 list = new ArrayList<JournalTemplate>();
1242 }
1243
1244 cacheResult(list);
1245
1246 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_TEMPLATEID,
1247 finderArgs, list);
1248
1249 closeSession(session);
1250 }
1251 }
1252
1253 return list;
1254 }
1255
1256 public JournalTemplate findByTemplateId_First(String templateId,
1257 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1258 List<JournalTemplate> list = findByTemplateId(templateId, 0, 1, obc);
1259
1260 if (list.isEmpty()) {
1261 StringBuilder msg = new StringBuilder();
1262
1263 msg.append("No JournalTemplate exists with the key {");
1264
1265 msg.append("templateId=" + templateId);
1266
1267 msg.append(StringPool.CLOSE_CURLY_BRACE);
1268
1269 throw new NoSuchTemplateException(msg.toString());
1270 }
1271 else {
1272 return list.get(0);
1273 }
1274 }
1275
1276 public JournalTemplate findByTemplateId_Last(String templateId,
1277 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1278 int count = countByTemplateId(templateId);
1279
1280 List<JournalTemplate> list = findByTemplateId(templateId, count - 1,
1281 count, obc);
1282
1283 if (list.isEmpty()) {
1284 StringBuilder msg = new StringBuilder();
1285
1286 msg.append("No JournalTemplate exists with the key {");
1287
1288 msg.append("templateId=" + templateId);
1289
1290 msg.append(StringPool.CLOSE_CURLY_BRACE);
1291
1292 throw new NoSuchTemplateException(msg.toString());
1293 }
1294 else {
1295 return list.get(0);
1296 }
1297 }
1298
1299 public JournalTemplate[] findByTemplateId_PrevAndNext(long id,
1300 String templateId, OrderByComparator obc)
1301 throws NoSuchTemplateException, SystemException {
1302 JournalTemplate journalTemplate = findByPrimaryKey(id);
1303
1304 int count = countByTemplateId(templateId);
1305
1306 Session session = null;
1307
1308 try {
1309 session = openSession();
1310
1311 StringBuilder query = new StringBuilder();
1312
1313 query.append(
1314 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1315
1316 if (templateId == null) {
1317 query.append("templateId IS NULL");
1318 }
1319 else {
1320 query.append("templateId = ?");
1321 }
1322
1323 query.append(" ");
1324
1325 if (obc != null) {
1326 query.append("ORDER BY ");
1327 query.append(obc.getOrderBy());
1328 }
1329
1330 else {
1331 query.append("ORDER BY ");
1332
1333 query.append("templateId ASC");
1334 }
1335
1336 Query q = session.createQuery(query.toString());
1337
1338 QueryPos qPos = QueryPos.getInstance(q);
1339
1340 if (templateId != null) {
1341 qPos.add(templateId);
1342 }
1343
1344 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1345 journalTemplate);
1346
1347 JournalTemplate[] array = new JournalTemplateImpl[3];
1348
1349 array[0] = (JournalTemplate)objArray[0];
1350 array[1] = (JournalTemplate)objArray[1];
1351 array[2] = (JournalTemplate)objArray[2];
1352
1353 return array;
1354 }
1355 catch (Exception e) {
1356 throw processException(e);
1357 }
1358 finally {
1359 closeSession(session);
1360 }
1361 }
1362
1363 public JournalTemplate findBySmallImageId(long smallImageId)
1364 throws NoSuchTemplateException, SystemException {
1365 JournalTemplate journalTemplate = fetchBySmallImageId(smallImageId);
1366
1367 if (journalTemplate == null) {
1368 StringBuilder msg = new StringBuilder();
1369
1370 msg.append("No JournalTemplate exists with the key {");
1371
1372 msg.append("smallImageId=" + smallImageId);
1373
1374 msg.append(StringPool.CLOSE_CURLY_BRACE);
1375
1376 if (_log.isWarnEnabled()) {
1377 _log.warn(msg.toString());
1378 }
1379
1380 throw new NoSuchTemplateException(msg.toString());
1381 }
1382
1383 return journalTemplate;
1384 }
1385
1386 public JournalTemplate fetchBySmallImageId(long smallImageId)
1387 throws SystemException {
1388 return fetchBySmallImageId(smallImageId, true);
1389 }
1390
1391 public JournalTemplate fetchBySmallImageId(long smallImageId,
1392 boolean retrieveFromCache) throws SystemException {
1393 Object[] finderArgs = new Object[] { new Long(smallImageId) };
1394
1395 Object result = null;
1396
1397 if (retrieveFromCache) {
1398 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
1399 finderArgs, this);
1400 }
1401
1402 if (result == null) {
1403 Session session = null;
1404
1405 try {
1406 session = openSession();
1407
1408 StringBuilder query = new StringBuilder();
1409
1410 query.append(
1411 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1412
1413 query.append("smallImageId = ?");
1414
1415 query.append(" ");
1416
1417 query.append("ORDER BY ");
1418
1419 query.append("templateId ASC");
1420
1421 Query q = session.createQuery(query.toString());
1422
1423 QueryPos qPos = QueryPos.getInstance(q);
1424
1425 qPos.add(smallImageId);
1426
1427 List<JournalTemplate> list = q.list();
1428
1429 result = list;
1430
1431 JournalTemplate journalTemplate = null;
1432
1433 if (list.isEmpty()) {
1434 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
1435 finderArgs, list);
1436 }
1437 else {
1438 journalTemplate = list.get(0);
1439
1440 cacheResult(journalTemplate);
1441
1442 if ((journalTemplate.getSmallImageId() != smallImageId)) {
1443 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
1444 finderArgs, journalTemplate);
1445 }
1446 }
1447
1448 return journalTemplate;
1449 }
1450 catch (Exception e) {
1451 throw processException(e);
1452 }
1453 finally {
1454 if (result == null) {
1455 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
1456 finderArgs, new ArrayList<JournalTemplate>());
1457 }
1458
1459 closeSession(session);
1460 }
1461 }
1462 else {
1463 if (result instanceof List) {
1464 return null;
1465 }
1466 else {
1467 return (JournalTemplate)result;
1468 }
1469 }
1470 }
1471
1472 public JournalTemplate findByG_T(long groupId, String templateId)
1473 throws NoSuchTemplateException, SystemException {
1474 JournalTemplate journalTemplate = fetchByG_T(groupId, templateId);
1475
1476 if (journalTemplate == null) {
1477 StringBuilder msg = new StringBuilder();
1478
1479 msg.append("No JournalTemplate exists with the key {");
1480
1481 msg.append("groupId=" + groupId);
1482
1483 msg.append(", ");
1484 msg.append("templateId=" + templateId);
1485
1486 msg.append(StringPool.CLOSE_CURLY_BRACE);
1487
1488 if (_log.isWarnEnabled()) {
1489 _log.warn(msg.toString());
1490 }
1491
1492 throw new NoSuchTemplateException(msg.toString());
1493 }
1494
1495 return journalTemplate;
1496 }
1497
1498 public JournalTemplate fetchByG_T(long groupId, String templateId)
1499 throws SystemException {
1500 return fetchByG_T(groupId, templateId, true);
1501 }
1502
1503 public JournalTemplate fetchByG_T(long groupId, String templateId,
1504 boolean retrieveFromCache) throws SystemException {
1505 Object[] finderArgs = new Object[] { new Long(groupId), templateId };
1506
1507 Object result = null;
1508
1509 if (retrieveFromCache) {
1510 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_T,
1511 finderArgs, this);
1512 }
1513
1514 if (result == null) {
1515 Session session = null;
1516
1517 try {
1518 session = openSession();
1519
1520 StringBuilder query = new StringBuilder();
1521
1522 query.append(
1523 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1524
1525 query.append("groupId = ?");
1526
1527 query.append(" AND ");
1528
1529 if (templateId == null) {
1530 query.append("templateId IS NULL");
1531 }
1532 else {
1533 query.append("templateId = ?");
1534 }
1535
1536 query.append(" ");
1537
1538 query.append("ORDER BY ");
1539
1540 query.append("templateId ASC");
1541
1542 Query q = session.createQuery(query.toString());
1543
1544 QueryPos qPos = QueryPos.getInstance(q);
1545
1546 qPos.add(groupId);
1547
1548 if (templateId != null) {
1549 qPos.add(templateId);
1550 }
1551
1552 List<JournalTemplate> list = q.list();
1553
1554 result = list;
1555
1556 JournalTemplate journalTemplate = null;
1557
1558 if (list.isEmpty()) {
1559 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_T,
1560 finderArgs, list);
1561 }
1562 else {
1563 journalTemplate = list.get(0);
1564
1565 cacheResult(journalTemplate);
1566
1567 if ((journalTemplate.getGroupId() != groupId) ||
1568 (journalTemplate.getTemplateId() == null) ||
1569 !journalTemplate.getTemplateId().equals(templateId)) {
1570 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_T,
1571 finderArgs, journalTemplate);
1572 }
1573 }
1574
1575 return journalTemplate;
1576 }
1577 catch (Exception e) {
1578 throw processException(e);
1579 }
1580 finally {
1581 if (result == null) {
1582 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_T,
1583 finderArgs, new ArrayList<JournalTemplate>());
1584 }
1585
1586 closeSession(session);
1587 }
1588 }
1589 else {
1590 if (result instanceof List) {
1591 return null;
1592 }
1593 else {
1594 return (JournalTemplate)result;
1595 }
1596 }
1597 }
1598
1599 public List<JournalTemplate> findByG_S(long groupId, String structureId)
1600 throws SystemException {
1601 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
1602
1603 List<JournalTemplate> list = (List<JournalTemplate>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_S,
1604 finderArgs, this);
1605
1606 if (list == null) {
1607 Session session = null;
1608
1609 try {
1610 session = openSession();
1611
1612 StringBuilder query = new StringBuilder();
1613
1614 query.append(
1615 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1616
1617 query.append("groupId = ?");
1618
1619 query.append(" AND ");
1620
1621 if (structureId == null) {
1622 query.append("structureId IS NULL");
1623 }
1624 else {
1625 query.append("structureId = ?");
1626 }
1627
1628 query.append(" ");
1629
1630 query.append("ORDER BY ");
1631
1632 query.append("templateId ASC");
1633
1634 Query q = session.createQuery(query.toString());
1635
1636 QueryPos qPos = QueryPos.getInstance(q);
1637
1638 qPos.add(groupId);
1639
1640 if (structureId != null) {
1641 qPos.add(structureId);
1642 }
1643
1644 list = q.list();
1645 }
1646 catch (Exception e) {
1647 throw processException(e);
1648 }
1649 finally {
1650 if (list == null) {
1651 list = new ArrayList<JournalTemplate>();
1652 }
1653
1654 cacheResult(list);
1655
1656 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_S, finderArgs,
1657 list);
1658
1659 closeSession(session);
1660 }
1661 }
1662
1663 return list;
1664 }
1665
1666 public List<JournalTemplate> findByG_S(long groupId, String structureId,
1667 int start, int end) throws SystemException {
1668 return findByG_S(groupId, structureId, start, end, null);
1669 }
1670
1671 public List<JournalTemplate> findByG_S(long groupId, String structureId,
1672 int start, int end, OrderByComparator obc) throws SystemException {
1673 Object[] finderArgs = new Object[] {
1674 new Long(groupId),
1675
1676 structureId,
1677
1678 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1679 };
1680
1681 List<JournalTemplate> list = (List<JournalTemplate>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_S,
1682 finderArgs, this);
1683
1684 if (list == null) {
1685 Session session = null;
1686
1687 try {
1688 session = openSession();
1689
1690 StringBuilder query = new StringBuilder();
1691
1692 query.append(
1693 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1694
1695 query.append("groupId = ?");
1696
1697 query.append(" AND ");
1698
1699 if (structureId == null) {
1700 query.append("structureId IS NULL");
1701 }
1702 else {
1703 query.append("structureId = ?");
1704 }
1705
1706 query.append(" ");
1707
1708 if (obc != null) {
1709 query.append("ORDER BY ");
1710 query.append(obc.getOrderBy());
1711 }
1712
1713 else {
1714 query.append("ORDER BY ");
1715
1716 query.append("templateId ASC");
1717 }
1718
1719 Query q = session.createQuery(query.toString());
1720
1721 QueryPos qPos = QueryPos.getInstance(q);
1722
1723 qPos.add(groupId);
1724
1725 if (structureId != null) {
1726 qPos.add(structureId);
1727 }
1728
1729 list = (List<JournalTemplate>)QueryUtil.list(q, getDialect(),
1730 start, end);
1731 }
1732 catch (Exception e) {
1733 throw processException(e);
1734 }
1735 finally {
1736 if (list == null) {
1737 list = new ArrayList<JournalTemplate>();
1738 }
1739
1740 cacheResult(list);
1741
1742 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_S,
1743 finderArgs, list);
1744
1745 closeSession(session);
1746 }
1747 }
1748
1749 return list;
1750 }
1751
1752 public JournalTemplate findByG_S_First(long groupId, String structureId,
1753 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1754 List<JournalTemplate> list = findByG_S(groupId, structureId, 0, 1, obc);
1755
1756 if (list.isEmpty()) {
1757 StringBuilder msg = new StringBuilder();
1758
1759 msg.append("No JournalTemplate exists with the key {");
1760
1761 msg.append("groupId=" + groupId);
1762
1763 msg.append(", ");
1764 msg.append("structureId=" + structureId);
1765
1766 msg.append(StringPool.CLOSE_CURLY_BRACE);
1767
1768 throw new NoSuchTemplateException(msg.toString());
1769 }
1770 else {
1771 return list.get(0);
1772 }
1773 }
1774
1775 public JournalTemplate findByG_S_Last(long groupId, String structureId,
1776 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1777 int count = countByG_S(groupId, structureId);
1778
1779 List<JournalTemplate> list = findByG_S(groupId, structureId, count - 1,
1780 count, obc);
1781
1782 if (list.isEmpty()) {
1783 StringBuilder msg = new StringBuilder();
1784
1785 msg.append("No JournalTemplate exists with the key {");
1786
1787 msg.append("groupId=" + groupId);
1788
1789 msg.append(", ");
1790 msg.append("structureId=" + structureId);
1791
1792 msg.append(StringPool.CLOSE_CURLY_BRACE);
1793
1794 throw new NoSuchTemplateException(msg.toString());
1795 }
1796 else {
1797 return list.get(0);
1798 }
1799 }
1800
1801 public JournalTemplate[] findByG_S_PrevAndNext(long id, long groupId,
1802 String structureId, OrderByComparator obc)
1803 throws NoSuchTemplateException, SystemException {
1804 JournalTemplate journalTemplate = findByPrimaryKey(id);
1805
1806 int count = countByG_S(groupId, structureId);
1807
1808 Session session = null;
1809
1810 try {
1811 session = openSession();
1812
1813 StringBuilder query = new StringBuilder();
1814
1815 query.append(
1816 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1817
1818 query.append("groupId = ?");
1819
1820 query.append(" AND ");
1821
1822 if (structureId == null) {
1823 query.append("structureId IS NULL");
1824 }
1825 else {
1826 query.append("structureId = ?");
1827 }
1828
1829 query.append(" ");
1830
1831 if (obc != null) {
1832 query.append("ORDER BY ");
1833 query.append(obc.getOrderBy());
1834 }
1835
1836 else {
1837 query.append("ORDER BY ");
1838
1839 query.append("templateId ASC");
1840 }
1841
1842 Query q = session.createQuery(query.toString());
1843
1844 QueryPos qPos = QueryPos.getInstance(q);
1845
1846 qPos.add(groupId);
1847
1848 if (structureId != null) {
1849 qPos.add(structureId);
1850 }
1851
1852 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1853 journalTemplate);
1854
1855 JournalTemplate[] array = new JournalTemplateImpl[3];
1856
1857 array[0] = (JournalTemplate)objArray[0];
1858 array[1] = (JournalTemplate)objArray[1];
1859 array[2] = (JournalTemplate)objArray[2];
1860
1861 return array;
1862 }
1863 catch (Exception e) {
1864 throw processException(e);
1865 }
1866 finally {
1867 closeSession(session);
1868 }
1869 }
1870
1871 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1872 throws SystemException {
1873 Session session = null;
1874
1875 try {
1876 session = openSession();
1877
1878 dynamicQuery.compile(session);
1879
1880 return dynamicQuery.list();
1881 }
1882 catch (Exception e) {
1883 throw processException(e);
1884 }
1885 finally {
1886 closeSession(session);
1887 }
1888 }
1889
1890 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1891 int start, int end) throws SystemException {
1892 Session session = null;
1893
1894 try {
1895 session = openSession();
1896
1897 dynamicQuery.setLimit(start, end);
1898
1899 dynamicQuery.compile(session);
1900
1901 return dynamicQuery.list();
1902 }
1903 catch (Exception e) {
1904 throw processException(e);
1905 }
1906 finally {
1907 closeSession(session);
1908 }
1909 }
1910
1911 public List<JournalTemplate> findAll() throws SystemException {
1912 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1913 }
1914
1915 public List<JournalTemplate> findAll(int start, int end)
1916 throws SystemException {
1917 return findAll(start, end, null);
1918 }
1919
1920 public List<JournalTemplate> findAll(int start, int end,
1921 OrderByComparator obc) throws SystemException {
1922 Object[] finderArgs = new Object[] {
1923 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1924 };
1925
1926 List<JournalTemplate> list = (List<JournalTemplate>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1927 finderArgs, this);
1928
1929 if (list == null) {
1930 Session session = null;
1931
1932 try {
1933 session = openSession();
1934
1935 StringBuilder query = new StringBuilder();
1936
1937 query.append(
1938 "FROM com.liferay.portlet.journal.model.JournalTemplate ");
1939
1940 if (obc != null) {
1941 query.append("ORDER BY ");
1942 query.append(obc.getOrderBy());
1943 }
1944
1945 else {
1946 query.append("ORDER BY ");
1947
1948 query.append("templateId ASC");
1949 }
1950
1951 Query q = session.createQuery(query.toString());
1952
1953 if (obc == null) {
1954 list = (List<JournalTemplate>)QueryUtil.list(q,
1955 getDialect(), start, end, false);
1956
1957 Collections.sort(list);
1958 }
1959 else {
1960 list = (List<JournalTemplate>)QueryUtil.list(q,
1961 getDialect(), start, end);
1962 }
1963 }
1964 catch (Exception e) {
1965 throw processException(e);
1966 }
1967 finally {
1968 if (list == null) {
1969 list = new ArrayList<JournalTemplate>();
1970 }
1971
1972 cacheResult(list);
1973
1974 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1975
1976 closeSession(session);
1977 }
1978 }
1979
1980 return list;
1981 }
1982
1983 public void removeByUuid(String uuid) throws SystemException {
1984 for (JournalTemplate journalTemplate : findByUuid(uuid)) {
1985 remove(journalTemplate);
1986 }
1987 }
1988
1989 public void removeByUUID_G(String uuid, long groupId)
1990 throws NoSuchTemplateException, SystemException {
1991 JournalTemplate journalTemplate = findByUUID_G(uuid, groupId);
1992
1993 remove(journalTemplate);
1994 }
1995
1996 public void removeByGroupId(long groupId) throws SystemException {
1997 for (JournalTemplate journalTemplate : findByGroupId(groupId)) {
1998 remove(journalTemplate);
1999 }
2000 }
2001
2002 public void removeByTemplateId(String templateId) throws SystemException {
2003 for (JournalTemplate journalTemplate : findByTemplateId(templateId)) {
2004 remove(journalTemplate);
2005 }
2006 }
2007
2008 public void removeBySmallImageId(long smallImageId)
2009 throws NoSuchTemplateException, SystemException {
2010 JournalTemplate journalTemplate = findBySmallImageId(smallImageId);
2011
2012 remove(journalTemplate);
2013 }
2014
2015 public void removeByG_T(long groupId, String templateId)
2016 throws NoSuchTemplateException, SystemException {
2017 JournalTemplate journalTemplate = findByG_T(groupId, templateId);
2018
2019 remove(journalTemplate);
2020 }
2021
2022 public void removeByG_S(long groupId, String structureId)
2023 throws SystemException {
2024 for (JournalTemplate journalTemplate : findByG_S(groupId, structureId)) {
2025 remove(journalTemplate);
2026 }
2027 }
2028
2029 public void removeAll() throws SystemException {
2030 for (JournalTemplate journalTemplate : findAll()) {
2031 remove(journalTemplate);
2032 }
2033 }
2034
2035 public int countByUuid(String uuid) throws SystemException {
2036 Object[] finderArgs = new Object[] { uuid };
2037
2038 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2039 finderArgs, this);
2040
2041 if (count == null) {
2042 Session session = null;
2043
2044 try {
2045 session = openSession();
2046
2047 StringBuilder query = new StringBuilder();
2048
2049 query.append("SELECT COUNT(*) ");
2050 query.append(
2051 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2052
2053 if (uuid == null) {
2054 query.append("uuid_ IS NULL");
2055 }
2056 else {
2057 query.append("uuid_ = ?");
2058 }
2059
2060 query.append(" ");
2061
2062 Query q = session.createQuery(query.toString());
2063
2064 QueryPos qPos = QueryPos.getInstance(q);
2065
2066 if (uuid != null) {
2067 qPos.add(uuid);
2068 }
2069
2070 count = (Long)q.uniqueResult();
2071 }
2072 catch (Exception e) {
2073 throw processException(e);
2074 }
2075 finally {
2076 if (count == null) {
2077 count = Long.valueOf(0);
2078 }
2079
2080 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2081 finderArgs, count);
2082
2083 closeSession(session);
2084 }
2085 }
2086
2087 return count.intValue();
2088 }
2089
2090 public int countByUUID_G(String uuid, long groupId)
2091 throws SystemException {
2092 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
2093
2094 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2095 finderArgs, this);
2096
2097 if (count == null) {
2098 Session session = null;
2099
2100 try {
2101 session = openSession();
2102
2103 StringBuilder query = new StringBuilder();
2104
2105 query.append("SELECT COUNT(*) ");
2106 query.append(
2107 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2108
2109 if (uuid == null) {
2110 query.append("uuid_ IS NULL");
2111 }
2112 else {
2113 query.append("uuid_ = ?");
2114 }
2115
2116 query.append(" AND ");
2117
2118 query.append("groupId = ?");
2119
2120 query.append(" ");
2121
2122 Query q = session.createQuery(query.toString());
2123
2124 QueryPos qPos = QueryPos.getInstance(q);
2125
2126 if (uuid != null) {
2127 qPos.add(uuid);
2128 }
2129
2130 qPos.add(groupId);
2131
2132 count = (Long)q.uniqueResult();
2133 }
2134 catch (Exception e) {
2135 throw processException(e);
2136 }
2137 finally {
2138 if (count == null) {
2139 count = Long.valueOf(0);
2140 }
2141
2142 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2143 finderArgs, count);
2144
2145 closeSession(session);
2146 }
2147 }
2148
2149 return count.intValue();
2150 }
2151
2152 public int countByGroupId(long groupId) throws SystemException {
2153 Object[] finderArgs = new Object[] { new Long(groupId) };
2154
2155 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2156 finderArgs, this);
2157
2158 if (count == null) {
2159 Session session = null;
2160
2161 try {
2162 session = openSession();
2163
2164 StringBuilder query = new StringBuilder();
2165
2166 query.append("SELECT COUNT(*) ");
2167 query.append(
2168 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2169
2170 query.append("groupId = ?");
2171
2172 query.append(" ");
2173
2174 Query q = session.createQuery(query.toString());
2175
2176 QueryPos qPos = QueryPos.getInstance(q);
2177
2178 qPos.add(groupId);
2179
2180 count = (Long)q.uniqueResult();
2181 }
2182 catch (Exception e) {
2183 throw processException(e);
2184 }
2185 finally {
2186 if (count == null) {
2187 count = Long.valueOf(0);
2188 }
2189
2190 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2191 finderArgs, count);
2192
2193 closeSession(session);
2194 }
2195 }
2196
2197 return count.intValue();
2198 }
2199
2200 public int countByTemplateId(String templateId) throws SystemException {
2201 Object[] finderArgs = new Object[] { templateId };
2202
2203 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
2204 finderArgs, this);
2205
2206 if (count == null) {
2207 Session session = null;
2208
2209 try {
2210 session = openSession();
2211
2212 StringBuilder query = new StringBuilder();
2213
2214 query.append("SELECT COUNT(*) ");
2215 query.append(
2216 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2217
2218 if (templateId == null) {
2219 query.append("templateId IS NULL");
2220 }
2221 else {
2222 query.append("templateId = ?");
2223 }
2224
2225 query.append(" ");
2226
2227 Query q = session.createQuery(query.toString());
2228
2229 QueryPos qPos = QueryPos.getInstance(q);
2230
2231 if (templateId != null) {
2232 qPos.add(templateId);
2233 }
2234
2235 count = (Long)q.uniqueResult();
2236 }
2237 catch (Exception e) {
2238 throw processException(e);
2239 }
2240 finally {
2241 if (count == null) {
2242 count = Long.valueOf(0);
2243 }
2244
2245 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
2246 finderArgs, count);
2247
2248 closeSession(session);
2249 }
2250 }
2251
2252 return count.intValue();
2253 }
2254
2255 public int countBySmallImageId(long smallImageId) throws SystemException {
2256 Object[] finderArgs = new Object[] { new Long(smallImageId) };
2257
2258 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
2259 finderArgs, this);
2260
2261 if (count == null) {
2262 Session session = null;
2263
2264 try {
2265 session = openSession();
2266
2267 StringBuilder query = new StringBuilder();
2268
2269 query.append("SELECT COUNT(*) ");
2270 query.append(
2271 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2272
2273 query.append("smallImageId = ?");
2274
2275 query.append(" ");
2276
2277 Query q = session.createQuery(query.toString());
2278
2279 QueryPos qPos = QueryPos.getInstance(q);
2280
2281 qPos.add(smallImageId);
2282
2283 count = (Long)q.uniqueResult();
2284 }
2285 catch (Exception e) {
2286 throw processException(e);
2287 }
2288 finally {
2289 if (count == null) {
2290 count = Long.valueOf(0);
2291 }
2292
2293 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
2294 finderArgs, count);
2295
2296 closeSession(session);
2297 }
2298 }
2299
2300 return count.intValue();
2301 }
2302
2303 public int countByG_T(long groupId, String templateId)
2304 throws SystemException {
2305 Object[] finderArgs = new Object[] { new Long(groupId), templateId };
2306
2307 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
2308 finderArgs, this);
2309
2310 if (count == null) {
2311 Session session = null;
2312
2313 try {
2314 session = openSession();
2315
2316 StringBuilder query = new StringBuilder();
2317
2318 query.append("SELECT COUNT(*) ");
2319 query.append(
2320 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2321
2322 query.append("groupId = ?");
2323
2324 query.append(" AND ");
2325
2326 if (templateId == null) {
2327 query.append("templateId IS NULL");
2328 }
2329 else {
2330 query.append("templateId = ?");
2331 }
2332
2333 query.append(" ");
2334
2335 Query q = session.createQuery(query.toString());
2336
2337 QueryPos qPos = QueryPos.getInstance(q);
2338
2339 qPos.add(groupId);
2340
2341 if (templateId != null) {
2342 qPos.add(templateId);
2343 }
2344
2345 count = (Long)q.uniqueResult();
2346 }
2347 catch (Exception e) {
2348 throw processException(e);
2349 }
2350 finally {
2351 if (count == null) {
2352 count = Long.valueOf(0);
2353 }
2354
2355 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_T, finderArgs,
2356 count);
2357
2358 closeSession(session);
2359 }
2360 }
2361
2362 return count.intValue();
2363 }
2364
2365 public int countByG_S(long groupId, String structureId)
2366 throws SystemException {
2367 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
2368
2369 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
2370 finderArgs, this);
2371
2372 if (count == null) {
2373 Session session = null;
2374
2375 try {
2376 session = openSession();
2377
2378 StringBuilder query = new StringBuilder();
2379
2380 query.append("SELECT COUNT(*) ");
2381 query.append(
2382 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2383
2384 query.append("groupId = ?");
2385
2386 query.append(" AND ");
2387
2388 if (structureId == null) {
2389 query.append("structureId IS NULL");
2390 }
2391 else {
2392 query.append("structureId = ?");
2393 }
2394
2395 query.append(" ");
2396
2397 Query q = session.createQuery(query.toString());
2398
2399 QueryPos qPos = QueryPos.getInstance(q);
2400
2401 qPos.add(groupId);
2402
2403 if (structureId != null) {
2404 qPos.add(structureId);
2405 }
2406
2407 count = (Long)q.uniqueResult();
2408 }
2409 catch (Exception e) {
2410 throw processException(e);
2411 }
2412 finally {
2413 if (count == null) {
2414 count = Long.valueOf(0);
2415 }
2416
2417 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
2418 count);
2419
2420 closeSession(session);
2421 }
2422 }
2423
2424 return count.intValue();
2425 }
2426
2427 public int countAll() throws SystemException {
2428 Object[] finderArgs = new Object[0];
2429
2430 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2431 finderArgs, this);
2432
2433 if (count == null) {
2434 Session session = null;
2435
2436 try {
2437 session = openSession();
2438
2439 Query q = session.createQuery(
2440 "SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalTemplate");
2441
2442 count = (Long)q.uniqueResult();
2443 }
2444 catch (Exception e) {
2445 throw processException(e);
2446 }
2447 finally {
2448 if (count == null) {
2449 count = Long.valueOf(0);
2450 }
2451
2452 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2453 count);
2454
2455 closeSession(session);
2456 }
2457 }
2458
2459 return count.intValue();
2460 }
2461
2462 public void afterPropertiesSet() {
2463 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2464 com.liferay.portal.util.PropsUtil.get(
2465 "value.object.listener.com.liferay.portlet.journal.model.JournalTemplate")));
2466
2467 if (listenerClassNames.length > 0) {
2468 try {
2469 List<ModelListener<JournalTemplate>> listenersList = new ArrayList<ModelListener<JournalTemplate>>();
2470
2471 for (String listenerClassName : listenerClassNames) {
2472 listenersList.add((ModelListener<JournalTemplate>)Class.forName(
2473 listenerClassName).newInstance());
2474 }
2475
2476 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2477 }
2478 catch (Exception e) {
2479 _log.error(e);
2480 }
2481 }
2482 }
2483
2484 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticlePersistence.impl")
2485 protected com.liferay.portlet.journal.service.persistence.JournalArticlePersistence journalArticlePersistence;
2486 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence.impl")
2487 protected com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence journalArticleImagePersistence;
2488 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence.impl")
2489 protected com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence journalArticleResourcePersistence;
2490 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence.impl")
2491 protected com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence journalContentSearchPersistence;
2492 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalFeedPersistence.impl")
2493 protected com.liferay.portlet.journal.service.persistence.JournalFeedPersistence journalFeedPersistence;
2494 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalStructurePersistence.impl")
2495 protected com.liferay.portlet.journal.service.persistence.JournalStructurePersistence journalStructurePersistence;
2496 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence.impl")
2497 protected com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence journalTemplatePersistence;
2498 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
2499 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
2500 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
2501 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2502 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
2503 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2504 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
2505 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
2506 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence.impl")
2507 protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
2508 private static Log _log = LogFactoryUtil.getLog(JournalTemplatePersistenceImpl.class);
2509}