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.NoSuchOrderItemException;
41 import com.liferay.portlet.shopping.model.ShoppingOrderItem;
42 import com.liferay.portlet.shopping.model.impl.ShoppingOrderItemImpl;
43 import com.liferay.portlet.shopping.model.impl.ShoppingOrderItemModelImpl;
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 ShoppingOrderItemPersistenceImpl extends BasePersistenceImpl<ShoppingOrderItem>
65 implements ShoppingOrderItemPersistence {
66 public static final String FINDER_CLASS_NAME_ENTITY = ShoppingOrderItemImpl.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_ORDERID = new FinderPath(ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
70 ShoppingOrderItemModelImpl.FINDER_CACHE_ENABLED,
71 FINDER_CLASS_NAME_LIST, "findByOrderId",
72 new String[] { Long.class.getName() });
73 public static final FinderPath FINDER_PATH_FIND_BY_OBC_ORDERID = new FinderPath(ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
74 ShoppingOrderItemModelImpl.FINDER_CACHE_ENABLED,
75 FINDER_CLASS_NAME_LIST, "findByOrderId",
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_ORDERID = new FinderPath(ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
83 ShoppingOrderItemModelImpl.FINDER_CACHE_ENABLED,
84 FINDER_CLASS_NAME_LIST, "countByOrderId",
85 new String[] { Long.class.getName() });
86 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
87 ShoppingOrderItemModelImpl.FINDER_CACHE_ENABLED,
88 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
89 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
90 ShoppingOrderItemModelImpl.FINDER_CACHE_ENABLED,
91 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
92
93 public void cacheResult(ShoppingOrderItem shoppingOrderItem) {
94 EntityCacheUtil.putResult(ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
95 ShoppingOrderItemImpl.class, shoppingOrderItem.getPrimaryKey(),
96 shoppingOrderItem);
97 }
98
99 public void cacheResult(List<ShoppingOrderItem> shoppingOrderItems) {
100 for (ShoppingOrderItem shoppingOrderItem : shoppingOrderItems) {
101 if (EntityCacheUtil.getResult(
102 ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
103 ShoppingOrderItemImpl.class,
104 shoppingOrderItem.getPrimaryKey(), this) == null) {
105 cacheResult(shoppingOrderItem);
106 }
107 }
108 }
109
110 public void clearCache() {
111 CacheRegistry.clear(ShoppingOrderItemImpl.class.getName());
112 EntityCacheUtil.clearCache(ShoppingOrderItemImpl.class.getName());
113 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
114 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
115 }
116
117 public ShoppingOrderItem create(long orderItemId) {
118 ShoppingOrderItem shoppingOrderItem = new ShoppingOrderItemImpl();
119
120 shoppingOrderItem.setNew(true);
121 shoppingOrderItem.setPrimaryKey(orderItemId);
122
123 return shoppingOrderItem;
124 }
125
126 public ShoppingOrderItem remove(Serializable primaryKey)
127 throws NoSuchModelException, SystemException {
128 return remove(((Long)primaryKey).longValue());
129 }
130
131 public ShoppingOrderItem remove(long orderItemId)
132 throws NoSuchOrderItemException, SystemException {
133 Session session = null;
134
135 try {
136 session = openSession();
137
138 ShoppingOrderItem shoppingOrderItem = (ShoppingOrderItem)session.get(ShoppingOrderItemImpl.class,
139 new Long(orderItemId));
140
141 if (shoppingOrderItem == null) {
142 if (_log.isWarnEnabled()) {
143 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orderItemId);
144 }
145
146 throw new NoSuchOrderItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
147 orderItemId);
148 }
149
150 return remove(shoppingOrderItem);
151 }
152 catch (NoSuchOrderItemException nsee) {
153 throw nsee;
154 }
155 catch (Exception e) {
156 throw processException(e);
157 }
158 finally {
159 closeSession(session);
160 }
161 }
162
163 public ShoppingOrderItem remove(ShoppingOrderItem shoppingOrderItem)
164 throws SystemException {
165 for (ModelListener<ShoppingOrderItem> listener : listeners) {
166 listener.onBeforeRemove(shoppingOrderItem);
167 }
168
169 shoppingOrderItem = removeImpl(shoppingOrderItem);
170
171 for (ModelListener<ShoppingOrderItem> listener : listeners) {
172 listener.onAfterRemove(shoppingOrderItem);
173 }
174
175 return shoppingOrderItem;
176 }
177
178 protected ShoppingOrderItem removeImpl(ShoppingOrderItem shoppingOrderItem)
179 throws SystemException {
180 shoppingOrderItem = toUnwrappedModel(shoppingOrderItem);
181
182 Session session = null;
183
184 try {
185 session = openSession();
186
187 if (shoppingOrderItem.isCachedModel() ||
188 BatchSessionUtil.isEnabled()) {
189 Object staleObject = session.get(ShoppingOrderItemImpl.class,
190 shoppingOrderItem.getPrimaryKeyObj());
191
192 if (staleObject != null) {
193 session.evict(staleObject);
194 }
195 }
196
197 session.delete(shoppingOrderItem);
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(ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
211 ShoppingOrderItemImpl.class, shoppingOrderItem.getPrimaryKey());
212
213 return shoppingOrderItem;
214 }
215
216
219 public ShoppingOrderItem update(ShoppingOrderItem shoppingOrderItem)
220 throws SystemException {
221 if (_log.isWarnEnabled()) {
222 _log.warn(
223 "Using the deprecated update(ShoppingOrderItem shoppingOrderItem) method. Use update(ShoppingOrderItem shoppingOrderItem, boolean merge) instead.");
224 }
225
226 return update(shoppingOrderItem, false);
227 }
228
229 public ShoppingOrderItem updateImpl(
230 com.liferay.portlet.shopping.model.ShoppingOrderItem shoppingOrderItem,
231 boolean merge) throws SystemException {
232 shoppingOrderItem = toUnwrappedModel(shoppingOrderItem);
233
234 Session session = null;
235
236 try {
237 session = openSession();
238
239 BatchSessionUtil.update(session, shoppingOrderItem, merge);
240
241 shoppingOrderItem.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(ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
253 ShoppingOrderItemImpl.class, shoppingOrderItem.getPrimaryKey(),
254 shoppingOrderItem);
255
256 return shoppingOrderItem;
257 }
258
259 protected ShoppingOrderItem toUnwrappedModel(
260 ShoppingOrderItem shoppingOrderItem) {
261 if (shoppingOrderItem instanceof ShoppingOrderItemImpl) {
262 return shoppingOrderItem;
263 }
264
265 ShoppingOrderItemImpl shoppingOrderItemImpl = new ShoppingOrderItemImpl();
266
267 shoppingOrderItemImpl.setNew(shoppingOrderItem.isNew());
268 shoppingOrderItemImpl.setPrimaryKey(shoppingOrderItem.getPrimaryKey());
269
270 shoppingOrderItemImpl.setOrderItemId(shoppingOrderItem.getOrderItemId());
271 shoppingOrderItemImpl.setOrderId(shoppingOrderItem.getOrderId());
272 shoppingOrderItemImpl.setItemId(shoppingOrderItem.getItemId());
273 shoppingOrderItemImpl.setSku(shoppingOrderItem.getSku());
274 shoppingOrderItemImpl.setName(shoppingOrderItem.getName());
275 shoppingOrderItemImpl.setDescription(shoppingOrderItem.getDescription());
276 shoppingOrderItemImpl.setProperties(shoppingOrderItem.getProperties());
277 shoppingOrderItemImpl.setPrice(shoppingOrderItem.getPrice());
278 shoppingOrderItemImpl.setQuantity(shoppingOrderItem.getQuantity());
279 shoppingOrderItemImpl.setShippedDate(shoppingOrderItem.getShippedDate());
280
281 return shoppingOrderItemImpl;
282 }
283
284 public ShoppingOrderItem findByPrimaryKey(Serializable primaryKey)
285 throws NoSuchModelException, SystemException {
286 return findByPrimaryKey(((Long)primaryKey).longValue());
287 }
288
289 public ShoppingOrderItem findByPrimaryKey(long orderItemId)
290 throws NoSuchOrderItemException, SystemException {
291 ShoppingOrderItem shoppingOrderItem = fetchByPrimaryKey(orderItemId);
292
293 if (shoppingOrderItem == null) {
294 if (_log.isWarnEnabled()) {
295 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orderItemId);
296 }
297
298 throw new NoSuchOrderItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
299 orderItemId);
300 }
301
302 return shoppingOrderItem;
303 }
304
305 public ShoppingOrderItem fetchByPrimaryKey(Serializable primaryKey)
306 throws SystemException {
307 return fetchByPrimaryKey(((Long)primaryKey).longValue());
308 }
309
310 public ShoppingOrderItem fetchByPrimaryKey(long orderItemId)
311 throws SystemException {
312 ShoppingOrderItem shoppingOrderItem = (ShoppingOrderItem)EntityCacheUtil.getResult(ShoppingOrderItemModelImpl.ENTITY_CACHE_ENABLED,
313 ShoppingOrderItemImpl.class, orderItemId, this);
314
315 if (shoppingOrderItem == null) {
316 Session session = null;
317
318 try {
319 session = openSession();
320
321 shoppingOrderItem = (ShoppingOrderItem)session.get(ShoppingOrderItemImpl.class,
322 new Long(orderItemId));
323 }
324 catch (Exception e) {
325 throw processException(e);
326 }
327 finally {
328 if (shoppingOrderItem != null) {
329 cacheResult(shoppingOrderItem);
330 }
331
332 closeSession(session);
333 }
334 }
335
336 return shoppingOrderItem;
337 }
338
339 public List<ShoppingOrderItem> findByOrderId(long orderId)
340 throws SystemException {
341 Object[] finderArgs = new Object[] { new Long(orderId) };
342
343 List<ShoppingOrderItem> list = (List<ShoppingOrderItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ORDERID,
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_SHOPPINGORDERITEM_WHERE);
355
356 query.append(_FINDER_COLUMN_ORDERID_ORDERID_2);
357
358 query.append(ShoppingOrderItemModelImpl.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(orderId);
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<ShoppingOrderItem>();
376 }
377
378 cacheResult(list);
379
380 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ORDERID,
381 finderArgs, list);
382
383 closeSession(session);
384 }
385 }
386
387 return list;
388 }
389
390 public List<ShoppingOrderItem> findByOrderId(long orderId, int start,
391 int end) throws SystemException {
392 return findByOrderId(orderId, start, end, null);
393 }
394
395 public List<ShoppingOrderItem> findByOrderId(long orderId, int start,
396 int end, OrderByComparator obc) throws SystemException {
397 Object[] finderArgs = new Object[] {
398 new Long(orderId),
399
400 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
401 };
402
403 List<ShoppingOrderItem> list = (List<ShoppingOrderItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ORDERID,
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_SHOPPINGORDERITEM_WHERE);
423
424 query.append(_FINDER_COLUMN_ORDERID_ORDERID_2);
425
426 if (obc != null) {
427 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
428 }
429
430 else {
431 query.append(ShoppingOrderItemModelImpl.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(orderId);
441
442 list = (List<ShoppingOrderItem>)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<ShoppingOrderItem>();
451 }
452
453 cacheResult(list);
454
455 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ORDERID,
456 finderArgs, list);
457
458 closeSession(session);
459 }
460 }
461
462 return list;
463 }
464
465 public ShoppingOrderItem findByOrderId_First(long orderId,
466 OrderByComparator obc) throws NoSuchOrderItemException, SystemException {
467 List<ShoppingOrderItem> list = findByOrderId(orderId, 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("orderId=");
475 msg.append(orderId);
476
477 msg.append(StringPool.CLOSE_CURLY_BRACE);
478
479 throw new NoSuchOrderItemException(msg.toString());
480 }
481 else {
482 return list.get(0);
483 }
484 }
485
486 public ShoppingOrderItem findByOrderId_Last(long orderId,
487 OrderByComparator obc) throws NoSuchOrderItemException, SystemException {
488 int count = countByOrderId(orderId);
489
490 List<ShoppingOrderItem> list = findByOrderId(orderId, 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("orderId=");
499 msg.append(orderId);
500
501 msg.append(StringPool.CLOSE_CURLY_BRACE);
502
503 throw new NoSuchOrderItemException(msg.toString());
504 }
505 else {
506 return list.get(0);
507 }
508 }
509
510 public ShoppingOrderItem[] findByOrderId_PrevAndNext(long orderItemId,
511 long orderId, OrderByComparator obc)
512 throws NoSuchOrderItemException, SystemException {
513 ShoppingOrderItem shoppingOrderItem = findByPrimaryKey(orderItemId);
514
515 int count = countByOrderId(orderId);
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_SHOPPINGORDERITEM_WHERE);
533
534 query.append(_FINDER_COLUMN_ORDERID_ORDERID_2);
535
536 if (obc != null) {
537 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
538 }
539
540 else {
541 query.append(ShoppingOrderItemModelImpl.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(orderId);
551
552 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
553 shoppingOrderItem);
554
555 ShoppingOrderItem[] array = new ShoppingOrderItemImpl[3];
556
557 array[0] = (ShoppingOrderItem)objArray[0];
558 array[1] = (ShoppingOrderItem)objArray[1];
559 array[2] = (ShoppingOrderItem)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<ShoppingOrderItem> findAll() throws SystemException {
612 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
613 }
614
615 public List<ShoppingOrderItem> findAll(int start, int end)
616 throws SystemException {
617 return findAll(start, end, null);
618 }
619
620 public List<ShoppingOrderItem> 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<ShoppingOrderItem> list = (List<ShoppingOrderItem>)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_SHOPPINGORDERITEM);
643
644 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
645
646 sql = query.toString();
647 }
648
649 else {
650 sql = _SQL_SELECT_SHOPPINGORDERITEM.concat(ShoppingOrderItemModelImpl.ORDER_BY_JPQL);
651 }
652
653 Query q = session.createQuery(sql);
654
655 if (obc == null) {
656 list = (List<ShoppingOrderItem>)QueryUtil.list(q,
657 getDialect(), start, end, false);
658
659 Collections.sort(list);
660 }
661 else {
662 list = (List<ShoppingOrderItem>)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<ShoppingOrderItem>();
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 removeByOrderId(long orderId) throws SystemException {
686 for (ShoppingOrderItem shoppingOrderItem : findByOrderId(orderId)) {
687 remove(shoppingOrderItem);
688 }
689 }
690
691 public void removeAll() throws SystemException {
692 for (ShoppingOrderItem shoppingOrderItem : findAll()) {
693 remove(shoppingOrderItem);
694 }
695 }
696
697 public int countByOrderId(long orderId) throws SystemException {
698 Object[] finderArgs = new Object[] { new Long(orderId) };
699
700 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ORDERID,
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_SHOPPINGORDERITEM_WHERE);
712
713 query.append(_FINDER_COLUMN_ORDERID_ORDERID_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(orderId);
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_ORDERID,
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_SHOPPINGORDERITEM);
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.ShoppingOrderItem")));
781
782 if (listenerClassNames.length > 0) {
783 try {
784 List<ModelListener<ShoppingOrderItem>> listenersList = new ArrayList<ModelListener<ShoppingOrderItem>>();
785
786 for (String listenerClassName : listenerClassNames) {
787 listenersList.add((ModelListener<ShoppingOrderItem>)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_SHOPPINGORDERITEM = "SELECT shoppingOrderItem FROM ShoppingOrderItem shoppingOrderItem";
820 private static final String _SQL_SELECT_SHOPPINGORDERITEM_WHERE = "SELECT shoppingOrderItem FROM ShoppingOrderItem shoppingOrderItem WHERE ";
821 private static final String _SQL_COUNT_SHOPPINGORDERITEM = "SELECT COUNT(shoppingOrderItem) FROM ShoppingOrderItem shoppingOrderItem";
822 private static final String _SQL_COUNT_SHOPPINGORDERITEM_WHERE = "SELECT COUNT(shoppingOrderItem) FROM ShoppingOrderItem shoppingOrderItem WHERE ";
823 private static final String _FINDER_COLUMN_ORDERID_ORDERID_2 = "shoppingOrderItem.orderId = ?";
824 private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingOrderItem.";
825 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingOrderItem exists with the primary key ";
826 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingOrderItem exists with the key {";
827 private static Log _log = LogFactoryUtil.getLog(ShoppingOrderItemPersistenceImpl.class);
828 }