1
22
23 package com.liferay.portlet.journal.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
27 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.Query;
29 import com.liferay.portal.kernel.dao.orm.QueryPos;
30 import com.liferay.portal.kernel.dao.orm.QueryUtil;
31 import com.liferay.portal.kernel.dao.orm.Session;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.ListUtil;
34 import com.liferay.portal.kernel.util.OrderByComparator;
35 import com.liferay.portal.kernel.util.StringPool;
36 import com.liferay.portal.kernel.util.StringUtil;
37 import com.liferay.portal.kernel.util.Validator;
38 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
39 import com.liferay.portal.model.ModelListener;
40 import com.liferay.portal.service.persistence.BatchSessionUtil;
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 {
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 if (BatchSessionUtil.isEnabled()) {
138 Object staleObject = session.get(JournalStructureImpl.class,
139 journalStructure.getPrimaryKeyObj());
140
141 if (staleObject != null) {
142 session.evict(staleObject);
143 }
144 }
145
146 session.delete(journalStructure);
147
148 session.flush();
149
150 return journalStructure;
151 }
152 catch (Exception e) {
153 throw processException(e);
154 }
155 finally {
156 closeSession(session);
157
158 FinderCacheUtil.clearCache(JournalStructure.class.getName());
159 }
160 }
161
162
165 public JournalStructure update(JournalStructure journalStructure)
166 throws SystemException {
167 if (_log.isWarnEnabled()) {
168 _log.warn(
169 "Using the deprecated update(JournalStructure journalStructure) method. Use update(JournalStructure journalStructure, boolean merge) instead.");
170 }
171
172 return update(journalStructure, false);
173 }
174
175
188 public JournalStructure update(JournalStructure journalStructure,
189 boolean merge) throws SystemException {
190 boolean isNew = journalStructure.isNew();
191
192 if (_listeners.length > 0) {
193 for (ModelListener listener : _listeners) {
194 if (isNew) {
195 listener.onBeforeCreate(journalStructure);
196 }
197 else {
198 listener.onBeforeUpdate(journalStructure);
199 }
200 }
201 }
202
203 journalStructure = updateImpl(journalStructure, merge);
204
205 if (_listeners.length > 0) {
206 for (ModelListener listener : _listeners) {
207 if (isNew) {
208 listener.onAfterCreate(journalStructure);
209 }
210 else {
211 listener.onAfterUpdate(journalStructure);
212 }
213 }
214 }
215
216 return journalStructure;
217 }
218
219 public JournalStructure updateImpl(
220 com.liferay.portlet.journal.model.JournalStructure journalStructure,
221 boolean merge) throws SystemException {
222 if (Validator.isNull(journalStructure.getUuid())) {
223 String uuid = PortalUUIDUtil.generate();
224
225 journalStructure.setUuid(uuid);
226 }
227
228 Session session = null;
229
230 try {
231 session = openSession();
232
233 BatchSessionUtil.update(session, journalStructure, merge);
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 = null;
1369
1370 if (obc == null) {
1371 list = (List<JournalStructure>)QueryUtil.list(q,
1372 getDialect(), start, end, false);
1373
1374 Collections.sort(list);
1375 }
1376 else {
1377 list = (List<JournalStructure>)QueryUtil.list(q,
1378 getDialect(), start, end);
1379 }
1380
1381 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1382 finderClassName, finderMethodName, finderParams,
1383 finderArgs, list);
1384
1385 return list;
1386 }
1387 catch (Exception e) {
1388 throw processException(e);
1389 }
1390 finally {
1391 closeSession(session);
1392 }
1393 }
1394 else {
1395 return (List<JournalStructure>)result;
1396 }
1397 }
1398
1399 public void removeByUuid(String uuid) throws SystemException {
1400 for (JournalStructure journalStructure : findByUuid(uuid)) {
1401 remove(journalStructure);
1402 }
1403 }
1404
1405 public void removeByUUID_G(String uuid, long groupId)
1406 throws NoSuchStructureException, SystemException {
1407 JournalStructure journalStructure = findByUUID_G(uuid, groupId);
1408
1409 remove(journalStructure);
1410 }
1411
1412 public void removeByGroupId(long groupId) throws SystemException {
1413 for (JournalStructure journalStructure : findByGroupId(groupId)) {
1414 remove(journalStructure);
1415 }
1416 }
1417
1418 public void removeByStructureId(String structureId)
1419 throws SystemException {
1420 for (JournalStructure journalStructure : findByStructureId(structureId)) {
1421 remove(journalStructure);
1422 }
1423 }
1424
1425 public void removeByG_S(long groupId, String structureId)
1426 throws NoSuchStructureException, SystemException {
1427 JournalStructure journalStructure = findByG_S(groupId, structureId);
1428
1429 remove(journalStructure);
1430 }
1431
1432 public void removeAll() throws SystemException {
1433 for (JournalStructure journalStructure : findAll()) {
1434 remove(journalStructure);
1435 }
1436 }
1437
1438 public int countByUuid(String uuid) throws SystemException {
1439 boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1440 String finderClassName = JournalStructure.class.getName();
1441 String finderMethodName = "countByUuid";
1442 String[] finderParams = new String[] { String.class.getName() };
1443 Object[] finderArgs = new Object[] { uuid };
1444
1445 Object result = null;
1446
1447 if (finderClassNameCacheEnabled) {
1448 result = FinderCacheUtil.getResult(finderClassName,
1449 finderMethodName, finderParams, finderArgs, this);
1450 }
1451
1452 if (result == null) {
1453 Session session = null;
1454
1455 try {
1456 session = openSession();
1457
1458 StringBuilder query = new StringBuilder();
1459
1460 query.append("SELECT COUNT(*) ");
1461 query.append(
1462 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1463
1464 if (uuid == null) {
1465 query.append("uuid_ IS NULL");
1466 }
1467 else {
1468 query.append("uuid_ = ?");
1469 }
1470
1471 query.append(" ");
1472
1473 Query q = session.createQuery(query.toString());
1474
1475 QueryPos qPos = QueryPos.getInstance(q);
1476
1477 if (uuid != null) {
1478 qPos.add(uuid);
1479 }
1480
1481 Long count = null;
1482
1483 Iterator<Long> itr = q.list().iterator();
1484
1485 if (itr.hasNext()) {
1486 count = itr.next();
1487 }
1488
1489 if (count == null) {
1490 count = new Long(0);
1491 }
1492
1493 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1494 finderClassName, finderMethodName, finderParams,
1495 finderArgs, count);
1496
1497 return count.intValue();
1498 }
1499 catch (Exception e) {
1500 throw processException(e);
1501 }
1502 finally {
1503 closeSession(session);
1504 }
1505 }
1506 else {
1507 return ((Long)result).intValue();
1508 }
1509 }
1510
1511 public int countByUUID_G(String uuid, long groupId)
1512 throws SystemException {
1513 boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1514 String finderClassName = JournalStructure.class.getName();
1515 String finderMethodName = "countByUUID_G";
1516 String[] finderParams = new String[] {
1517 String.class.getName(), Long.class.getName()
1518 };
1519 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1520
1521 Object result = null;
1522
1523 if (finderClassNameCacheEnabled) {
1524 result = FinderCacheUtil.getResult(finderClassName,
1525 finderMethodName, finderParams, finderArgs, this);
1526 }
1527
1528 if (result == null) {
1529 Session session = null;
1530
1531 try {
1532 session = openSession();
1533
1534 StringBuilder query = new StringBuilder();
1535
1536 query.append("SELECT COUNT(*) ");
1537 query.append(
1538 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1539
1540 if (uuid == null) {
1541 query.append("uuid_ IS NULL");
1542 }
1543 else {
1544 query.append("uuid_ = ?");
1545 }
1546
1547 query.append(" AND ");
1548
1549 query.append("groupId = ?");
1550
1551 query.append(" ");
1552
1553 Query q = session.createQuery(query.toString());
1554
1555 QueryPos qPos = QueryPos.getInstance(q);
1556
1557 if (uuid != null) {
1558 qPos.add(uuid);
1559 }
1560
1561 qPos.add(groupId);
1562
1563 Long count = null;
1564
1565 Iterator<Long> itr = q.list().iterator();
1566
1567 if (itr.hasNext()) {
1568 count = itr.next();
1569 }
1570
1571 if (count == null) {
1572 count = new Long(0);
1573 }
1574
1575 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1576 finderClassName, finderMethodName, finderParams,
1577 finderArgs, count);
1578
1579 return count.intValue();
1580 }
1581 catch (Exception e) {
1582 throw processException(e);
1583 }
1584 finally {
1585 closeSession(session);
1586 }
1587 }
1588 else {
1589 return ((Long)result).intValue();
1590 }
1591 }
1592
1593 public int countByGroupId(long groupId) throws SystemException {
1594 boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1595 String finderClassName = JournalStructure.class.getName();
1596 String finderMethodName = "countByGroupId";
1597 String[] finderParams = new String[] { Long.class.getName() };
1598 Object[] finderArgs = new Object[] { new Long(groupId) };
1599
1600 Object result = null;
1601
1602 if (finderClassNameCacheEnabled) {
1603 result = FinderCacheUtil.getResult(finderClassName,
1604 finderMethodName, finderParams, finderArgs, this);
1605 }
1606
1607 if (result == null) {
1608 Session session = null;
1609
1610 try {
1611 session = openSession();
1612
1613 StringBuilder query = new StringBuilder();
1614
1615 query.append("SELECT COUNT(*) ");
1616 query.append(
1617 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1618
1619 query.append("groupId = ?");
1620
1621 query.append(" ");
1622
1623 Query q = session.createQuery(query.toString());
1624
1625 QueryPos qPos = QueryPos.getInstance(q);
1626
1627 qPos.add(groupId);
1628
1629 Long count = null;
1630
1631 Iterator<Long> itr = q.list().iterator();
1632
1633 if (itr.hasNext()) {
1634 count = itr.next();
1635 }
1636
1637 if (count == null) {
1638 count = new Long(0);
1639 }
1640
1641 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1642 finderClassName, finderMethodName, finderParams,
1643 finderArgs, count);
1644
1645 return count.intValue();
1646 }
1647 catch (Exception e) {
1648 throw processException(e);
1649 }
1650 finally {
1651 closeSession(session);
1652 }
1653 }
1654 else {
1655 return ((Long)result).intValue();
1656 }
1657 }
1658
1659 public int countByStructureId(String structureId) throws SystemException {
1660 boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1661 String finderClassName = JournalStructure.class.getName();
1662 String finderMethodName = "countByStructureId";
1663 String[] finderParams = new String[] { String.class.getName() };
1664 Object[] finderArgs = new Object[] { structureId };
1665
1666 Object result = null;
1667
1668 if (finderClassNameCacheEnabled) {
1669 result = FinderCacheUtil.getResult(finderClassName,
1670 finderMethodName, finderParams, finderArgs, this);
1671 }
1672
1673 if (result == null) {
1674 Session session = null;
1675
1676 try {
1677 session = openSession();
1678
1679 StringBuilder query = new StringBuilder();
1680
1681 query.append("SELECT COUNT(*) ");
1682 query.append(
1683 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1684
1685 if (structureId == null) {
1686 query.append("structureId IS NULL");
1687 }
1688 else {
1689 query.append("structureId = ?");
1690 }
1691
1692 query.append(" ");
1693
1694 Query q = session.createQuery(query.toString());
1695
1696 QueryPos qPos = QueryPos.getInstance(q);
1697
1698 if (structureId != null) {
1699 qPos.add(structureId);
1700 }
1701
1702 Long count = null;
1703
1704 Iterator<Long> itr = q.list().iterator();
1705
1706 if (itr.hasNext()) {
1707 count = itr.next();
1708 }
1709
1710 if (count == null) {
1711 count = new Long(0);
1712 }
1713
1714 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1715 finderClassName, finderMethodName, finderParams,
1716 finderArgs, count);
1717
1718 return count.intValue();
1719 }
1720 catch (Exception e) {
1721 throw processException(e);
1722 }
1723 finally {
1724 closeSession(session);
1725 }
1726 }
1727 else {
1728 return ((Long)result).intValue();
1729 }
1730 }
1731
1732 public int countByG_S(long groupId, String structureId)
1733 throws SystemException {
1734 boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1735 String finderClassName = JournalStructure.class.getName();
1736 String finderMethodName = "countByG_S";
1737 String[] finderParams = new String[] {
1738 Long.class.getName(), String.class.getName()
1739 };
1740 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
1741
1742 Object result = null;
1743
1744 if (finderClassNameCacheEnabled) {
1745 result = FinderCacheUtil.getResult(finderClassName,
1746 finderMethodName, finderParams, finderArgs, this);
1747 }
1748
1749 if (result == null) {
1750 Session session = null;
1751
1752 try {
1753 session = openSession();
1754
1755 StringBuilder query = new StringBuilder();
1756
1757 query.append("SELECT COUNT(*) ");
1758 query.append(
1759 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1760
1761 query.append("groupId = ?");
1762
1763 query.append(" AND ");
1764
1765 if (structureId == null) {
1766 query.append("structureId IS NULL");
1767 }
1768 else {
1769 query.append("structureId = ?");
1770 }
1771
1772 query.append(" ");
1773
1774 Query q = session.createQuery(query.toString());
1775
1776 QueryPos qPos = QueryPos.getInstance(q);
1777
1778 qPos.add(groupId);
1779
1780 if (structureId != null) {
1781 qPos.add(structureId);
1782 }
1783
1784 Long count = null;
1785
1786 Iterator<Long> itr = q.list().iterator();
1787
1788 if (itr.hasNext()) {
1789 count = itr.next();
1790 }
1791
1792 if (count == null) {
1793 count = new Long(0);
1794 }
1795
1796 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1797 finderClassName, finderMethodName, finderParams,
1798 finderArgs, count);
1799
1800 return count.intValue();
1801 }
1802 catch (Exception e) {
1803 throw processException(e);
1804 }
1805 finally {
1806 closeSession(session);
1807 }
1808 }
1809 else {
1810 return ((Long)result).intValue();
1811 }
1812 }
1813
1814 public int countAll() throws SystemException {
1815 boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1816 String finderClassName = JournalStructure.class.getName();
1817 String finderMethodName = "countAll";
1818 String[] finderParams = new String[] { };
1819 Object[] finderArgs = new Object[] { };
1820
1821 Object result = null;
1822
1823 if (finderClassNameCacheEnabled) {
1824 result = FinderCacheUtil.getResult(finderClassName,
1825 finderMethodName, finderParams, finderArgs, this);
1826 }
1827
1828 if (result == null) {
1829 Session session = null;
1830
1831 try {
1832 session = openSession();
1833
1834 Query q = session.createQuery(
1835 "SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalStructure");
1836
1837 Long count = null;
1838
1839 Iterator<Long> itr = q.list().iterator();
1840
1841 if (itr.hasNext()) {
1842 count = itr.next();
1843 }
1844
1845 if (count == null) {
1846 count = new Long(0);
1847 }
1848
1849 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1850 finderClassName, finderMethodName, finderParams,
1851 finderArgs, count);
1852
1853 return count.intValue();
1854 }
1855 catch (Exception e) {
1856 throw processException(e);
1857 }
1858 finally {
1859 closeSession(session);
1860 }
1861 }
1862 else {
1863 return ((Long)result).intValue();
1864 }
1865 }
1866
1867 public void registerListener(ModelListener listener) {
1868 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1869
1870 listeners.add(listener);
1871
1872 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1873 }
1874
1875 public void unregisterListener(ModelListener listener) {
1876 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1877
1878 listeners.remove(listener);
1879
1880 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1881 }
1882
1883 public void afterPropertiesSet() {
1884 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1885 com.liferay.portal.util.PropsUtil.get(
1886 "value.object.listener.com.liferay.portlet.journal.model.JournalStructure")));
1887
1888 if (listenerClassNames.length > 0) {
1889 try {
1890 List<ModelListener> listeners = new ArrayList<ModelListener>();
1891
1892 for (String listenerClassName : listenerClassNames) {
1893 listeners.add((ModelListener)Class.forName(
1894 listenerClassName).newInstance());
1895 }
1896
1897 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1898 }
1899 catch (Exception e) {
1900 _log.error(e);
1901 }
1902 }
1903 }
1904
1905 private static Log _log = LogFactory.getLog(JournalStructurePersistenceImpl.class);
1906 private ModelListener[] _listeners = new ModelListener[0];
1907}