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