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