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