1
14
15 package com.liferay.portlet.shopping.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.kernel.annotation.BeanReference;
19 import com.liferay.portal.kernel.cache.CacheRegistry;
20 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
21 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.exception.SystemException;
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 public ShoppingItemPrice updateImpl(
217 com.liferay.portlet.shopping.model.ShoppingItemPrice shoppingItemPrice,
218 boolean merge) throws SystemException {
219 shoppingItemPrice = toUnwrappedModel(shoppingItemPrice);
220
221 Session session = null;
222
223 try {
224 session = openSession();
225
226 BatchSessionUtil.update(session, shoppingItemPrice, merge);
227
228 shoppingItemPrice.setNew(false);
229 }
230 catch (Exception e) {
231 throw processException(e);
232 }
233 finally {
234 closeSession(session);
235 }
236
237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
238
239 EntityCacheUtil.putResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
240 ShoppingItemPriceImpl.class, shoppingItemPrice.getPrimaryKey(),
241 shoppingItemPrice);
242
243 return shoppingItemPrice;
244 }
245
246 protected ShoppingItemPrice toUnwrappedModel(
247 ShoppingItemPrice shoppingItemPrice) {
248 if (shoppingItemPrice instanceof ShoppingItemPriceImpl) {
249 return shoppingItemPrice;
250 }
251
252 ShoppingItemPriceImpl shoppingItemPriceImpl = new ShoppingItemPriceImpl();
253
254 shoppingItemPriceImpl.setNew(shoppingItemPrice.isNew());
255 shoppingItemPriceImpl.setPrimaryKey(shoppingItemPrice.getPrimaryKey());
256
257 shoppingItemPriceImpl.setItemPriceId(shoppingItemPrice.getItemPriceId());
258 shoppingItemPriceImpl.setItemId(shoppingItemPrice.getItemId());
259 shoppingItemPriceImpl.setMinQuantity(shoppingItemPrice.getMinQuantity());
260 shoppingItemPriceImpl.setMaxQuantity(shoppingItemPrice.getMaxQuantity());
261 shoppingItemPriceImpl.setPrice(shoppingItemPrice.getPrice());
262 shoppingItemPriceImpl.setDiscount(shoppingItemPrice.getDiscount());
263 shoppingItemPriceImpl.setTaxable(shoppingItemPrice.isTaxable());
264 shoppingItemPriceImpl.setShipping(shoppingItemPrice.getShipping());
265 shoppingItemPriceImpl.setUseShippingFormula(shoppingItemPrice.isUseShippingFormula());
266 shoppingItemPriceImpl.setStatus(shoppingItemPrice.getStatus());
267
268 return shoppingItemPriceImpl;
269 }
270
271 public ShoppingItemPrice findByPrimaryKey(Serializable primaryKey)
272 throws NoSuchModelException, SystemException {
273 return findByPrimaryKey(((Long)primaryKey).longValue());
274 }
275
276 public ShoppingItemPrice findByPrimaryKey(long itemPriceId)
277 throws NoSuchItemPriceException, SystemException {
278 ShoppingItemPrice shoppingItemPrice = fetchByPrimaryKey(itemPriceId);
279
280 if (shoppingItemPrice == null) {
281 if (_log.isWarnEnabled()) {
282 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + itemPriceId);
283 }
284
285 throw new NoSuchItemPriceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
286 itemPriceId);
287 }
288
289 return shoppingItemPrice;
290 }
291
292 public ShoppingItemPrice fetchByPrimaryKey(Serializable primaryKey)
293 throws SystemException {
294 return fetchByPrimaryKey(((Long)primaryKey).longValue());
295 }
296
297 public ShoppingItemPrice fetchByPrimaryKey(long itemPriceId)
298 throws SystemException {
299 ShoppingItemPrice shoppingItemPrice = (ShoppingItemPrice)EntityCacheUtil.getResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
300 ShoppingItemPriceImpl.class, itemPriceId, this);
301
302 if (shoppingItemPrice == null) {
303 Session session = null;
304
305 try {
306 session = openSession();
307
308 shoppingItemPrice = (ShoppingItemPrice)session.get(ShoppingItemPriceImpl.class,
309 new Long(itemPriceId));
310 }
311 catch (Exception e) {
312 throw processException(e);
313 }
314 finally {
315 if (shoppingItemPrice != null) {
316 cacheResult(shoppingItemPrice);
317 }
318
319 closeSession(session);
320 }
321 }
322
323 return shoppingItemPrice;
324 }
325
326 public List<ShoppingItemPrice> findByItemId(long itemId)
327 throws SystemException {
328 Object[] finderArgs = new Object[] { new Long(itemId) };
329
330 List<ShoppingItemPrice> list = (List<ShoppingItemPrice>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ITEMID,
331 finderArgs, this);
332
333 if (list == null) {
334 Session session = null;
335
336 try {
337 session = openSession();
338
339 StringBundler query = new StringBundler(3);
340
341 query.append(_SQL_SELECT_SHOPPINGITEMPRICE_WHERE);
342
343 query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
344
345 query.append(ShoppingItemPriceModelImpl.ORDER_BY_JPQL);
346
347 String sql = query.toString();
348
349 Query q = session.createQuery(sql);
350
351 QueryPos qPos = QueryPos.getInstance(q);
352
353 qPos.add(itemId);
354
355 list = q.list();
356 }
357 catch (Exception e) {
358 throw processException(e);
359 }
360 finally {
361 if (list == null) {
362 list = new ArrayList<ShoppingItemPrice>();
363 }
364
365 cacheResult(list);
366
367 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ITEMID,
368 finderArgs, list);
369
370 closeSession(session);
371 }
372 }
373
374 return list;
375 }
376
377 public List<ShoppingItemPrice> findByItemId(long itemId, int start, int end)
378 throws SystemException {
379 return findByItemId(itemId, start, end, null);
380 }
381
382 public List<ShoppingItemPrice> findByItemId(long itemId, int start,
383 int end, OrderByComparator obc) throws SystemException {
384 Object[] finderArgs = new Object[] {
385 new Long(itemId),
386
387 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
388 };
389
390 List<ShoppingItemPrice> list = (List<ShoppingItemPrice>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ITEMID,
391 finderArgs, this);
392
393 if (list == null) {
394 Session session = null;
395
396 try {
397 session = openSession();
398
399 StringBundler query = null;
400
401 if (obc != null) {
402 query = new StringBundler(3 +
403 (obc.getOrderByFields().length * 3));
404 }
405 else {
406 query = new StringBundler(3);
407 }
408
409 query.append(_SQL_SELECT_SHOPPINGITEMPRICE_WHERE);
410
411 query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
412
413 if (obc != null) {
414 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
415 }
416
417 else {
418 query.append(ShoppingItemPriceModelImpl.ORDER_BY_JPQL);
419 }
420
421 String sql = query.toString();
422
423 Query q = session.createQuery(sql);
424
425 QueryPos qPos = QueryPos.getInstance(q);
426
427 qPos.add(itemId);
428
429 list = (List<ShoppingItemPrice>)QueryUtil.list(q, getDialect(),
430 start, end);
431 }
432 catch (Exception e) {
433 throw processException(e);
434 }
435 finally {
436 if (list == null) {
437 list = new ArrayList<ShoppingItemPrice>();
438 }
439
440 cacheResult(list);
441
442 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ITEMID,
443 finderArgs, list);
444
445 closeSession(session);
446 }
447 }
448
449 return list;
450 }
451
452 public ShoppingItemPrice findByItemId_First(long itemId,
453 OrderByComparator obc) throws NoSuchItemPriceException, SystemException {
454 List<ShoppingItemPrice> list = findByItemId(itemId, 0, 1, obc);
455
456 if (list.isEmpty()) {
457 StringBundler msg = new StringBundler(4);
458
459 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
460
461 msg.append("itemId=");
462 msg.append(itemId);
463
464 msg.append(StringPool.CLOSE_CURLY_BRACE);
465
466 throw new NoSuchItemPriceException(msg.toString());
467 }
468 else {
469 return list.get(0);
470 }
471 }
472
473 public ShoppingItemPrice findByItemId_Last(long itemId,
474 OrderByComparator obc) throws NoSuchItemPriceException, SystemException {
475 int count = countByItemId(itemId);
476
477 List<ShoppingItemPrice> list = findByItemId(itemId, count - 1, count,
478 obc);
479
480 if (list.isEmpty()) {
481 StringBundler msg = new StringBundler(4);
482
483 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
484
485 msg.append("itemId=");
486 msg.append(itemId);
487
488 msg.append(StringPool.CLOSE_CURLY_BRACE);
489
490 throw new NoSuchItemPriceException(msg.toString());
491 }
492 else {
493 return list.get(0);
494 }
495 }
496
497 public ShoppingItemPrice[] findByItemId_PrevAndNext(long itemPriceId,
498 long itemId, OrderByComparator obc)
499 throws NoSuchItemPriceException, SystemException {
500 ShoppingItemPrice shoppingItemPrice = findByPrimaryKey(itemPriceId);
501
502 int count = countByItemId(itemId);
503
504 Session session = null;
505
506 try {
507 session = openSession();
508
509 StringBundler query = null;
510
511 if (obc != null) {
512 query = new StringBundler(3 +
513 (obc.getOrderByFields().length * 3));
514 }
515 else {
516 query = new StringBundler(3);
517 }
518
519 query.append(_SQL_SELECT_SHOPPINGITEMPRICE_WHERE);
520
521 query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
522
523 if (obc != null) {
524 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
525 }
526
527 else {
528 query.append(ShoppingItemPriceModelImpl.ORDER_BY_JPQL);
529 }
530
531 String sql = query.toString();
532
533 Query q = session.createQuery(sql);
534
535 QueryPos qPos = QueryPos.getInstance(q);
536
537 qPos.add(itemId);
538
539 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
540 shoppingItemPrice);
541
542 ShoppingItemPrice[] array = new ShoppingItemPriceImpl[3];
543
544 array[0] = (ShoppingItemPrice)objArray[0];
545 array[1] = (ShoppingItemPrice)objArray[1];
546 array[2] = (ShoppingItemPrice)objArray[2];
547
548 return array;
549 }
550 catch (Exception e) {
551 throw processException(e);
552 }
553 finally {
554 closeSession(session);
555 }
556 }
557
558 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
559 throws SystemException {
560 Session session = null;
561
562 try {
563 session = openSession();
564
565 dynamicQuery.compile(session);
566
567 return dynamicQuery.list();
568 }
569 catch (Exception e) {
570 throw processException(e);
571 }
572 finally {
573 closeSession(session);
574 }
575 }
576
577 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
578 int start, int end) throws SystemException {
579 Session session = null;
580
581 try {
582 session = openSession();
583
584 dynamicQuery.setLimit(start, end);
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<ShoppingItemPrice> findAll() throws SystemException {
599 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
600 }
601
602 public List<ShoppingItemPrice> findAll(int start, int end)
603 throws SystemException {
604 return findAll(start, end, null);
605 }
606
607 public List<ShoppingItemPrice> findAll(int start, int end,
608 OrderByComparator obc) throws SystemException {
609 Object[] finderArgs = new Object[] {
610 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
611 };
612
613 List<ShoppingItemPrice> list = (List<ShoppingItemPrice>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
614 finderArgs, this);
615
616 if (list == null) {
617 Session session = null;
618
619 try {
620 session = openSession();
621
622 StringBundler query = null;
623 String sql = null;
624
625 if (obc != null) {
626 query = new StringBundler(2 +
627 (obc.getOrderByFields().length * 3));
628
629 query.append(_SQL_SELECT_SHOPPINGITEMPRICE);
630
631 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
632
633 sql = query.toString();
634 }
635
636 else {
637 sql = _SQL_SELECT_SHOPPINGITEMPRICE.concat(ShoppingItemPriceModelImpl.ORDER_BY_JPQL);
638 }
639
640 Query q = session.createQuery(sql);
641
642 if (obc == null) {
643 list = (List<ShoppingItemPrice>)QueryUtil.list(q,
644 getDialect(), start, end, false);
645
646 Collections.sort(list);
647 }
648 else {
649 list = (List<ShoppingItemPrice>)QueryUtil.list(q,
650 getDialect(), start, end);
651 }
652 }
653 catch (Exception e) {
654 throw processException(e);
655 }
656 finally {
657 if (list == null) {
658 list = new ArrayList<ShoppingItemPrice>();
659 }
660
661 cacheResult(list);
662
663 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
664
665 closeSession(session);
666 }
667 }
668
669 return list;
670 }
671
672 public void removeByItemId(long itemId) throws SystemException {
673 for (ShoppingItemPrice shoppingItemPrice : findByItemId(itemId)) {
674 remove(shoppingItemPrice);
675 }
676 }
677
678 public void removeAll() throws SystemException {
679 for (ShoppingItemPrice shoppingItemPrice : findAll()) {
680 remove(shoppingItemPrice);
681 }
682 }
683
684 public int countByItemId(long itemId) throws SystemException {
685 Object[] finderArgs = new Object[] { new Long(itemId) };
686
687 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ITEMID,
688 finderArgs, this);
689
690 if (count == null) {
691 Session session = null;
692
693 try {
694 session = openSession();
695
696 StringBundler query = new StringBundler(2);
697
698 query.append(_SQL_COUNT_SHOPPINGITEMPRICE_WHERE);
699
700 query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
701
702 String sql = query.toString();
703
704 Query q = session.createQuery(sql);
705
706 QueryPos qPos = QueryPos.getInstance(q);
707
708 qPos.add(itemId);
709
710 count = (Long)q.uniqueResult();
711 }
712 catch (Exception e) {
713 throw processException(e);
714 }
715 finally {
716 if (count == null) {
717 count = Long.valueOf(0);
718 }
719
720 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ITEMID,
721 finderArgs, count);
722
723 closeSession(session);
724 }
725 }
726
727 return count.intValue();
728 }
729
730 public int countAll() throws SystemException {
731 Object[] finderArgs = new Object[0];
732
733 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
734 finderArgs, this);
735
736 if (count == null) {
737 Session session = null;
738
739 try {
740 session = openSession();
741
742 Query q = session.createQuery(_SQL_COUNT_SHOPPINGITEMPRICE);
743
744 count = (Long)q.uniqueResult();
745 }
746 catch (Exception e) {
747 throw processException(e);
748 }
749 finally {
750 if (count == null) {
751 count = Long.valueOf(0);
752 }
753
754 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
755 count);
756
757 closeSession(session);
758 }
759 }
760
761 return count.intValue();
762 }
763
764 public void afterPropertiesSet() {
765 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
766 com.liferay.portal.util.PropsUtil.get(
767 "value.object.listener.com.liferay.portlet.shopping.model.ShoppingItemPrice")));
768
769 if (listenerClassNames.length > 0) {
770 try {
771 List<ModelListener<ShoppingItemPrice>> listenersList = new ArrayList<ModelListener<ShoppingItemPrice>>();
772
773 for (String listenerClassName : listenerClassNames) {
774 listenersList.add((ModelListener<ShoppingItemPrice>)Class.forName(
775 listenerClassName).newInstance());
776 }
777
778 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
779 }
780 catch (Exception e) {
781 _log.error(e);
782 }
783 }
784 }
785
786 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence")
787 protected com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence shoppingCartPersistence;
788 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence")
789 protected com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence shoppingCategoryPersistence;
790 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence")
791 protected com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence shoppingCouponPersistence;
792 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingItemPersistence")
793 protected com.liferay.portlet.shopping.service.persistence.ShoppingItemPersistence shoppingItemPersistence;
794 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingItemFieldPersistence")
795 protected com.liferay.portlet.shopping.service.persistence.ShoppingItemFieldPersistence shoppingItemFieldPersistence;
796 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistence")
797 protected com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistence shoppingItemPricePersistence;
798 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence")
799 protected com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence shoppingOrderPersistence;
800 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingOrderItemPersistence")
801 protected com.liferay.portlet.shopping.service.persistence.ShoppingOrderItemPersistence shoppingOrderItemPersistence;
802 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
803 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
804 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
805 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
806 private static final String _SQL_SELECT_SHOPPINGITEMPRICE = "SELECT shoppingItemPrice FROM ShoppingItemPrice shoppingItemPrice";
807 private static final String _SQL_SELECT_SHOPPINGITEMPRICE_WHERE = "SELECT shoppingItemPrice FROM ShoppingItemPrice shoppingItemPrice WHERE ";
808 private static final String _SQL_COUNT_SHOPPINGITEMPRICE = "SELECT COUNT(shoppingItemPrice) FROM ShoppingItemPrice shoppingItemPrice";
809 private static final String _SQL_COUNT_SHOPPINGITEMPRICE_WHERE = "SELECT COUNT(shoppingItemPrice) FROM ShoppingItemPrice shoppingItemPrice WHERE ";
810 private static final String _FINDER_COLUMN_ITEMID_ITEMID_2 = "shoppingItemPrice.itemId = ?";
811 private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingItemPrice.";
812 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingItemPrice exists with the primary key ";
813 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingItemPrice exists with the key {";
814 private static Log _log = LogFactoryUtil.getLog(ShoppingItemPricePersistenceImpl.class);
815 }