1
22
23 package com.liferay.portlet.journal.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.DynamicQuery;
27 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
28 import com.liferay.portal.kernel.util.GetterUtil;
29 import com.liferay.portal.kernel.util.OrderByComparator;
30 import com.liferay.portal.kernel.util.StringMaker;
31 import com.liferay.portal.kernel.util.StringPool;
32 import com.liferay.portal.kernel.util.StringUtil;
33 import com.liferay.portal.model.ModelListener;
34 import com.liferay.portal.service.persistence.BasePersistence;
35 import com.liferay.portal.spring.hibernate.FinderCache;
36 import com.liferay.portal.spring.hibernate.HibernateUtil;
37 import com.liferay.portal.util.PropsUtil;
38
39 import com.liferay.portlet.journal.NoSuchArticleResourceException;
40 import com.liferay.portlet.journal.model.JournalArticleResource;
41 import com.liferay.portlet.journal.model.impl.JournalArticleResourceImpl;
42 import com.liferay.portlet.journal.model.impl.JournalArticleResourceModelImpl;
43
44 import com.liferay.util.dao.hibernate.QueryUtil;
45
46 import org.apache.commons.logging.Log;
47 import org.apache.commons.logging.LogFactory;
48
49 import org.hibernate.Query;
50 import org.hibernate.Session;
51
52 import java.util.ArrayList;
53 import java.util.Collections;
54 import java.util.Iterator;
55 import java.util.List;
56
57
63 public class JournalArticleResourcePersistenceImpl extends BasePersistence
64 implements JournalArticleResourcePersistence {
65 public JournalArticleResource create(long resourcePrimKey) {
66 JournalArticleResource journalArticleResource = new JournalArticleResourceImpl();
67
68 journalArticleResource.setNew(true);
69 journalArticleResource.setPrimaryKey(resourcePrimKey);
70
71 return journalArticleResource;
72 }
73
74 public JournalArticleResource remove(long resourcePrimKey)
75 throws NoSuchArticleResourceException, SystemException {
76 Session session = null;
77
78 try {
79 session = openSession();
80
81 JournalArticleResource journalArticleResource = (JournalArticleResource)session.get(JournalArticleResourceImpl.class,
82 new Long(resourcePrimKey));
83
84 if (journalArticleResource == null) {
85 if (_log.isWarnEnabled()) {
86 _log.warn(
87 "No JournalArticleResource exists with the primary key " +
88 resourcePrimKey);
89 }
90
91 throw new NoSuchArticleResourceException(
92 "No JournalArticleResource exists with the primary key " +
93 resourcePrimKey);
94 }
95
96 return remove(journalArticleResource);
97 }
98 catch (NoSuchArticleResourceException nsee) {
99 throw nsee;
100 }
101 catch (Exception e) {
102 throw HibernateUtil.processException(e);
103 }
104 finally {
105 closeSession(session);
106 }
107 }
108
109 public JournalArticleResource remove(
110 JournalArticleResource journalArticleResource)
111 throws SystemException {
112 if (_listeners != null) {
113 for (ModelListener listener : _listeners) {
114 listener.onBeforeRemove(journalArticleResource);
115 }
116 }
117
118 journalArticleResource = removeImpl(journalArticleResource);
119
120 if (_listeners != null) {
121 for (ModelListener listener : _listeners) {
122 listener.onAfterRemove(journalArticleResource);
123 }
124 }
125
126 return journalArticleResource;
127 }
128
129 protected JournalArticleResource removeImpl(
130 JournalArticleResource journalArticleResource)
131 throws SystemException {
132 Session session = null;
133
134 try {
135 session = openSession();
136
137 session.delete(journalArticleResource);
138
139 session.flush();
140
141 return journalArticleResource;
142 }
143 catch (Exception e) {
144 throw HibernateUtil.processException(e);
145 }
146 finally {
147 closeSession(session);
148
149 FinderCache.clearCache(JournalArticleResource.class.getName());
150 }
151 }
152
153
156 public JournalArticleResource update(
157 JournalArticleResource journalArticleResource)
158 throws SystemException {
159 if (_log.isWarnEnabled()) {
160 _log.warn(
161 "Using the deprecated update(JournalArticleResource journalArticleResource) method. Use update(JournalArticleResource journalArticleResource, boolean merge) instead.");
162 }
163
164 return update(journalArticleResource, false);
165 }
166
167
180 public JournalArticleResource update(
181 JournalArticleResource journalArticleResource, boolean merge)
182 throws SystemException {
183 boolean isNew = journalArticleResource.isNew();
184
185 if (_listeners != null) {
186 for (ModelListener listener : _listeners) {
187 if (isNew) {
188 listener.onBeforeCreate(journalArticleResource);
189 }
190 else {
191 listener.onBeforeUpdate(journalArticleResource);
192 }
193 }
194 }
195
196 journalArticleResource = updateImpl(journalArticleResource, merge);
197
198 if (_listeners != null) {
199 for (ModelListener listener : _listeners) {
200 if (isNew) {
201 listener.onAfterCreate(journalArticleResource);
202 }
203 else {
204 listener.onAfterUpdate(journalArticleResource);
205 }
206 }
207 }
208
209 return journalArticleResource;
210 }
211
212 public JournalArticleResource updateImpl(
213 com.liferay.portlet.journal.model.JournalArticleResource journalArticleResource,
214 boolean merge) throws SystemException {
215 Session session = null;
216
217 try {
218 session = openSession();
219
220 if (merge) {
221 session.merge(journalArticleResource);
222 }
223 else {
224 if (journalArticleResource.isNew()) {
225 session.save(journalArticleResource);
226 }
227 }
228
229 session.flush();
230
231 journalArticleResource.setNew(false);
232
233 return journalArticleResource;
234 }
235 catch (Exception e) {
236 throw HibernateUtil.processException(e);
237 }
238 finally {
239 closeSession(session);
240
241 FinderCache.clearCache(JournalArticleResource.class.getName());
242 }
243 }
244
245 public JournalArticleResource findByPrimaryKey(long resourcePrimKey)
246 throws NoSuchArticleResourceException, SystemException {
247 JournalArticleResource journalArticleResource = fetchByPrimaryKey(resourcePrimKey);
248
249 if (journalArticleResource == null) {
250 if (_log.isWarnEnabled()) {
251 _log.warn(
252 "No JournalArticleResource exists with the primary key " +
253 resourcePrimKey);
254 }
255
256 throw new NoSuchArticleResourceException(
257 "No JournalArticleResource exists with the primary key " +
258 resourcePrimKey);
259 }
260
261 return journalArticleResource;
262 }
263
264 public JournalArticleResource fetchByPrimaryKey(long resourcePrimKey)
265 throws SystemException {
266 Session session = null;
267
268 try {
269 session = openSession();
270
271 return (JournalArticleResource)session.get(JournalArticleResourceImpl.class,
272 new Long(resourcePrimKey));
273 }
274 catch (Exception e) {
275 throw HibernateUtil.processException(e);
276 }
277 finally {
278 closeSession(session);
279 }
280 }
281
282 public List<JournalArticleResource> findByGroupId(long groupId)
283 throws SystemException {
284 boolean finderClassNameCacheEnabled = JournalArticleResourceModelImpl.CACHE_ENABLED;
285 String finderClassName = JournalArticleResource.class.getName();
286 String finderMethodName = "findByGroupId";
287 String[] finderParams = new String[] { Long.class.getName() };
288 Object[] finderArgs = new Object[] { new Long(groupId) };
289
290 Object result = null;
291
292 if (finderClassNameCacheEnabled) {
293 result = FinderCache.getResult(finderClassName, finderMethodName,
294 finderParams, finderArgs, getSessionFactory());
295 }
296
297 if (result == null) {
298 Session session = null;
299
300 try {
301 session = openSession();
302
303 StringMaker query = new StringMaker();
304
305 query.append(
306 "FROM com.liferay.portlet.journal.model.JournalArticleResource WHERE ");
307
308 query.append("groupId = ?");
309
310 query.append(" ");
311
312 Query q = session.createQuery(query.toString());
313
314 int queryPos = 0;
315
316 q.setLong(queryPos++, groupId);
317
318 List<JournalArticleResource> list = q.list();
319
320 FinderCache.putResult(finderClassNameCacheEnabled,
321 finderClassName, finderMethodName, finderParams,
322 finderArgs, list);
323
324 return list;
325 }
326 catch (Exception e) {
327 throw HibernateUtil.processException(e);
328 }
329 finally {
330 closeSession(session);
331 }
332 }
333 else {
334 return (List<JournalArticleResource>)result;
335 }
336 }
337
338 public List<JournalArticleResource> findByGroupId(long groupId, int begin,
339 int end) throws SystemException {
340 return findByGroupId(groupId, begin, end, null);
341 }
342
343 public List<JournalArticleResource> findByGroupId(long groupId, int begin,
344 int end, OrderByComparator obc) throws SystemException {
345 boolean finderClassNameCacheEnabled = JournalArticleResourceModelImpl.CACHE_ENABLED;
346 String finderClassName = JournalArticleResource.class.getName();
347 String finderMethodName = "findByGroupId";
348 String[] finderParams = new String[] {
349 Long.class.getName(),
350
351 "java.lang.Integer", "java.lang.Integer",
352 "com.liferay.portal.kernel.util.OrderByComparator"
353 };
354 Object[] finderArgs = new Object[] {
355 new Long(groupId),
356
357 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
358 };
359
360 Object result = null;
361
362 if (finderClassNameCacheEnabled) {
363 result = FinderCache.getResult(finderClassName, finderMethodName,
364 finderParams, finderArgs, getSessionFactory());
365 }
366
367 if (result == null) {
368 Session session = null;
369
370 try {
371 session = openSession();
372
373 StringMaker query = new StringMaker();
374
375 query.append(
376 "FROM com.liferay.portlet.journal.model.JournalArticleResource WHERE ");
377
378 query.append("groupId = ?");
379
380 query.append(" ");
381
382 if (obc != null) {
383 query.append("ORDER BY ");
384 query.append(obc.getOrderBy());
385 }
386
387 Query q = session.createQuery(query.toString());
388
389 int queryPos = 0;
390
391 q.setLong(queryPos++, groupId);
392
393 List<JournalArticleResource> list = (List<JournalArticleResource>)QueryUtil.list(q,
394 getDialect(), begin, end);
395
396 FinderCache.putResult(finderClassNameCacheEnabled,
397 finderClassName, finderMethodName, finderParams,
398 finderArgs, list);
399
400 return list;
401 }
402 catch (Exception e) {
403 throw HibernateUtil.processException(e);
404 }
405 finally {
406 closeSession(session);
407 }
408 }
409 else {
410 return (List<JournalArticleResource>)result;
411 }
412 }
413
414 public JournalArticleResource findByGroupId_First(long groupId,
415 OrderByComparator obc)
416 throws NoSuchArticleResourceException, SystemException {
417 List<JournalArticleResource> list = findByGroupId(groupId, 0, 1, obc);
418
419 if (list.size() == 0) {
420 StringMaker msg = new StringMaker();
421
422 msg.append("No JournalArticleResource exists with the key {");
423
424 msg.append("groupId=" + groupId);
425
426 msg.append(StringPool.CLOSE_CURLY_BRACE);
427
428 throw new NoSuchArticleResourceException(msg.toString());
429 }
430 else {
431 return list.get(0);
432 }
433 }
434
435 public JournalArticleResource findByGroupId_Last(long groupId,
436 OrderByComparator obc)
437 throws NoSuchArticleResourceException, SystemException {
438 int count = countByGroupId(groupId);
439
440 List<JournalArticleResource> list = findByGroupId(groupId, count - 1,
441 count, obc);
442
443 if (list.size() == 0) {
444 StringMaker msg = new StringMaker();
445
446 msg.append("No JournalArticleResource exists with the key {");
447
448 msg.append("groupId=" + groupId);
449
450 msg.append(StringPool.CLOSE_CURLY_BRACE);
451
452 throw new NoSuchArticleResourceException(msg.toString());
453 }
454 else {
455 return list.get(0);
456 }
457 }
458
459 public JournalArticleResource[] findByGroupId_PrevAndNext(
460 long resourcePrimKey, long groupId, OrderByComparator obc)
461 throws NoSuchArticleResourceException, SystemException {
462 JournalArticleResource journalArticleResource = findByPrimaryKey(resourcePrimKey);
463
464 int count = countByGroupId(groupId);
465
466 Session session = null;
467
468 try {
469 session = openSession();
470
471 StringMaker query = new StringMaker();
472
473 query.append(
474 "FROM com.liferay.portlet.journal.model.JournalArticleResource WHERE ");
475
476 query.append("groupId = ?");
477
478 query.append(" ");
479
480 if (obc != null) {
481 query.append("ORDER BY ");
482 query.append(obc.getOrderBy());
483 }
484
485 Query q = session.createQuery(query.toString());
486
487 int queryPos = 0;
488
489 q.setLong(queryPos++, groupId);
490
491 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
492 journalArticleResource);
493
494 JournalArticleResource[] array = new JournalArticleResourceImpl[3];
495
496 array[0] = (JournalArticleResource)objArray[0];
497 array[1] = (JournalArticleResource)objArray[1];
498 array[2] = (JournalArticleResource)objArray[2];
499
500 return array;
501 }
502 catch (Exception e) {
503 throw HibernateUtil.processException(e);
504 }
505 finally {
506 closeSession(session);
507 }
508 }
509
510 public JournalArticleResource findByG_A(long groupId, String articleId)
511 throws NoSuchArticleResourceException, SystemException {
512 JournalArticleResource journalArticleResource = fetchByG_A(groupId,
513 articleId);
514
515 if (journalArticleResource == null) {
516 StringMaker msg = new StringMaker();
517
518 msg.append("No JournalArticleResource exists with the key {");
519
520 msg.append("groupId=" + groupId);
521
522 msg.append(", ");
523 msg.append("articleId=" + articleId);
524
525 msg.append(StringPool.CLOSE_CURLY_BRACE);
526
527 if (_log.isWarnEnabled()) {
528 _log.warn(msg.toString());
529 }
530
531 throw new NoSuchArticleResourceException(msg.toString());
532 }
533
534 return journalArticleResource;
535 }
536
537 public JournalArticleResource fetchByG_A(long groupId, String articleId)
538 throws SystemException {
539 boolean finderClassNameCacheEnabled = JournalArticleResourceModelImpl.CACHE_ENABLED;
540 String finderClassName = JournalArticleResource.class.getName();
541 String finderMethodName = "fetchByG_A";
542 String[] finderParams = new String[] {
543 Long.class.getName(), String.class.getName()
544 };
545 Object[] finderArgs = new Object[] { new Long(groupId), articleId };
546
547 Object result = null;
548
549 if (finderClassNameCacheEnabled) {
550 result = FinderCache.getResult(finderClassName, finderMethodName,
551 finderParams, finderArgs, getSessionFactory());
552 }
553
554 if (result == null) {
555 Session session = null;
556
557 try {
558 session = openSession();
559
560 StringMaker query = new StringMaker();
561
562 query.append(
563 "FROM com.liferay.portlet.journal.model.JournalArticleResource WHERE ");
564
565 query.append("groupId = ?");
566
567 query.append(" AND ");
568
569 if (articleId == null) {
570 query.append("articleId IS NULL");
571 }
572 else {
573 query.append("articleId = ?");
574 }
575
576 query.append(" ");
577
578 Query q = session.createQuery(query.toString());
579
580 int queryPos = 0;
581
582 q.setLong(queryPos++, groupId);
583
584 if (articleId != null) {
585 q.setString(queryPos++, articleId);
586 }
587
588 List<JournalArticleResource> list = q.list();
589
590 FinderCache.putResult(finderClassNameCacheEnabled,
591 finderClassName, finderMethodName, finderParams,
592 finderArgs, list);
593
594 if (list.size() == 0) {
595 return null;
596 }
597 else {
598 return list.get(0);
599 }
600 }
601 catch (Exception e) {
602 throw HibernateUtil.processException(e);
603 }
604 finally {
605 closeSession(session);
606 }
607 }
608 else {
609 List<JournalArticleResource> list = (List<JournalArticleResource>)result;
610
611 if (list.size() == 0) {
612 return null;
613 }
614 else {
615 return list.get(0);
616 }
617 }
618 }
619
620 public List<JournalArticleResource> findWithDynamicQuery(
621 DynamicQueryInitializer queryInitializer) throws SystemException {
622 Session session = null;
623
624 try {
625 session = openSession();
626
627 DynamicQuery query = queryInitializer.initialize(session);
628
629 return query.list();
630 }
631 catch (Exception e) {
632 throw HibernateUtil.processException(e);
633 }
634 finally {
635 closeSession(session);
636 }
637 }
638
639 public List<JournalArticleResource> findWithDynamicQuery(
640 DynamicQueryInitializer queryInitializer, int begin, int end)
641 throws SystemException {
642 Session session = null;
643
644 try {
645 session = openSession();
646
647 DynamicQuery query = queryInitializer.initialize(session);
648
649 query.setLimit(begin, end);
650
651 return query.list();
652 }
653 catch (Exception e) {
654 throw HibernateUtil.processException(e);
655 }
656 finally {
657 closeSession(session);
658 }
659 }
660
661 public List<JournalArticleResource> findAll() throws SystemException {
662 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
663 }
664
665 public List<JournalArticleResource> findAll(int begin, int end)
666 throws SystemException {
667 return findAll(begin, end, null);
668 }
669
670 public List<JournalArticleResource> findAll(int begin, int end,
671 OrderByComparator obc) throws SystemException {
672 boolean finderClassNameCacheEnabled = JournalArticleResourceModelImpl.CACHE_ENABLED;
673 String finderClassName = JournalArticleResource.class.getName();
674 String finderMethodName = "findAll";
675 String[] finderParams = new String[] {
676 "java.lang.Integer", "java.lang.Integer",
677 "com.liferay.portal.kernel.util.OrderByComparator"
678 };
679 Object[] finderArgs = new Object[] {
680 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
681 };
682
683 Object result = null;
684
685 if (finderClassNameCacheEnabled) {
686 result = FinderCache.getResult(finderClassName, finderMethodName,
687 finderParams, finderArgs, getSessionFactory());
688 }
689
690 if (result == null) {
691 Session session = null;
692
693 try {
694 session = openSession();
695
696 StringMaker query = new StringMaker();
697
698 query.append(
699 "FROM com.liferay.portlet.journal.model.JournalArticleResource ");
700
701 if (obc != null) {
702 query.append("ORDER BY ");
703 query.append(obc.getOrderBy());
704 }
705
706 Query q = session.createQuery(query.toString());
707
708 List<JournalArticleResource> list = (List<JournalArticleResource>)QueryUtil.list(q,
709 getDialect(), begin, end);
710
711 if (obc == null) {
712 Collections.sort(list);
713 }
714
715 FinderCache.putResult(finderClassNameCacheEnabled,
716 finderClassName, finderMethodName, finderParams,
717 finderArgs, list);
718
719 return list;
720 }
721 catch (Exception e) {
722 throw HibernateUtil.processException(e);
723 }
724 finally {
725 closeSession(session);
726 }
727 }
728 else {
729 return (List<JournalArticleResource>)result;
730 }
731 }
732
733 public void removeByGroupId(long groupId) throws SystemException {
734 for (JournalArticleResource journalArticleResource : findByGroupId(
735 groupId)) {
736 remove(journalArticleResource);
737 }
738 }
739
740 public void removeByG_A(long groupId, String articleId)
741 throws NoSuchArticleResourceException, SystemException {
742 JournalArticleResource journalArticleResource = findByG_A(groupId,
743 articleId);
744
745 remove(journalArticleResource);
746 }
747
748 public void removeAll() throws SystemException {
749 for (JournalArticleResource journalArticleResource : findAll()) {
750 remove(journalArticleResource);
751 }
752 }
753
754 public int countByGroupId(long groupId) throws SystemException {
755 boolean finderClassNameCacheEnabled = JournalArticleResourceModelImpl.CACHE_ENABLED;
756 String finderClassName = JournalArticleResource.class.getName();
757 String finderMethodName = "countByGroupId";
758 String[] finderParams = new String[] { Long.class.getName() };
759 Object[] finderArgs = new Object[] { new Long(groupId) };
760
761 Object result = null;
762
763 if (finderClassNameCacheEnabled) {
764 result = FinderCache.getResult(finderClassName, finderMethodName,
765 finderParams, finderArgs, getSessionFactory());
766 }
767
768 if (result == null) {
769 Session session = null;
770
771 try {
772 session = openSession();
773
774 StringMaker query = new StringMaker();
775
776 query.append("SELECT COUNT(*) ");
777 query.append(
778 "FROM com.liferay.portlet.journal.model.JournalArticleResource WHERE ");
779
780 query.append("groupId = ?");
781
782 query.append(" ");
783
784 Query q = session.createQuery(query.toString());
785
786 int queryPos = 0;
787
788 q.setLong(queryPos++, groupId);
789
790 Long count = null;
791
792 Iterator<Long> itr = q.list().iterator();
793
794 if (itr.hasNext()) {
795 count = itr.next();
796 }
797
798 if (count == null) {
799 count = new Long(0);
800 }
801
802 FinderCache.putResult(finderClassNameCacheEnabled,
803 finderClassName, finderMethodName, finderParams,
804 finderArgs, count);
805
806 return count.intValue();
807 }
808 catch (Exception e) {
809 throw HibernateUtil.processException(e);
810 }
811 finally {
812 closeSession(session);
813 }
814 }
815 else {
816 return ((Long)result).intValue();
817 }
818 }
819
820 public int countByG_A(long groupId, String articleId)
821 throws SystemException {
822 boolean finderClassNameCacheEnabled = JournalArticleResourceModelImpl.CACHE_ENABLED;
823 String finderClassName = JournalArticleResource.class.getName();
824 String finderMethodName = "countByG_A";
825 String[] finderParams = new String[] {
826 Long.class.getName(), String.class.getName()
827 };
828 Object[] finderArgs = new Object[] { new Long(groupId), articleId };
829
830 Object result = null;
831
832 if (finderClassNameCacheEnabled) {
833 result = FinderCache.getResult(finderClassName, finderMethodName,
834 finderParams, finderArgs, getSessionFactory());
835 }
836
837 if (result == null) {
838 Session session = null;
839
840 try {
841 session = openSession();
842
843 StringMaker query = new StringMaker();
844
845 query.append("SELECT COUNT(*) ");
846 query.append(
847 "FROM com.liferay.portlet.journal.model.JournalArticleResource WHERE ");
848
849 query.append("groupId = ?");
850
851 query.append(" AND ");
852
853 if (articleId == null) {
854 query.append("articleId IS NULL");
855 }
856 else {
857 query.append("articleId = ?");
858 }
859
860 query.append(" ");
861
862 Query q = session.createQuery(query.toString());
863
864 int queryPos = 0;
865
866 q.setLong(queryPos++, groupId);
867
868 if (articleId != null) {
869 q.setString(queryPos++, articleId);
870 }
871
872 Long count = null;
873
874 Iterator<Long> itr = q.list().iterator();
875
876 if (itr.hasNext()) {
877 count = itr.next();
878 }
879
880 if (count == null) {
881 count = new Long(0);
882 }
883
884 FinderCache.putResult(finderClassNameCacheEnabled,
885 finderClassName, finderMethodName, finderParams,
886 finderArgs, count);
887
888 return count.intValue();
889 }
890 catch (Exception e) {
891 throw HibernateUtil.processException(e);
892 }
893 finally {
894 closeSession(session);
895 }
896 }
897 else {
898 return ((Long)result).intValue();
899 }
900 }
901
902 public int countAll() throws SystemException {
903 boolean finderClassNameCacheEnabled = JournalArticleResourceModelImpl.CACHE_ENABLED;
904 String finderClassName = JournalArticleResource.class.getName();
905 String finderMethodName = "countAll";
906 String[] finderParams = new String[] { };
907 Object[] finderArgs = new Object[] { };
908
909 Object result = null;
910
911 if (finderClassNameCacheEnabled) {
912 result = FinderCache.getResult(finderClassName, finderMethodName,
913 finderParams, finderArgs, getSessionFactory());
914 }
915
916 if (result == null) {
917 Session session = null;
918
919 try {
920 session = openSession();
921
922 Query q = session.createQuery(
923 "SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalArticleResource");
924
925 Long count = null;
926
927 Iterator<Long> itr = q.list().iterator();
928
929 if (itr.hasNext()) {
930 count = itr.next();
931 }
932
933 if (count == null) {
934 count = new Long(0);
935 }
936
937 FinderCache.putResult(finderClassNameCacheEnabled,
938 finderClassName, finderMethodName, finderParams,
939 finderArgs, count);
940
941 return count.intValue();
942 }
943 catch (Exception e) {
944 throw HibernateUtil.processException(e);
945 }
946 finally {
947 closeSession(session);
948 }
949 }
950 else {
951 return ((Long)result).intValue();
952 }
953 }
954
955 protected void initDao() {
956 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
957 PropsUtil.get(
958 "value.object.listener.com.liferay.portlet.journal.model.JournalArticleResource")));
959
960 if (listenerClassNames.length > 0) {
961 try {
962 List<ModelListener> listeners = new ArrayList<ModelListener>();
963
964 for (String listenerClassName : listenerClassNames) {
965 listeners.add((ModelListener)Class.forName(
966 listenerClassName).newInstance());
967 }
968
969 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
970 }
971 catch (Exception e) {
972 _log.error(e);
973 }
974 }
975 }
976
977 private static Log _log = LogFactory.getLog(JournalArticleResourcePersistenceImpl.class);
978 private ModelListener[] _listeners;
979 }