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.jdbc.MappingSqlQuery;
28 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
29 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
30 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.Query;
33 import com.liferay.portal.kernel.dao.orm.QueryPos;
34 import com.liferay.portal.kernel.dao.orm.QueryUtil;
35 import com.liferay.portal.kernel.dao.orm.SQLQuery;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.dao.orm.Type;
38 import com.liferay.portal.kernel.log.Log;
39 import com.liferay.portal.kernel.log.LogFactoryUtil;
40 import com.liferay.portal.kernel.util.GetterUtil;
41 import com.liferay.portal.kernel.util.OrderByComparator;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.shopping.NoSuchItemException;
49 import com.liferay.portlet.shopping.model.ShoppingItem;
50 import com.liferay.portlet.shopping.model.impl.ShoppingItemImpl;
51 import com.liferay.portlet.shopping.model.impl.ShoppingItemModelImpl;
52
53 import java.sql.Types;
54
55 import java.util.ArrayList;
56 import java.util.Collections;
57 import java.util.Iterator;
58 import java.util.List;
59
60
66 public class ShoppingItemPersistenceImpl extends BasePersistenceImpl
67 implements ShoppingItemPersistence {
68 public ShoppingItem create(long itemId) {
69 ShoppingItem shoppingItem = new ShoppingItemImpl();
70
71 shoppingItem.setNew(true);
72 shoppingItem.setPrimaryKey(itemId);
73
74 return shoppingItem;
75 }
76
77 public ShoppingItem remove(long itemId)
78 throws NoSuchItemException, SystemException {
79 Session session = null;
80
81 try {
82 session = openSession();
83
84 ShoppingItem shoppingItem = (ShoppingItem)session.get(ShoppingItemImpl.class,
85 new Long(itemId));
86
87 if (shoppingItem == null) {
88 if (_log.isWarnEnabled()) {
89 _log.warn("No ShoppingItem exists with the primary key " +
90 itemId);
91 }
92
93 throw new NoSuchItemException(
94 "No ShoppingItem exists with the primary key " + itemId);
95 }
96
97 return remove(shoppingItem);
98 }
99 catch (NoSuchItemException nsee) {
100 throw nsee;
101 }
102 catch (Exception e) {
103 throw processException(e);
104 }
105 finally {
106 closeSession(session);
107 }
108 }
109
110 public ShoppingItem remove(ShoppingItem shoppingItem)
111 throws SystemException {
112 for (ModelListener listener : listeners) {
113 listener.onBeforeRemove(shoppingItem);
114 }
115
116 shoppingItem = removeImpl(shoppingItem);
117
118 for (ModelListener listener : listeners) {
119 listener.onAfterRemove(shoppingItem);
120 }
121
122 return shoppingItem;
123 }
124
125 protected ShoppingItem removeImpl(ShoppingItem shoppingItem)
126 throws SystemException {
127 Session session = null;
128
129 try {
130 session = openSession();
131
132 if (BatchSessionUtil.isEnabled()) {
133 Object staleObject = session.get(ShoppingItemImpl.class,
134 shoppingItem.getPrimaryKeyObj());
135
136 if (staleObject != null) {
137 session.evict(staleObject);
138 }
139 }
140
141 session.delete(shoppingItem);
142
143 session.flush();
144
145 return shoppingItem;
146 }
147 catch (Exception e) {
148 throw processException(e);
149 }
150 finally {
151 closeSession(session);
152
153 FinderCacheUtil.clearCache(ShoppingItem.class.getName());
154 }
155 }
156
157
160 public ShoppingItem update(ShoppingItem shoppingItem)
161 throws SystemException {
162 if (_log.isWarnEnabled()) {
163 _log.warn(
164 "Using the deprecated update(ShoppingItem shoppingItem) method. Use update(ShoppingItem shoppingItem, boolean merge) instead.");
165 }
166
167 return update(shoppingItem, false);
168 }
169
170
183 public ShoppingItem update(ShoppingItem shoppingItem, boolean merge)
184 throws SystemException {
185 boolean isNew = shoppingItem.isNew();
186
187 for (ModelListener listener : listeners) {
188 if (isNew) {
189 listener.onBeforeCreate(shoppingItem);
190 }
191 else {
192 listener.onBeforeUpdate(shoppingItem);
193 }
194 }
195
196 shoppingItem = updateImpl(shoppingItem, merge);
197
198 for (ModelListener listener : listeners) {
199 if (isNew) {
200 listener.onAfterCreate(shoppingItem);
201 }
202 else {
203 listener.onAfterUpdate(shoppingItem);
204 }
205 }
206
207 return shoppingItem;
208 }
209
210 public ShoppingItem updateImpl(
211 com.liferay.portlet.shopping.model.ShoppingItem shoppingItem,
212 boolean merge) throws SystemException {
213 Session session = null;
214
215 try {
216 session = openSession();
217
218 BatchSessionUtil.update(session, shoppingItem, merge);
219
220 shoppingItem.setNew(false);
221
222 return shoppingItem;
223 }
224 catch (Exception e) {
225 throw processException(e);
226 }
227 finally {
228 closeSession(session);
229
230 FinderCacheUtil.clearCache(ShoppingItem.class.getName());
231 }
232 }
233
234 public ShoppingItem findByPrimaryKey(long itemId)
235 throws NoSuchItemException, SystemException {
236 ShoppingItem shoppingItem = fetchByPrimaryKey(itemId);
237
238 if (shoppingItem == null) {
239 if (_log.isWarnEnabled()) {
240 _log.warn("No ShoppingItem exists with the primary key " +
241 itemId);
242 }
243
244 throw new NoSuchItemException(
245 "No ShoppingItem exists with the primary key " + itemId);
246 }
247
248 return shoppingItem;
249 }
250
251 public ShoppingItem fetchByPrimaryKey(long itemId)
252 throws SystemException {
253 Session session = null;
254
255 try {
256 session = openSession();
257
258 return (ShoppingItem)session.get(ShoppingItemImpl.class,
259 new Long(itemId));
260 }
261 catch (Exception e) {
262 throw processException(e);
263 }
264 finally {
265 closeSession(session);
266 }
267 }
268
269 public List<ShoppingItem> findByCategoryId(long categoryId)
270 throws SystemException {
271 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
272 String finderClassName = ShoppingItem.class.getName();
273 String finderMethodName = "findByCategoryId";
274 String[] finderParams = new String[] { Long.class.getName() };
275 Object[] finderArgs = new Object[] { new Long(categoryId) };
276
277 Object result = null;
278
279 if (finderClassNameCacheEnabled) {
280 result = FinderCacheUtil.getResult(finderClassName,
281 finderMethodName, finderParams, finderArgs, this);
282 }
283
284 if (result == null) {
285 Session session = null;
286
287 try {
288 session = openSession();
289
290 StringBuilder query = new StringBuilder();
291
292 query.append(
293 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
294
295 query.append("categoryId = ?");
296
297 query.append(" ");
298
299 query.append("ORDER BY ");
300
301 query.append("itemId ASC");
302
303 Query q = session.createQuery(query.toString());
304
305 QueryPos qPos = QueryPos.getInstance(q);
306
307 qPos.add(categoryId);
308
309 List<ShoppingItem> list = q.list();
310
311 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
312 finderClassName, finderMethodName, finderParams,
313 finderArgs, list);
314
315 return list;
316 }
317 catch (Exception e) {
318 throw processException(e);
319 }
320 finally {
321 closeSession(session);
322 }
323 }
324 else {
325 return (List<ShoppingItem>)result;
326 }
327 }
328
329 public List<ShoppingItem> findByCategoryId(long categoryId, int start,
330 int end) throws SystemException {
331 return findByCategoryId(categoryId, start, end, null);
332 }
333
334 public List<ShoppingItem> findByCategoryId(long categoryId, int start,
335 int end, OrderByComparator obc) throws SystemException {
336 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
337 String finderClassName = ShoppingItem.class.getName();
338 String finderMethodName = "findByCategoryId";
339 String[] finderParams = new String[] {
340 Long.class.getName(),
341
342 "java.lang.Integer", "java.lang.Integer",
343 "com.liferay.portal.kernel.util.OrderByComparator"
344 };
345 Object[] finderArgs = new Object[] {
346 new Long(categoryId),
347
348 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
349 };
350
351 Object result = null;
352
353 if (finderClassNameCacheEnabled) {
354 result = FinderCacheUtil.getResult(finderClassName,
355 finderMethodName, finderParams, finderArgs, this);
356 }
357
358 if (result == null) {
359 Session session = null;
360
361 try {
362 session = openSession();
363
364 StringBuilder query = new StringBuilder();
365
366 query.append(
367 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
368
369 query.append("categoryId = ?");
370
371 query.append(" ");
372
373 if (obc != null) {
374 query.append("ORDER BY ");
375 query.append(obc.getOrderBy());
376 }
377
378 else {
379 query.append("ORDER BY ");
380
381 query.append("itemId ASC");
382 }
383
384 Query q = session.createQuery(query.toString());
385
386 QueryPos qPos = QueryPos.getInstance(q);
387
388 qPos.add(categoryId);
389
390 List<ShoppingItem> list = (List<ShoppingItem>)QueryUtil.list(q,
391 getDialect(), start, end);
392
393 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
394 finderClassName, finderMethodName, finderParams,
395 finderArgs, list);
396
397 return list;
398 }
399 catch (Exception e) {
400 throw processException(e);
401 }
402 finally {
403 closeSession(session);
404 }
405 }
406 else {
407 return (List<ShoppingItem>)result;
408 }
409 }
410
411 public ShoppingItem findByCategoryId_First(long categoryId,
412 OrderByComparator obc) throws NoSuchItemException, SystemException {
413 List<ShoppingItem> list = findByCategoryId(categoryId, 0, 1, obc);
414
415 if (list.size() == 0) {
416 StringBuilder msg = new StringBuilder();
417
418 msg.append("No ShoppingItem exists with the key {");
419
420 msg.append("categoryId=" + categoryId);
421
422 msg.append(StringPool.CLOSE_CURLY_BRACE);
423
424 throw new NoSuchItemException(msg.toString());
425 }
426 else {
427 return list.get(0);
428 }
429 }
430
431 public ShoppingItem findByCategoryId_Last(long categoryId,
432 OrderByComparator obc) throws NoSuchItemException, SystemException {
433 int count = countByCategoryId(categoryId);
434
435 List<ShoppingItem> list = findByCategoryId(categoryId, count - 1,
436 count, obc);
437
438 if (list.size() == 0) {
439 StringBuilder msg = new StringBuilder();
440
441 msg.append("No ShoppingItem exists with the key {");
442
443 msg.append("categoryId=" + categoryId);
444
445 msg.append(StringPool.CLOSE_CURLY_BRACE);
446
447 throw new NoSuchItemException(msg.toString());
448 }
449 else {
450 return list.get(0);
451 }
452 }
453
454 public ShoppingItem[] findByCategoryId_PrevAndNext(long itemId,
455 long categoryId, OrderByComparator obc)
456 throws NoSuchItemException, SystemException {
457 ShoppingItem shoppingItem = findByPrimaryKey(itemId);
458
459 int count = countByCategoryId(categoryId);
460
461 Session session = null;
462
463 try {
464 session = openSession();
465
466 StringBuilder query = new StringBuilder();
467
468 query.append(
469 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
470
471 query.append("categoryId = ?");
472
473 query.append(" ");
474
475 if (obc != null) {
476 query.append("ORDER BY ");
477 query.append(obc.getOrderBy());
478 }
479
480 else {
481 query.append("ORDER BY ");
482
483 query.append("itemId ASC");
484 }
485
486 Query q = session.createQuery(query.toString());
487
488 QueryPos qPos = QueryPos.getInstance(q);
489
490 qPos.add(categoryId);
491
492 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
493 shoppingItem);
494
495 ShoppingItem[] array = new ShoppingItemImpl[3];
496
497 array[0] = (ShoppingItem)objArray[0];
498 array[1] = (ShoppingItem)objArray[1];
499 array[2] = (ShoppingItem)objArray[2];
500
501 return array;
502 }
503 catch (Exception e) {
504 throw processException(e);
505 }
506 finally {
507 closeSession(session);
508 }
509 }
510
511 public ShoppingItem findBySmallImageId(long smallImageId)
512 throws NoSuchItemException, SystemException {
513 ShoppingItem shoppingItem = fetchBySmallImageId(smallImageId);
514
515 if (shoppingItem == null) {
516 StringBuilder msg = new StringBuilder();
517
518 msg.append("No ShoppingItem exists with the key {");
519
520 msg.append("smallImageId=" + smallImageId);
521
522 msg.append(StringPool.CLOSE_CURLY_BRACE);
523
524 if (_log.isWarnEnabled()) {
525 _log.warn(msg.toString());
526 }
527
528 throw new NoSuchItemException(msg.toString());
529 }
530
531 return shoppingItem;
532 }
533
534 public ShoppingItem fetchBySmallImageId(long smallImageId)
535 throws SystemException {
536 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
537 String finderClassName = ShoppingItem.class.getName();
538 String finderMethodName = "fetchBySmallImageId";
539 String[] finderParams = new String[] { Long.class.getName() };
540 Object[] finderArgs = new Object[] { new Long(smallImageId) };
541
542 Object result = null;
543
544 if (finderClassNameCacheEnabled) {
545 result = FinderCacheUtil.getResult(finderClassName,
546 finderMethodName, finderParams, finderArgs, this);
547 }
548
549 if (result == null) {
550 Session session = null;
551
552 try {
553 session = openSession();
554
555 StringBuilder query = new StringBuilder();
556
557 query.append(
558 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
559
560 query.append("smallImageId = ?");
561
562 query.append(" ");
563
564 query.append("ORDER BY ");
565
566 query.append("itemId ASC");
567
568 Query q = session.createQuery(query.toString());
569
570 QueryPos qPos = QueryPos.getInstance(q);
571
572 qPos.add(smallImageId);
573
574 List<ShoppingItem> list = q.list();
575
576 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
577 finderClassName, finderMethodName, finderParams,
578 finderArgs, list);
579
580 if (list.size() == 0) {
581 return null;
582 }
583 else {
584 return list.get(0);
585 }
586 }
587 catch (Exception e) {
588 throw processException(e);
589 }
590 finally {
591 closeSession(session);
592 }
593 }
594 else {
595 List<ShoppingItem> list = (List<ShoppingItem>)result;
596
597 if (list.size() == 0) {
598 return null;
599 }
600 else {
601 return list.get(0);
602 }
603 }
604 }
605
606 public ShoppingItem findByMediumImageId(long mediumImageId)
607 throws NoSuchItemException, SystemException {
608 ShoppingItem shoppingItem = fetchByMediumImageId(mediumImageId);
609
610 if (shoppingItem == null) {
611 StringBuilder msg = new StringBuilder();
612
613 msg.append("No ShoppingItem exists with the key {");
614
615 msg.append("mediumImageId=" + mediumImageId);
616
617 msg.append(StringPool.CLOSE_CURLY_BRACE);
618
619 if (_log.isWarnEnabled()) {
620 _log.warn(msg.toString());
621 }
622
623 throw new NoSuchItemException(msg.toString());
624 }
625
626 return shoppingItem;
627 }
628
629 public ShoppingItem fetchByMediumImageId(long mediumImageId)
630 throws SystemException {
631 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
632 String finderClassName = ShoppingItem.class.getName();
633 String finderMethodName = "fetchByMediumImageId";
634 String[] finderParams = new String[] { Long.class.getName() };
635 Object[] finderArgs = new Object[] { new Long(mediumImageId) };
636
637 Object result = null;
638
639 if (finderClassNameCacheEnabled) {
640 result = FinderCacheUtil.getResult(finderClassName,
641 finderMethodName, finderParams, finderArgs, this);
642 }
643
644 if (result == null) {
645 Session session = null;
646
647 try {
648 session = openSession();
649
650 StringBuilder query = new StringBuilder();
651
652 query.append(
653 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
654
655 query.append("mediumImageId = ?");
656
657 query.append(" ");
658
659 query.append("ORDER BY ");
660
661 query.append("itemId ASC");
662
663 Query q = session.createQuery(query.toString());
664
665 QueryPos qPos = QueryPos.getInstance(q);
666
667 qPos.add(mediumImageId);
668
669 List<ShoppingItem> list = q.list();
670
671 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
672 finderClassName, finderMethodName, finderParams,
673 finderArgs, list);
674
675 if (list.size() == 0) {
676 return null;
677 }
678 else {
679 return list.get(0);
680 }
681 }
682 catch (Exception e) {
683 throw processException(e);
684 }
685 finally {
686 closeSession(session);
687 }
688 }
689 else {
690 List<ShoppingItem> list = (List<ShoppingItem>)result;
691
692 if (list.size() == 0) {
693 return null;
694 }
695 else {
696 return list.get(0);
697 }
698 }
699 }
700
701 public ShoppingItem findByLargeImageId(long largeImageId)
702 throws NoSuchItemException, SystemException {
703 ShoppingItem shoppingItem = fetchByLargeImageId(largeImageId);
704
705 if (shoppingItem == null) {
706 StringBuilder msg = new StringBuilder();
707
708 msg.append("No ShoppingItem exists with the key {");
709
710 msg.append("largeImageId=" + largeImageId);
711
712 msg.append(StringPool.CLOSE_CURLY_BRACE);
713
714 if (_log.isWarnEnabled()) {
715 _log.warn(msg.toString());
716 }
717
718 throw new NoSuchItemException(msg.toString());
719 }
720
721 return shoppingItem;
722 }
723
724 public ShoppingItem fetchByLargeImageId(long largeImageId)
725 throws SystemException {
726 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
727 String finderClassName = ShoppingItem.class.getName();
728 String finderMethodName = "fetchByLargeImageId";
729 String[] finderParams = new String[] { Long.class.getName() };
730 Object[] finderArgs = new Object[] { new Long(largeImageId) };
731
732 Object result = null;
733
734 if (finderClassNameCacheEnabled) {
735 result = FinderCacheUtil.getResult(finderClassName,
736 finderMethodName, finderParams, finderArgs, this);
737 }
738
739 if (result == null) {
740 Session session = null;
741
742 try {
743 session = openSession();
744
745 StringBuilder query = new StringBuilder();
746
747 query.append(
748 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
749
750 query.append("largeImageId = ?");
751
752 query.append(" ");
753
754 query.append("ORDER BY ");
755
756 query.append("itemId ASC");
757
758 Query q = session.createQuery(query.toString());
759
760 QueryPos qPos = QueryPos.getInstance(q);
761
762 qPos.add(largeImageId);
763
764 List<ShoppingItem> list = q.list();
765
766 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
767 finderClassName, finderMethodName, finderParams,
768 finderArgs, list);
769
770 if (list.size() == 0) {
771 return null;
772 }
773 else {
774 return list.get(0);
775 }
776 }
777 catch (Exception e) {
778 throw processException(e);
779 }
780 finally {
781 closeSession(session);
782 }
783 }
784 else {
785 List<ShoppingItem> list = (List<ShoppingItem>)result;
786
787 if (list.size() == 0) {
788 return null;
789 }
790 else {
791 return list.get(0);
792 }
793 }
794 }
795
796 public ShoppingItem findByC_S(long companyId, String sku)
797 throws NoSuchItemException, SystemException {
798 ShoppingItem shoppingItem = fetchByC_S(companyId, sku);
799
800 if (shoppingItem == null) {
801 StringBuilder msg = new StringBuilder();
802
803 msg.append("No ShoppingItem exists with the key {");
804
805 msg.append("companyId=" + companyId);
806
807 msg.append(", ");
808 msg.append("sku=" + sku);
809
810 msg.append(StringPool.CLOSE_CURLY_BRACE);
811
812 if (_log.isWarnEnabled()) {
813 _log.warn(msg.toString());
814 }
815
816 throw new NoSuchItemException(msg.toString());
817 }
818
819 return shoppingItem;
820 }
821
822 public ShoppingItem fetchByC_S(long companyId, String sku)
823 throws SystemException {
824 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
825 String finderClassName = ShoppingItem.class.getName();
826 String finderMethodName = "fetchByC_S";
827 String[] finderParams = new String[] {
828 Long.class.getName(), String.class.getName()
829 };
830 Object[] finderArgs = new Object[] { new Long(companyId), sku };
831
832 Object result = null;
833
834 if (finderClassNameCacheEnabled) {
835 result = FinderCacheUtil.getResult(finderClassName,
836 finderMethodName, finderParams, finderArgs, this);
837 }
838
839 if (result == null) {
840 Session session = null;
841
842 try {
843 session = openSession();
844
845 StringBuilder query = new StringBuilder();
846
847 query.append(
848 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
849
850 query.append("companyId = ?");
851
852 query.append(" AND ");
853
854 if (sku == null) {
855 query.append("sku IS NULL");
856 }
857 else {
858 query.append("sku = ?");
859 }
860
861 query.append(" ");
862
863 query.append("ORDER BY ");
864
865 query.append("itemId ASC");
866
867 Query q = session.createQuery(query.toString());
868
869 QueryPos qPos = QueryPos.getInstance(q);
870
871 qPos.add(companyId);
872
873 if (sku != null) {
874 qPos.add(sku);
875 }
876
877 List<ShoppingItem> list = q.list();
878
879 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
880 finderClassName, finderMethodName, finderParams,
881 finderArgs, list);
882
883 if (list.size() == 0) {
884 return null;
885 }
886 else {
887 return list.get(0);
888 }
889 }
890 catch (Exception e) {
891 throw processException(e);
892 }
893 finally {
894 closeSession(session);
895 }
896 }
897 else {
898 List<ShoppingItem> list = (List<ShoppingItem>)result;
899
900 if (list.size() == 0) {
901 return null;
902 }
903 else {
904 return list.get(0);
905 }
906 }
907 }
908
909 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
910 throws SystemException {
911 Session session = null;
912
913 try {
914 session = openSession();
915
916 dynamicQuery.compile(session);
917
918 return dynamicQuery.list();
919 }
920 catch (Exception e) {
921 throw processException(e);
922 }
923 finally {
924 closeSession(session);
925 }
926 }
927
928 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
929 int start, int end) throws SystemException {
930 Session session = null;
931
932 try {
933 session = openSession();
934
935 dynamicQuery.setLimit(start, end);
936
937 dynamicQuery.compile(session);
938
939 return dynamicQuery.list();
940 }
941 catch (Exception e) {
942 throw processException(e);
943 }
944 finally {
945 closeSession(session);
946 }
947 }
948
949 public List<ShoppingItem> findAll() throws SystemException {
950 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
951 }
952
953 public List<ShoppingItem> findAll(int start, int end)
954 throws SystemException {
955 return findAll(start, end, null);
956 }
957
958 public List<ShoppingItem> findAll(int start, int end, OrderByComparator obc)
959 throws SystemException {
960 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
961 String finderClassName = ShoppingItem.class.getName();
962 String finderMethodName = "findAll";
963 String[] finderParams = new String[] {
964 "java.lang.Integer", "java.lang.Integer",
965 "com.liferay.portal.kernel.util.OrderByComparator"
966 };
967 Object[] finderArgs = new Object[] {
968 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
969 };
970
971 Object result = null;
972
973 if (finderClassNameCacheEnabled) {
974 result = FinderCacheUtil.getResult(finderClassName,
975 finderMethodName, finderParams, finderArgs, this);
976 }
977
978 if (result == null) {
979 Session session = null;
980
981 try {
982 session = openSession();
983
984 StringBuilder query = new StringBuilder();
985
986 query.append(
987 "FROM com.liferay.portlet.shopping.model.ShoppingItem ");
988
989 if (obc != null) {
990 query.append("ORDER BY ");
991 query.append(obc.getOrderBy());
992 }
993
994 else {
995 query.append("ORDER BY ");
996
997 query.append("itemId ASC");
998 }
999
1000 Query q = session.createQuery(query.toString());
1001
1002 List<ShoppingItem> list = null;
1003
1004 if (obc == null) {
1005 list = (List<ShoppingItem>)QueryUtil.list(q, getDialect(),
1006 start, end, false);
1007
1008 Collections.sort(list);
1009 }
1010 else {
1011 list = (List<ShoppingItem>)QueryUtil.list(q, getDialect(),
1012 start, end);
1013 }
1014
1015 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1016 finderClassName, finderMethodName, finderParams,
1017 finderArgs, list);
1018
1019 return list;
1020 }
1021 catch (Exception e) {
1022 throw processException(e);
1023 }
1024 finally {
1025 closeSession(session);
1026 }
1027 }
1028 else {
1029 return (List<ShoppingItem>)result;
1030 }
1031 }
1032
1033 public void removeByCategoryId(long categoryId) throws SystemException {
1034 for (ShoppingItem shoppingItem : findByCategoryId(categoryId)) {
1035 remove(shoppingItem);
1036 }
1037 }
1038
1039 public void removeBySmallImageId(long smallImageId)
1040 throws NoSuchItemException, SystemException {
1041 ShoppingItem shoppingItem = findBySmallImageId(smallImageId);
1042
1043 remove(shoppingItem);
1044 }
1045
1046 public void removeByMediumImageId(long mediumImageId)
1047 throws NoSuchItemException, SystemException {
1048 ShoppingItem shoppingItem = findByMediumImageId(mediumImageId);
1049
1050 remove(shoppingItem);
1051 }
1052
1053 public void removeByLargeImageId(long largeImageId)
1054 throws NoSuchItemException, SystemException {
1055 ShoppingItem shoppingItem = findByLargeImageId(largeImageId);
1056
1057 remove(shoppingItem);
1058 }
1059
1060 public void removeByC_S(long companyId, String sku)
1061 throws NoSuchItemException, SystemException {
1062 ShoppingItem shoppingItem = findByC_S(companyId, sku);
1063
1064 remove(shoppingItem);
1065 }
1066
1067 public void removeAll() throws SystemException {
1068 for (ShoppingItem shoppingItem : findAll()) {
1069 remove(shoppingItem);
1070 }
1071 }
1072
1073 public int countByCategoryId(long categoryId) throws SystemException {
1074 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
1075 String finderClassName = ShoppingItem.class.getName();
1076 String finderMethodName = "countByCategoryId";
1077 String[] finderParams = new String[] { Long.class.getName() };
1078 Object[] finderArgs = new Object[] { new Long(categoryId) };
1079
1080 Object result = null;
1081
1082 if (finderClassNameCacheEnabled) {
1083 result = FinderCacheUtil.getResult(finderClassName,
1084 finderMethodName, finderParams, finderArgs, this);
1085 }
1086
1087 if (result == null) {
1088 Session session = null;
1089
1090 try {
1091 session = openSession();
1092
1093 StringBuilder query = new StringBuilder();
1094
1095 query.append("SELECT COUNT(*) ");
1096 query.append(
1097 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
1098
1099 query.append("categoryId = ?");
1100
1101 query.append(" ");
1102
1103 Query q = session.createQuery(query.toString());
1104
1105 QueryPos qPos = QueryPos.getInstance(q);
1106
1107 qPos.add(categoryId);
1108
1109 Long count = null;
1110
1111 Iterator<Long> itr = q.list().iterator();
1112
1113 if (itr.hasNext()) {
1114 count = itr.next();
1115 }
1116
1117 if (count == null) {
1118 count = new Long(0);
1119 }
1120
1121 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1122 finderClassName, finderMethodName, finderParams,
1123 finderArgs, count);
1124
1125 return count.intValue();
1126 }
1127 catch (Exception e) {
1128 throw processException(e);
1129 }
1130 finally {
1131 closeSession(session);
1132 }
1133 }
1134 else {
1135 return ((Long)result).intValue();
1136 }
1137 }
1138
1139 public int countBySmallImageId(long smallImageId) throws SystemException {
1140 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
1141 String finderClassName = ShoppingItem.class.getName();
1142 String finderMethodName = "countBySmallImageId";
1143 String[] finderParams = new String[] { Long.class.getName() };
1144 Object[] finderArgs = new Object[] { new Long(smallImageId) };
1145
1146 Object result = null;
1147
1148 if (finderClassNameCacheEnabled) {
1149 result = FinderCacheUtil.getResult(finderClassName,
1150 finderMethodName, finderParams, finderArgs, this);
1151 }
1152
1153 if (result == null) {
1154 Session session = null;
1155
1156 try {
1157 session = openSession();
1158
1159 StringBuilder query = new StringBuilder();
1160
1161 query.append("SELECT COUNT(*) ");
1162 query.append(
1163 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
1164
1165 query.append("smallImageId = ?");
1166
1167 query.append(" ");
1168
1169 Query q = session.createQuery(query.toString());
1170
1171 QueryPos qPos = QueryPos.getInstance(q);
1172
1173 qPos.add(smallImageId);
1174
1175 Long count = null;
1176
1177 Iterator<Long> itr = q.list().iterator();
1178
1179 if (itr.hasNext()) {
1180 count = itr.next();
1181 }
1182
1183 if (count == null) {
1184 count = new Long(0);
1185 }
1186
1187 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1188 finderClassName, finderMethodName, finderParams,
1189 finderArgs, count);
1190
1191 return count.intValue();
1192 }
1193 catch (Exception e) {
1194 throw processException(e);
1195 }
1196 finally {
1197 closeSession(session);
1198 }
1199 }
1200 else {
1201 return ((Long)result).intValue();
1202 }
1203 }
1204
1205 public int countByMediumImageId(long mediumImageId)
1206 throws SystemException {
1207 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
1208 String finderClassName = ShoppingItem.class.getName();
1209 String finderMethodName = "countByMediumImageId";
1210 String[] finderParams = new String[] { Long.class.getName() };
1211 Object[] finderArgs = new Object[] { new Long(mediumImageId) };
1212
1213 Object result = null;
1214
1215 if (finderClassNameCacheEnabled) {
1216 result = FinderCacheUtil.getResult(finderClassName,
1217 finderMethodName, finderParams, finderArgs, this);
1218 }
1219
1220 if (result == null) {
1221 Session session = null;
1222
1223 try {
1224 session = openSession();
1225
1226 StringBuilder query = new StringBuilder();
1227
1228 query.append("SELECT COUNT(*) ");
1229 query.append(
1230 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
1231
1232 query.append("mediumImageId = ?");
1233
1234 query.append(" ");
1235
1236 Query q = session.createQuery(query.toString());
1237
1238 QueryPos qPos = QueryPos.getInstance(q);
1239
1240 qPos.add(mediumImageId);
1241
1242 Long count = null;
1243
1244 Iterator<Long> itr = q.list().iterator();
1245
1246 if (itr.hasNext()) {
1247 count = itr.next();
1248 }
1249
1250 if (count == null) {
1251 count = new Long(0);
1252 }
1253
1254 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1255 finderClassName, finderMethodName, finderParams,
1256 finderArgs, count);
1257
1258 return count.intValue();
1259 }
1260 catch (Exception e) {
1261 throw processException(e);
1262 }
1263 finally {
1264 closeSession(session);
1265 }
1266 }
1267 else {
1268 return ((Long)result).intValue();
1269 }
1270 }
1271
1272 public int countByLargeImageId(long largeImageId) throws SystemException {
1273 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
1274 String finderClassName = ShoppingItem.class.getName();
1275 String finderMethodName = "countByLargeImageId";
1276 String[] finderParams = new String[] { Long.class.getName() };
1277 Object[] finderArgs = new Object[] { new Long(largeImageId) };
1278
1279 Object result = null;
1280
1281 if (finderClassNameCacheEnabled) {
1282 result = FinderCacheUtil.getResult(finderClassName,
1283 finderMethodName, finderParams, finderArgs, this);
1284 }
1285
1286 if (result == null) {
1287 Session session = null;
1288
1289 try {
1290 session = openSession();
1291
1292 StringBuilder query = new StringBuilder();
1293
1294 query.append("SELECT COUNT(*) ");
1295 query.append(
1296 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
1297
1298 query.append("largeImageId = ?");
1299
1300 query.append(" ");
1301
1302 Query q = session.createQuery(query.toString());
1303
1304 QueryPos qPos = QueryPos.getInstance(q);
1305
1306 qPos.add(largeImageId);
1307
1308 Long count = null;
1309
1310 Iterator<Long> itr = q.list().iterator();
1311
1312 if (itr.hasNext()) {
1313 count = itr.next();
1314 }
1315
1316 if (count == null) {
1317 count = new Long(0);
1318 }
1319
1320 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1321 finderClassName, finderMethodName, finderParams,
1322 finderArgs, count);
1323
1324 return count.intValue();
1325 }
1326 catch (Exception e) {
1327 throw processException(e);
1328 }
1329 finally {
1330 closeSession(session);
1331 }
1332 }
1333 else {
1334 return ((Long)result).intValue();
1335 }
1336 }
1337
1338 public int countByC_S(long companyId, String sku) throws SystemException {
1339 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
1340 String finderClassName = ShoppingItem.class.getName();
1341 String finderMethodName = "countByC_S";
1342 String[] finderParams = new String[] {
1343 Long.class.getName(), String.class.getName()
1344 };
1345 Object[] finderArgs = new Object[] { new Long(companyId), sku };
1346
1347 Object result = null;
1348
1349 if (finderClassNameCacheEnabled) {
1350 result = FinderCacheUtil.getResult(finderClassName,
1351 finderMethodName, finderParams, finderArgs, this);
1352 }
1353
1354 if (result == null) {
1355 Session session = null;
1356
1357 try {
1358 session = openSession();
1359
1360 StringBuilder query = new StringBuilder();
1361
1362 query.append("SELECT COUNT(*) ");
1363 query.append(
1364 "FROM com.liferay.portlet.shopping.model.ShoppingItem WHERE ");
1365
1366 query.append("companyId = ?");
1367
1368 query.append(" AND ");
1369
1370 if (sku == null) {
1371 query.append("sku IS NULL");
1372 }
1373 else {
1374 query.append("sku = ?");
1375 }
1376
1377 query.append(" ");
1378
1379 Query q = session.createQuery(query.toString());
1380
1381 QueryPos qPos = QueryPos.getInstance(q);
1382
1383 qPos.add(companyId);
1384
1385 if (sku != null) {
1386 qPos.add(sku);
1387 }
1388
1389 Long count = null;
1390
1391 Iterator<Long> itr = q.list().iterator();
1392
1393 if (itr.hasNext()) {
1394 count = itr.next();
1395 }
1396
1397 if (count == null) {
1398 count = new Long(0);
1399 }
1400
1401 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1402 finderClassName, finderMethodName, finderParams,
1403 finderArgs, count);
1404
1405 return count.intValue();
1406 }
1407 catch (Exception e) {
1408 throw processException(e);
1409 }
1410 finally {
1411 closeSession(session);
1412 }
1413 }
1414 else {
1415 return ((Long)result).intValue();
1416 }
1417 }
1418
1419 public int countAll() throws SystemException {
1420 boolean finderClassNameCacheEnabled = ShoppingItemModelImpl.CACHE_ENABLED;
1421 String finderClassName = ShoppingItem.class.getName();
1422 String finderMethodName = "countAll";
1423 String[] finderParams = new String[] { };
1424 Object[] finderArgs = new Object[] { };
1425
1426 Object result = null;
1427
1428 if (finderClassNameCacheEnabled) {
1429 result = FinderCacheUtil.getResult(finderClassName,
1430 finderMethodName, finderParams, finderArgs, this);
1431 }
1432
1433 if (result == null) {
1434 Session session = null;
1435
1436 try {
1437 session = openSession();
1438
1439 Query q = session.createQuery(
1440 "SELECT COUNT(*) FROM com.liferay.portlet.shopping.model.ShoppingItem");
1441
1442 Long count = null;
1443
1444 Iterator<Long> itr = q.list().iterator();
1445
1446 if (itr.hasNext()) {
1447 count = itr.next();
1448 }
1449
1450 if (count == null) {
1451 count = new Long(0);
1452 }
1453
1454 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1455 finderClassName, finderMethodName, finderParams,
1456 finderArgs, count);
1457
1458 return count.intValue();
1459 }
1460 catch (Exception e) {
1461 throw processException(e);
1462 }
1463 finally {
1464 closeSession(session);
1465 }
1466 }
1467 else {
1468 return ((Long)result).intValue();
1469 }
1470 }
1471
1472 public List<com.liferay.portlet.shopping.model.ShoppingItemPrice> getShoppingItemPrices(
1473 long pk) throws SystemException {
1474 return getShoppingItemPrices(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1475 }
1476
1477 public List<com.liferay.portlet.shopping.model.ShoppingItemPrice> getShoppingItemPrices(
1478 long pk, int start, int end) throws SystemException {
1479 return getShoppingItemPrices(pk, start, end, null);
1480 }
1481
1482 public List<com.liferay.portlet.shopping.model.ShoppingItemPrice> getShoppingItemPrices(
1483 long pk, int start, int end, OrderByComparator obc)
1484 throws SystemException {
1485 boolean finderClassNameCacheEnabled = com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.CACHE_ENABLED;
1486
1487 String finderClassName = com.liferay.portlet.shopping.model.ShoppingItemPrice.class.getName();
1488
1489 String finderMethodName = "getShoppingItemPrices";
1490 String[] finderParams = new String[] {
1491 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1492 "com.liferay.portal.kernel.util.OrderByComparator"
1493 };
1494 Object[] finderArgs = new Object[] {
1495 new Long(pk), String.valueOf(start), String.valueOf(end),
1496 String.valueOf(obc)
1497 };
1498
1499 Object result = null;
1500
1501 if (finderClassNameCacheEnabled) {
1502 result = FinderCacheUtil.getResult(finderClassName,
1503 finderMethodName, finderParams, finderArgs, this);
1504 }
1505
1506 if (result == null) {
1507 Session session = null;
1508
1509 try {
1510 session = openSession();
1511
1512 StringBuilder sb = new StringBuilder();
1513
1514 sb.append(_SQL_GETSHOPPINGITEMPRICES);
1515
1516 if (obc != null) {
1517 sb.append("ORDER BY ");
1518 sb.append(obc.getOrderBy());
1519 }
1520
1521 else {
1522 sb.append("ORDER BY ");
1523
1524 sb.append("ShoppingItemPrice.itemId ASC, ");
1525 sb.append("ShoppingItemPrice.itemPriceId ASC");
1526 }
1527
1528 String sql = sb.toString();
1529
1530 SQLQuery q = session.createSQLQuery(sql);
1531
1532 q.addEntity("ShoppingItemPrice",
1533 com.liferay.portlet.shopping.model.impl.ShoppingItemPriceImpl.class);
1534
1535 QueryPos qPos = QueryPos.getInstance(q);
1536
1537 qPos.add(pk);
1538
1539 List<com.liferay.portlet.shopping.model.ShoppingItemPrice> list = (List<com.liferay.portlet.shopping.model.ShoppingItemPrice>)QueryUtil.list(q,
1540 getDialect(), start, end);
1541
1542 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1543 finderClassName, finderMethodName, finderParams,
1544 finderArgs, list);
1545
1546 return list;
1547 }
1548 catch (Exception e) {
1549 throw processException(e);
1550 }
1551 finally {
1552 closeSession(session);
1553 }
1554 }
1555 else {
1556 return (List<com.liferay.portlet.shopping.model.ShoppingItemPrice>)result;
1557 }
1558 }
1559
1560 public int getShoppingItemPricesSize(long pk) throws SystemException {
1561 boolean finderClassNameCacheEnabled = com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.CACHE_ENABLED;
1562
1563 String finderClassName = com.liferay.portlet.shopping.model.ShoppingItemPrice.class.getName();
1564
1565 String finderMethodName = "getShoppingItemPricesSize";
1566 String[] finderParams = new String[] { Long.class.getName() };
1567 Object[] finderArgs = new Object[] { new Long(pk) };
1568
1569 Object result = null;
1570
1571 if (finderClassNameCacheEnabled) {
1572 result = FinderCacheUtil.getResult(finderClassName,
1573 finderMethodName, finderParams, finderArgs, this);
1574 }
1575
1576 if (result == null) {
1577 Session session = null;
1578
1579 try {
1580 session = openSession();
1581
1582 SQLQuery q = session.createSQLQuery(_SQL_GETSHOPPINGITEMPRICESSIZE);
1583
1584 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1585
1586 QueryPos qPos = QueryPos.getInstance(q);
1587
1588 qPos.add(pk);
1589
1590 Long count = null;
1591
1592 Iterator<Long> itr = q.list().iterator();
1593
1594 if (itr.hasNext()) {
1595 count = itr.next();
1596 }
1597
1598 if (count == null) {
1599 count = new Long(0);
1600 }
1601
1602 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1603 finderClassName, finderMethodName, finderParams,
1604 finderArgs, count);
1605
1606 return count.intValue();
1607 }
1608 catch (Exception e) {
1609 throw processException(e);
1610 }
1611 finally {
1612 closeSession(session);
1613 }
1614 }
1615 else {
1616 return ((Long)result).intValue();
1617 }
1618 }
1619
1620 public boolean containsShoppingItemPrice(long pk, long shoppingItemPricePK)
1621 throws SystemException {
1622 boolean finderClassNameCacheEnabled = com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.CACHE_ENABLED;
1623
1624 String finderClassName = com.liferay.portlet.shopping.model.ShoppingItemPrice.class.getName();
1625
1626 String finderMethodName = "containsShoppingItemPrices";
1627 String[] finderParams = new String[] {
1628 Long.class.getName(),
1629
1630 Long.class.getName()
1631 };
1632 Object[] finderArgs = new Object[] {
1633 new Long(pk),
1634
1635 new Long(shoppingItemPricePK)
1636 };
1637
1638 Object result = null;
1639
1640 if (finderClassNameCacheEnabled) {
1641 result = FinderCacheUtil.getResult(finderClassName,
1642 finderMethodName, finderParams, finderArgs, this);
1643 }
1644
1645 if (result == null) {
1646 try {
1647 Boolean value = Boolean.valueOf(containsShoppingItemPrice.contains(
1648 pk, shoppingItemPricePK));
1649
1650 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1651 finderClassName, finderMethodName, finderParams,
1652 finderArgs, value);
1653
1654 return value.booleanValue();
1655 }
1656 catch (Exception e) {
1657 throw processException(e);
1658 }
1659 }
1660 else {
1661 return ((Boolean)result).booleanValue();
1662 }
1663 }
1664
1665 public boolean containsShoppingItemPrices(long pk)
1666 throws SystemException {
1667 if (getShoppingItemPricesSize(pk) > 0) {
1668 return true;
1669 }
1670 else {
1671 return false;
1672 }
1673 }
1674
1675 public void afterPropertiesSet() {
1676 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1677 com.liferay.portal.util.PropsUtil.get(
1678 "value.object.listener.com.liferay.portlet.shopping.model.ShoppingItem")));
1679
1680 if (listenerClassNames.length > 0) {
1681 try {
1682 List<ModelListener> listenersList = new ArrayList<ModelListener>();
1683
1684 for (String listenerClassName : listenerClassNames) {
1685 listenersList.add((ModelListener)Class.forName(
1686 listenerClassName).newInstance());
1687 }
1688
1689 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1690 }
1691 catch (Exception e) {
1692 _log.error(e);
1693 }
1694 }
1695
1696 containsShoppingItemPrice = new ContainsShoppingItemPrice(this);
1697 }
1698
1699 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence.impl")
1700 protected com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence shoppingCartPersistence;
1701 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence.impl")
1702 protected com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence shoppingCategoryPersistence;
1703 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence.impl")
1704 protected com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence shoppingCouponPersistence;
1705 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingItemPersistence.impl")
1706 protected com.liferay.portlet.shopping.service.persistence.ShoppingItemPersistence shoppingItemPersistence;
1707 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingItemFieldPersistence.impl")
1708 protected com.liferay.portlet.shopping.service.persistence.ShoppingItemFieldPersistence shoppingItemFieldPersistence;
1709 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistence.impl")
1710 protected com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistence shoppingItemPricePersistence;
1711 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence.impl")
1712 protected com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence shoppingOrderPersistence;
1713 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingOrderItemPersistence.impl")
1714 protected com.liferay.portlet.shopping.service.persistence.ShoppingOrderItemPersistence shoppingOrderItemPersistence;
1715 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
1716 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1717 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1718 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1719 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1720 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1721 protected ContainsShoppingItemPrice containsShoppingItemPrice;
1722
1723 protected class ContainsShoppingItemPrice {
1724 protected ContainsShoppingItemPrice(
1725 ShoppingItemPersistenceImpl persistenceImpl) {
1726 super();
1727
1728 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1729 _SQL_CONTAINSSHOPPINGITEMPRICE,
1730 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
1731 }
1732
1733 protected boolean contains(long itemId, long itemPriceId) {
1734 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1735 new Long(itemId), new Long(itemPriceId)
1736 });
1737
1738 if (results.size() > 0) {
1739 Integer count = results.get(0);
1740
1741 if (count.intValue() > 0) {
1742 return true;
1743 }
1744 }
1745
1746 return false;
1747 }
1748
1749 private MappingSqlQuery _mappingSqlQuery;
1750 }
1751
1752 private static final String _SQL_GETSHOPPINGITEMPRICES = "SELECT {ShoppingItemPrice.*} FROM ShoppingItemPrice INNER JOIN ShoppingItem ON (ShoppingItem.itemId = ShoppingItemPrice.itemId) WHERE (ShoppingItem.itemId = ?)";
1753 private static final String _SQL_GETSHOPPINGITEMPRICESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM ShoppingItemPrice WHERE itemId = ?";
1754 private static final String _SQL_CONTAINSSHOPPINGITEMPRICE = "SELECT COUNT(*) AS COUNT_VALUE FROM ShoppingItemPrice WHERE itemId = ? AND itemPriceId = ?";
1755 private static Log _log = LogFactoryUtil.getLog(ShoppingItemPersistenceImpl.class);
1756}