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