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