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