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