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