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