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