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