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