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.SQLQuery;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.dao.orm.Type;
29 import com.liferay.portal.kernel.exception.SystemException;
30 import com.liferay.portal.kernel.log.Log;
31 import com.liferay.portal.kernel.log.LogFactoryUtil;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.InstanceFactory;
34 import com.liferay.portal.kernel.util.OrderByComparator;
35 import com.liferay.portal.kernel.util.StringBundler;
36 import com.liferay.portal.kernel.util.StringPool;
37 import com.liferay.portal.kernel.util.StringUtil;
38 import com.liferay.portal.kernel.util.Validator;
39 import com.liferay.portal.model.ModelListener;
40 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
41 import com.liferay.portal.service.persistence.BatchSessionUtil;
42 import com.liferay.portal.service.persistence.CompanyPersistence;
43 import com.liferay.portal.service.persistence.ResourcePersistence;
44 import com.liferay.portal.service.persistence.UserPersistence;
45 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
46
47 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
48 import com.liferay.portlet.shopping.NoSuchOrderException;
49 import com.liferay.portlet.shopping.model.ShoppingOrder;
50 import com.liferay.portlet.shopping.model.impl.ShoppingOrderImpl;
51 import com.liferay.portlet.shopping.model.impl.ShoppingOrderModelImpl;
52
53 import java.io.Serializable;
54
55 import java.util.ArrayList;
56 import java.util.Collections;
57 import java.util.List;
58
59
72 public class ShoppingOrderPersistenceImpl extends BasePersistenceImpl<ShoppingOrder>
73 implements ShoppingOrderPersistence {
74 public static final String FINDER_CLASS_NAME_ENTITY = ShoppingOrderImpl.class.getName();
75 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
76 ".List";
77 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
78 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
79 FINDER_CLASS_NAME_LIST, "findByGroupId",
80 new String[] {
81 Long.class.getName(),
82
83 "java.lang.Integer", "java.lang.Integer",
84 "com.liferay.portal.kernel.util.OrderByComparator"
85 });
86 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
87 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
88 FINDER_CLASS_NAME_LIST, "countByGroupId",
89 new String[] { Long.class.getName() });
90 public static final FinderPath FINDER_PATH_FETCH_BY_NUMBER = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
91 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
92 FINDER_CLASS_NAME_ENTITY, "fetchByNumber",
93 new String[] { String.class.getName() });
94 public static final FinderPath FINDER_PATH_COUNT_BY_NUMBER = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
95 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
96 FINDER_CLASS_NAME_LIST, "countByNumber",
97 new String[] { String.class.getName() });
98 public static final FinderPath FINDER_PATH_FETCH_BY_PPTXNID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
99 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
100 FINDER_CLASS_NAME_ENTITY, "fetchByPPTxnId",
101 new String[] { String.class.getName() });
102 public static final FinderPath FINDER_PATH_COUNT_BY_PPTXNID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
103 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
104 FINDER_CLASS_NAME_LIST, "countByPPTxnId",
105 new String[] { String.class.getName() });
106 public static final FinderPath FINDER_PATH_FIND_BY_G_U_PPPS = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
107 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
108 FINDER_CLASS_NAME_LIST, "findByG_U_PPPS",
109 new String[] {
110 Long.class.getName(), Long.class.getName(),
111 String.class.getName(),
112
113 "java.lang.Integer", "java.lang.Integer",
114 "com.liferay.portal.kernel.util.OrderByComparator"
115 });
116 public static final FinderPath FINDER_PATH_COUNT_BY_G_U_PPPS = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
117 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
118 FINDER_CLASS_NAME_LIST, "countByG_U_PPPS",
119 new String[] {
120 Long.class.getName(), Long.class.getName(),
121 String.class.getName()
122 });
123 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
124 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
125 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
126 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
127 ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
128 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
129
130 public void cacheResult(ShoppingOrder shoppingOrder) {
131 EntityCacheUtil.putResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
132 ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey(),
133 shoppingOrder);
134
135 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
136 new Object[] { shoppingOrder.getNumber() }, shoppingOrder);
137
138 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
139 new Object[] { shoppingOrder.getPpTxnId() }, shoppingOrder);
140 }
141
142 public void cacheResult(List<ShoppingOrder> shoppingOrders) {
143 for (ShoppingOrder shoppingOrder : shoppingOrders) {
144 if (EntityCacheUtil.getResult(
145 ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
146 ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey(),
147 this) == null) {
148 cacheResult(shoppingOrder);
149 }
150 }
151 }
152
153 public void clearCache() {
154 CacheRegistry.clear(ShoppingOrderImpl.class.getName());
155 EntityCacheUtil.clearCache(ShoppingOrderImpl.class.getName());
156 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
157 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
158 }
159
160 public void clearCache(ShoppingOrder shoppingOrder) {
161 EntityCacheUtil.removeResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
162 ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey());
163
164 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NUMBER,
165 new Object[] { shoppingOrder.getNumber() });
166
167 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PPTXNID,
168 new Object[] { shoppingOrder.getPpTxnId() });
169 }
170
171 public ShoppingOrder create(long orderId) {
172 ShoppingOrder shoppingOrder = new ShoppingOrderImpl();
173
174 shoppingOrder.setNew(true);
175 shoppingOrder.setPrimaryKey(orderId);
176
177 return shoppingOrder;
178 }
179
180 public ShoppingOrder remove(Serializable primaryKey)
181 throws NoSuchModelException, SystemException {
182 return remove(((Long)primaryKey).longValue());
183 }
184
185 public ShoppingOrder remove(long orderId)
186 throws NoSuchOrderException, SystemException {
187 Session session = null;
188
189 try {
190 session = openSession();
191
192 ShoppingOrder shoppingOrder = (ShoppingOrder)session.get(ShoppingOrderImpl.class,
193 new Long(orderId));
194
195 if (shoppingOrder == null) {
196 if (_log.isWarnEnabled()) {
197 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orderId);
198 }
199
200 throw new NoSuchOrderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
201 orderId);
202 }
203
204 return remove(shoppingOrder);
205 }
206 catch (NoSuchOrderException nsee) {
207 throw nsee;
208 }
209 catch (Exception e) {
210 throw processException(e);
211 }
212 finally {
213 closeSession(session);
214 }
215 }
216
217 public ShoppingOrder remove(ShoppingOrder shoppingOrder)
218 throws SystemException {
219 for (ModelListener<ShoppingOrder> listener : listeners) {
220 listener.onBeforeRemove(shoppingOrder);
221 }
222
223 shoppingOrder = removeImpl(shoppingOrder);
224
225 for (ModelListener<ShoppingOrder> listener : listeners) {
226 listener.onAfterRemove(shoppingOrder);
227 }
228
229 return shoppingOrder;
230 }
231
232 protected ShoppingOrder removeImpl(ShoppingOrder shoppingOrder)
233 throws SystemException {
234 shoppingOrder = toUnwrappedModel(shoppingOrder);
235
236 Session session = null;
237
238 try {
239 session = openSession();
240
241 if (shoppingOrder.isCachedModel() || BatchSessionUtil.isEnabled()) {
242 Object staleObject = session.get(ShoppingOrderImpl.class,
243 shoppingOrder.getPrimaryKeyObj());
244
245 if (staleObject != null) {
246 session.evict(staleObject);
247 }
248 }
249
250 session.delete(shoppingOrder);
251
252 session.flush();
253 }
254 catch (Exception e) {
255 throw processException(e);
256 }
257 finally {
258 closeSession(session);
259 }
260
261 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
262
263 ShoppingOrderModelImpl shoppingOrderModelImpl = (ShoppingOrderModelImpl)shoppingOrder;
264
265 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NUMBER,
266 new Object[] { shoppingOrderModelImpl.getOriginalNumber() });
267
268 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PPTXNID,
269 new Object[] { shoppingOrderModelImpl.getOriginalPpTxnId() });
270
271 EntityCacheUtil.removeResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
272 ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey());
273
274 return shoppingOrder;
275 }
276
277 public ShoppingOrder updateImpl(
278 com.liferay.portlet.shopping.model.ShoppingOrder shoppingOrder,
279 boolean merge) throws SystemException {
280 shoppingOrder = toUnwrappedModel(shoppingOrder);
281
282 boolean isNew = shoppingOrder.isNew();
283
284 ShoppingOrderModelImpl shoppingOrderModelImpl = (ShoppingOrderModelImpl)shoppingOrder;
285
286 Session session = null;
287
288 try {
289 session = openSession();
290
291 BatchSessionUtil.update(session, shoppingOrder, merge);
292
293 shoppingOrder.setNew(false);
294 }
295 catch (Exception e) {
296 throw processException(e);
297 }
298 finally {
299 closeSession(session);
300 }
301
302 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
303
304 EntityCacheUtil.putResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
305 ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey(),
306 shoppingOrder);
307
308 if (!isNew &&
309 (!Validator.equals(shoppingOrder.getNumber(),
310 shoppingOrderModelImpl.getOriginalNumber()))) {
311 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NUMBER,
312 new Object[] { shoppingOrderModelImpl.getOriginalNumber() });
313 }
314
315 if (isNew ||
316 (!Validator.equals(shoppingOrder.getNumber(),
317 shoppingOrderModelImpl.getOriginalNumber()))) {
318 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
319 new Object[] { shoppingOrder.getNumber() }, shoppingOrder);
320 }
321
322 if (!isNew &&
323 (!Validator.equals(shoppingOrder.getPpTxnId(),
324 shoppingOrderModelImpl.getOriginalPpTxnId()))) {
325 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PPTXNID,
326 new Object[] { shoppingOrderModelImpl.getOriginalPpTxnId() });
327 }
328
329 if (isNew ||
330 (!Validator.equals(shoppingOrder.getPpTxnId(),
331 shoppingOrderModelImpl.getOriginalPpTxnId()))) {
332 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
333 new Object[] { shoppingOrder.getPpTxnId() }, shoppingOrder);
334 }
335
336 return shoppingOrder;
337 }
338
339 protected ShoppingOrder toUnwrappedModel(ShoppingOrder shoppingOrder) {
340 if (shoppingOrder instanceof ShoppingOrderImpl) {
341 return shoppingOrder;
342 }
343
344 ShoppingOrderImpl shoppingOrderImpl = new ShoppingOrderImpl();
345
346 shoppingOrderImpl.setNew(shoppingOrder.isNew());
347 shoppingOrderImpl.setPrimaryKey(shoppingOrder.getPrimaryKey());
348
349 shoppingOrderImpl.setOrderId(shoppingOrder.getOrderId());
350 shoppingOrderImpl.setGroupId(shoppingOrder.getGroupId());
351 shoppingOrderImpl.setCompanyId(shoppingOrder.getCompanyId());
352 shoppingOrderImpl.setUserId(shoppingOrder.getUserId());
353 shoppingOrderImpl.setUserName(shoppingOrder.getUserName());
354 shoppingOrderImpl.setCreateDate(shoppingOrder.getCreateDate());
355 shoppingOrderImpl.setModifiedDate(shoppingOrder.getModifiedDate());
356 shoppingOrderImpl.setNumber(shoppingOrder.getNumber());
357 shoppingOrderImpl.setTax(shoppingOrder.getTax());
358 shoppingOrderImpl.setShipping(shoppingOrder.getShipping());
359 shoppingOrderImpl.setAltShipping(shoppingOrder.getAltShipping());
360 shoppingOrderImpl.setRequiresShipping(shoppingOrder.isRequiresShipping());
361 shoppingOrderImpl.setInsure(shoppingOrder.isInsure());
362 shoppingOrderImpl.setInsurance(shoppingOrder.getInsurance());
363 shoppingOrderImpl.setCouponCodes(shoppingOrder.getCouponCodes());
364 shoppingOrderImpl.setCouponDiscount(shoppingOrder.getCouponDiscount());
365 shoppingOrderImpl.setBillingFirstName(shoppingOrder.getBillingFirstName());
366 shoppingOrderImpl.setBillingLastName(shoppingOrder.getBillingLastName());
367 shoppingOrderImpl.setBillingEmailAddress(shoppingOrder.getBillingEmailAddress());
368 shoppingOrderImpl.setBillingCompany(shoppingOrder.getBillingCompany());
369 shoppingOrderImpl.setBillingStreet(shoppingOrder.getBillingStreet());
370 shoppingOrderImpl.setBillingCity(shoppingOrder.getBillingCity());
371 shoppingOrderImpl.setBillingState(shoppingOrder.getBillingState());
372 shoppingOrderImpl.setBillingZip(shoppingOrder.getBillingZip());
373 shoppingOrderImpl.setBillingCountry(shoppingOrder.getBillingCountry());
374 shoppingOrderImpl.setBillingPhone(shoppingOrder.getBillingPhone());
375 shoppingOrderImpl.setShipToBilling(shoppingOrder.isShipToBilling());
376 shoppingOrderImpl.setShippingFirstName(shoppingOrder.getShippingFirstName());
377 shoppingOrderImpl.setShippingLastName(shoppingOrder.getShippingLastName());
378 shoppingOrderImpl.setShippingEmailAddress(shoppingOrder.getShippingEmailAddress());
379 shoppingOrderImpl.setShippingCompany(shoppingOrder.getShippingCompany());
380 shoppingOrderImpl.setShippingStreet(shoppingOrder.getShippingStreet());
381 shoppingOrderImpl.setShippingCity(shoppingOrder.getShippingCity());
382 shoppingOrderImpl.setShippingState(shoppingOrder.getShippingState());
383 shoppingOrderImpl.setShippingZip(shoppingOrder.getShippingZip());
384 shoppingOrderImpl.setShippingCountry(shoppingOrder.getShippingCountry());
385 shoppingOrderImpl.setShippingPhone(shoppingOrder.getShippingPhone());
386 shoppingOrderImpl.setCcName(shoppingOrder.getCcName());
387 shoppingOrderImpl.setCcType(shoppingOrder.getCcType());
388 shoppingOrderImpl.setCcNumber(shoppingOrder.getCcNumber());
389 shoppingOrderImpl.setCcExpMonth(shoppingOrder.getCcExpMonth());
390 shoppingOrderImpl.setCcExpYear(shoppingOrder.getCcExpYear());
391 shoppingOrderImpl.setCcVerNumber(shoppingOrder.getCcVerNumber());
392 shoppingOrderImpl.setComments(shoppingOrder.getComments());
393 shoppingOrderImpl.setPpTxnId(shoppingOrder.getPpTxnId());
394 shoppingOrderImpl.setPpPaymentStatus(shoppingOrder.getPpPaymentStatus());
395 shoppingOrderImpl.setPpPaymentGross(shoppingOrder.getPpPaymentGross());
396 shoppingOrderImpl.setPpReceiverEmail(shoppingOrder.getPpReceiverEmail());
397 shoppingOrderImpl.setPpPayerEmail(shoppingOrder.getPpPayerEmail());
398 shoppingOrderImpl.setSendOrderEmail(shoppingOrder.isSendOrderEmail());
399 shoppingOrderImpl.setSendShippingEmail(shoppingOrder.isSendShippingEmail());
400
401 return shoppingOrderImpl;
402 }
403
404 public ShoppingOrder findByPrimaryKey(Serializable primaryKey)
405 throws NoSuchModelException, SystemException {
406 return findByPrimaryKey(((Long)primaryKey).longValue());
407 }
408
409 public ShoppingOrder findByPrimaryKey(long orderId)
410 throws NoSuchOrderException, SystemException {
411 ShoppingOrder shoppingOrder = fetchByPrimaryKey(orderId);
412
413 if (shoppingOrder == null) {
414 if (_log.isWarnEnabled()) {
415 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orderId);
416 }
417
418 throw new NoSuchOrderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
419 orderId);
420 }
421
422 return shoppingOrder;
423 }
424
425 public ShoppingOrder fetchByPrimaryKey(Serializable primaryKey)
426 throws SystemException {
427 return fetchByPrimaryKey(((Long)primaryKey).longValue());
428 }
429
430 public ShoppingOrder fetchByPrimaryKey(long orderId)
431 throws SystemException {
432 ShoppingOrder shoppingOrder = (ShoppingOrder)EntityCacheUtil.getResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
433 ShoppingOrderImpl.class, orderId, this);
434
435 if (shoppingOrder == null) {
436 Session session = null;
437
438 try {
439 session = openSession();
440
441 shoppingOrder = (ShoppingOrder)session.get(ShoppingOrderImpl.class,
442 new Long(orderId));
443 }
444 catch (Exception e) {
445 throw processException(e);
446 }
447 finally {
448 if (shoppingOrder != null) {
449 cacheResult(shoppingOrder);
450 }
451
452 closeSession(session);
453 }
454 }
455
456 return shoppingOrder;
457 }
458
459 public List<ShoppingOrder> findByGroupId(long groupId)
460 throws SystemException {
461 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
462 }
463
464 public List<ShoppingOrder> findByGroupId(long groupId, int start, int end)
465 throws SystemException {
466 return findByGroupId(groupId, start, end, null);
467 }
468
469 public List<ShoppingOrder> findByGroupId(long groupId, int start, int end,
470 OrderByComparator orderByComparator) throws SystemException {
471 Object[] finderArgs = new Object[] {
472 new Long(groupId),
473
474 String.valueOf(start), String.valueOf(end),
475 String.valueOf(orderByComparator)
476 };
477
478 List<ShoppingOrder> list = (List<ShoppingOrder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
479 finderArgs, this);
480
481 if (list == null) {
482 Session session = null;
483
484 try {
485 session = openSession();
486
487 StringBundler query = null;
488
489 if (orderByComparator != null) {
490 query = new StringBundler(3 +
491 (orderByComparator.getOrderByFields().length * 3));
492 }
493 else {
494 query = new StringBundler(3);
495 }
496
497 query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
498
499 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
500
501 if (orderByComparator != null) {
502 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
503 orderByComparator);
504 }
505
506 else {
507 query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
508 }
509
510 String sql = query.toString();
511
512 Query q = session.createQuery(sql);
513
514 QueryPos qPos = QueryPos.getInstance(q);
515
516 qPos.add(groupId);
517
518 list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
519 start, end);
520 }
521 catch (Exception e) {
522 throw processException(e);
523 }
524 finally {
525 if (list == null) {
526 list = new ArrayList<ShoppingOrder>();
527 }
528
529 cacheResult(list);
530
531 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
532 finderArgs, list);
533
534 closeSession(session);
535 }
536 }
537
538 return list;
539 }
540
541 public ShoppingOrder findByGroupId_First(long groupId,
542 OrderByComparator orderByComparator)
543 throws NoSuchOrderException, SystemException {
544 List<ShoppingOrder> list = findByGroupId(groupId, 0, 1,
545 orderByComparator);
546
547 if (list.isEmpty()) {
548 StringBundler msg = new StringBundler(4);
549
550 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
551
552 msg.append("groupId=");
553 msg.append(groupId);
554
555 msg.append(StringPool.CLOSE_CURLY_BRACE);
556
557 throw new NoSuchOrderException(msg.toString());
558 }
559 else {
560 return list.get(0);
561 }
562 }
563
564 public ShoppingOrder findByGroupId_Last(long groupId,
565 OrderByComparator orderByComparator)
566 throws NoSuchOrderException, SystemException {
567 int count = countByGroupId(groupId);
568
569 List<ShoppingOrder> list = findByGroupId(groupId, count - 1, count,
570 orderByComparator);
571
572 if (list.isEmpty()) {
573 StringBundler msg = new StringBundler(4);
574
575 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
576
577 msg.append("groupId=");
578 msg.append(groupId);
579
580 msg.append(StringPool.CLOSE_CURLY_BRACE);
581
582 throw new NoSuchOrderException(msg.toString());
583 }
584 else {
585 return list.get(0);
586 }
587 }
588
589 public ShoppingOrder[] findByGroupId_PrevAndNext(long orderId,
590 long groupId, OrderByComparator orderByComparator)
591 throws NoSuchOrderException, SystemException {
592 ShoppingOrder shoppingOrder = findByPrimaryKey(orderId);
593
594 Session session = null;
595
596 try {
597 session = openSession();
598
599 ShoppingOrder[] array = new ShoppingOrderImpl[3];
600
601 array[0] = getByGroupId_PrevAndNext(session, shoppingOrder,
602 groupId, orderByComparator, true);
603
604 array[1] = shoppingOrder;
605
606 array[2] = getByGroupId_PrevAndNext(session, shoppingOrder,
607 groupId, orderByComparator, false);
608
609 return array;
610 }
611 catch (Exception e) {
612 throw processException(e);
613 }
614 finally {
615 closeSession(session);
616 }
617 }
618
619 protected ShoppingOrder getByGroupId_PrevAndNext(Session session,
620 ShoppingOrder shoppingOrder, long groupId,
621 OrderByComparator orderByComparator, boolean previous) {
622 StringBundler query = null;
623
624 if (orderByComparator != null) {
625 query = new StringBundler(6 +
626 (orderByComparator.getOrderByFields().length * 6));
627 }
628 else {
629 query = new StringBundler(3);
630 }
631
632 query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
633
634 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
635
636 if (orderByComparator != null) {
637 String[] orderByFields = orderByComparator.getOrderByFields();
638
639 if (orderByFields.length > 0) {
640 query.append(WHERE_AND);
641 }
642
643 for (int i = 0; i < orderByFields.length; i++) {
644 query.append(_ORDER_BY_ENTITY_ALIAS);
645 query.append(orderByFields[i]);
646
647 if ((i + 1) < orderByFields.length) {
648 if (orderByComparator.isAscending() ^ previous) {
649 query.append(WHERE_GREATER_THAN_HAS_NEXT);
650 }
651 else {
652 query.append(WHERE_LESSER_THAN_HAS_NEXT);
653 }
654 }
655 else {
656 if (orderByComparator.isAscending() ^ previous) {
657 query.append(WHERE_GREATER_THAN);
658 }
659 else {
660 query.append(WHERE_LESSER_THAN);
661 }
662 }
663 }
664
665 query.append(ORDER_BY_CLAUSE);
666
667 for (int i = 0; i < orderByFields.length; i++) {
668 query.append(_ORDER_BY_ENTITY_ALIAS);
669 query.append(orderByFields[i]);
670
671 if ((i + 1) < orderByFields.length) {
672 if (orderByComparator.isAscending() ^ previous) {
673 query.append(ORDER_BY_ASC_HAS_NEXT);
674 }
675 else {
676 query.append(ORDER_BY_DESC_HAS_NEXT);
677 }
678 }
679 else {
680 if (orderByComparator.isAscending() ^ previous) {
681 query.append(ORDER_BY_ASC);
682 }
683 else {
684 query.append(ORDER_BY_DESC);
685 }
686 }
687 }
688 }
689
690 else {
691 query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
692 }
693
694 String sql = query.toString();
695
696 Query q = session.createQuery(sql);
697
698 q.setFirstResult(0);
699 q.setMaxResults(2);
700
701 QueryPos qPos = QueryPos.getInstance(q);
702
703 qPos.add(groupId);
704
705 if (orderByComparator != null) {
706 Object[] values = orderByComparator.getOrderByValues(shoppingOrder);
707
708 for (Object value : values) {
709 qPos.add(value);
710 }
711 }
712
713 List<ShoppingOrder> list = q.list();
714
715 if (list.size() == 2) {
716 return list.get(1);
717 }
718 else {
719 return null;
720 }
721 }
722
723 public List<ShoppingOrder> filterFindByGroupId(long groupId)
724 throws SystemException {
725 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
726 QueryUtil.ALL_POS, null);
727 }
728
729 public List<ShoppingOrder> filterFindByGroupId(long groupId, int start,
730 int end) throws SystemException {
731 return filterFindByGroupId(groupId, start, end, null);
732 }
733
734 public List<ShoppingOrder> filterFindByGroupId(long groupId, int start,
735 int end, OrderByComparator orderByComparator) throws SystemException {
736 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
737 return findByGroupId(groupId, start, end, orderByComparator);
738 }
739
740 Session session = null;
741
742 try {
743 session = openSession();
744
745 StringBundler query = null;
746
747 if (orderByComparator != null) {
748 query = new StringBundler(3 +
749 (orderByComparator.getOrderByFields().length * 3));
750 }
751 else {
752 query = new StringBundler(3);
753 }
754
755 query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_WHERE);
756
757 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
758
759 if (orderByComparator != null) {
760 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
761 orderByComparator);
762 }
763
764 else {
765 query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
766 }
767
768 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
769 ShoppingOrder.class.getName(), _FILTER_COLUMN_ORDERID,
770 _FILTER_COLUMN_USERID, groupId);
771
772 SQLQuery q = session.createSQLQuery(sql);
773
774 q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingOrderImpl.class);
775
776 QueryPos qPos = QueryPos.getInstance(q);
777
778 qPos.add(groupId);
779
780 return (List<ShoppingOrder>)QueryUtil.list(q, getDialect(), start,
781 end);
782 }
783 catch (Exception e) {
784 throw processException(e);
785 }
786 finally {
787 closeSession(session);
788 }
789 }
790
791 public ShoppingOrder findByNumber(String number)
792 throws NoSuchOrderException, SystemException {
793 ShoppingOrder shoppingOrder = fetchByNumber(number);
794
795 if (shoppingOrder == null) {
796 StringBundler msg = new StringBundler(4);
797
798 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
799
800 msg.append("number=");
801 msg.append(number);
802
803 msg.append(StringPool.CLOSE_CURLY_BRACE);
804
805 if (_log.isWarnEnabled()) {
806 _log.warn(msg.toString());
807 }
808
809 throw new NoSuchOrderException(msg.toString());
810 }
811
812 return shoppingOrder;
813 }
814
815 public ShoppingOrder fetchByNumber(String number) throws SystemException {
816 return fetchByNumber(number, true);
817 }
818
819 public ShoppingOrder fetchByNumber(String number, boolean retrieveFromCache)
820 throws SystemException {
821 Object[] finderArgs = new Object[] { number };
822
823 Object result = null;
824
825 if (retrieveFromCache) {
826 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_NUMBER,
827 finderArgs, this);
828 }
829
830 if (result == null) {
831 Session session = null;
832
833 try {
834 session = openSession();
835
836 StringBundler query = new StringBundler(3);
837
838 query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
839
840 if (number == null) {
841 query.append(_FINDER_COLUMN_NUMBER_NUMBER_1);
842 }
843 else {
844 if (number.equals(StringPool.BLANK)) {
845 query.append(_FINDER_COLUMN_NUMBER_NUMBER_3);
846 }
847 else {
848 query.append(_FINDER_COLUMN_NUMBER_NUMBER_2);
849 }
850 }
851
852 query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
853
854 String sql = query.toString();
855
856 Query q = session.createQuery(sql);
857
858 QueryPos qPos = QueryPos.getInstance(q);
859
860 if (number != null) {
861 qPos.add(number);
862 }
863
864 List<ShoppingOrder> list = q.list();
865
866 result = list;
867
868 ShoppingOrder shoppingOrder = null;
869
870 if (list.isEmpty()) {
871 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
872 finderArgs, list);
873 }
874 else {
875 shoppingOrder = list.get(0);
876
877 cacheResult(shoppingOrder);
878
879 if ((shoppingOrder.getNumber() == null) ||
880 !shoppingOrder.getNumber().equals(number)) {
881 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
882 finderArgs, shoppingOrder);
883 }
884 }
885
886 return shoppingOrder;
887 }
888 catch (Exception e) {
889 throw processException(e);
890 }
891 finally {
892 if (result == null) {
893 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
894 finderArgs, new ArrayList<ShoppingOrder>());
895 }
896
897 closeSession(session);
898 }
899 }
900 else {
901 if (result instanceof List<?>) {
902 return null;
903 }
904 else {
905 return (ShoppingOrder)result;
906 }
907 }
908 }
909
910 public ShoppingOrder findByPPTxnId(String ppTxnId)
911 throws NoSuchOrderException, SystemException {
912 ShoppingOrder shoppingOrder = fetchByPPTxnId(ppTxnId);
913
914 if (shoppingOrder == null) {
915 StringBundler msg = new StringBundler(4);
916
917 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
918
919 msg.append("ppTxnId=");
920 msg.append(ppTxnId);
921
922 msg.append(StringPool.CLOSE_CURLY_BRACE);
923
924 if (_log.isWarnEnabled()) {
925 _log.warn(msg.toString());
926 }
927
928 throw new NoSuchOrderException(msg.toString());
929 }
930
931 return shoppingOrder;
932 }
933
934 public ShoppingOrder fetchByPPTxnId(String ppTxnId)
935 throws SystemException {
936 return fetchByPPTxnId(ppTxnId, true);
937 }
938
939 public ShoppingOrder fetchByPPTxnId(String ppTxnId,
940 boolean retrieveFromCache) throws SystemException {
941 Object[] finderArgs = new Object[] { ppTxnId };
942
943 Object result = null;
944
945 if (retrieveFromCache) {
946 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PPTXNID,
947 finderArgs, this);
948 }
949
950 if (result == null) {
951 Session session = null;
952
953 try {
954 session = openSession();
955
956 StringBundler query = new StringBundler(3);
957
958 query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
959
960 if (ppTxnId == null) {
961 query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_1);
962 }
963 else {
964 if (ppTxnId.equals(StringPool.BLANK)) {
965 query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_3);
966 }
967 else {
968 query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_2);
969 }
970 }
971
972 query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
973
974 String sql = query.toString();
975
976 Query q = session.createQuery(sql);
977
978 QueryPos qPos = QueryPos.getInstance(q);
979
980 if (ppTxnId != null) {
981 qPos.add(ppTxnId);
982 }
983
984 List<ShoppingOrder> list = q.list();
985
986 result = list;
987
988 ShoppingOrder shoppingOrder = null;
989
990 if (list.isEmpty()) {
991 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
992 finderArgs, list);
993 }
994 else {
995 shoppingOrder = list.get(0);
996
997 cacheResult(shoppingOrder);
998
999 if ((shoppingOrder.getPpTxnId() == null) ||
1000 !shoppingOrder.getPpTxnId().equals(ppTxnId)) {
1001 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
1002 finderArgs, shoppingOrder);
1003 }
1004 }
1005
1006 return shoppingOrder;
1007 }
1008 catch (Exception e) {
1009 throw processException(e);
1010 }
1011 finally {
1012 if (result == null) {
1013 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
1014 finderArgs, new ArrayList<ShoppingOrder>());
1015 }
1016
1017 closeSession(session);
1018 }
1019 }
1020 else {
1021 if (result instanceof List<?>) {
1022 return null;
1023 }
1024 else {
1025 return (ShoppingOrder)result;
1026 }
1027 }
1028 }
1029
1030 public List<ShoppingOrder> findByG_U_PPPS(long groupId, long userId,
1031 String ppPaymentStatus) throws SystemException {
1032 return findByG_U_PPPS(groupId, userId, ppPaymentStatus,
1033 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1034 }
1035
1036 public List<ShoppingOrder> findByG_U_PPPS(long groupId, long userId,
1037 String ppPaymentStatus, int start, int end) throws SystemException {
1038 return findByG_U_PPPS(groupId, userId, ppPaymentStatus, start, end, null);
1039 }
1040
1041 public List<ShoppingOrder> findByG_U_PPPS(long groupId, long userId,
1042 String ppPaymentStatus, int start, int end,
1043 OrderByComparator orderByComparator) throws SystemException {
1044 Object[] finderArgs = new Object[] {
1045 new Long(groupId), new Long(userId),
1046
1047 ppPaymentStatus,
1048
1049 String.valueOf(start), String.valueOf(end),
1050 String.valueOf(orderByComparator)
1051 };
1052
1053 List<ShoppingOrder> list = (List<ShoppingOrder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U_PPPS,
1054 finderArgs, this);
1055
1056 if (list == null) {
1057 Session session = null;
1058
1059 try {
1060 session = openSession();
1061
1062 StringBundler query = null;
1063
1064 if (orderByComparator != null) {
1065 query = new StringBundler(5 +
1066 (orderByComparator.getOrderByFields().length * 3));
1067 }
1068 else {
1069 query = new StringBundler(5);
1070 }
1071
1072 query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
1073
1074 query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
1075
1076 query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
1077
1078 if (ppPaymentStatus == null) {
1079 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
1080 }
1081 else {
1082 if (ppPaymentStatus.equals(StringPool.BLANK)) {
1083 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
1084 }
1085 else {
1086 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
1087 }
1088 }
1089
1090 if (orderByComparator != null) {
1091 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1092 orderByComparator);
1093 }
1094
1095 else {
1096 query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1097 }
1098
1099 String sql = query.toString();
1100
1101 Query q = session.createQuery(sql);
1102
1103 QueryPos qPos = QueryPos.getInstance(q);
1104
1105 qPos.add(groupId);
1106
1107 qPos.add(userId);
1108
1109 if (ppPaymentStatus != null) {
1110 qPos.add(ppPaymentStatus);
1111 }
1112
1113 list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
1114 start, end);
1115 }
1116 catch (Exception e) {
1117 throw processException(e);
1118 }
1119 finally {
1120 if (list == null) {
1121 list = new ArrayList<ShoppingOrder>();
1122 }
1123
1124 cacheResult(list);
1125
1126 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U_PPPS,
1127 finderArgs, list);
1128
1129 closeSession(session);
1130 }
1131 }
1132
1133 return list;
1134 }
1135
1136 public ShoppingOrder findByG_U_PPPS_First(long groupId, long userId,
1137 String ppPaymentStatus, OrderByComparator orderByComparator)
1138 throws NoSuchOrderException, SystemException {
1139 List<ShoppingOrder> list = findByG_U_PPPS(groupId, userId,
1140 ppPaymentStatus, 0, 1, orderByComparator);
1141
1142 if (list.isEmpty()) {
1143 StringBundler msg = new StringBundler(8);
1144
1145 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1146
1147 msg.append("groupId=");
1148 msg.append(groupId);
1149
1150 msg.append(", userId=");
1151 msg.append(userId);
1152
1153 msg.append(", ppPaymentStatus=");
1154 msg.append(ppPaymentStatus);
1155
1156 msg.append(StringPool.CLOSE_CURLY_BRACE);
1157
1158 throw new NoSuchOrderException(msg.toString());
1159 }
1160 else {
1161 return list.get(0);
1162 }
1163 }
1164
1165 public ShoppingOrder findByG_U_PPPS_Last(long groupId, long userId,
1166 String ppPaymentStatus, OrderByComparator orderByComparator)
1167 throws NoSuchOrderException, SystemException {
1168 int count = countByG_U_PPPS(groupId, userId, ppPaymentStatus);
1169
1170 List<ShoppingOrder> list = findByG_U_PPPS(groupId, userId,
1171 ppPaymentStatus, count - 1, count, orderByComparator);
1172
1173 if (list.isEmpty()) {
1174 StringBundler msg = new StringBundler(8);
1175
1176 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1177
1178 msg.append("groupId=");
1179 msg.append(groupId);
1180
1181 msg.append(", userId=");
1182 msg.append(userId);
1183
1184 msg.append(", ppPaymentStatus=");
1185 msg.append(ppPaymentStatus);
1186
1187 msg.append(StringPool.CLOSE_CURLY_BRACE);
1188
1189 throw new NoSuchOrderException(msg.toString());
1190 }
1191 else {
1192 return list.get(0);
1193 }
1194 }
1195
1196 public ShoppingOrder[] findByG_U_PPPS_PrevAndNext(long orderId,
1197 long groupId, long userId, String ppPaymentStatus,
1198 OrderByComparator orderByComparator)
1199 throws NoSuchOrderException, SystemException {
1200 ShoppingOrder shoppingOrder = findByPrimaryKey(orderId);
1201
1202 Session session = null;
1203
1204 try {
1205 session = openSession();
1206
1207 ShoppingOrder[] array = new ShoppingOrderImpl[3];
1208
1209 array[0] = getByG_U_PPPS_PrevAndNext(session, shoppingOrder,
1210 groupId, userId, ppPaymentStatus, orderByComparator, true);
1211
1212 array[1] = shoppingOrder;
1213
1214 array[2] = getByG_U_PPPS_PrevAndNext(session, shoppingOrder,
1215 groupId, userId, ppPaymentStatus, orderByComparator, false);
1216
1217 return array;
1218 }
1219 catch (Exception e) {
1220 throw processException(e);
1221 }
1222 finally {
1223 closeSession(session);
1224 }
1225 }
1226
1227 protected ShoppingOrder getByG_U_PPPS_PrevAndNext(Session session,
1228 ShoppingOrder shoppingOrder, long groupId, long userId,
1229 String ppPaymentStatus, OrderByComparator orderByComparator,
1230 boolean previous) {
1231 StringBundler query = null;
1232
1233 if (orderByComparator != null) {
1234 query = new StringBundler(6 +
1235 (orderByComparator.getOrderByFields().length * 6));
1236 }
1237 else {
1238 query = new StringBundler(3);
1239 }
1240
1241 query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
1242
1243 query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
1244
1245 query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
1246
1247 if (ppPaymentStatus == null) {
1248 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
1249 }
1250 else {
1251 if (ppPaymentStatus.equals(StringPool.BLANK)) {
1252 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
1253 }
1254 else {
1255 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
1256 }
1257 }
1258
1259 if (orderByComparator != null) {
1260 String[] orderByFields = orderByComparator.getOrderByFields();
1261
1262 if (orderByFields.length > 0) {
1263 query.append(WHERE_AND);
1264 }
1265
1266 for (int i = 0; i < orderByFields.length; i++) {
1267 query.append(_ORDER_BY_ENTITY_ALIAS);
1268 query.append(orderByFields[i]);
1269
1270 if ((i + 1) < orderByFields.length) {
1271 if (orderByComparator.isAscending() ^ previous) {
1272 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1273 }
1274 else {
1275 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1276 }
1277 }
1278 else {
1279 if (orderByComparator.isAscending() ^ previous) {
1280 query.append(WHERE_GREATER_THAN);
1281 }
1282 else {
1283 query.append(WHERE_LESSER_THAN);
1284 }
1285 }
1286 }
1287
1288 query.append(ORDER_BY_CLAUSE);
1289
1290 for (int i = 0; i < orderByFields.length; i++) {
1291 query.append(_ORDER_BY_ENTITY_ALIAS);
1292 query.append(orderByFields[i]);
1293
1294 if ((i + 1) < orderByFields.length) {
1295 if (orderByComparator.isAscending() ^ previous) {
1296 query.append(ORDER_BY_ASC_HAS_NEXT);
1297 }
1298 else {
1299 query.append(ORDER_BY_DESC_HAS_NEXT);
1300 }
1301 }
1302 else {
1303 if (orderByComparator.isAscending() ^ previous) {
1304 query.append(ORDER_BY_ASC);
1305 }
1306 else {
1307 query.append(ORDER_BY_DESC);
1308 }
1309 }
1310 }
1311 }
1312
1313 else {
1314 query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1315 }
1316
1317 String sql = query.toString();
1318
1319 Query q = session.createQuery(sql);
1320
1321 q.setFirstResult(0);
1322 q.setMaxResults(2);
1323
1324 QueryPos qPos = QueryPos.getInstance(q);
1325
1326 qPos.add(groupId);
1327
1328 qPos.add(userId);
1329
1330 if (ppPaymentStatus != null) {
1331 qPos.add(ppPaymentStatus);
1332 }
1333
1334 if (orderByComparator != null) {
1335 Object[] values = orderByComparator.getOrderByValues(shoppingOrder);
1336
1337 for (Object value : values) {
1338 qPos.add(value);
1339 }
1340 }
1341
1342 List<ShoppingOrder> list = q.list();
1343
1344 if (list.size() == 2) {
1345 return list.get(1);
1346 }
1347 else {
1348 return null;
1349 }
1350 }
1351
1352 public List<ShoppingOrder> filterFindByG_U_PPPS(long groupId, long userId,
1353 String ppPaymentStatus) throws SystemException {
1354 return filterFindByG_U_PPPS(groupId, userId, ppPaymentStatus,
1355 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1356 }
1357
1358 public List<ShoppingOrder> filterFindByG_U_PPPS(long groupId, long userId,
1359 String ppPaymentStatus, int start, int end) throws SystemException {
1360 return filterFindByG_U_PPPS(groupId, userId, ppPaymentStatus, start,
1361 end, null);
1362 }
1363
1364 public List<ShoppingOrder> filterFindByG_U_PPPS(long groupId, long userId,
1365 String ppPaymentStatus, int start, int end,
1366 OrderByComparator orderByComparator) throws SystemException {
1367 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1368 return findByG_U_PPPS(groupId, userId, ppPaymentStatus, start, end,
1369 orderByComparator);
1370 }
1371
1372 Session session = null;
1373
1374 try {
1375 session = openSession();
1376
1377 StringBundler query = null;
1378
1379 if (orderByComparator != null) {
1380 query = new StringBundler(5 +
1381 (orderByComparator.getOrderByFields().length * 3));
1382 }
1383 else {
1384 query = new StringBundler(5);
1385 }
1386
1387 query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_WHERE);
1388
1389 query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
1390
1391 query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
1392
1393 if (ppPaymentStatus == null) {
1394 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
1395 }
1396 else {
1397 if (ppPaymentStatus.equals(StringPool.BLANK)) {
1398 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
1399 }
1400 else {
1401 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
1402 }
1403 }
1404
1405 if (orderByComparator != null) {
1406 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1407 orderByComparator);
1408 }
1409
1410 else {
1411 query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1412 }
1413
1414 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1415 ShoppingOrder.class.getName(), _FILTER_COLUMN_ORDERID,
1416 _FILTER_COLUMN_USERID, groupId);
1417
1418 SQLQuery q = session.createSQLQuery(sql);
1419
1420 q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingOrderImpl.class);
1421
1422 QueryPos qPos = QueryPos.getInstance(q);
1423
1424 qPos.add(groupId);
1425
1426 qPos.add(userId);
1427
1428 if (ppPaymentStatus != null) {
1429 qPos.add(ppPaymentStatus);
1430 }
1431
1432 return (List<ShoppingOrder>)QueryUtil.list(q, getDialect(), start,
1433 end);
1434 }
1435 catch (Exception e) {
1436 throw processException(e);
1437 }
1438 finally {
1439 closeSession(session);
1440 }
1441 }
1442
1443 public List<ShoppingOrder> findAll() throws SystemException {
1444 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1445 }
1446
1447 public List<ShoppingOrder> findAll(int start, int end)
1448 throws SystemException {
1449 return findAll(start, end, null);
1450 }
1451
1452 public List<ShoppingOrder> findAll(int start, int end,
1453 OrderByComparator orderByComparator) throws SystemException {
1454 Object[] finderArgs = new Object[] {
1455 String.valueOf(start), String.valueOf(end),
1456 String.valueOf(orderByComparator)
1457 };
1458
1459 List<ShoppingOrder> list = (List<ShoppingOrder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1460 finderArgs, this);
1461
1462 if (list == null) {
1463 Session session = null;
1464
1465 try {
1466 session = openSession();
1467
1468 StringBundler query = null;
1469 String sql = null;
1470
1471 if (orderByComparator != null) {
1472 query = new StringBundler(2 +
1473 (orderByComparator.getOrderByFields().length * 3));
1474
1475 query.append(_SQL_SELECT_SHOPPINGORDER);
1476
1477 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1478 orderByComparator);
1479
1480 sql = query.toString();
1481 }
1482
1483 else {
1484 sql = _SQL_SELECT_SHOPPINGORDER.concat(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1485 }
1486
1487 Query q = session.createQuery(sql);
1488
1489 if (orderByComparator == null) {
1490 list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
1491 start, end, false);
1492
1493 Collections.sort(list);
1494 }
1495 else {
1496 list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
1497 start, end);
1498 }
1499 }
1500 catch (Exception e) {
1501 throw processException(e);
1502 }
1503 finally {
1504 if (list == null) {
1505 list = new ArrayList<ShoppingOrder>();
1506 }
1507
1508 cacheResult(list);
1509
1510 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1511
1512 closeSession(session);
1513 }
1514 }
1515
1516 return list;
1517 }
1518
1519 public void removeByGroupId(long groupId) throws SystemException {
1520 for (ShoppingOrder shoppingOrder : findByGroupId(groupId)) {
1521 remove(shoppingOrder);
1522 }
1523 }
1524
1525 public void removeByNumber(String number)
1526 throws NoSuchOrderException, SystemException {
1527 ShoppingOrder shoppingOrder = findByNumber(number);
1528
1529 remove(shoppingOrder);
1530 }
1531
1532 public void removeByPPTxnId(String ppTxnId)
1533 throws NoSuchOrderException, SystemException {
1534 ShoppingOrder shoppingOrder = findByPPTxnId(ppTxnId);
1535
1536 remove(shoppingOrder);
1537 }
1538
1539 public void removeByG_U_PPPS(long groupId, long userId,
1540 String ppPaymentStatus) throws SystemException {
1541 for (ShoppingOrder shoppingOrder : findByG_U_PPPS(groupId, userId,
1542 ppPaymentStatus)) {
1543 remove(shoppingOrder);
1544 }
1545 }
1546
1547 public void removeAll() throws SystemException {
1548 for (ShoppingOrder shoppingOrder : findAll()) {
1549 remove(shoppingOrder);
1550 }
1551 }
1552
1553 public int countByGroupId(long groupId) throws SystemException {
1554 Object[] finderArgs = new Object[] { new Long(groupId) };
1555
1556 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1557 finderArgs, this);
1558
1559 if (count == null) {
1560 Session session = null;
1561
1562 try {
1563 session = openSession();
1564
1565 StringBundler query = new StringBundler(2);
1566
1567 query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
1568
1569 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1570
1571 String sql = query.toString();
1572
1573 Query q = session.createQuery(sql);
1574
1575 QueryPos qPos = QueryPos.getInstance(q);
1576
1577 qPos.add(groupId);
1578
1579 count = (Long)q.uniqueResult();
1580 }
1581 catch (Exception e) {
1582 throw processException(e);
1583 }
1584 finally {
1585 if (count == null) {
1586 count = Long.valueOf(0);
1587 }
1588
1589 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1590 finderArgs, count);
1591
1592 closeSession(session);
1593 }
1594 }
1595
1596 return count.intValue();
1597 }
1598
1599 public int filterCountByGroupId(long groupId) throws SystemException {
1600 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1601 return countByGroupId(groupId);
1602 }
1603
1604 Session session = null;
1605
1606 try {
1607 session = openSession();
1608
1609 StringBundler query = new StringBundler(2);
1610
1611 query.append(_FILTER_SQL_COUNT_SHOPPINGORDER_WHERE);
1612
1613 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1614
1615 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1616 ShoppingOrder.class.getName(), _FILTER_COLUMN_ORDERID,
1617 _FILTER_COLUMN_USERID, groupId);
1618
1619 SQLQuery q = session.createSQLQuery(sql);
1620
1621 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1622
1623 QueryPos qPos = QueryPos.getInstance(q);
1624
1625 qPos.add(groupId);
1626
1627 Long count = (Long)q.uniqueResult();
1628
1629 return count.intValue();
1630 }
1631 catch (Exception e) {
1632 throw processException(e);
1633 }
1634 finally {
1635 closeSession(session);
1636 }
1637 }
1638
1639 public int countByNumber(String number) throws SystemException {
1640 Object[] finderArgs = new Object[] { number };
1641
1642 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NUMBER,
1643 finderArgs, this);
1644
1645 if (count == null) {
1646 Session session = null;
1647
1648 try {
1649 session = openSession();
1650
1651 StringBundler query = new StringBundler(2);
1652
1653 query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
1654
1655 if (number == null) {
1656 query.append(_FINDER_COLUMN_NUMBER_NUMBER_1);
1657 }
1658 else {
1659 if (number.equals(StringPool.BLANK)) {
1660 query.append(_FINDER_COLUMN_NUMBER_NUMBER_3);
1661 }
1662 else {
1663 query.append(_FINDER_COLUMN_NUMBER_NUMBER_2);
1664 }
1665 }
1666
1667 String sql = query.toString();
1668
1669 Query q = session.createQuery(sql);
1670
1671 QueryPos qPos = QueryPos.getInstance(q);
1672
1673 if (number != null) {
1674 qPos.add(number);
1675 }
1676
1677 count = (Long)q.uniqueResult();
1678 }
1679 catch (Exception e) {
1680 throw processException(e);
1681 }
1682 finally {
1683 if (count == null) {
1684 count = Long.valueOf(0);
1685 }
1686
1687 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NUMBER,
1688 finderArgs, count);
1689
1690 closeSession(session);
1691 }
1692 }
1693
1694 return count.intValue();
1695 }
1696
1697 public int countByPPTxnId(String ppTxnId) throws SystemException {
1698 Object[] finderArgs = new Object[] { ppTxnId };
1699
1700 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PPTXNID,
1701 finderArgs, this);
1702
1703 if (count == null) {
1704 Session session = null;
1705
1706 try {
1707 session = openSession();
1708
1709 StringBundler query = new StringBundler(2);
1710
1711 query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
1712
1713 if (ppTxnId == null) {
1714 query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_1);
1715 }
1716 else {
1717 if (ppTxnId.equals(StringPool.BLANK)) {
1718 query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_3);
1719 }
1720 else {
1721 query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_2);
1722 }
1723 }
1724
1725 String sql = query.toString();
1726
1727 Query q = session.createQuery(sql);
1728
1729 QueryPos qPos = QueryPos.getInstance(q);
1730
1731 if (ppTxnId != null) {
1732 qPos.add(ppTxnId);
1733 }
1734
1735 count = (Long)q.uniqueResult();
1736 }
1737 catch (Exception e) {
1738 throw processException(e);
1739 }
1740 finally {
1741 if (count == null) {
1742 count = Long.valueOf(0);
1743 }
1744
1745 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PPTXNID,
1746 finderArgs, count);
1747
1748 closeSession(session);
1749 }
1750 }
1751
1752 return count.intValue();
1753 }
1754
1755 public int countByG_U_PPPS(long groupId, long userId, String ppPaymentStatus)
1756 throws SystemException {
1757 Object[] finderArgs = new Object[] {
1758 new Long(groupId), new Long(userId),
1759
1760 ppPaymentStatus
1761 };
1762
1763 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_PPPS,
1764 finderArgs, this);
1765
1766 if (count == null) {
1767 Session session = null;
1768
1769 try {
1770 session = openSession();
1771
1772 StringBundler query = new StringBundler(4);
1773
1774 query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
1775
1776 query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
1777
1778 query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
1779
1780 if (ppPaymentStatus == null) {
1781 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
1782 }
1783 else {
1784 if (ppPaymentStatus.equals(StringPool.BLANK)) {
1785 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
1786 }
1787 else {
1788 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
1789 }
1790 }
1791
1792 String sql = query.toString();
1793
1794 Query q = session.createQuery(sql);
1795
1796 QueryPos qPos = QueryPos.getInstance(q);
1797
1798 qPos.add(groupId);
1799
1800 qPos.add(userId);
1801
1802 if (ppPaymentStatus != null) {
1803 qPos.add(ppPaymentStatus);
1804 }
1805
1806 count = (Long)q.uniqueResult();
1807 }
1808 catch (Exception e) {
1809 throw processException(e);
1810 }
1811 finally {
1812 if (count == null) {
1813 count = Long.valueOf(0);
1814 }
1815
1816 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_PPPS,
1817 finderArgs, count);
1818
1819 closeSession(session);
1820 }
1821 }
1822
1823 return count.intValue();
1824 }
1825
1826 public int filterCountByG_U_PPPS(long groupId, long userId,
1827 String ppPaymentStatus) throws SystemException {
1828 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1829 return countByG_U_PPPS(groupId, userId, ppPaymentStatus);
1830 }
1831
1832 Session session = null;
1833
1834 try {
1835 session = openSession();
1836
1837 StringBundler query = new StringBundler(4);
1838
1839 query.append(_FILTER_SQL_COUNT_SHOPPINGORDER_WHERE);
1840
1841 query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
1842
1843 query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
1844
1845 if (ppPaymentStatus == null) {
1846 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
1847 }
1848 else {
1849 if (ppPaymentStatus.equals(StringPool.BLANK)) {
1850 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
1851 }
1852 else {
1853 query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
1854 }
1855 }
1856
1857 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1858 ShoppingOrder.class.getName(), _FILTER_COLUMN_ORDERID,
1859 _FILTER_COLUMN_USERID, groupId);
1860
1861 SQLQuery q = session.createSQLQuery(sql);
1862
1863 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1864
1865 QueryPos qPos = QueryPos.getInstance(q);
1866
1867 qPos.add(groupId);
1868
1869 qPos.add(userId);
1870
1871 if (ppPaymentStatus != null) {
1872 qPos.add(ppPaymentStatus);
1873 }
1874
1875 Long count = (Long)q.uniqueResult();
1876
1877 return count.intValue();
1878 }
1879 catch (Exception e) {
1880 throw processException(e);
1881 }
1882 finally {
1883 closeSession(session);
1884 }
1885 }
1886
1887 public int countAll() throws SystemException {
1888 Object[] finderArgs = new Object[0];
1889
1890 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1891 finderArgs, this);
1892
1893 if (count == null) {
1894 Session session = null;
1895
1896 try {
1897 session = openSession();
1898
1899 Query q = session.createQuery(_SQL_COUNT_SHOPPINGORDER);
1900
1901 count = (Long)q.uniqueResult();
1902 }
1903 catch (Exception e) {
1904 throw processException(e);
1905 }
1906 finally {
1907 if (count == null) {
1908 count = Long.valueOf(0);
1909 }
1910
1911 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1912 count);
1913
1914 closeSession(session);
1915 }
1916 }
1917
1918 return count.intValue();
1919 }
1920
1921 public void afterPropertiesSet() {
1922 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1923 com.liferay.portal.util.PropsUtil.get(
1924 "value.object.listener.com.liferay.portlet.shopping.model.ShoppingOrder")));
1925
1926 if (listenerClassNames.length > 0) {
1927 try {
1928 List<ModelListener<ShoppingOrder>> listenersList = new ArrayList<ModelListener<ShoppingOrder>>();
1929
1930 for (String listenerClassName : listenerClassNames) {
1931 listenersList.add((ModelListener<ShoppingOrder>)InstanceFactory.newInstance(
1932 listenerClassName));
1933 }
1934
1935 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1936 }
1937 catch (Exception e) {
1938 _log.error(e);
1939 }
1940 }
1941 }
1942
1943 @BeanReference(type = ShoppingCartPersistence.class)
1944 protected ShoppingCartPersistence shoppingCartPersistence;
1945 @BeanReference(type = ShoppingCategoryPersistence.class)
1946 protected ShoppingCategoryPersistence shoppingCategoryPersistence;
1947 @BeanReference(type = ShoppingCouponPersistence.class)
1948 protected ShoppingCouponPersistence shoppingCouponPersistence;
1949 @BeanReference(type = ShoppingItemPersistence.class)
1950 protected ShoppingItemPersistence shoppingItemPersistence;
1951 @BeanReference(type = ShoppingItemFieldPersistence.class)
1952 protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
1953 @BeanReference(type = ShoppingItemPricePersistence.class)
1954 protected ShoppingItemPricePersistence shoppingItemPricePersistence;
1955 @BeanReference(type = ShoppingOrderPersistence.class)
1956 protected ShoppingOrderPersistence shoppingOrderPersistence;
1957 @BeanReference(type = ShoppingOrderItemPersistence.class)
1958 protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
1959 @BeanReference(type = CompanyPersistence.class)
1960 protected CompanyPersistence companyPersistence;
1961 @BeanReference(type = ResourcePersistence.class)
1962 protected ResourcePersistence resourcePersistence;
1963 @BeanReference(type = UserPersistence.class)
1964 protected UserPersistence userPersistence;
1965 @BeanReference(type = MBMessagePersistence.class)
1966 protected MBMessagePersistence mbMessagePersistence;
1967 private static final String _SQL_SELECT_SHOPPINGORDER = "SELECT shoppingOrder FROM ShoppingOrder shoppingOrder";
1968 private static final String _SQL_SELECT_SHOPPINGORDER_WHERE = "SELECT shoppingOrder FROM ShoppingOrder shoppingOrder WHERE ";
1969 private static final String _SQL_COUNT_SHOPPINGORDER = "SELECT COUNT(shoppingOrder) FROM ShoppingOrder shoppingOrder";
1970 private static final String _SQL_COUNT_SHOPPINGORDER_WHERE = "SELECT COUNT(shoppingOrder) FROM ShoppingOrder shoppingOrder WHERE ";
1971 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "shoppingOrder.groupId = ?";
1972 private static final String _FINDER_COLUMN_NUMBER_NUMBER_1 = "shoppingOrder.number IS NULL";
1973 private static final String _FINDER_COLUMN_NUMBER_NUMBER_2 = "shoppingOrder.number = ?";
1974 private static final String _FINDER_COLUMN_NUMBER_NUMBER_3 = "(shoppingOrder.number IS NULL OR shoppingOrder.number = ?)";
1975 private static final String _FINDER_COLUMN_PPTXNID_PPTXNID_1 = "shoppingOrder.ppTxnId IS NULL";
1976 private static final String _FINDER_COLUMN_PPTXNID_PPTXNID_2 = "shoppingOrder.ppTxnId = ?";
1977 private static final String _FINDER_COLUMN_PPTXNID_PPTXNID_3 = "(shoppingOrder.ppTxnId IS NULL OR shoppingOrder.ppTxnId = ?)";
1978 private static final String _FINDER_COLUMN_G_U_PPPS_GROUPID_2 = "shoppingOrder.groupId = ? AND ";
1979 private static final String _FINDER_COLUMN_G_U_PPPS_USERID_2 = "shoppingOrder.userId = ? AND ";
1980 private static final String _FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1 = "shoppingOrder.ppPaymentStatus IS NULL";
1981 private static final String _FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2 = "shoppingOrder.ppPaymentStatus = ?";
1982 private static final String _FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3 = "(shoppingOrder.ppPaymentStatus IS NULL OR shoppingOrder.ppPaymentStatus = ?)";
1983 private static final String _FILTER_SQL_SELECT_SHOPPINGORDER_WHERE = "SELECT DISTINCT {shoppingOrder.*} FROM ShoppingOrder shoppingOrder WHERE ";
1984 private static final String _FILTER_SQL_COUNT_SHOPPINGORDER_WHERE = "SELECT COUNT(DISTINCT shoppingOrder.orderId) AS COUNT_VALUE FROM ShoppingOrder shoppingOrder WHERE ";
1985 private static final String _FILTER_COLUMN_ORDERID = "shoppingOrder.orderId";
1986 private static final String _FILTER_COLUMN_USERID = "shoppingOrder.userId";
1987 private static final String _FILTER_ENTITY_ALIAS = "shoppingOrder";
1988 private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingOrder.";
1989 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingOrder exists with the primary key ";
1990 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingOrder exists with the key {";
1991 private static Log _log = LogFactoryUtil.getLog(ShoppingOrderPersistenceImpl.class);
1992}