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