001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.shopping.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
040    import com.liferay.portal.service.persistence.BatchSessionUtil;
041    import com.liferay.portal.service.persistence.CompanyPersistence;
042    import com.liferay.portal.service.persistence.ResourcePersistence;
043    import com.liferay.portal.service.persistence.UserPersistence;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    
046    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
047    import com.liferay.portlet.shopping.NoSuchOrderException;
048    import com.liferay.portlet.shopping.model.ShoppingOrder;
049    import com.liferay.portlet.shopping.model.impl.ShoppingOrderImpl;
050    import com.liferay.portlet.shopping.model.impl.ShoppingOrderModelImpl;
051    
052    import java.io.Serializable;
053    
054    import java.util.ArrayList;
055    import java.util.Collections;
056    import java.util.List;
057    
058    /**
059     * The persistence implementation for the shopping order service.
060     *
061     * <p>
062     * Never modify or reference this class directly. Always use {@link ShoppingOrderUtil} to access the shopping order persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
063     * </p>
064     *
065     * <p>
066     * Caching information and settings can be found in <code>portal.properties</code>
067     * </p>
068     *
069     * @author Brian Wing Shun Chan
070     * @see ShoppingOrderPersistence
071     * @see ShoppingOrderUtil
072     * @generated
073     */
074    public class ShoppingOrderPersistenceImpl extends BasePersistenceImpl<ShoppingOrder>
075            implements ShoppingOrderPersistence {
076            public static final String FINDER_CLASS_NAME_ENTITY = ShoppingOrderImpl.class.getName();
077            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
078                    ".List";
079            public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
080                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
081                            FINDER_CLASS_NAME_LIST, "findByGroupId",
082                            new String[] {
083                                    Long.class.getName(),
084                                    
085                            "java.lang.Integer", "java.lang.Integer",
086                                    "com.liferay.portal.kernel.util.OrderByComparator"
087                            });
088            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
089                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
090                            FINDER_CLASS_NAME_LIST, "countByGroupId",
091                            new String[] { Long.class.getName() });
092            public static final FinderPath FINDER_PATH_FETCH_BY_NUMBER = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
093                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
094                            FINDER_CLASS_NAME_ENTITY, "fetchByNumber",
095                            new String[] { String.class.getName() });
096            public static final FinderPath FINDER_PATH_COUNT_BY_NUMBER = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
097                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
098                            FINDER_CLASS_NAME_LIST, "countByNumber",
099                            new String[] { String.class.getName() });
100            public static final FinderPath FINDER_PATH_FETCH_BY_PPTXNID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
101                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
102                            FINDER_CLASS_NAME_ENTITY, "fetchByPPTxnId",
103                            new String[] { String.class.getName() });
104            public static final FinderPath FINDER_PATH_COUNT_BY_PPTXNID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
105                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
106                            FINDER_CLASS_NAME_LIST, "countByPPTxnId",
107                            new String[] { String.class.getName() });
108            public static final FinderPath FINDER_PATH_FIND_BY_G_U_PPPS = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
109                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
110                            FINDER_CLASS_NAME_LIST, "findByG_U_PPPS",
111                            new String[] {
112                                    Long.class.getName(), Long.class.getName(),
113                                    String.class.getName(),
114                                    
115                            "java.lang.Integer", "java.lang.Integer",
116                                    "com.liferay.portal.kernel.util.OrderByComparator"
117                            });
118            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_PPPS = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
119                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
120                            FINDER_CLASS_NAME_LIST, "countByG_U_PPPS",
121                            new String[] {
122                                    Long.class.getName(), Long.class.getName(),
123                                    String.class.getName()
124                            });
125            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
126                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
127                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
128            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
129                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
130                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
131    
132            /**
133             * Caches the shopping order in the entity cache if it is enabled.
134             *
135             * @param shoppingOrder the shopping order to cache
136             */
137            public void cacheResult(ShoppingOrder shoppingOrder) {
138                    EntityCacheUtil.putResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
139                            ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey(),
140                            shoppingOrder);
141    
142                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
143                            new Object[] { shoppingOrder.getNumber() }, shoppingOrder);
144    
145                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
146                            new Object[] { shoppingOrder.getPpTxnId() }, shoppingOrder);
147            }
148    
149            /**
150             * Caches the shopping orders in the entity cache if it is enabled.
151             *
152             * @param shoppingOrders the shopping orders to cache
153             */
154            public void cacheResult(List<ShoppingOrder> shoppingOrders) {
155                    for (ShoppingOrder shoppingOrder : shoppingOrders) {
156                            if (EntityCacheUtil.getResult(
157                                                    ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
158                                                    ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey(),
159                                                    this) == null) {
160                                    cacheResult(shoppingOrder);
161                            }
162                    }
163            }
164    
165            /**
166             * Clears the cache for all shopping orders.
167             *
168             * <p>
169             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
170             * </p>
171             */
172            public void clearCache() {
173                    CacheRegistryUtil.clear(ShoppingOrderImpl.class.getName());
174                    EntityCacheUtil.clearCache(ShoppingOrderImpl.class.getName());
175                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
176                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
177            }
178    
179            /**
180             * Clears the cache for the shopping order.
181             *
182             * <p>
183             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
184             * </p>
185             */
186            public void clearCache(ShoppingOrder shoppingOrder) {
187                    EntityCacheUtil.removeResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
188                            ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey());
189    
190                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NUMBER,
191                            new Object[] { shoppingOrder.getNumber() });
192    
193                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PPTXNID,
194                            new Object[] { shoppingOrder.getPpTxnId() });
195            }
196    
197            /**
198             * Creates a new shopping order with the primary key. Does not add the shopping order to the database.
199             *
200             * @param orderId the primary key for the new shopping order
201             * @return the new shopping order
202             */
203            public ShoppingOrder create(long orderId) {
204                    ShoppingOrder shoppingOrder = new ShoppingOrderImpl();
205    
206                    shoppingOrder.setNew(true);
207                    shoppingOrder.setPrimaryKey(orderId);
208    
209                    return shoppingOrder;
210            }
211    
212            /**
213             * Removes the shopping order with the primary key from the database. Also notifies the appropriate model listeners.
214             *
215             * @param primaryKey the primary key of the shopping order to remove
216             * @return the shopping order that was removed
217             * @throws com.liferay.portal.NoSuchModelException if a shopping order with the primary key could not be found
218             * @throws SystemException if a system exception occurred
219             */
220            public ShoppingOrder remove(Serializable primaryKey)
221                    throws NoSuchModelException, SystemException {
222                    return remove(((Long)primaryKey).longValue());
223            }
224    
225            /**
226             * Removes the shopping order with the primary key from the database. Also notifies the appropriate model listeners.
227             *
228             * @param orderId the primary key of the shopping order to remove
229             * @return the shopping order that was removed
230             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
231             * @throws SystemException if a system exception occurred
232             */
233            public ShoppingOrder remove(long orderId)
234                    throws NoSuchOrderException, SystemException {
235                    Session session = null;
236    
237                    try {
238                            session = openSession();
239    
240                            ShoppingOrder shoppingOrder = (ShoppingOrder)session.get(ShoppingOrderImpl.class,
241                                            new Long(orderId));
242    
243                            if (shoppingOrder == null) {
244                                    if (_log.isWarnEnabled()) {
245                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orderId);
246                                    }
247    
248                                    throw new NoSuchOrderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
249                                            orderId);
250                            }
251    
252                            return remove(shoppingOrder);
253                    }
254                    catch (NoSuchOrderException nsee) {
255                            throw nsee;
256                    }
257                    catch (Exception e) {
258                            throw processException(e);
259                    }
260                    finally {
261                            closeSession(session);
262                    }
263            }
264    
265            protected ShoppingOrder removeImpl(ShoppingOrder shoppingOrder)
266                    throws SystemException {
267                    shoppingOrder = toUnwrappedModel(shoppingOrder);
268    
269                    Session session = null;
270    
271                    try {
272                            session = openSession();
273    
274                            if (shoppingOrder.isCachedModel() || BatchSessionUtil.isEnabled()) {
275                                    Object staleObject = session.get(ShoppingOrderImpl.class,
276                                                    shoppingOrder.getPrimaryKeyObj());
277    
278                                    if (staleObject != null) {
279                                            session.evict(staleObject);
280                                    }
281                            }
282    
283                            session.delete(shoppingOrder);
284    
285                            session.flush();
286                    }
287                    catch (Exception e) {
288                            throw processException(e);
289                    }
290                    finally {
291                            closeSession(session);
292                    }
293    
294                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
295    
296                    ShoppingOrderModelImpl shoppingOrderModelImpl = (ShoppingOrderModelImpl)shoppingOrder;
297    
298                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NUMBER,
299                            new Object[] { shoppingOrderModelImpl.getOriginalNumber() });
300    
301                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PPTXNID,
302                            new Object[] { shoppingOrderModelImpl.getOriginalPpTxnId() });
303    
304                    EntityCacheUtil.removeResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
305                            ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey());
306    
307                    return shoppingOrder;
308            }
309    
310            public ShoppingOrder updateImpl(
311                    com.liferay.portlet.shopping.model.ShoppingOrder shoppingOrder,
312                    boolean merge) throws SystemException {
313                    shoppingOrder = toUnwrappedModel(shoppingOrder);
314    
315                    boolean isNew = shoppingOrder.isNew();
316    
317                    ShoppingOrderModelImpl shoppingOrderModelImpl = (ShoppingOrderModelImpl)shoppingOrder;
318    
319                    Session session = null;
320    
321                    try {
322                            session = openSession();
323    
324                            BatchSessionUtil.update(session, shoppingOrder, merge);
325    
326                            shoppingOrder.setNew(false);
327                    }
328                    catch (Exception e) {
329                            throw processException(e);
330                    }
331                    finally {
332                            closeSession(session);
333                    }
334    
335                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
336    
337                    EntityCacheUtil.putResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
338                            ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey(),
339                            shoppingOrder);
340    
341                    if (!isNew &&
342                                    (!Validator.equals(shoppingOrder.getNumber(),
343                                            shoppingOrderModelImpl.getOriginalNumber()))) {
344                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NUMBER,
345                                    new Object[] { shoppingOrderModelImpl.getOriginalNumber() });
346                    }
347    
348                    if (isNew ||
349                                    (!Validator.equals(shoppingOrder.getNumber(),
350                                            shoppingOrderModelImpl.getOriginalNumber()))) {
351                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
352                                    new Object[] { shoppingOrder.getNumber() }, shoppingOrder);
353                    }
354    
355                    if (!isNew &&
356                                    (!Validator.equals(shoppingOrder.getPpTxnId(),
357                                            shoppingOrderModelImpl.getOriginalPpTxnId()))) {
358                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PPTXNID,
359                                    new Object[] { shoppingOrderModelImpl.getOriginalPpTxnId() });
360                    }
361    
362                    if (isNew ||
363                                    (!Validator.equals(shoppingOrder.getPpTxnId(),
364                                            shoppingOrderModelImpl.getOriginalPpTxnId()))) {
365                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
366                                    new Object[] { shoppingOrder.getPpTxnId() }, shoppingOrder);
367                    }
368    
369                    return shoppingOrder;
370            }
371    
372            protected ShoppingOrder toUnwrappedModel(ShoppingOrder shoppingOrder) {
373                    if (shoppingOrder instanceof ShoppingOrderImpl) {
374                            return shoppingOrder;
375                    }
376    
377                    ShoppingOrderImpl shoppingOrderImpl = new ShoppingOrderImpl();
378    
379                    shoppingOrderImpl.setNew(shoppingOrder.isNew());
380                    shoppingOrderImpl.setPrimaryKey(shoppingOrder.getPrimaryKey());
381    
382                    shoppingOrderImpl.setOrderId(shoppingOrder.getOrderId());
383                    shoppingOrderImpl.setGroupId(shoppingOrder.getGroupId());
384                    shoppingOrderImpl.setCompanyId(shoppingOrder.getCompanyId());
385                    shoppingOrderImpl.setUserId(shoppingOrder.getUserId());
386                    shoppingOrderImpl.setUserName(shoppingOrder.getUserName());
387                    shoppingOrderImpl.setCreateDate(shoppingOrder.getCreateDate());
388                    shoppingOrderImpl.setModifiedDate(shoppingOrder.getModifiedDate());
389                    shoppingOrderImpl.setNumber(shoppingOrder.getNumber());
390                    shoppingOrderImpl.setTax(shoppingOrder.getTax());
391                    shoppingOrderImpl.setShipping(shoppingOrder.getShipping());
392                    shoppingOrderImpl.setAltShipping(shoppingOrder.getAltShipping());
393                    shoppingOrderImpl.setRequiresShipping(shoppingOrder.isRequiresShipping());
394                    shoppingOrderImpl.setInsure(shoppingOrder.isInsure());
395                    shoppingOrderImpl.setInsurance(shoppingOrder.getInsurance());
396                    shoppingOrderImpl.setCouponCodes(shoppingOrder.getCouponCodes());
397                    shoppingOrderImpl.setCouponDiscount(shoppingOrder.getCouponDiscount());
398                    shoppingOrderImpl.setBillingFirstName(shoppingOrder.getBillingFirstName());
399                    shoppingOrderImpl.setBillingLastName(shoppingOrder.getBillingLastName());
400                    shoppingOrderImpl.setBillingEmailAddress(shoppingOrder.getBillingEmailAddress());
401                    shoppingOrderImpl.setBillingCompany(shoppingOrder.getBillingCompany());
402                    shoppingOrderImpl.setBillingStreet(shoppingOrder.getBillingStreet());
403                    shoppingOrderImpl.setBillingCity(shoppingOrder.getBillingCity());
404                    shoppingOrderImpl.setBillingState(shoppingOrder.getBillingState());
405                    shoppingOrderImpl.setBillingZip(shoppingOrder.getBillingZip());
406                    shoppingOrderImpl.setBillingCountry(shoppingOrder.getBillingCountry());
407                    shoppingOrderImpl.setBillingPhone(shoppingOrder.getBillingPhone());
408                    shoppingOrderImpl.setShipToBilling(shoppingOrder.isShipToBilling());
409                    shoppingOrderImpl.setShippingFirstName(shoppingOrder.getShippingFirstName());
410                    shoppingOrderImpl.setShippingLastName(shoppingOrder.getShippingLastName());
411                    shoppingOrderImpl.setShippingEmailAddress(shoppingOrder.getShippingEmailAddress());
412                    shoppingOrderImpl.setShippingCompany(shoppingOrder.getShippingCompany());
413                    shoppingOrderImpl.setShippingStreet(shoppingOrder.getShippingStreet());
414                    shoppingOrderImpl.setShippingCity(shoppingOrder.getShippingCity());
415                    shoppingOrderImpl.setShippingState(shoppingOrder.getShippingState());
416                    shoppingOrderImpl.setShippingZip(shoppingOrder.getShippingZip());
417                    shoppingOrderImpl.setShippingCountry(shoppingOrder.getShippingCountry());
418                    shoppingOrderImpl.setShippingPhone(shoppingOrder.getShippingPhone());
419                    shoppingOrderImpl.setCcName(shoppingOrder.getCcName());
420                    shoppingOrderImpl.setCcType(shoppingOrder.getCcType());
421                    shoppingOrderImpl.setCcNumber(shoppingOrder.getCcNumber());
422                    shoppingOrderImpl.setCcExpMonth(shoppingOrder.getCcExpMonth());
423                    shoppingOrderImpl.setCcExpYear(shoppingOrder.getCcExpYear());
424                    shoppingOrderImpl.setCcVerNumber(shoppingOrder.getCcVerNumber());
425                    shoppingOrderImpl.setComments(shoppingOrder.getComments());
426                    shoppingOrderImpl.setPpTxnId(shoppingOrder.getPpTxnId());
427                    shoppingOrderImpl.setPpPaymentStatus(shoppingOrder.getPpPaymentStatus());
428                    shoppingOrderImpl.setPpPaymentGross(shoppingOrder.getPpPaymentGross());
429                    shoppingOrderImpl.setPpReceiverEmail(shoppingOrder.getPpReceiverEmail());
430                    shoppingOrderImpl.setPpPayerEmail(shoppingOrder.getPpPayerEmail());
431                    shoppingOrderImpl.setSendOrderEmail(shoppingOrder.isSendOrderEmail());
432                    shoppingOrderImpl.setSendShippingEmail(shoppingOrder.isSendShippingEmail());
433    
434                    return shoppingOrderImpl;
435            }
436    
437            /**
438             * Finds the shopping order with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
439             *
440             * @param primaryKey the primary key of the shopping order to find
441             * @return the shopping order
442             * @throws com.liferay.portal.NoSuchModelException if a shopping order with the primary key could not be found
443             * @throws SystemException if a system exception occurred
444             */
445            public ShoppingOrder findByPrimaryKey(Serializable primaryKey)
446                    throws NoSuchModelException, SystemException {
447                    return findByPrimaryKey(((Long)primaryKey).longValue());
448            }
449    
450            /**
451             * Finds the shopping order with the primary key or throws a {@link com.liferay.portlet.shopping.NoSuchOrderException} if it could not be found.
452             *
453             * @param orderId the primary key of the shopping order to find
454             * @return the shopping order
455             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
456             * @throws SystemException if a system exception occurred
457             */
458            public ShoppingOrder findByPrimaryKey(long orderId)
459                    throws NoSuchOrderException, SystemException {
460                    ShoppingOrder shoppingOrder = fetchByPrimaryKey(orderId);
461    
462                    if (shoppingOrder == null) {
463                            if (_log.isWarnEnabled()) {
464                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orderId);
465                            }
466    
467                            throw new NoSuchOrderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
468                                    orderId);
469                    }
470    
471                    return shoppingOrder;
472            }
473    
474            /**
475             * Finds the shopping order with the primary key or returns <code>null</code> if it could not be found.
476             *
477             * @param primaryKey the primary key of the shopping order to find
478             * @return the shopping order, or <code>null</code> if a shopping order with the primary key could not be found
479             * @throws SystemException if a system exception occurred
480             */
481            public ShoppingOrder fetchByPrimaryKey(Serializable primaryKey)
482                    throws SystemException {
483                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
484            }
485    
486            /**
487             * Finds the shopping order with the primary key or returns <code>null</code> if it could not be found.
488             *
489             * @param orderId the primary key of the shopping order to find
490             * @return the shopping order, or <code>null</code> if a shopping order with the primary key could not be found
491             * @throws SystemException if a system exception occurred
492             */
493            public ShoppingOrder fetchByPrimaryKey(long orderId)
494                    throws SystemException {
495                    ShoppingOrder shoppingOrder = (ShoppingOrder)EntityCacheUtil.getResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
496                                    ShoppingOrderImpl.class, orderId, this);
497    
498                    if (shoppingOrder == null) {
499                            Session session = null;
500    
501                            try {
502                                    session = openSession();
503    
504                                    shoppingOrder = (ShoppingOrder)session.get(ShoppingOrderImpl.class,
505                                                    new Long(orderId));
506                            }
507                            catch (Exception e) {
508                                    throw processException(e);
509                            }
510                            finally {
511                                    if (shoppingOrder != null) {
512                                            cacheResult(shoppingOrder);
513                                    }
514    
515                                    closeSession(session);
516                            }
517                    }
518    
519                    return shoppingOrder;
520            }
521    
522            /**
523             * Finds all the shopping orders where groupId = &#63;.
524             *
525             * @param groupId the group id to search with
526             * @return the matching shopping orders
527             * @throws SystemException if a system exception occurred
528             */
529            public List<ShoppingOrder> findByGroupId(long groupId)
530                    throws SystemException {
531                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
532            }
533    
534            /**
535             * Finds a range of all the shopping orders where groupId = &#63;.
536             *
537             * <p>
538             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
539             * </p>
540             *
541             * @param groupId the group id to search with
542             * @param start the lower bound of the range of shopping orders to return
543             * @param end the upper bound of the range of shopping orders to return (not inclusive)
544             * @return the range of matching shopping orders
545             * @throws SystemException if a system exception occurred
546             */
547            public List<ShoppingOrder> findByGroupId(long groupId, int start, int end)
548                    throws SystemException {
549                    return findByGroupId(groupId, start, end, null);
550            }
551    
552            /**
553             * Finds an ordered range of all the shopping orders where groupId = &#63;.
554             *
555             * <p>
556             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
557             * </p>
558             *
559             * @param groupId the group id to search with
560             * @param start the lower bound of the range of shopping orders to return
561             * @param end the upper bound of the range of shopping orders to return (not inclusive)
562             * @param orderByComparator the comparator to order the results by
563             * @return the ordered range of matching shopping orders
564             * @throws SystemException if a system exception occurred
565             */
566            public List<ShoppingOrder> findByGroupId(long groupId, int start, int end,
567                    OrderByComparator orderByComparator) throws SystemException {
568                    Object[] finderArgs = new Object[] {
569                                    groupId,
570                                    
571                                    String.valueOf(start), String.valueOf(end),
572                                    String.valueOf(orderByComparator)
573                            };
574    
575                    List<ShoppingOrder> list = (List<ShoppingOrder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
576                                    finderArgs, this);
577    
578                    if (list == null) {
579                            Session session = null;
580    
581                            try {
582                                    session = openSession();
583    
584                                    StringBundler query = null;
585    
586                                    if (orderByComparator != null) {
587                                            query = new StringBundler(3 +
588                                                            (orderByComparator.getOrderByFields().length * 3));
589                                    }
590                                    else {
591                                            query = new StringBundler(3);
592                                    }
593    
594                                    query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
595    
596                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
597    
598                                    if (orderByComparator != null) {
599                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
600                                                    orderByComparator);
601                                    }
602    
603                                    else {
604                                            query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
605                                    }
606    
607                                    String sql = query.toString();
608    
609                                    Query q = session.createQuery(sql);
610    
611                                    QueryPos qPos = QueryPos.getInstance(q);
612    
613                                    qPos.add(groupId);
614    
615                                    list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
616                                                    start, end);
617                            }
618                            catch (Exception e) {
619                                    throw processException(e);
620                            }
621                            finally {
622                                    if (list == null) {
623                                            list = new ArrayList<ShoppingOrder>();
624                                    }
625    
626                                    cacheResult(list);
627    
628                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
629                                            finderArgs, list);
630    
631                                    closeSession(session);
632                            }
633                    }
634    
635                    return list;
636            }
637    
638            /**
639             * Finds the first shopping order in the ordered set where groupId = &#63;.
640             *
641             * <p>
642             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
643             * </p>
644             *
645             * @param groupId the group id to search with
646             * @param orderByComparator the comparator to order the set by
647             * @return the first matching shopping order
648             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
649             * @throws SystemException if a system exception occurred
650             */
651            public ShoppingOrder findByGroupId_First(long groupId,
652                    OrderByComparator orderByComparator)
653                    throws NoSuchOrderException, SystemException {
654                    List<ShoppingOrder> list = findByGroupId(groupId, 0, 1,
655                                    orderByComparator);
656    
657                    if (list.isEmpty()) {
658                            StringBundler msg = new StringBundler(4);
659    
660                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
661    
662                            msg.append("groupId=");
663                            msg.append(groupId);
664    
665                            msg.append(StringPool.CLOSE_CURLY_BRACE);
666    
667                            throw new NoSuchOrderException(msg.toString());
668                    }
669                    else {
670                            return list.get(0);
671                    }
672            }
673    
674            /**
675             * Finds the last shopping order in the ordered set where groupId = &#63;.
676             *
677             * <p>
678             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
679             * </p>
680             *
681             * @param groupId the group id to search with
682             * @param orderByComparator the comparator to order the set by
683             * @return the last matching shopping order
684             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
685             * @throws SystemException if a system exception occurred
686             */
687            public ShoppingOrder findByGroupId_Last(long groupId,
688                    OrderByComparator orderByComparator)
689                    throws NoSuchOrderException, SystemException {
690                    int count = countByGroupId(groupId);
691    
692                    List<ShoppingOrder> list = findByGroupId(groupId, count - 1, count,
693                                    orderByComparator);
694    
695                    if (list.isEmpty()) {
696                            StringBundler msg = new StringBundler(4);
697    
698                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
699    
700                            msg.append("groupId=");
701                            msg.append(groupId);
702    
703                            msg.append(StringPool.CLOSE_CURLY_BRACE);
704    
705                            throw new NoSuchOrderException(msg.toString());
706                    }
707                    else {
708                            return list.get(0);
709                    }
710            }
711    
712            /**
713             * Finds the shopping orders before and after the current shopping order in the ordered set where groupId = &#63;.
714             *
715             * <p>
716             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
717             * </p>
718             *
719             * @param orderId the primary key of the current shopping order
720             * @param groupId the group id to search with
721             * @param orderByComparator the comparator to order the set by
722             * @return the previous, current, and next shopping order
723             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
724             * @throws SystemException if a system exception occurred
725             */
726            public ShoppingOrder[] findByGroupId_PrevAndNext(long orderId,
727                    long groupId, OrderByComparator orderByComparator)
728                    throws NoSuchOrderException, SystemException {
729                    ShoppingOrder shoppingOrder = findByPrimaryKey(orderId);
730    
731                    Session session = null;
732    
733                    try {
734                            session = openSession();
735    
736                            ShoppingOrder[] array = new ShoppingOrderImpl[3];
737    
738                            array[0] = getByGroupId_PrevAndNext(session, shoppingOrder,
739                                            groupId, orderByComparator, true);
740    
741                            array[1] = shoppingOrder;
742    
743                            array[2] = getByGroupId_PrevAndNext(session, shoppingOrder,
744                                            groupId, orderByComparator, false);
745    
746                            return array;
747                    }
748                    catch (Exception e) {
749                            throw processException(e);
750                    }
751                    finally {
752                            closeSession(session);
753                    }
754            }
755    
756            protected ShoppingOrder getByGroupId_PrevAndNext(Session session,
757                    ShoppingOrder shoppingOrder, long groupId,
758                    OrderByComparator orderByComparator, boolean previous) {
759                    StringBundler query = null;
760    
761                    if (orderByComparator != null) {
762                            query = new StringBundler(6 +
763                                            (orderByComparator.getOrderByFields().length * 6));
764                    }
765                    else {
766                            query = new StringBundler(3);
767                    }
768    
769                    query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
770    
771                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
772    
773                    if (orderByComparator != null) {
774                            String[] orderByFields = orderByComparator.getOrderByFields();
775    
776                            if (orderByFields.length > 0) {
777                                    query.append(WHERE_AND);
778                            }
779    
780                            for (int i = 0; i < orderByFields.length; i++) {
781                                    query.append(_ORDER_BY_ENTITY_ALIAS);
782                                    query.append(orderByFields[i]);
783    
784                                    if ((i + 1) < orderByFields.length) {
785                                            if (orderByComparator.isAscending() ^ previous) {
786                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
787                                            }
788                                            else {
789                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
790                                            }
791                                    }
792                                    else {
793                                            if (orderByComparator.isAscending() ^ previous) {
794                                                    query.append(WHERE_GREATER_THAN);
795                                            }
796                                            else {
797                                                    query.append(WHERE_LESSER_THAN);
798                                            }
799                                    }
800                            }
801    
802                            query.append(ORDER_BY_CLAUSE);
803    
804                            for (int i = 0; i < orderByFields.length; i++) {
805                                    query.append(_ORDER_BY_ENTITY_ALIAS);
806                                    query.append(orderByFields[i]);
807    
808                                    if ((i + 1) < orderByFields.length) {
809                                            if (orderByComparator.isAscending() ^ previous) {
810                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
811                                            }
812                                            else {
813                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
814                                            }
815                                    }
816                                    else {
817                                            if (orderByComparator.isAscending() ^ previous) {
818                                                    query.append(ORDER_BY_ASC);
819                                            }
820                                            else {
821                                                    query.append(ORDER_BY_DESC);
822                                            }
823                                    }
824                            }
825                    }
826    
827                    else {
828                            query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
829                    }
830    
831                    String sql = query.toString();
832    
833                    Query q = session.createQuery(sql);
834    
835                    q.setFirstResult(0);
836                    q.setMaxResults(2);
837    
838                    QueryPos qPos = QueryPos.getInstance(q);
839    
840                    qPos.add(groupId);
841    
842                    if (orderByComparator != null) {
843                            Object[] values = orderByComparator.getOrderByValues(shoppingOrder);
844    
845                            for (Object value : values) {
846                                    qPos.add(value);
847                            }
848                    }
849    
850                    List<ShoppingOrder> list = q.list();
851    
852                    if (list.size() == 2) {
853                            return list.get(1);
854                    }
855                    else {
856                            return null;
857                    }
858            }
859    
860            /**
861             * Filters by the user's permissions and finds all the shopping orders where groupId = &#63;.
862             *
863             * @param groupId the group id to search with
864             * @return the matching shopping orders that the user has permission to view
865             * @throws SystemException if a system exception occurred
866             */
867            public List<ShoppingOrder> filterFindByGroupId(long groupId)
868                    throws SystemException {
869                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
870                            QueryUtil.ALL_POS, null);
871            }
872    
873            /**
874             * Filters by the user's permissions and finds a range of all the shopping orders where groupId = &#63;.
875             *
876             * <p>
877             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
878             * </p>
879             *
880             * @param groupId the group id to search with
881             * @param start the lower bound of the range of shopping orders to return
882             * @param end the upper bound of the range of shopping orders to return (not inclusive)
883             * @return the range of matching shopping orders that the user has permission to view
884             * @throws SystemException if a system exception occurred
885             */
886            public List<ShoppingOrder> filterFindByGroupId(long groupId, int start,
887                    int end) throws SystemException {
888                    return filterFindByGroupId(groupId, start, end, null);
889            }
890    
891            /**
892             * Filters by the user's permissions and finds an ordered range of all the shopping orders where groupId = &#63;.
893             *
894             * <p>
895             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
896             * </p>
897             *
898             * @param groupId the group id to search with
899             * @param start the lower bound of the range of shopping orders to return
900             * @param end the upper bound of the range of shopping orders to return (not inclusive)
901             * @param orderByComparator the comparator to order the results by
902             * @return the ordered range of matching shopping orders that the user has permission to view
903             * @throws SystemException if a system exception occurred
904             */
905            public List<ShoppingOrder> filterFindByGroupId(long groupId, int start,
906                    int end, OrderByComparator orderByComparator) throws SystemException {
907                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
908                            return findByGroupId(groupId, start, end, orderByComparator);
909                    }
910    
911                    Session session = null;
912    
913                    try {
914                            session = openSession();
915    
916                            StringBundler query = null;
917    
918                            if (orderByComparator != null) {
919                                    query = new StringBundler(3 +
920                                                    (orderByComparator.getOrderByFields().length * 3));
921                            }
922                            else {
923                                    query = new StringBundler(3);
924                            }
925    
926                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_WHERE);
927    
928                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
929    
930                            if (orderByComparator != null) {
931                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
932                                            orderByComparator);
933                            }
934    
935                            else {
936                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
937                            }
938    
939                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
940                                            ShoppingOrder.class.getName(), _FILTER_COLUMN_PK,
941                                            _FILTER_COLUMN_USERID, groupId);
942    
943                            SQLQuery q = session.createSQLQuery(sql);
944    
945                            q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingOrderImpl.class);
946    
947                            QueryPos qPos = QueryPos.getInstance(q);
948    
949                            qPos.add(groupId);
950    
951                            return (List<ShoppingOrder>)QueryUtil.list(q, getDialect(), start,
952                                    end);
953                    }
954                    catch (Exception e) {
955                            throw processException(e);
956                    }
957                    finally {
958                            closeSession(session);
959                    }
960            }
961    
962            /**
963             * Finds the shopping order where number = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchOrderException} if it could not be found.
964             *
965             * @param number the number to search with
966             * @return the matching shopping order
967             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
968             * @throws SystemException if a system exception occurred
969             */
970            public ShoppingOrder findByNumber(String number)
971                    throws NoSuchOrderException, SystemException {
972                    ShoppingOrder shoppingOrder = fetchByNumber(number);
973    
974                    if (shoppingOrder == null) {
975                            StringBundler msg = new StringBundler(4);
976    
977                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
978    
979                            msg.append("number=");
980                            msg.append(number);
981    
982                            msg.append(StringPool.CLOSE_CURLY_BRACE);
983    
984                            if (_log.isWarnEnabled()) {
985                                    _log.warn(msg.toString());
986                            }
987    
988                            throw new NoSuchOrderException(msg.toString());
989                    }
990    
991                    return shoppingOrder;
992            }
993    
994            /**
995             * Finds the shopping order where number = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
996             *
997             * @param number the number to search with
998             * @return the matching shopping order, or <code>null</code> if a matching shopping order could not be found
999             * @throws SystemException if a system exception occurred
1000             */
1001            public ShoppingOrder fetchByNumber(String number) throws SystemException {
1002                    return fetchByNumber(number, true);
1003            }
1004    
1005            /**
1006             * Finds the shopping order where number = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1007             *
1008             * @param number the number to search with
1009             * @return the matching shopping order, or <code>null</code> if a matching shopping order could not be found
1010             * @throws SystemException if a system exception occurred
1011             */
1012            public ShoppingOrder fetchByNumber(String number, boolean retrieveFromCache)
1013                    throws SystemException {
1014                    Object[] finderArgs = new Object[] { number };
1015    
1016                    Object result = null;
1017    
1018                    if (retrieveFromCache) {
1019                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_NUMBER,
1020                                            finderArgs, this);
1021                    }
1022    
1023                    if (result == null) {
1024                            Session session = null;
1025    
1026                            try {
1027                                    session = openSession();
1028    
1029                                    StringBundler query = new StringBundler(3);
1030    
1031                                    query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
1032    
1033                                    if (number == null) {
1034                                            query.append(_FINDER_COLUMN_NUMBER_NUMBER_1);
1035                                    }
1036                                    else {
1037                                            if (number.equals(StringPool.BLANK)) {
1038                                                    query.append(_FINDER_COLUMN_NUMBER_NUMBER_3);
1039                                            }
1040                                            else {
1041                                                    query.append(_FINDER_COLUMN_NUMBER_NUMBER_2);
1042                                            }
1043                                    }
1044    
1045                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1046    
1047                                    String sql = query.toString();
1048    
1049                                    Query q = session.createQuery(sql);
1050    
1051                                    QueryPos qPos = QueryPos.getInstance(q);
1052    
1053                                    if (number != null) {
1054                                            qPos.add(number);
1055                                    }
1056    
1057                                    List<ShoppingOrder> list = q.list();
1058    
1059                                    result = list;
1060    
1061                                    ShoppingOrder shoppingOrder = null;
1062    
1063                                    if (list.isEmpty()) {
1064                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
1065                                                    finderArgs, list);
1066                                    }
1067                                    else {
1068                                            shoppingOrder = list.get(0);
1069    
1070                                            cacheResult(shoppingOrder);
1071    
1072                                            if ((shoppingOrder.getNumber() == null) ||
1073                                                            !shoppingOrder.getNumber().equals(number)) {
1074                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
1075                                                            finderArgs, shoppingOrder);
1076                                            }
1077                                    }
1078    
1079                                    return shoppingOrder;
1080                            }
1081                            catch (Exception e) {
1082                                    throw processException(e);
1083                            }
1084                            finally {
1085                                    if (result == null) {
1086                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
1087                                                    finderArgs, new ArrayList<ShoppingOrder>());
1088                                    }
1089    
1090                                    closeSession(session);
1091                            }
1092                    }
1093                    else {
1094                            if (result instanceof List<?>) {
1095                                    return null;
1096                            }
1097                            else {
1098                                    return (ShoppingOrder)result;
1099                            }
1100                    }
1101            }
1102    
1103            /**
1104             * Finds the shopping order where ppTxnId = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchOrderException} if it could not be found.
1105             *
1106             * @param ppTxnId the pp txn id to search with
1107             * @return the matching shopping order
1108             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
1109             * @throws SystemException if a system exception occurred
1110             */
1111            public ShoppingOrder findByPPTxnId(String ppTxnId)
1112                    throws NoSuchOrderException, SystemException {
1113                    ShoppingOrder shoppingOrder = fetchByPPTxnId(ppTxnId);
1114    
1115                    if (shoppingOrder == null) {
1116                            StringBundler msg = new StringBundler(4);
1117    
1118                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1119    
1120                            msg.append("ppTxnId=");
1121                            msg.append(ppTxnId);
1122    
1123                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1124    
1125                            if (_log.isWarnEnabled()) {
1126                                    _log.warn(msg.toString());
1127                            }
1128    
1129                            throw new NoSuchOrderException(msg.toString());
1130                    }
1131    
1132                    return shoppingOrder;
1133            }
1134    
1135            /**
1136             * Finds the shopping order where ppTxnId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1137             *
1138             * @param ppTxnId the pp txn id to search with
1139             * @return the matching shopping order, or <code>null</code> if a matching shopping order could not be found
1140             * @throws SystemException if a system exception occurred
1141             */
1142            public ShoppingOrder fetchByPPTxnId(String ppTxnId)
1143                    throws SystemException {
1144                    return fetchByPPTxnId(ppTxnId, true);
1145            }
1146    
1147            /**
1148             * Finds the shopping order where ppTxnId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1149             *
1150             * @param ppTxnId the pp txn id to search with
1151             * @return the matching shopping order, or <code>null</code> if a matching shopping order could not be found
1152             * @throws SystemException if a system exception occurred
1153             */
1154            public ShoppingOrder fetchByPPTxnId(String ppTxnId,
1155                    boolean retrieveFromCache) throws SystemException {
1156                    Object[] finderArgs = new Object[] { ppTxnId };
1157    
1158                    Object result = null;
1159    
1160                    if (retrieveFromCache) {
1161                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PPTXNID,
1162                                            finderArgs, this);
1163                    }
1164    
1165                    if (result == null) {
1166                            Session session = null;
1167    
1168                            try {
1169                                    session = openSession();
1170    
1171                                    StringBundler query = new StringBundler(3);
1172    
1173                                    query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
1174    
1175                                    if (ppTxnId == null) {
1176                                            query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_1);
1177                                    }
1178                                    else {
1179                                            if (ppTxnId.equals(StringPool.BLANK)) {
1180                                                    query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_3);
1181                                            }
1182                                            else {
1183                                                    query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_2);
1184                                            }
1185                                    }
1186    
1187                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1188    
1189                                    String sql = query.toString();
1190    
1191                                    Query q = session.createQuery(sql);
1192    
1193                                    QueryPos qPos = QueryPos.getInstance(q);
1194    
1195                                    if (ppTxnId != null) {
1196                                            qPos.add(ppTxnId);
1197                                    }
1198    
1199                                    List<ShoppingOrder> list = q.list();
1200    
1201                                    result = list;
1202    
1203                                    ShoppingOrder shoppingOrder = null;
1204    
1205                                    if (list.isEmpty()) {
1206                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
1207                                                    finderArgs, list);
1208                                    }
1209                                    else {
1210                                            shoppingOrder = list.get(0);
1211    
1212                                            cacheResult(shoppingOrder);
1213    
1214                                            if ((shoppingOrder.getPpTxnId() == null) ||
1215                                                            !shoppingOrder.getPpTxnId().equals(ppTxnId)) {
1216                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
1217                                                            finderArgs, shoppingOrder);
1218                                            }
1219                                    }
1220    
1221                                    return shoppingOrder;
1222                            }
1223                            catch (Exception e) {
1224                                    throw processException(e);
1225                            }
1226                            finally {
1227                                    if (result == null) {
1228                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
1229                                                    finderArgs, new ArrayList<ShoppingOrder>());
1230                                    }
1231    
1232                                    closeSession(session);
1233                            }
1234                    }
1235                    else {
1236                            if (result instanceof List<?>) {
1237                                    return null;
1238                            }
1239                            else {
1240                                    return (ShoppingOrder)result;
1241                            }
1242                    }
1243            }
1244    
1245            /**
1246             * Finds all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1247             *
1248             * @param groupId the group id to search with
1249             * @param userId the user id to search with
1250             * @param ppPaymentStatus the pp payment status to search with
1251             * @return the matching shopping orders
1252             * @throws SystemException if a system exception occurred
1253             */
1254            public List<ShoppingOrder> findByG_U_PPPS(long groupId, long userId,
1255                    String ppPaymentStatus) throws SystemException {
1256                    return findByG_U_PPPS(groupId, userId, ppPaymentStatus,
1257                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1258            }
1259    
1260            /**
1261             * Finds a range of all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1262             *
1263             * <p>
1264             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1265             * </p>
1266             *
1267             * @param groupId the group id to search with
1268             * @param userId the user id to search with
1269             * @param ppPaymentStatus the pp payment status to search with
1270             * @param start the lower bound of the range of shopping orders to return
1271             * @param end the upper bound of the range of shopping orders to return (not inclusive)
1272             * @return the range of matching shopping orders
1273             * @throws SystemException if a system exception occurred
1274             */
1275            public List<ShoppingOrder> findByG_U_PPPS(long groupId, long userId,
1276                    String ppPaymentStatus, int start, int end) throws SystemException {
1277                    return findByG_U_PPPS(groupId, userId, ppPaymentStatus, start, end, null);
1278            }
1279    
1280            /**
1281             * Finds an ordered range of all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1282             *
1283             * <p>
1284             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1285             * </p>
1286             *
1287             * @param groupId the group id to search with
1288             * @param userId the user id to search with
1289             * @param ppPaymentStatus the pp payment status to search with
1290             * @param start the lower bound of the range of shopping orders to return
1291             * @param end the upper bound of the range of shopping orders to return (not inclusive)
1292             * @param orderByComparator the comparator to order the results by
1293             * @return the ordered range of matching shopping orders
1294             * @throws SystemException if a system exception occurred
1295             */
1296            public List<ShoppingOrder> findByG_U_PPPS(long groupId, long userId,
1297                    String ppPaymentStatus, int start, int end,
1298                    OrderByComparator orderByComparator) throws SystemException {
1299                    Object[] finderArgs = new Object[] {
1300                                    groupId, userId, ppPaymentStatus,
1301                                    
1302                                    String.valueOf(start), String.valueOf(end),
1303                                    String.valueOf(orderByComparator)
1304                            };
1305    
1306                    List<ShoppingOrder> list = (List<ShoppingOrder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U_PPPS,
1307                                    finderArgs, this);
1308    
1309                    if (list == null) {
1310                            Session session = null;
1311    
1312                            try {
1313                                    session = openSession();
1314    
1315                                    StringBundler query = null;
1316    
1317                                    if (orderByComparator != null) {
1318                                            query = new StringBundler(5 +
1319                                                            (orderByComparator.getOrderByFields().length * 3));
1320                                    }
1321                                    else {
1322                                            query = new StringBundler(5);
1323                                    }
1324    
1325                                    query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
1326    
1327                                    query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
1328    
1329                                    query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
1330    
1331                                    if (ppPaymentStatus == null) {
1332                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
1333                                    }
1334                                    else {
1335                                            if (ppPaymentStatus.equals(StringPool.BLANK)) {
1336                                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
1337                                            }
1338                                            else {
1339                                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
1340                                            }
1341                                    }
1342    
1343                                    if (orderByComparator != null) {
1344                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1345                                                    orderByComparator);
1346                                    }
1347    
1348                                    else {
1349                                            query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1350                                    }
1351    
1352                                    String sql = query.toString();
1353    
1354                                    Query q = session.createQuery(sql);
1355    
1356                                    QueryPos qPos = QueryPos.getInstance(q);
1357    
1358                                    qPos.add(groupId);
1359    
1360                                    qPos.add(userId);
1361    
1362                                    if (ppPaymentStatus != null) {
1363                                            qPos.add(ppPaymentStatus);
1364                                    }
1365    
1366                                    list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
1367                                                    start, end);
1368                            }
1369                            catch (Exception e) {
1370                                    throw processException(e);
1371                            }
1372                            finally {
1373                                    if (list == null) {
1374                                            list = new ArrayList<ShoppingOrder>();
1375                                    }
1376    
1377                                    cacheResult(list);
1378    
1379                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U_PPPS,
1380                                            finderArgs, list);
1381    
1382                                    closeSession(session);
1383                            }
1384                    }
1385    
1386                    return list;
1387            }
1388    
1389            /**
1390             * Finds the first shopping order in the ordered set where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1391             *
1392             * <p>
1393             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1394             * </p>
1395             *
1396             * @param groupId the group id to search with
1397             * @param userId the user id to search with
1398             * @param ppPaymentStatus the pp payment status to search with
1399             * @param orderByComparator the comparator to order the set by
1400             * @return the first matching shopping order
1401             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
1402             * @throws SystemException if a system exception occurred
1403             */
1404            public ShoppingOrder findByG_U_PPPS_First(long groupId, long userId,
1405                    String ppPaymentStatus, OrderByComparator orderByComparator)
1406                    throws NoSuchOrderException, SystemException {
1407                    List<ShoppingOrder> list = findByG_U_PPPS(groupId, userId,
1408                                    ppPaymentStatus, 0, 1, orderByComparator);
1409    
1410                    if (list.isEmpty()) {
1411                            StringBundler msg = new StringBundler(8);
1412    
1413                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1414    
1415                            msg.append("groupId=");
1416                            msg.append(groupId);
1417    
1418                            msg.append(", userId=");
1419                            msg.append(userId);
1420    
1421                            msg.append(", ppPaymentStatus=");
1422                            msg.append(ppPaymentStatus);
1423    
1424                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1425    
1426                            throw new NoSuchOrderException(msg.toString());
1427                    }
1428                    else {
1429                            return list.get(0);
1430                    }
1431            }
1432    
1433            /**
1434             * Finds the last shopping order in the ordered set where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1435             *
1436             * <p>
1437             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1438             * </p>
1439             *
1440             * @param groupId the group id to search with
1441             * @param userId the user id to search with
1442             * @param ppPaymentStatus the pp payment status to search with
1443             * @param orderByComparator the comparator to order the set by
1444             * @return the last matching shopping order
1445             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
1446             * @throws SystemException if a system exception occurred
1447             */
1448            public ShoppingOrder findByG_U_PPPS_Last(long groupId, long userId,
1449                    String ppPaymentStatus, OrderByComparator orderByComparator)
1450                    throws NoSuchOrderException, SystemException {
1451                    int count = countByG_U_PPPS(groupId, userId, ppPaymentStatus);
1452    
1453                    List<ShoppingOrder> list = findByG_U_PPPS(groupId, userId,
1454                                    ppPaymentStatus, count - 1, count, orderByComparator);
1455    
1456                    if (list.isEmpty()) {
1457                            StringBundler msg = new StringBundler(8);
1458    
1459                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1460    
1461                            msg.append("groupId=");
1462                            msg.append(groupId);
1463    
1464                            msg.append(", userId=");
1465                            msg.append(userId);
1466    
1467                            msg.append(", ppPaymentStatus=");
1468                            msg.append(ppPaymentStatus);
1469    
1470                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1471    
1472                            throw new NoSuchOrderException(msg.toString());
1473                    }
1474                    else {
1475                            return list.get(0);
1476                    }
1477            }
1478    
1479            /**
1480             * Finds the shopping orders before and after the current shopping order in the ordered set where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1481             *
1482             * <p>
1483             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1484             * </p>
1485             *
1486             * @param orderId the primary key of the current shopping order
1487             * @param groupId the group id to search with
1488             * @param userId the user id to search with
1489             * @param ppPaymentStatus the pp payment status to search with
1490             * @param orderByComparator the comparator to order the set by
1491             * @return the previous, current, and next shopping order
1492             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
1493             * @throws SystemException if a system exception occurred
1494             */
1495            public ShoppingOrder[] findByG_U_PPPS_PrevAndNext(long orderId,
1496                    long groupId, long userId, String ppPaymentStatus,
1497                    OrderByComparator orderByComparator)
1498                    throws NoSuchOrderException, SystemException {
1499                    ShoppingOrder shoppingOrder = findByPrimaryKey(orderId);
1500    
1501                    Session session = null;
1502    
1503                    try {
1504                            session = openSession();
1505    
1506                            ShoppingOrder[] array = new ShoppingOrderImpl[3];
1507    
1508                            array[0] = getByG_U_PPPS_PrevAndNext(session, shoppingOrder,
1509                                            groupId, userId, ppPaymentStatus, orderByComparator, true);
1510    
1511                            array[1] = shoppingOrder;
1512    
1513                            array[2] = getByG_U_PPPS_PrevAndNext(session, shoppingOrder,
1514                                            groupId, userId, ppPaymentStatus, orderByComparator, false);
1515    
1516                            return array;
1517                    }
1518                    catch (Exception e) {
1519                            throw processException(e);
1520                    }
1521                    finally {
1522                            closeSession(session);
1523                    }
1524            }
1525    
1526            protected ShoppingOrder getByG_U_PPPS_PrevAndNext(Session session,
1527                    ShoppingOrder shoppingOrder, long groupId, long userId,
1528                    String ppPaymentStatus, OrderByComparator orderByComparator,
1529                    boolean previous) {
1530                    StringBundler query = null;
1531    
1532                    if (orderByComparator != null) {
1533                            query = new StringBundler(6 +
1534                                            (orderByComparator.getOrderByFields().length * 6));
1535                    }
1536                    else {
1537                            query = new StringBundler(3);
1538                    }
1539    
1540                    query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
1541    
1542                    query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
1543    
1544                    query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
1545    
1546                    if (ppPaymentStatus == null) {
1547                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
1548                    }
1549                    else {
1550                            if (ppPaymentStatus.equals(StringPool.BLANK)) {
1551                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
1552                            }
1553                            else {
1554                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
1555                            }
1556                    }
1557    
1558                    if (orderByComparator != null) {
1559                            String[] orderByFields = orderByComparator.getOrderByFields();
1560    
1561                            if (orderByFields.length > 0) {
1562                                    query.append(WHERE_AND);
1563                            }
1564    
1565                            for (int i = 0; i < orderByFields.length; i++) {
1566                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1567                                    query.append(orderByFields[i]);
1568    
1569                                    if ((i + 1) < orderByFields.length) {
1570                                            if (orderByComparator.isAscending() ^ previous) {
1571                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1572                                            }
1573                                            else {
1574                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1575                                            }
1576                                    }
1577                                    else {
1578                                            if (orderByComparator.isAscending() ^ previous) {
1579                                                    query.append(WHERE_GREATER_THAN);
1580                                            }
1581                                            else {
1582                                                    query.append(WHERE_LESSER_THAN);
1583                                            }
1584                                    }
1585                            }
1586    
1587                            query.append(ORDER_BY_CLAUSE);
1588    
1589                            for (int i = 0; i < orderByFields.length; i++) {
1590                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1591                                    query.append(orderByFields[i]);
1592    
1593                                    if ((i + 1) < orderByFields.length) {
1594                                            if (orderByComparator.isAscending() ^ previous) {
1595                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1596                                            }
1597                                            else {
1598                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1599                                            }
1600                                    }
1601                                    else {
1602                                            if (orderByComparator.isAscending() ^ previous) {
1603                                                    query.append(ORDER_BY_ASC);
1604                                            }
1605                                            else {
1606                                                    query.append(ORDER_BY_DESC);
1607                                            }
1608                                    }
1609                            }
1610                    }
1611    
1612                    else {
1613                            query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1614                    }
1615    
1616                    String sql = query.toString();
1617    
1618                    Query q = session.createQuery(sql);
1619    
1620                    q.setFirstResult(0);
1621                    q.setMaxResults(2);
1622    
1623                    QueryPos qPos = QueryPos.getInstance(q);
1624    
1625                    qPos.add(groupId);
1626    
1627                    qPos.add(userId);
1628    
1629                    if (ppPaymentStatus != null) {
1630                            qPos.add(ppPaymentStatus);
1631                    }
1632    
1633                    if (orderByComparator != null) {
1634                            Object[] values = orderByComparator.getOrderByValues(shoppingOrder);
1635    
1636                            for (Object value : values) {
1637                                    qPos.add(value);
1638                            }
1639                    }
1640    
1641                    List<ShoppingOrder> list = q.list();
1642    
1643                    if (list.size() == 2) {
1644                            return list.get(1);
1645                    }
1646                    else {
1647                            return null;
1648                    }
1649            }
1650    
1651            /**
1652             * Filters by the user's permissions and finds all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1653             *
1654             * @param groupId the group id to search with
1655             * @param userId the user id to search with
1656             * @param ppPaymentStatus the pp payment status to search with
1657             * @return the matching shopping orders that the user has permission to view
1658             * @throws SystemException if a system exception occurred
1659             */
1660            public List<ShoppingOrder> filterFindByG_U_PPPS(long groupId, long userId,
1661                    String ppPaymentStatus) throws SystemException {
1662                    return filterFindByG_U_PPPS(groupId, userId, ppPaymentStatus,
1663                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1664            }
1665    
1666            /**
1667             * Filters by the user's permissions and finds a range of all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1668             *
1669             * <p>
1670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1671             * </p>
1672             *
1673             * @param groupId the group id to search with
1674             * @param userId the user id to search with
1675             * @param ppPaymentStatus the pp payment status to search with
1676             * @param start the lower bound of the range of shopping orders to return
1677             * @param end the upper bound of the range of shopping orders to return (not inclusive)
1678             * @return the range of matching shopping orders that the user has permission to view
1679             * @throws SystemException if a system exception occurred
1680             */
1681            public List<ShoppingOrder> filterFindByG_U_PPPS(long groupId, long userId,
1682                    String ppPaymentStatus, int start, int end) throws SystemException {
1683                    return filterFindByG_U_PPPS(groupId, userId, ppPaymentStatus, start,
1684                            end, null);
1685            }
1686    
1687            /**
1688             * Filters by the user's permissions and finds an ordered range of all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1689             *
1690             * <p>
1691             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1692             * </p>
1693             *
1694             * @param groupId the group id to search with
1695             * @param userId the user id to search with
1696             * @param ppPaymentStatus the pp payment status to search with
1697             * @param start the lower bound of the range of shopping orders to return
1698             * @param end the upper bound of the range of shopping orders to return (not inclusive)
1699             * @param orderByComparator the comparator to order the results by
1700             * @return the ordered range of matching shopping orders that the user has permission to view
1701             * @throws SystemException if a system exception occurred
1702             */
1703            public List<ShoppingOrder> filterFindByG_U_PPPS(long groupId, long userId,
1704                    String ppPaymentStatus, int start, int end,
1705                    OrderByComparator orderByComparator) throws SystemException {
1706                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1707                            return findByG_U_PPPS(groupId, userId, ppPaymentStatus, start, end,
1708                                    orderByComparator);
1709                    }
1710    
1711                    Session session = null;
1712    
1713                    try {
1714                            session = openSession();
1715    
1716                            StringBundler query = null;
1717    
1718                            if (orderByComparator != null) {
1719                                    query = new StringBundler(5 +
1720                                                    (orderByComparator.getOrderByFields().length * 3));
1721                            }
1722                            else {
1723                                    query = new StringBundler(5);
1724                            }
1725    
1726                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_WHERE);
1727    
1728                            query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
1729    
1730                            query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
1731    
1732                            if (ppPaymentStatus == null) {
1733                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
1734                            }
1735                            else {
1736                                    if (ppPaymentStatus.equals(StringPool.BLANK)) {
1737                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
1738                                    }
1739                                    else {
1740                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
1741                                    }
1742                            }
1743    
1744                            if (orderByComparator != null) {
1745                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1746                                            orderByComparator);
1747                            }
1748    
1749                            else {
1750                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1751                            }
1752    
1753                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1754                                            ShoppingOrder.class.getName(), _FILTER_COLUMN_PK,
1755                                            _FILTER_COLUMN_USERID, groupId);
1756    
1757                            SQLQuery q = session.createSQLQuery(sql);
1758    
1759                            q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingOrderImpl.class);
1760    
1761                            QueryPos qPos = QueryPos.getInstance(q);
1762    
1763                            qPos.add(groupId);
1764    
1765                            qPos.add(userId);
1766    
1767                            if (ppPaymentStatus != null) {
1768                                    qPos.add(ppPaymentStatus);
1769                            }
1770    
1771                            return (List<ShoppingOrder>)QueryUtil.list(q, getDialect(), start,
1772                                    end);
1773                    }
1774                    catch (Exception e) {
1775                            throw processException(e);
1776                    }
1777                    finally {
1778                            closeSession(session);
1779                    }
1780            }
1781    
1782            /**
1783             * Finds all the shopping orders.
1784             *
1785             * @return the shopping orders
1786             * @throws SystemException if a system exception occurred
1787             */
1788            public List<ShoppingOrder> findAll() throws SystemException {
1789                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1790            }
1791    
1792            /**
1793             * Finds a range of all the shopping orders.
1794             *
1795             * <p>
1796             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1797             * </p>
1798             *
1799             * @param start the lower bound of the range of shopping orders to return
1800             * @param end the upper bound of the range of shopping orders to return (not inclusive)
1801             * @return the range of shopping orders
1802             * @throws SystemException if a system exception occurred
1803             */
1804            public List<ShoppingOrder> findAll(int start, int end)
1805                    throws SystemException {
1806                    return findAll(start, end, null);
1807            }
1808    
1809            /**
1810             * Finds an ordered range of all the shopping orders.
1811             *
1812             * <p>
1813             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1814             * </p>
1815             *
1816             * @param start the lower bound of the range of shopping orders to return
1817             * @param end the upper bound of the range of shopping orders to return (not inclusive)
1818             * @param orderByComparator the comparator to order the results by
1819             * @return the ordered range of shopping orders
1820             * @throws SystemException if a system exception occurred
1821             */
1822            public List<ShoppingOrder> findAll(int start, int end,
1823                    OrderByComparator orderByComparator) throws SystemException {
1824                    Object[] finderArgs = new Object[] {
1825                                    String.valueOf(start), String.valueOf(end),
1826                                    String.valueOf(orderByComparator)
1827                            };
1828    
1829                    List<ShoppingOrder> list = (List<ShoppingOrder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1830                                    finderArgs, this);
1831    
1832                    if (list == null) {
1833                            Session session = null;
1834    
1835                            try {
1836                                    session = openSession();
1837    
1838                                    StringBundler query = null;
1839                                    String sql = null;
1840    
1841                                    if (orderByComparator != null) {
1842                                            query = new StringBundler(2 +
1843                                                            (orderByComparator.getOrderByFields().length * 3));
1844    
1845                                            query.append(_SQL_SELECT_SHOPPINGORDER);
1846    
1847                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1848                                                    orderByComparator);
1849    
1850                                            sql = query.toString();
1851                                    }
1852                                    else {
1853                                            sql = _SQL_SELECT_SHOPPINGORDER.concat(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1854                                    }
1855    
1856                                    Query q = session.createQuery(sql);
1857    
1858                                    if (orderByComparator == null) {
1859                                            list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
1860                                                            start, end, false);
1861    
1862                                            Collections.sort(list);
1863                                    }
1864                                    else {
1865                                            list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
1866                                                            start, end);
1867                                    }
1868                            }
1869                            catch (Exception e) {
1870                                    throw processException(e);
1871                            }
1872                            finally {
1873                                    if (list == null) {
1874                                            list = new ArrayList<ShoppingOrder>();
1875                                    }
1876    
1877                                    cacheResult(list);
1878    
1879                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1880    
1881                                    closeSession(session);
1882                            }
1883                    }
1884    
1885                    return list;
1886            }
1887    
1888            /**
1889             * Removes all the shopping orders where groupId = &#63; from the database.
1890             *
1891             * @param groupId the group id to search with
1892             * @throws SystemException if a system exception occurred
1893             */
1894            public void removeByGroupId(long groupId) throws SystemException {
1895                    for (ShoppingOrder shoppingOrder : findByGroupId(groupId)) {
1896                            remove(shoppingOrder);
1897                    }
1898            }
1899    
1900            /**
1901             * Removes the shopping order where number = &#63; from the database.
1902             *
1903             * @param number the number to search with
1904             * @throws SystemException if a system exception occurred
1905             */
1906            public void removeByNumber(String number)
1907                    throws NoSuchOrderException, SystemException {
1908                    ShoppingOrder shoppingOrder = findByNumber(number);
1909    
1910                    remove(shoppingOrder);
1911            }
1912    
1913            /**
1914             * Removes the shopping order where ppTxnId = &#63; from the database.
1915             *
1916             * @param ppTxnId the pp txn id to search with
1917             * @throws SystemException if a system exception occurred
1918             */
1919            public void removeByPPTxnId(String ppTxnId)
1920                    throws NoSuchOrderException, SystemException {
1921                    ShoppingOrder shoppingOrder = findByPPTxnId(ppTxnId);
1922    
1923                    remove(shoppingOrder);
1924            }
1925    
1926            /**
1927             * Removes all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63; from the database.
1928             *
1929             * @param groupId the group id to search with
1930             * @param userId the user id to search with
1931             * @param ppPaymentStatus the pp payment status to search with
1932             * @throws SystemException if a system exception occurred
1933             */
1934            public void removeByG_U_PPPS(long groupId, long userId,
1935                    String ppPaymentStatus) throws SystemException {
1936                    for (ShoppingOrder shoppingOrder : findByG_U_PPPS(groupId, userId,
1937                                    ppPaymentStatus)) {
1938                            remove(shoppingOrder);
1939                    }
1940            }
1941    
1942            /**
1943             * Removes all the shopping orders from the database.
1944             *
1945             * @throws SystemException if a system exception occurred
1946             */
1947            public void removeAll() throws SystemException {
1948                    for (ShoppingOrder shoppingOrder : findAll()) {
1949                            remove(shoppingOrder);
1950                    }
1951            }
1952    
1953            /**
1954             * Counts all the shopping orders where groupId = &#63;.
1955             *
1956             * @param groupId the group id to search with
1957             * @return the number of matching shopping orders
1958             * @throws SystemException if a system exception occurred
1959             */
1960            public int countByGroupId(long groupId) throws SystemException {
1961                    Object[] finderArgs = new Object[] { groupId };
1962    
1963                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1964                                    finderArgs, this);
1965    
1966                    if (count == null) {
1967                            Session session = null;
1968    
1969                            try {
1970                                    session = openSession();
1971    
1972                                    StringBundler query = new StringBundler(2);
1973    
1974                                    query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
1975    
1976                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1977    
1978                                    String sql = query.toString();
1979    
1980                                    Query q = session.createQuery(sql);
1981    
1982                                    QueryPos qPos = QueryPos.getInstance(q);
1983    
1984                                    qPos.add(groupId);
1985    
1986                                    count = (Long)q.uniqueResult();
1987                            }
1988                            catch (Exception e) {
1989                                    throw processException(e);
1990                            }
1991                            finally {
1992                                    if (count == null) {
1993                                            count = Long.valueOf(0);
1994                                    }
1995    
1996                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1997                                            finderArgs, count);
1998    
1999                                    closeSession(session);
2000                            }
2001                    }
2002    
2003                    return count.intValue();
2004            }
2005    
2006            /**
2007             * Filters by the user's permissions and counts all the shopping orders where groupId = &#63;.
2008             *
2009             * @param groupId the group id to search with
2010             * @return the number of matching shopping orders that the user has permission to view
2011             * @throws SystemException if a system exception occurred
2012             */
2013            public int filterCountByGroupId(long groupId) throws SystemException {
2014                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2015                            return countByGroupId(groupId);
2016                    }
2017    
2018                    Session session = null;
2019    
2020                    try {
2021                            session = openSession();
2022    
2023                            StringBundler query = new StringBundler(2);
2024    
2025                            query.append(_FILTER_SQL_COUNT_SHOPPINGORDER_WHERE);
2026    
2027                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2028    
2029                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2030                                            ShoppingOrder.class.getName(), _FILTER_COLUMN_PK,
2031                                            _FILTER_COLUMN_USERID, groupId);
2032    
2033                            SQLQuery q = session.createSQLQuery(sql);
2034    
2035                            q.addScalar(COUNT_COLUMN_NAME,
2036                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2037    
2038                            QueryPos qPos = QueryPos.getInstance(q);
2039    
2040                            qPos.add(groupId);
2041    
2042                            Long count = (Long)q.uniqueResult();
2043    
2044                            return count.intValue();
2045                    }
2046                    catch (Exception e) {
2047                            throw processException(e);
2048                    }
2049                    finally {
2050                            closeSession(session);
2051                    }
2052            }
2053    
2054            /**
2055             * Counts all the shopping orders where number = &#63;.
2056             *
2057             * @param number the number to search with
2058             * @return the number of matching shopping orders
2059             * @throws SystemException if a system exception occurred
2060             */
2061            public int countByNumber(String number) throws SystemException {
2062                    Object[] finderArgs = new Object[] { number };
2063    
2064                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NUMBER,
2065                                    finderArgs, this);
2066    
2067                    if (count == null) {
2068                            Session session = null;
2069    
2070                            try {
2071                                    session = openSession();
2072    
2073                                    StringBundler query = new StringBundler(2);
2074    
2075                                    query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
2076    
2077                                    if (number == null) {
2078                                            query.append(_FINDER_COLUMN_NUMBER_NUMBER_1);
2079                                    }
2080                                    else {
2081                                            if (number.equals(StringPool.BLANK)) {
2082                                                    query.append(_FINDER_COLUMN_NUMBER_NUMBER_3);
2083                                            }
2084                                            else {
2085                                                    query.append(_FINDER_COLUMN_NUMBER_NUMBER_2);
2086                                            }
2087                                    }
2088    
2089                                    String sql = query.toString();
2090    
2091                                    Query q = session.createQuery(sql);
2092    
2093                                    QueryPos qPos = QueryPos.getInstance(q);
2094    
2095                                    if (number != null) {
2096                                            qPos.add(number);
2097                                    }
2098    
2099                                    count = (Long)q.uniqueResult();
2100                            }
2101                            catch (Exception e) {
2102                                    throw processException(e);
2103                            }
2104                            finally {
2105                                    if (count == null) {
2106                                            count = Long.valueOf(0);
2107                                    }
2108    
2109                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NUMBER,
2110                                            finderArgs, count);
2111    
2112                                    closeSession(session);
2113                            }
2114                    }
2115    
2116                    return count.intValue();
2117            }
2118    
2119            /**
2120             * Counts all the shopping orders where ppTxnId = &#63;.
2121             *
2122             * @param ppTxnId the pp txn id to search with
2123             * @return the number of matching shopping orders
2124             * @throws SystemException if a system exception occurred
2125             */
2126            public int countByPPTxnId(String ppTxnId) throws SystemException {
2127                    Object[] finderArgs = new Object[] { ppTxnId };
2128    
2129                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PPTXNID,
2130                                    finderArgs, this);
2131    
2132                    if (count == null) {
2133                            Session session = null;
2134    
2135                            try {
2136                                    session = openSession();
2137    
2138                                    StringBundler query = new StringBundler(2);
2139    
2140                                    query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
2141    
2142                                    if (ppTxnId == null) {
2143                                            query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_1);
2144                                    }
2145                                    else {
2146                                            if (ppTxnId.equals(StringPool.BLANK)) {
2147                                                    query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_3);
2148                                            }
2149                                            else {
2150                                                    query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_2);
2151                                            }
2152                                    }
2153    
2154                                    String sql = query.toString();
2155    
2156                                    Query q = session.createQuery(sql);
2157    
2158                                    QueryPos qPos = QueryPos.getInstance(q);
2159    
2160                                    if (ppTxnId != null) {
2161                                            qPos.add(ppTxnId);
2162                                    }
2163    
2164                                    count = (Long)q.uniqueResult();
2165                            }
2166                            catch (Exception e) {
2167                                    throw processException(e);
2168                            }
2169                            finally {
2170                                    if (count == null) {
2171                                            count = Long.valueOf(0);
2172                                    }
2173    
2174                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PPTXNID,
2175                                            finderArgs, count);
2176    
2177                                    closeSession(session);
2178                            }
2179                    }
2180    
2181                    return count.intValue();
2182            }
2183    
2184            /**
2185             * Counts all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
2186             *
2187             * @param groupId the group id to search with
2188             * @param userId the user id to search with
2189             * @param ppPaymentStatus the pp payment status to search with
2190             * @return the number of matching shopping orders
2191             * @throws SystemException if a system exception occurred
2192             */
2193            public int countByG_U_PPPS(long groupId, long userId, String ppPaymentStatus)
2194                    throws SystemException {
2195                    Object[] finderArgs = new Object[] { groupId, userId, ppPaymentStatus };
2196    
2197                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_PPPS,
2198                                    finderArgs, this);
2199    
2200                    if (count == null) {
2201                            Session session = null;
2202    
2203                            try {
2204                                    session = openSession();
2205    
2206                                    StringBundler query = new StringBundler(4);
2207    
2208                                    query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
2209    
2210                                    query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
2211    
2212                                    query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
2213    
2214                                    if (ppPaymentStatus == null) {
2215                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
2216                                    }
2217                                    else {
2218                                            if (ppPaymentStatus.equals(StringPool.BLANK)) {
2219                                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
2220                                            }
2221                                            else {
2222                                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
2223                                            }
2224                                    }
2225    
2226                                    String sql = query.toString();
2227    
2228                                    Query q = session.createQuery(sql);
2229    
2230                                    QueryPos qPos = QueryPos.getInstance(q);
2231    
2232                                    qPos.add(groupId);
2233    
2234                                    qPos.add(userId);
2235    
2236                                    if (ppPaymentStatus != null) {
2237                                            qPos.add(ppPaymentStatus);
2238                                    }
2239    
2240                                    count = (Long)q.uniqueResult();
2241                            }
2242                            catch (Exception e) {
2243                                    throw processException(e);
2244                            }
2245                            finally {
2246                                    if (count == null) {
2247                                            count = Long.valueOf(0);
2248                                    }
2249    
2250                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_PPPS,
2251                                            finderArgs, count);
2252    
2253                                    closeSession(session);
2254                            }
2255                    }
2256    
2257                    return count.intValue();
2258            }
2259    
2260            /**
2261             * Filters by the user's permissions and counts all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
2262             *
2263             * @param groupId the group id to search with
2264             * @param userId the user id to search with
2265             * @param ppPaymentStatus the pp payment status to search with
2266             * @return the number of matching shopping orders that the user has permission to view
2267             * @throws SystemException if a system exception occurred
2268             */
2269            public int filterCountByG_U_PPPS(long groupId, long userId,
2270                    String ppPaymentStatus) throws SystemException {
2271                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2272                            return countByG_U_PPPS(groupId, userId, ppPaymentStatus);
2273                    }
2274    
2275                    Session session = null;
2276    
2277                    try {
2278                            session = openSession();
2279    
2280                            StringBundler query = new StringBundler(4);
2281    
2282                            query.append(_FILTER_SQL_COUNT_SHOPPINGORDER_WHERE);
2283    
2284                            query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
2285    
2286                            query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
2287    
2288                            if (ppPaymentStatus == null) {
2289                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
2290                            }
2291                            else {
2292                                    if (ppPaymentStatus.equals(StringPool.BLANK)) {
2293                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
2294                                    }
2295                                    else {
2296                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
2297                                    }
2298                            }
2299    
2300                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2301                                            ShoppingOrder.class.getName(), _FILTER_COLUMN_PK,
2302                                            _FILTER_COLUMN_USERID, groupId);
2303    
2304                            SQLQuery q = session.createSQLQuery(sql);
2305    
2306                            q.addScalar(COUNT_COLUMN_NAME,
2307                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2308    
2309                            QueryPos qPos = QueryPos.getInstance(q);
2310    
2311                            qPos.add(groupId);
2312    
2313                            qPos.add(userId);
2314    
2315                            if (ppPaymentStatus != null) {
2316                                    qPos.add(ppPaymentStatus);
2317                            }
2318    
2319                            Long count = (Long)q.uniqueResult();
2320    
2321                            return count.intValue();
2322                    }
2323                    catch (Exception e) {
2324                            throw processException(e);
2325                    }
2326                    finally {
2327                            closeSession(session);
2328                    }
2329            }
2330    
2331            /**
2332             * Counts all the shopping orders.
2333             *
2334             * @return the number of shopping orders
2335             * @throws SystemException if a system exception occurred
2336             */
2337            public int countAll() throws SystemException {
2338                    Object[] finderArgs = new Object[0];
2339    
2340                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2341                                    finderArgs, this);
2342    
2343                    if (count == null) {
2344                            Session session = null;
2345    
2346                            try {
2347                                    session = openSession();
2348    
2349                                    Query q = session.createQuery(_SQL_COUNT_SHOPPINGORDER);
2350    
2351                                    count = (Long)q.uniqueResult();
2352                            }
2353                            catch (Exception e) {
2354                                    throw processException(e);
2355                            }
2356                            finally {
2357                                    if (count == null) {
2358                                            count = Long.valueOf(0);
2359                                    }
2360    
2361                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2362                                            count);
2363    
2364                                    closeSession(session);
2365                            }
2366                    }
2367    
2368                    return count.intValue();
2369            }
2370    
2371            /**
2372             * Initializes the shopping order persistence.
2373             */
2374            public void afterPropertiesSet() {
2375                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2376                                            com.liferay.portal.util.PropsUtil.get(
2377                                                    "value.object.listener.com.liferay.portlet.shopping.model.ShoppingOrder")));
2378    
2379                    if (listenerClassNames.length > 0) {
2380                            try {
2381                                    List<ModelListener<ShoppingOrder>> listenersList = new ArrayList<ModelListener<ShoppingOrder>>();
2382    
2383                                    for (String listenerClassName : listenerClassNames) {
2384                                            listenersList.add((ModelListener<ShoppingOrder>)InstanceFactory.newInstance(
2385                                                            listenerClassName));
2386                                    }
2387    
2388                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2389                            }
2390                            catch (Exception e) {
2391                                    _log.error(e);
2392                            }
2393                    }
2394            }
2395    
2396            @BeanReference(type = ShoppingCartPersistence.class)
2397            protected ShoppingCartPersistence shoppingCartPersistence;
2398            @BeanReference(type = ShoppingCategoryPersistence.class)
2399            protected ShoppingCategoryPersistence shoppingCategoryPersistence;
2400            @BeanReference(type = ShoppingCouponPersistence.class)
2401            protected ShoppingCouponPersistence shoppingCouponPersistence;
2402            @BeanReference(type = ShoppingItemPersistence.class)
2403            protected ShoppingItemPersistence shoppingItemPersistence;
2404            @BeanReference(type = ShoppingItemFieldPersistence.class)
2405            protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
2406            @BeanReference(type = ShoppingItemPricePersistence.class)
2407            protected ShoppingItemPricePersistence shoppingItemPricePersistence;
2408            @BeanReference(type = ShoppingOrderPersistence.class)
2409            protected ShoppingOrderPersistence shoppingOrderPersistence;
2410            @BeanReference(type = ShoppingOrderItemPersistence.class)
2411            protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
2412            @BeanReference(type = CompanyPersistence.class)
2413            protected CompanyPersistence companyPersistence;
2414            @BeanReference(type = ResourcePersistence.class)
2415            protected ResourcePersistence resourcePersistence;
2416            @BeanReference(type = UserPersistence.class)
2417            protected UserPersistence userPersistence;
2418            @BeanReference(type = MBMessagePersistence.class)
2419            protected MBMessagePersistence mbMessagePersistence;
2420            private static final String _SQL_SELECT_SHOPPINGORDER = "SELECT shoppingOrder FROM ShoppingOrder shoppingOrder";
2421            private static final String _SQL_SELECT_SHOPPINGORDER_WHERE = "SELECT shoppingOrder FROM ShoppingOrder shoppingOrder WHERE ";
2422            private static final String _SQL_COUNT_SHOPPINGORDER = "SELECT COUNT(shoppingOrder) FROM ShoppingOrder shoppingOrder";
2423            private static final String _SQL_COUNT_SHOPPINGORDER_WHERE = "SELECT COUNT(shoppingOrder) FROM ShoppingOrder shoppingOrder WHERE ";
2424            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "shoppingOrder.groupId = ?";
2425            private static final String _FINDER_COLUMN_NUMBER_NUMBER_1 = "shoppingOrder.number IS NULL";
2426            private static final String _FINDER_COLUMN_NUMBER_NUMBER_2 = "shoppingOrder.number = ?";
2427            private static final String _FINDER_COLUMN_NUMBER_NUMBER_3 = "(shoppingOrder.number IS NULL OR shoppingOrder.number = ?)";
2428            private static final String _FINDER_COLUMN_PPTXNID_PPTXNID_1 = "shoppingOrder.ppTxnId IS NULL";
2429            private static final String _FINDER_COLUMN_PPTXNID_PPTXNID_2 = "shoppingOrder.ppTxnId = ?";
2430            private static final String _FINDER_COLUMN_PPTXNID_PPTXNID_3 = "(shoppingOrder.ppTxnId IS NULL OR shoppingOrder.ppTxnId = ?)";
2431            private static final String _FINDER_COLUMN_G_U_PPPS_GROUPID_2 = "shoppingOrder.groupId = ? AND ";
2432            private static final String _FINDER_COLUMN_G_U_PPPS_USERID_2 = "shoppingOrder.userId = ? AND ";
2433            private static final String _FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1 = "shoppingOrder.ppPaymentStatus IS NULL";
2434            private static final String _FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2 = "shoppingOrder.ppPaymentStatus = ?";
2435            private static final String _FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3 = "(shoppingOrder.ppPaymentStatus IS NULL OR shoppingOrder.ppPaymentStatus = ?)";
2436            private static final String _FILTER_SQL_SELECT_SHOPPINGORDER_WHERE = "SELECT DISTINCT {shoppingOrder.*} FROM ShoppingOrder shoppingOrder WHERE ";
2437            private static final String _FILTER_SQL_COUNT_SHOPPINGORDER_WHERE = "SELECT COUNT(DISTINCT shoppingOrder.orderId) AS COUNT_VALUE FROM ShoppingOrder shoppingOrder WHERE ";
2438            private static final String _FILTER_COLUMN_PK = "shoppingOrder.orderId";
2439            private static final String _FILTER_COLUMN_USERID = "shoppingOrder.userId";
2440            private static final String _FILTER_ENTITY_ALIAS = "shoppingOrder";
2441            private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingOrder.";
2442            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingOrder exists with the primary key ";
2443            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingOrder exists with the key {";
2444            private static Log _log = LogFactoryUtil.getLog(ShoppingOrderPersistenceImpl.class);
2445    }