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