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