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