001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.shopping.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.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.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041    import com.liferay.portal.service.persistence.BatchSessionUtil;
042    import com.liferay.portal.service.persistence.CompanyPersistence;
043    import com.liferay.portal.service.persistence.ResourcePersistence;
044    import com.liferay.portal.service.persistence.SubscriptionPersistence;
045    import com.liferay.portal.service.persistence.UserPersistence;
046    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047    
048    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
049    import com.liferay.portlet.shopping.NoSuchOrderException;
050    import com.liferay.portlet.shopping.model.ShoppingOrder;
051    import com.liferay.portlet.shopping.model.impl.ShoppingOrderImpl;
052    import com.liferay.portlet.shopping.model.impl.ShoppingOrderModelImpl;
053    
054    import java.io.Serializable;
055    
056    import java.util.ArrayList;
057    import java.util.Collections;
058    import java.util.List;
059    
060    /**
061     * The persistence implementation for the shopping order service.
062     *
063     * <p>
064     * Caching information and settings can be found in <code>portal.properties</code>
065     * </p>
066     *
067     * @author Brian Wing Shun Chan
068     * @see ShoppingOrderPersistence
069     * @see ShoppingOrderUtil
070     * @generated
071     */
072    public class ShoppingOrderPersistenceImpl extends BasePersistenceImpl<ShoppingOrder>
073            implements ShoppingOrderPersistence {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * 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.
078             */
079            public static final String FINDER_CLASS_NAME_ENTITY = ShoppingOrderImpl.class.getName();
080            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List1";
082            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List2";
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
085                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
086                            ShoppingOrderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
087                            "findByGroupId",
088                            new String[] {
089                                    Long.class.getName(),
090                                    
091                            "java.lang.Integer", "java.lang.Integer",
092                                    "com.liferay.portal.kernel.util.OrderByComparator"
093                            });
094            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
095                    new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
096                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
097                            ShoppingOrderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
098                            "findByGroupId", new String[] { Long.class.getName() },
099                            ShoppingOrderModelImpl.GROUPID_COLUMN_BITMASK);
100            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
101                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED, Long.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
103                            new String[] { Long.class.getName() });
104            public static final FinderPath FINDER_PATH_FETCH_BY_NUMBER = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
105                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
106                            ShoppingOrderImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByNumber",
107                            new String[] { String.class.getName() },
108                            ShoppingOrderModelImpl.NUMBER_COLUMN_BITMASK);
109            public static final FinderPath FINDER_PATH_COUNT_BY_NUMBER = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
110                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED, Long.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByNumber",
112                            new String[] { String.class.getName() });
113            public static final FinderPath FINDER_PATH_FETCH_BY_PPTXNID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
114                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
115                            ShoppingOrderImpl.class, FINDER_CLASS_NAME_ENTITY,
116                            "fetchByPPTxnId", new String[] { String.class.getName() },
117                            ShoppingOrderModelImpl.PPTXNID_COLUMN_BITMASK);
118            public static final FinderPath FINDER_PATH_COUNT_BY_PPTXNID = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
119                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED, Long.class,
120                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPPTxnId",
121                            new String[] { String.class.getName() });
122            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_PPPS = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
123                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
124                            ShoppingOrderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
125                            "findByG_U_PPPS",
126                            new String[] {
127                                    Long.class.getName(), Long.class.getName(),
128                                    String.class.getName(),
129                                    
130                            "java.lang.Integer", "java.lang.Integer",
131                                    "com.liferay.portal.kernel.util.OrderByComparator"
132                            });
133            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_PPPS =
134                    new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
135                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
136                            ShoppingOrderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
137                            "findByG_U_PPPS",
138                            new String[] {
139                                    Long.class.getName(), Long.class.getName(),
140                                    String.class.getName()
141                            },
142                            ShoppingOrderModelImpl.GROUPID_COLUMN_BITMASK |
143                            ShoppingOrderModelImpl.USERID_COLUMN_BITMASK |
144                            ShoppingOrderModelImpl.PPPAYMENTSTATUS_COLUMN_BITMASK);
145            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_PPPS = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
146                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED, Long.class,
147                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_PPPS",
148                            new String[] {
149                                    Long.class.getName(), Long.class.getName(),
150                                    String.class.getName()
151                            });
152            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
153                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
154                            ShoppingOrderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
155                            "findAll", new String[0]);
156            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
157                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED,
158                            ShoppingOrderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
159                            "findAll", new String[0]);
160            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
161                            ShoppingOrderModelImpl.FINDER_CACHE_ENABLED, Long.class,
162                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
163    
164            /**
165             * Caches the shopping order in the entity cache if it is enabled.
166             *
167             * @param shoppingOrder the shopping order
168             */
169            public void cacheResult(ShoppingOrder shoppingOrder) {
170                    EntityCacheUtil.putResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
171                            ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey(),
172                            shoppingOrder);
173    
174                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
175                            new Object[] { shoppingOrder.getNumber() }, shoppingOrder);
176    
177                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
178                            new Object[] { shoppingOrder.getPpTxnId() }, shoppingOrder);
179    
180                    shoppingOrder.resetOriginalValues();
181            }
182    
183            /**
184             * Caches the shopping orders in the entity cache if it is enabled.
185             *
186             * @param shoppingOrders the shopping orders
187             */
188            public void cacheResult(List<ShoppingOrder> shoppingOrders) {
189                    for (ShoppingOrder shoppingOrder : shoppingOrders) {
190                            if (EntityCacheUtil.getResult(
191                                                    ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
192                                                    ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey()) == null) {
193                                    cacheResult(shoppingOrder);
194                            }
195                            else {
196                                    shoppingOrder.resetOriginalValues();
197                            }
198                    }
199            }
200    
201            /**
202             * Clears the cache for all shopping orders.
203             *
204             * <p>
205             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
206             * </p>
207             */
208            @Override
209            public void clearCache() {
210                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
211                            CacheRegistryUtil.clear(ShoppingOrderImpl.class.getName());
212                    }
213    
214                    EntityCacheUtil.clearCache(ShoppingOrderImpl.class.getName());
215    
216                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
217                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
218                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
219            }
220    
221            /**
222             * Clears the cache for the shopping order.
223             *
224             * <p>
225             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
226             * </p>
227             */
228            @Override
229            public void clearCache(ShoppingOrder shoppingOrder) {
230                    EntityCacheUtil.removeResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
231                            ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey());
232    
233                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
234                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
235    
236                    clearUniqueFindersCache(shoppingOrder);
237            }
238    
239            @Override
240            public void clearCache(List<ShoppingOrder> shoppingOrders) {
241                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
242                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
243    
244                    for (ShoppingOrder shoppingOrder : shoppingOrders) {
245                            EntityCacheUtil.removeResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
246                                    ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey());
247    
248                            clearUniqueFindersCache(shoppingOrder);
249                    }
250            }
251    
252            protected void cacheUniqueFindersCache(ShoppingOrder shoppingOrder) {
253                    if (shoppingOrder.isNew()) {
254                            Object[] args = new Object[] { shoppingOrder.getNumber() };
255    
256                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NUMBER, args,
257                                    Long.valueOf(1));
258                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER, args,
259                                    shoppingOrder);
260    
261                            args = new Object[] { shoppingOrder.getPpTxnId() };
262    
263                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PPTXNID, args,
264                                    Long.valueOf(1));
265                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID, args,
266                                    shoppingOrder);
267                    }
268                    else {
269                            ShoppingOrderModelImpl shoppingOrderModelImpl = (ShoppingOrderModelImpl)shoppingOrder;
270    
271                            if ((shoppingOrderModelImpl.getColumnBitmask() &
272                                            FINDER_PATH_FETCH_BY_NUMBER.getColumnBitmask()) != 0) {
273                                    Object[] args = new Object[] { shoppingOrder.getNumber() };
274    
275                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NUMBER, args,
276                                            Long.valueOf(1));
277                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER, args,
278                                            shoppingOrder);
279                            }
280    
281                            if ((shoppingOrderModelImpl.getColumnBitmask() &
282                                            FINDER_PATH_FETCH_BY_PPTXNID.getColumnBitmask()) != 0) {
283                                    Object[] args = new Object[] { shoppingOrder.getPpTxnId() };
284    
285                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PPTXNID, args,
286                                            Long.valueOf(1));
287                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID, args,
288                                            shoppingOrder);
289                            }
290                    }
291            }
292    
293            protected void clearUniqueFindersCache(ShoppingOrder shoppingOrder) {
294                    ShoppingOrderModelImpl shoppingOrderModelImpl = (ShoppingOrderModelImpl)shoppingOrder;
295    
296                    Object[] args = new Object[] { shoppingOrder.getNumber() };
297    
298                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NUMBER, args);
299                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NUMBER, args);
300    
301                    if ((shoppingOrderModelImpl.getColumnBitmask() &
302                                    FINDER_PATH_FETCH_BY_NUMBER.getColumnBitmask()) != 0) {
303                            args = new Object[] { shoppingOrderModelImpl.getOriginalNumber() };
304    
305                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NUMBER, args);
306                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NUMBER, args);
307                    }
308    
309                    args = new Object[] { shoppingOrder.getPpTxnId() };
310    
311                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PPTXNID, args);
312                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PPTXNID, args);
313    
314                    if ((shoppingOrderModelImpl.getColumnBitmask() &
315                                    FINDER_PATH_FETCH_BY_PPTXNID.getColumnBitmask()) != 0) {
316                            args = new Object[] { shoppingOrderModelImpl.getOriginalPpTxnId() };
317    
318                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PPTXNID, args);
319                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PPTXNID, args);
320                    }
321            }
322    
323            /**
324             * Creates a new shopping order with the primary key. Does not add the shopping order to the database.
325             *
326             * @param orderId the primary key for the new shopping order
327             * @return the new shopping order
328             */
329            public ShoppingOrder create(long orderId) {
330                    ShoppingOrder shoppingOrder = new ShoppingOrderImpl();
331    
332                    shoppingOrder.setNew(true);
333                    shoppingOrder.setPrimaryKey(orderId);
334    
335                    return shoppingOrder;
336            }
337    
338            /**
339             * Removes the shopping order with the primary key from the database. Also notifies the appropriate model listeners.
340             *
341             * @param orderId the primary key of the shopping order
342             * @return the shopping order that was removed
343             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
344             * @throws SystemException if a system exception occurred
345             */
346            public ShoppingOrder remove(long orderId)
347                    throws NoSuchOrderException, SystemException {
348                    return remove(Long.valueOf(orderId));
349            }
350    
351            /**
352             * Removes the shopping order with the primary key from the database. Also notifies the appropriate model listeners.
353             *
354             * @param primaryKey the primary key of the shopping order
355             * @return the shopping order that was removed
356             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
357             * @throws SystemException if a system exception occurred
358             */
359            @Override
360            public ShoppingOrder remove(Serializable primaryKey)
361                    throws NoSuchOrderException, SystemException {
362                    Session session = null;
363    
364                    try {
365                            session = openSession();
366    
367                            ShoppingOrder shoppingOrder = (ShoppingOrder)session.get(ShoppingOrderImpl.class,
368                                            primaryKey);
369    
370                            if (shoppingOrder == null) {
371                                    if (_log.isWarnEnabled()) {
372                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
373                                    }
374    
375                                    throw new NoSuchOrderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
376                                            primaryKey);
377                            }
378    
379                            return remove(shoppingOrder);
380                    }
381                    catch (NoSuchOrderException nsee) {
382                            throw nsee;
383                    }
384                    catch (Exception e) {
385                            throw processException(e);
386                    }
387                    finally {
388                            closeSession(session);
389                    }
390            }
391    
392            @Override
393            protected ShoppingOrder removeImpl(ShoppingOrder shoppingOrder)
394                    throws SystemException {
395                    shoppingOrder = toUnwrappedModel(shoppingOrder);
396    
397                    Session session = null;
398    
399                    try {
400                            session = openSession();
401    
402                            BatchSessionUtil.delete(session, shoppingOrder);
403                    }
404                    catch (Exception e) {
405                            throw processException(e);
406                    }
407                    finally {
408                            closeSession(session);
409                    }
410    
411                    clearCache(shoppingOrder);
412    
413                    return shoppingOrder;
414            }
415    
416            @Override
417            public ShoppingOrder updateImpl(
418                    com.liferay.portlet.shopping.model.ShoppingOrder shoppingOrder,
419                    boolean merge) throws SystemException {
420                    shoppingOrder = toUnwrappedModel(shoppingOrder);
421    
422                    boolean isNew = shoppingOrder.isNew();
423    
424                    ShoppingOrderModelImpl shoppingOrderModelImpl = (ShoppingOrderModelImpl)shoppingOrder;
425    
426                    Session session = null;
427    
428                    try {
429                            session = openSession();
430    
431                            BatchSessionUtil.update(session, shoppingOrder, merge);
432    
433                            shoppingOrder.setNew(false);
434                    }
435                    catch (Exception e) {
436                            throw processException(e);
437                    }
438                    finally {
439                            closeSession(session);
440                    }
441    
442                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
443    
444                    if (isNew || !ShoppingOrderModelImpl.COLUMN_BITMASK_ENABLED) {
445                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
446                    }
447    
448                    else {
449                            if ((shoppingOrderModelImpl.getColumnBitmask() &
450                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
451                                    Object[] args = new Object[] {
452                                                    Long.valueOf(shoppingOrderModelImpl.getOriginalGroupId())
453                                            };
454    
455                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
456                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
457                                            args);
458    
459                                    args = new Object[] {
460                                                    Long.valueOf(shoppingOrderModelImpl.getGroupId())
461                                            };
462    
463                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
464                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
465                                            args);
466                            }
467    
468                            if ((shoppingOrderModelImpl.getColumnBitmask() &
469                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_PPPS.getColumnBitmask()) != 0) {
470                                    Object[] args = new Object[] {
471                                                    Long.valueOf(shoppingOrderModelImpl.getOriginalGroupId()),
472                                                    Long.valueOf(shoppingOrderModelImpl.getOriginalUserId()),
473                                                    
474                                                    shoppingOrderModelImpl.getOriginalPpPaymentStatus()
475                                            };
476    
477                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_PPPS, args);
478                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_PPPS,
479                                            args);
480    
481                                    args = new Object[] {
482                                                    Long.valueOf(shoppingOrderModelImpl.getGroupId()),
483                                                    Long.valueOf(shoppingOrderModelImpl.getUserId()),
484                                                    
485                                                    shoppingOrderModelImpl.getPpPaymentStatus()
486                                            };
487    
488                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_PPPS, args);
489                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_PPPS,
490                                            args);
491                            }
492                    }
493    
494                    EntityCacheUtil.putResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
495                            ShoppingOrderImpl.class, shoppingOrder.getPrimaryKey(),
496                            shoppingOrder);
497    
498                    clearUniqueFindersCache(shoppingOrder);
499                    cacheUniqueFindersCache(shoppingOrder);
500    
501                    return shoppingOrder;
502            }
503    
504            protected ShoppingOrder toUnwrappedModel(ShoppingOrder shoppingOrder) {
505                    if (shoppingOrder instanceof ShoppingOrderImpl) {
506                            return shoppingOrder;
507                    }
508    
509                    ShoppingOrderImpl shoppingOrderImpl = new ShoppingOrderImpl();
510    
511                    shoppingOrderImpl.setNew(shoppingOrder.isNew());
512                    shoppingOrderImpl.setPrimaryKey(shoppingOrder.getPrimaryKey());
513    
514                    shoppingOrderImpl.setOrderId(shoppingOrder.getOrderId());
515                    shoppingOrderImpl.setGroupId(shoppingOrder.getGroupId());
516                    shoppingOrderImpl.setCompanyId(shoppingOrder.getCompanyId());
517                    shoppingOrderImpl.setUserId(shoppingOrder.getUserId());
518                    shoppingOrderImpl.setUserName(shoppingOrder.getUserName());
519                    shoppingOrderImpl.setCreateDate(shoppingOrder.getCreateDate());
520                    shoppingOrderImpl.setModifiedDate(shoppingOrder.getModifiedDate());
521                    shoppingOrderImpl.setNumber(shoppingOrder.getNumber());
522                    shoppingOrderImpl.setTax(shoppingOrder.getTax());
523                    shoppingOrderImpl.setShipping(shoppingOrder.getShipping());
524                    shoppingOrderImpl.setAltShipping(shoppingOrder.getAltShipping());
525                    shoppingOrderImpl.setRequiresShipping(shoppingOrder.isRequiresShipping());
526                    shoppingOrderImpl.setInsure(shoppingOrder.isInsure());
527                    shoppingOrderImpl.setInsurance(shoppingOrder.getInsurance());
528                    shoppingOrderImpl.setCouponCodes(shoppingOrder.getCouponCodes());
529                    shoppingOrderImpl.setCouponDiscount(shoppingOrder.getCouponDiscount());
530                    shoppingOrderImpl.setBillingFirstName(shoppingOrder.getBillingFirstName());
531                    shoppingOrderImpl.setBillingLastName(shoppingOrder.getBillingLastName());
532                    shoppingOrderImpl.setBillingEmailAddress(shoppingOrder.getBillingEmailAddress());
533                    shoppingOrderImpl.setBillingCompany(shoppingOrder.getBillingCompany());
534                    shoppingOrderImpl.setBillingStreet(shoppingOrder.getBillingStreet());
535                    shoppingOrderImpl.setBillingCity(shoppingOrder.getBillingCity());
536                    shoppingOrderImpl.setBillingState(shoppingOrder.getBillingState());
537                    shoppingOrderImpl.setBillingZip(shoppingOrder.getBillingZip());
538                    shoppingOrderImpl.setBillingCountry(shoppingOrder.getBillingCountry());
539                    shoppingOrderImpl.setBillingPhone(shoppingOrder.getBillingPhone());
540                    shoppingOrderImpl.setShipToBilling(shoppingOrder.isShipToBilling());
541                    shoppingOrderImpl.setShippingFirstName(shoppingOrder.getShippingFirstName());
542                    shoppingOrderImpl.setShippingLastName(shoppingOrder.getShippingLastName());
543                    shoppingOrderImpl.setShippingEmailAddress(shoppingOrder.getShippingEmailAddress());
544                    shoppingOrderImpl.setShippingCompany(shoppingOrder.getShippingCompany());
545                    shoppingOrderImpl.setShippingStreet(shoppingOrder.getShippingStreet());
546                    shoppingOrderImpl.setShippingCity(shoppingOrder.getShippingCity());
547                    shoppingOrderImpl.setShippingState(shoppingOrder.getShippingState());
548                    shoppingOrderImpl.setShippingZip(shoppingOrder.getShippingZip());
549                    shoppingOrderImpl.setShippingCountry(shoppingOrder.getShippingCountry());
550                    shoppingOrderImpl.setShippingPhone(shoppingOrder.getShippingPhone());
551                    shoppingOrderImpl.setCcName(shoppingOrder.getCcName());
552                    shoppingOrderImpl.setCcType(shoppingOrder.getCcType());
553                    shoppingOrderImpl.setCcNumber(shoppingOrder.getCcNumber());
554                    shoppingOrderImpl.setCcExpMonth(shoppingOrder.getCcExpMonth());
555                    shoppingOrderImpl.setCcExpYear(shoppingOrder.getCcExpYear());
556                    shoppingOrderImpl.setCcVerNumber(shoppingOrder.getCcVerNumber());
557                    shoppingOrderImpl.setComments(shoppingOrder.getComments());
558                    shoppingOrderImpl.setPpTxnId(shoppingOrder.getPpTxnId());
559                    shoppingOrderImpl.setPpPaymentStatus(shoppingOrder.getPpPaymentStatus());
560                    shoppingOrderImpl.setPpPaymentGross(shoppingOrder.getPpPaymentGross());
561                    shoppingOrderImpl.setPpReceiverEmail(shoppingOrder.getPpReceiverEmail());
562                    shoppingOrderImpl.setPpPayerEmail(shoppingOrder.getPpPayerEmail());
563                    shoppingOrderImpl.setSendOrderEmail(shoppingOrder.isSendOrderEmail());
564                    shoppingOrderImpl.setSendShippingEmail(shoppingOrder.isSendShippingEmail());
565    
566                    return shoppingOrderImpl;
567            }
568    
569            /**
570             * Returns the shopping order with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
571             *
572             * @param primaryKey the primary key of the shopping order
573             * @return the shopping order
574             * @throws com.liferay.portal.NoSuchModelException if a shopping order with the primary key could not be found
575             * @throws SystemException if a system exception occurred
576             */
577            @Override
578            public ShoppingOrder findByPrimaryKey(Serializable primaryKey)
579                    throws NoSuchModelException, SystemException {
580                    return findByPrimaryKey(((Long)primaryKey).longValue());
581            }
582    
583            /**
584             * Returns the shopping order with the primary key or throws a {@link com.liferay.portlet.shopping.NoSuchOrderException} if it could not be found.
585             *
586             * @param orderId the primary key of the shopping order
587             * @return the shopping order
588             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
589             * @throws SystemException if a system exception occurred
590             */
591            public ShoppingOrder findByPrimaryKey(long orderId)
592                    throws NoSuchOrderException, SystemException {
593                    ShoppingOrder shoppingOrder = fetchByPrimaryKey(orderId);
594    
595                    if (shoppingOrder == null) {
596                            if (_log.isWarnEnabled()) {
597                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orderId);
598                            }
599    
600                            throw new NoSuchOrderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
601                                    orderId);
602                    }
603    
604                    return shoppingOrder;
605            }
606    
607            /**
608             * Returns the shopping order with the primary key or returns <code>null</code> if it could not be found.
609             *
610             * @param primaryKey the primary key of the shopping order
611             * @return the shopping order, or <code>null</code> if a shopping order with the primary key could not be found
612             * @throws SystemException if a system exception occurred
613             */
614            @Override
615            public ShoppingOrder fetchByPrimaryKey(Serializable primaryKey)
616                    throws SystemException {
617                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
618            }
619    
620            /**
621             * Returns the shopping order with the primary key or returns <code>null</code> if it could not be found.
622             *
623             * @param orderId the primary key of the shopping order
624             * @return the shopping order, or <code>null</code> if a shopping order with the primary key could not be found
625             * @throws SystemException if a system exception occurred
626             */
627            public ShoppingOrder fetchByPrimaryKey(long orderId)
628                    throws SystemException {
629                    ShoppingOrder shoppingOrder = (ShoppingOrder)EntityCacheUtil.getResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
630                                    ShoppingOrderImpl.class, orderId);
631    
632                    if (shoppingOrder == _nullShoppingOrder) {
633                            return null;
634                    }
635    
636                    if (shoppingOrder == null) {
637                            Session session = null;
638    
639                            boolean hasException = false;
640    
641                            try {
642                                    session = openSession();
643    
644                                    shoppingOrder = (ShoppingOrder)session.get(ShoppingOrderImpl.class,
645                                                    Long.valueOf(orderId));
646                            }
647                            catch (Exception e) {
648                                    hasException = true;
649    
650                                    throw processException(e);
651                            }
652                            finally {
653                                    if (shoppingOrder != null) {
654                                            cacheResult(shoppingOrder);
655                                    }
656                                    else if (!hasException) {
657                                            EntityCacheUtil.putResult(ShoppingOrderModelImpl.ENTITY_CACHE_ENABLED,
658                                                    ShoppingOrderImpl.class, orderId, _nullShoppingOrder);
659                                    }
660    
661                                    closeSession(session);
662                            }
663                    }
664    
665                    return shoppingOrder;
666            }
667    
668            /**
669             * Returns all the shopping orders where groupId = &#63;.
670             *
671             * @param groupId the group ID
672             * @return the matching shopping orders
673             * @throws SystemException if a system exception occurred
674             */
675            public List<ShoppingOrder> findByGroupId(long groupId)
676                    throws SystemException {
677                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
678            }
679    
680            /**
681             * Returns a range of all the shopping orders where groupId = &#63;.
682             *
683             * <p>
684             * 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.
685             * </p>
686             *
687             * @param groupId the group ID
688             * @param start the lower bound of the range of shopping orders
689             * @param end the upper bound of the range of shopping orders (not inclusive)
690             * @return the range of matching shopping orders
691             * @throws SystemException if a system exception occurred
692             */
693            public List<ShoppingOrder> findByGroupId(long groupId, int start, int end)
694                    throws SystemException {
695                    return findByGroupId(groupId, start, end, null);
696            }
697    
698            /**
699             * Returns an ordered range of all the shopping orders where groupId = &#63;.
700             *
701             * <p>
702             * 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.
703             * </p>
704             *
705             * @param groupId the group ID
706             * @param start the lower bound of the range of shopping orders
707             * @param end the upper bound of the range of shopping orders (not inclusive)
708             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
709             * @return the ordered range of matching shopping orders
710             * @throws SystemException if a system exception occurred
711             */
712            public List<ShoppingOrder> findByGroupId(long groupId, int start, int end,
713                    OrderByComparator orderByComparator) throws SystemException {
714                    FinderPath finderPath = null;
715                    Object[] finderArgs = null;
716    
717                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
718                                    (orderByComparator == null)) {
719                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
720                            finderArgs = new Object[] { groupId };
721                    }
722                    else {
723                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
724                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
725                    }
726    
727                    List<ShoppingOrder> list = (List<ShoppingOrder>)FinderCacheUtil.getResult(finderPath,
728                                    finderArgs, this);
729    
730                    if ((list != null) && !list.isEmpty()) {
731                            for (ShoppingOrder shoppingOrder : list) {
732                                    if ((groupId != shoppingOrder.getGroupId())) {
733                                            list = null;
734    
735                                            break;
736                                    }
737                            }
738                    }
739    
740                    if (list == null) {
741                            StringBundler query = null;
742    
743                            if (orderByComparator != null) {
744                                    query = new StringBundler(3 +
745                                                    (orderByComparator.getOrderByFields().length * 3));
746                            }
747                            else {
748                                    query = new StringBundler(3);
749                            }
750    
751                            query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
752    
753                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
754    
755                            if (orderByComparator != null) {
756                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
757                                            orderByComparator);
758                            }
759    
760                            else {
761                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
762                            }
763    
764                            String sql = query.toString();
765    
766                            Session session = null;
767    
768                            try {
769                                    session = openSession();
770    
771                                    Query q = session.createQuery(sql);
772    
773                                    QueryPos qPos = QueryPos.getInstance(q);
774    
775                                    qPos.add(groupId);
776    
777                                    list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
778                                                    start, end);
779                            }
780                            catch (Exception e) {
781                                    throw processException(e);
782                            }
783                            finally {
784                                    if (list == null) {
785                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
786                                    }
787                                    else {
788                                            cacheResult(list);
789    
790                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
791                                    }
792    
793                                    closeSession(session);
794                            }
795                    }
796    
797                    return list;
798            }
799    
800            /**
801             * Returns the first shopping order in the ordered set where groupId = &#63;.
802             *
803             * @param groupId the group ID
804             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
805             * @return the first matching shopping order
806             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
807             * @throws SystemException if a system exception occurred
808             */
809            public ShoppingOrder findByGroupId_First(long groupId,
810                    OrderByComparator orderByComparator)
811                    throws NoSuchOrderException, SystemException {
812                    ShoppingOrder shoppingOrder = fetchByGroupId_First(groupId,
813                                    orderByComparator);
814    
815                    if (shoppingOrder != null) {
816                            return shoppingOrder;
817                    }
818    
819                    StringBundler msg = new StringBundler(4);
820    
821                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
822    
823                    msg.append("groupId=");
824                    msg.append(groupId);
825    
826                    msg.append(StringPool.CLOSE_CURLY_BRACE);
827    
828                    throw new NoSuchOrderException(msg.toString());
829            }
830    
831            /**
832             * Returns the first shopping order in the ordered set where groupId = &#63;.
833             *
834             * @param groupId the group ID
835             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
836             * @return the first matching shopping order, or <code>null</code> if a matching shopping order could not be found
837             * @throws SystemException if a system exception occurred
838             */
839            public ShoppingOrder fetchByGroupId_First(long groupId,
840                    OrderByComparator orderByComparator) throws SystemException {
841                    List<ShoppingOrder> list = findByGroupId(groupId, 0, 1,
842                                    orderByComparator);
843    
844                    if (!list.isEmpty()) {
845                            return list.get(0);
846                    }
847    
848                    return null;
849            }
850    
851            /**
852             * Returns the last shopping order in the ordered set where groupId = &#63;.
853             *
854             * @param groupId the group ID
855             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
856             * @return the last matching shopping order
857             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
858             * @throws SystemException if a system exception occurred
859             */
860            public ShoppingOrder findByGroupId_Last(long groupId,
861                    OrderByComparator orderByComparator)
862                    throws NoSuchOrderException, SystemException {
863                    ShoppingOrder shoppingOrder = fetchByGroupId_Last(groupId,
864                                    orderByComparator);
865    
866                    if (shoppingOrder != null) {
867                            return shoppingOrder;
868                    }
869    
870                    StringBundler msg = new StringBundler(4);
871    
872                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
873    
874                    msg.append("groupId=");
875                    msg.append(groupId);
876    
877                    msg.append(StringPool.CLOSE_CURLY_BRACE);
878    
879                    throw new NoSuchOrderException(msg.toString());
880            }
881    
882            /**
883             * Returns the last shopping order in the ordered set where groupId = &#63;.
884             *
885             * @param groupId the group ID
886             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
887             * @return the last matching shopping order, or <code>null</code> if a matching shopping order could not be found
888             * @throws SystemException if a system exception occurred
889             */
890            public ShoppingOrder fetchByGroupId_Last(long groupId,
891                    OrderByComparator orderByComparator) throws SystemException {
892                    int count = countByGroupId(groupId);
893    
894                    List<ShoppingOrder> list = findByGroupId(groupId, count - 1, count,
895                                    orderByComparator);
896    
897                    if (!list.isEmpty()) {
898                            return list.get(0);
899                    }
900    
901                    return null;
902            }
903    
904            /**
905             * Returns the shopping orders before and after the current shopping order in the ordered set where groupId = &#63;.
906             *
907             * @param orderId the primary key of the current shopping order
908             * @param groupId the group ID
909             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
910             * @return the previous, current, and next shopping order
911             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
912             * @throws SystemException if a system exception occurred
913             */
914            public ShoppingOrder[] findByGroupId_PrevAndNext(long orderId,
915                    long groupId, OrderByComparator orderByComparator)
916                    throws NoSuchOrderException, SystemException {
917                    ShoppingOrder shoppingOrder = findByPrimaryKey(orderId);
918    
919                    Session session = null;
920    
921                    try {
922                            session = openSession();
923    
924                            ShoppingOrder[] array = new ShoppingOrderImpl[3];
925    
926                            array[0] = getByGroupId_PrevAndNext(session, shoppingOrder,
927                                            groupId, orderByComparator, true);
928    
929                            array[1] = shoppingOrder;
930    
931                            array[2] = getByGroupId_PrevAndNext(session, shoppingOrder,
932                                            groupId, orderByComparator, false);
933    
934                            return array;
935                    }
936                    catch (Exception e) {
937                            throw processException(e);
938                    }
939                    finally {
940                            closeSession(session);
941                    }
942            }
943    
944            protected ShoppingOrder getByGroupId_PrevAndNext(Session session,
945                    ShoppingOrder shoppingOrder, long groupId,
946                    OrderByComparator orderByComparator, boolean previous) {
947                    StringBundler query = null;
948    
949                    if (orderByComparator != null) {
950                            query = new StringBundler(6 +
951                                            (orderByComparator.getOrderByFields().length * 6));
952                    }
953                    else {
954                            query = new StringBundler(3);
955                    }
956    
957                    query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
958    
959                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
960    
961                    if (orderByComparator != null) {
962                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
963    
964                            if (orderByConditionFields.length > 0) {
965                                    query.append(WHERE_AND);
966                            }
967    
968                            for (int i = 0; i < orderByConditionFields.length; i++) {
969                                    query.append(_ORDER_BY_ENTITY_ALIAS);
970                                    query.append(orderByConditionFields[i]);
971    
972                                    if ((i + 1) < orderByConditionFields.length) {
973                                            if (orderByComparator.isAscending() ^ previous) {
974                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
975                                            }
976                                            else {
977                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
978                                            }
979                                    }
980                                    else {
981                                            if (orderByComparator.isAscending() ^ previous) {
982                                                    query.append(WHERE_GREATER_THAN);
983                                            }
984                                            else {
985                                                    query.append(WHERE_LESSER_THAN);
986                                            }
987                                    }
988                            }
989    
990                            query.append(ORDER_BY_CLAUSE);
991    
992                            String[] orderByFields = orderByComparator.getOrderByFields();
993    
994                            for (int i = 0; i < orderByFields.length; i++) {
995                                    query.append(_ORDER_BY_ENTITY_ALIAS);
996                                    query.append(orderByFields[i]);
997    
998                                    if ((i + 1) < orderByFields.length) {
999                                            if (orderByComparator.isAscending() ^ previous) {
1000                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1001                                            }
1002                                            else {
1003                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1004                                            }
1005                                    }
1006                                    else {
1007                                            if (orderByComparator.isAscending() ^ previous) {
1008                                                    query.append(ORDER_BY_ASC);
1009                                            }
1010                                            else {
1011                                                    query.append(ORDER_BY_DESC);
1012                                            }
1013                                    }
1014                            }
1015                    }
1016    
1017                    else {
1018                            query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1019                    }
1020    
1021                    String sql = query.toString();
1022    
1023                    Query q = session.createQuery(sql);
1024    
1025                    q.setFirstResult(0);
1026                    q.setMaxResults(2);
1027    
1028                    QueryPos qPos = QueryPos.getInstance(q);
1029    
1030                    qPos.add(groupId);
1031    
1032                    if (orderByComparator != null) {
1033                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingOrder);
1034    
1035                            for (Object value : values) {
1036                                    qPos.add(value);
1037                            }
1038                    }
1039    
1040                    List<ShoppingOrder> list = q.list();
1041    
1042                    if (list.size() == 2) {
1043                            return list.get(1);
1044                    }
1045                    else {
1046                            return null;
1047                    }
1048            }
1049    
1050            /**
1051             * Returns all the shopping orders that the user has permission to view where groupId = &#63;.
1052             *
1053             * @param groupId the group ID
1054             * @return the matching shopping orders that the user has permission to view
1055             * @throws SystemException if a system exception occurred
1056             */
1057            public List<ShoppingOrder> filterFindByGroupId(long groupId)
1058                    throws SystemException {
1059                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1060                            QueryUtil.ALL_POS, null);
1061            }
1062    
1063            /**
1064             * Returns a range of all the shopping orders that the user has permission to view where groupId = &#63;.
1065             *
1066             * <p>
1067             * 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.
1068             * </p>
1069             *
1070             * @param groupId the group ID
1071             * @param start the lower bound of the range of shopping orders
1072             * @param end the upper bound of the range of shopping orders (not inclusive)
1073             * @return the range of matching shopping orders that the user has permission to view
1074             * @throws SystemException if a system exception occurred
1075             */
1076            public List<ShoppingOrder> filterFindByGroupId(long groupId, int start,
1077                    int end) throws SystemException {
1078                    return filterFindByGroupId(groupId, start, end, null);
1079            }
1080    
1081            /**
1082             * Returns an ordered range of all the shopping orders that the user has permissions to view where groupId = &#63;.
1083             *
1084             * <p>
1085             * 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.
1086             * </p>
1087             *
1088             * @param groupId the group ID
1089             * @param start the lower bound of the range of shopping orders
1090             * @param end the upper bound of the range of shopping orders (not inclusive)
1091             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1092             * @return the ordered range of matching shopping orders that the user has permission to view
1093             * @throws SystemException if a system exception occurred
1094             */
1095            public List<ShoppingOrder> filterFindByGroupId(long groupId, int start,
1096                    int end, OrderByComparator orderByComparator) throws SystemException {
1097                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1098                            return findByGroupId(groupId, start, end, orderByComparator);
1099                    }
1100    
1101                    StringBundler query = null;
1102    
1103                    if (orderByComparator != null) {
1104                            query = new StringBundler(3 +
1105                                            (orderByComparator.getOrderByFields().length * 3));
1106                    }
1107                    else {
1108                            query = new StringBundler(3);
1109                    }
1110    
1111                    if (getDB().isSupportsInlineDistinct()) {
1112                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_WHERE);
1113                    }
1114                    else {
1115                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_1);
1116                    }
1117    
1118                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1119    
1120                    if (!getDB().isSupportsInlineDistinct()) {
1121                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_2);
1122                    }
1123    
1124                    if (orderByComparator != null) {
1125                            if (getDB().isSupportsInlineDistinct()) {
1126                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1127                                            orderByComparator);
1128                            }
1129                            else {
1130                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1131                                            orderByComparator);
1132                            }
1133                    }
1134    
1135                    else {
1136                            if (getDB().isSupportsInlineDistinct()) {
1137                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1138                            }
1139                            else {
1140                                    query.append(ShoppingOrderModelImpl.ORDER_BY_SQL);
1141                            }
1142                    }
1143    
1144                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1145                                    ShoppingOrder.class.getName(),
1146                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1147    
1148                    Session session = null;
1149    
1150                    try {
1151                            session = openSession();
1152    
1153                            SQLQuery q = session.createSQLQuery(sql);
1154    
1155                            if (getDB().isSupportsInlineDistinct()) {
1156                                    q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingOrderImpl.class);
1157                            }
1158                            else {
1159                                    q.addEntity(_FILTER_ENTITY_TABLE, ShoppingOrderImpl.class);
1160                            }
1161    
1162                            QueryPos qPos = QueryPos.getInstance(q);
1163    
1164                            qPos.add(groupId);
1165    
1166                            return (List<ShoppingOrder>)QueryUtil.list(q, getDialect(), start,
1167                                    end);
1168                    }
1169                    catch (Exception e) {
1170                            throw processException(e);
1171                    }
1172                    finally {
1173                            closeSession(session);
1174                    }
1175            }
1176    
1177            /**
1178             * Returns the shopping orders before and after the current shopping order in the ordered set of shopping orders that the user has permission to view where groupId = &#63;.
1179             *
1180             * @param orderId the primary key of the current shopping order
1181             * @param groupId the group ID
1182             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1183             * @return the previous, current, and next shopping order
1184             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
1185             * @throws SystemException if a system exception occurred
1186             */
1187            public ShoppingOrder[] filterFindByGroupId_PrevAndNext(long orderId,
1188                    long groupId, OrderByComparator orderByComparator)
1189                    throws NoSuchOrderException, SystemException {
1190                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1191                            return findByGroupId_PrevAndNext(orderId, groupId, orderByComparator);
1192                    }
1193    
1194                    ShoppingOrder shoppingOrder = findByPrimaryKey(orderId);
1195    
1196                    Session session = null;
1197    
1198                    try {
1199                            session = openSession();
1200    
1201                            ShoppingOrder[] array = new ShoppingOrderImpl[3];
1202    
1203                            array[0] = filterGetByGroupId_PrevAndNext(session, shoppingOrder,
1204                                            groupId, orderByComparator, true);
1205    
1206                            array[1] = shoppingOrder;
1207    
1208                            array[2] = filterGetByGroupId_PrevAndNext(session, shoppingOrder,
1209                                            groupId, orderByComparator, false);
1210    
1211                            return array;
1212                    }
1213                    catch (Exception e) {
1214                            throw processException(e);
1215                    }
1216                    finally {
1217                            closeSession(session);
1218                    }
1219            }
1220    
1221            protected ShoppingOrder filterGetByGroupId_PrevAndNext(Session session,
1222                    ShoppingOrder shoppingOrder, long groupId,
1223                    OrderByComparator orderByComparator, boolean previous) {
1224                    StringBundler query = null;
1225    
1226                    if (orderByComparator != null) {
1227                            query = new StringBundler(6 +
1228                                            (orderByComparator.getOrderByFields().length * 6));
1229                    }
1230                    else {
1231                            query = new StringBundler(3);
1232                    }
1233    
1234                    if (getDB().isSupportsInlineDistinct()) {
1235                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_WHERE);
1236                    }
1237                    else {
1238                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_1);
1239                    }
1240    
1241                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1242    
1243                    if (!getDB().isSupportsInlineDistinct()) {
1244                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_2);
1245                    }
1246    
1247                    if (orderByComparator != null) {
1248                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1249    
1250                            if (orderByConditionFields.length > 0) {
1251                                    query.append(WHERE_AND);
1252                            }
1253    
1254                            for (int i = 0; i < orderByConditionFields.length; i++) {
1255                                    if (getDB().isSupportsInlineDistinct()) {
1256                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1257                                    }
1258                                    else {
1259                                            query.append(_ORDER_BY_ENTITY_TABLE);
1260                                    }
1261    
1262                                    query.append(orderByConditionFields[i]);
1263    
1264                                    if ((i + 1) < orderByConditionFields.length) {
1265                                            if (orderByComparator.isAscending() ^ previous) {
1266                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1267                                            }
1268                                            else {
1269                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1270                                            }
1271                                    }
1272                                    else {
1273                                            if (orderByComparator.isAscending() ^ previous) {
1274                                                    query.append(WHERE_GREATER_THAN);
1275                                            }
1276                                            else {
1277                                                    query.append(WHERE_LESSER_THAN);
1278                                            }
1279                                    }
1280                            }
1281    
1282                            query.append(ORDER_BY_CLAUSE);
1283    
1284                            String[] orderByFields = orderByComparator.getOrderByFields();
1285    
1286                            for (int i = 0; i < orderByFields.length; i++) {
1287                                    if (getDB().isSupportsInlineDistinct()) {
1288                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1289                                    }
1290                                    else {
1291                                            query.append(_ORDER_BY_ENTITY_TABLE);
1292                                    }
1293    
1294                                    query.append(orderByFields[i]);
1295    
1296                                    if ((i + 1) < orderByFields.length) {
1297                                            if (orderByComparator.isAscending() ^ previous) {
1298                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1299                                            }
1300                                            else {
1301                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1302                                            }
1303                                    }
1304                                    else {
1305                                            if (orderByComparator.isAscending() ^ previous) {
1306                                                    query.append(ORDER_BY_ASC);
1307                                            }
1308                                            else {
1309                                                    query.append(ORDER_BY_DESC);
1310                                            }
1311                                    }
1312                            }
1313                    }
1314    
1315                    else {
1316                            if (getDB().isSupportsInlineDistinct()) {
1317                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1318                            }
1319                            else {
1320                                    query.append(ShoppingOrderModelImpl.ORDER_BY_SQL);
1321                            }
1322                    }
1323    
1324                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1325                                    ShoppingOrder.class.getName(),
1326                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1327    
1328                    SQLQuery q = session.createSQLQuery(sql);
1329    
1330                    q.setFirstResult(0);
1331                    q.setMaxResults(2);
1332    
1333                    if (getDB().isSupportsInlineDistinct()) {
1334                            q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingOrderImpl.class);
1335                    }
1336                    else {
1337                            q.addEntity(_FILTER_ENTITY_TABLE, ShoppingOrderImpl.class);
1338                    }
1339    
1340                    QueryPos qPos = QueryPos.getInstance(q);
1341    
1342                    qPos.add(groupId);
1343    
1344                    if (orderByComparator != null) {
1345                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingOrder);
1346    
1347                            for (Object value : values) {
1348                                    qPos.add(value);
1349                            }
1350                    }
1351    
1352                    List<ShoppingOrder> list = q.list();
1353    
1354                    if (list.size() == 2) {
1355                            return list.get(1);
1356                    }
1357                    else {
1358                            return null;
1359                    }
1360            }
1361    
1362            /**
1363             * Returns the shopping order where number = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchOrderException} if it could not be found.
1364             *
1365             * @param number the number
1366             * @return the matching shopping order
1367             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
1368             * @throws SystemException if a system exception occurred
1369             */
1370            public ShoppingOrder findByNumber(String number)
1371                    throws NoSuchOrderException, SystemException {
1372                    ShoppingOrder shoppingOrder = fetchByNumber(number);
1373    
1374                    if (shoppingOrder == null) {
1375                            StringBundler msg = new StringBundler(4);
1376    
1377                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1378    
1379                            msg.append("number=");
1380                            msg.append(number);
1381    
1382                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1383    
1384                            if (_log.isWarnEnabled()) {
1385                                    _log.warn(msg.toString());
1386                            }
1387    
1388                            throw new NoSuchOrderException(msg.toString());
1389                    }
1390    
1391                    return shoppingOrder;
1392            }
1393    
1394            /**
1395             * Returns the shopping order where number = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1396             *
1397             * @param number the number
1398             * @return the matching shopping order, or <code>null</code> if a matching shopping order could not be found
1399             * @throws SystemException if a system exception occurred
1400             */
1401            public ShoppingOrder fetchByNumber(String number) throws SystemException {
1402                    return fetchByNumber(number, true);
1403            }
1404    
1405            /**
1406             * Returns the shopping order where number = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1407             *
1408             * @param number the number
1409             * @param retrieveFromCache whether to use the finder cache
1410             * @return the matching shopping order, or <code>null</code> if a matching shopping order could not be found
1411             * @throws SystemException if a system exception occurred
1412             */
1413            public ShoppingOrder fetchByNumber(String number, boolean retrieveFromCache)
1414                    throws SystemException {
1415                    Object[] finderArgs = new Object[] { number };
1416    
1417                    Object result = null;
1418    
1419                    if (retrieveFromCache) {
1420                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_NUMBER,
1421                                            finderArgs, this);
1422                    }
1423    
1424                    if (result instanceof ShoppingOrder) {
1425                            ShoppingOrder shoppingOrder = (ShoppingOrder)result;
1426    
1427                            if (!Validator.equals(number, shoppingOrder.getNumber())) {
1428                                    result = null;
1429                            }
1430                    }
1431    
1432                    if (result == null) {
1433                            StringBundler query = new StringBundler(3);
1434    
1435                            query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
1436    
1437                            if (number == null) {
1438                                    query.append(_FINDER_COLUMN_NUMBER_NUMBER_1);
1439                            }
1440                            else {
1441                                    if (number.equals(StringPool.BLANK)) {
1442                                            query.append(_FINDER_COLUMN_NUMBER_NUMBER_3);
1443                                    }
1444                                    else {
1445                                            query.append(_FINDER_COLUMN_NUMBER_NUMBER_2);
1446                                    }
1447                            }
1448    
1449                            query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1450    
1451                            String sql = query.toString();
1452    
1453                            Session session = null;
1454    
1455                            try {
1456                                    session = openSession();
1457    
1458                                    Query q = session.createQuery(sql);
1459    
1460                                    QueryPos qPos = QueryPos.getInstance(q);
1461    
1462                                    if (number != null) {
1463                                            qPos.add(number);
1464                                    }
1465    
1466                                    List<ShoppingOrder> list = q.list();
1467    
1468                                    result = list;
1469    
1470                                    ShoppingOrder shoppingOrder = null;
1471    
1472                                    if (list.isEmpty()) {
1473                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
1474                                                    finderArgs, list);
1475                                    }
1476                                    else {
1477                                            shoppingOrder = list.get(0);
1478    
1479                                            cacheResult(shoppingOrder);
1480    
1481                                            if ((shoppingOrder.getNumber() == null) ||
1482                                                            !shoppingOrder.getNumber().equals(number)) {
1483                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NUMBER,
1484                                                            finderArgs, shoppingOrder);
1485                                            }
1486                                    }
1487    
1488                                    return shoppingOrder;
1489                            }
1490                            catch (Exception e) {
1491                                    throw processException(e);
1492                            }
1493                            finally {
1494                                    if (result == null) {
1495                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NUMBER,
1496                                                    finderArgs);
1497                                    }
1498    
1499                                    closeSession(session);
1500                            }
1501                    }
1502                    else {
1503                            if (result instanceof List<?>) {
1504                                    return null;
1505                            }
1506                            else {
1507                                    return (ShoppingOrder)result;
1508                            }
1509                    }
1510            }
1511    
1512            /**
1513             * Returns the shopping order where ppTxnId = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchOrderException} if it could not be found.
1514             *
1515             * @param ppTxnId the pp txn ID
1516             * @return the matching shopping order
1517             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
1518             * @throws SystemException if a system exception occurred
1519             */
1520            public ShoppingOrder findByPPTxnId(String ppTxnId)
1521                    throws NoSuchOrderException, SystemException {
1522                    ShoppingOrder shoppingOrder = fetchByPPTxnId(ppTxnId);
1523    
1524                    if (shoppingOrder == null) {
1525                            StringBundler msg = new StringBundler(4);
1526    
1527                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1528    
1529                            msg.append("ppTxnId=");
1530                            msg.append(ppTxnId);
1531    
1532                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1533    
1534                            if (_log.isWarnEnabled()) {
1535                                    _log.warn(msg.toString());
1536                            }
1537    
1538                            throw new NoSuchOrderException(msg.toString());
1539                    }
1540    
1541                    return shoppingOrder;
1542            }
1543    
1544            /**
1545             * Returns the shopping order where ppTxnId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1546             *
1547             * @param ppTxnId the pp txn ID
1548             * @return the matching shopping order, or <code>null</code> if a matching shopping order could not be found
1549             * @throws SystemException if a system exception occurred
1550             */
1551            public ShoppingOrder fetchByPPTxnId(String ppTxnId)
1552                    throws SystemException {
1553                    return fetchByPPTxnId(ppTxnId, true);
1554            }
1555    
1556            /**
1557             * Returns the shopping order where ppTxnId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1558             *
1559             * @param ppTxnId the pp txn ID
1560             * @param retrieveFromCache whether to use the finder cache
1561             * @return the matching shopping order, or <code>null</code> if a matching shopping order could not be found
1562             * @throws SystemException if a system exception occurred
1563             */
1564            public ShoppingOrder fetchByPPTxnId(String ppTxnId,
1565                    boolean retrieveFromCache) throws SystemException {
1566                    Object[] finderArgs = new Object[] { ppTxnId };
1567    
1568                    Object result = null;
1569    
1570                    if (retrieveFromCache) {
1571                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PPTXNID,
1572                                            finderArgs, this);
1573                    }
1574    
1575                    if (result instanceof ShoppingOrder) {
1576                            ShoppingOrder shoppingOrder = (ShoppingOrder)result;
1577    
1578                            if (!Validator.equals(ppTxnId, shoppingOrder.getPpTxnId())) {
1579                                    result = null;
1580                            }
1581                    }
1582    
1583                    if (result == null) {
1584                            StringBundler query = new StringBundler(3);
1585    
1586                            query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
1587    
1588                            if (ppTxnId == null) {
1589                                    query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_1);
1590                            }
1591                            else {
1592                                    if (ppTxnId.equals(StringPool.BLANK)) {
1593                                            query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_3);
1594                                    }
1595                                    else {
1596                                            query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_2);
1597                                    }
1598                            }
1599    
1600                            query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1601    
1602                            String sql = query.toString();
1603    
1604                            Session session = null;
1605    
1606                            try {
1607                                    session = openSession();
1608    
1609                                    Query q = session.createQuery(sql);
1610    
1611                                    QueryPos qPos = QueryPos.getInstance(q);
1612    
1613                                    if (ppTxnId != null) {
1614                                            qPos.add(ppTxnId);
1615                                    }
1616    
1617                                    List<ShoppingOrder> list = q.list();
1618    
1619                                    result = list;
1620    
1621                                    ShoppingOrder shoppingOrder = null;
1622    
1623                                    if (list.isEmpty()) {
1624                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
1625                                                    finderArgs, list);
1626                                    }
1627                                    else {
1628                                            shoppingOrder = list.get(0);
1629    
1630                                            cacheResult(shoppingOrder);
1631    
1632                                            if ((shoppingOrder.getPpTxnId() == null) ||
1633                                                            !shoppingOrder.getPpTxnId().equals(ppTxnId)) {
1634                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PPTXNID,
1635                                                            finderArgs, shoppingOrder);
1636                                            }
1637                                    }
1638    
1639                                    return shoppingOrder;
1640                            }
1641                            catch (Exception e) {
1642                                    throw processException(e);
1643                            }
1644                            finally {
1645                                    if (result == null) {
1646                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PPTXNID,
1647                                                    finderArgs);
1648                                    }
1649    
1650                                    closeSession(session);
1651                            }
1652                    }
1653                    else {
1654                            if (result instanceof List<?>) {
1655                                    return null;
1656                            }
1657                            else {
1658                                    return (ShoppingOrder)result;
1659                            }
1660                    }
1661            }
1662    
1663            /**
1664             * Returns all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1665             *
1666             * @param groupId the group ID
1667             * @param userId the user ID
1668             * @param ppPaymentStatus the pp payment status
1669             * @return the matching shopping orders
1670             * @throws SystemException if a system exception occurred
1671             */
1672            public List<ShoppingOrder> findByG_U_PPPS(long groupId, long userId,
1673                    String ppPaymentStatus) throws SystemException {
1674                    return findByG_U_PPPS(groupId, userId, ppPaymentStatus,
1675                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1676            }
1677    
1678            /**
1679             * Returns a range of all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1680             *
1681             * <p>
1682             * 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.
1683             * </p>
1684             *
1685             * @param groupId the group ID
1686             * @param userId the user ID
1687             * @param ppPaymentStatus the pp payment status
1688             * @param start the lower bound of the range of shopping orders
1689             * @param end the upper bound of the range of shopping orders (not inclusive)
1690             * @return the range of matching shopping orders
1691             * @throws SystemException if a system exception occurred
1692             */
1693            public List<ShoppingOrder> findByG_U_PPPS(long groupId, long userId,
1694                    String ppPaymentStatus, int start, int end) throws SystemException {
1695                    return findByG_U_PPPS(groupId, userId, ppPaymentStatus, start, end, null);
1696            }
1697    
1698            /**
1699             * Returns an ordered range of all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1700             *
1701             * <p>
1702             * 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.
1703             * </p>
1704             *
1705             * @param groupId the group ID
1706             * @param userId the user ID
1707             * @param ppPaymentStatus the pp payment status
1708             * @param start the lower bound of the range of shopping orders
1709             * @param end the upper bound of the range of shopping orders (not inclusive)
1710             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1711             * @return the ordered range of matching shopping orders
1712             * @throws SystemException if a system exception occurred
1713             */
1714            public List<ShoppingOrder> findByG_U_PPPS(long groupId, long userId,
1715                    String ppPaymentStatus, int start, int end,
1716                    OrderByComparator orderByComparator) throws SystemException {
1717                    FinderPath finderPath = null;
1718                    Object[] finderArgs = null;
1719    
1720                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1721                                    (orderByComparator == null)) {
1722                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_PPPS;
1723                            finderArgs = new Object[] { groupId, userId, ppPaymentStatus };
1724                    }
1725                    else {
1726                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_PPPS;
1727                            finderArgs = new Object[] {
1728                                            groupId, userId, ppPaymentStatus,
1729                                            
1730                                            start, end, orderByComparator
1731                                    };
1732                    }
1733    
1734                    List<ShoppingOrder> list = (List<ShoppingOrder>)FinderCacheUtil.getResult(finderPath,
1735                                    finderArgs, this);
1736    
1737                    if ((list != null) && !list.isEmpty()) {
1738                            for (ShoppingOrder shoppingOrder : list) {
1739                                    if ((groupId != shoppingOrder.getGroupId()) ||
1740                                                    (userId != shoppingOrder.getUserId()) ||
1741                                                    !Validator.equals(ppPaymentStatus,
1742                                                            shoppingOrder.getPpPaymentStatus())) {
1743                                            list = null;
1744    
1745                                            break;
1746                                    }
1747                            }
1748                    }
1749    
1750                    if (list == null) {
1751                            StringBundler query = null;
1752    
1753                            if (orderByComparator != null) {
1754                                    query = new StringBundler(5 +
1755                                                    (orderByComparator.getOrderByFields().length * 3));
1756                            }
1757                            else {
1758                                    query = new StringBundler(5);
1759                            }
1760    
1761                            query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
1762    
1763                            query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
1764    
1765                            query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
1766    
1767                            if (ppPaymentStatus == null) {
1768                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
1769                            }
1770                            else {
1771                                    if (ppPaymentStatus.equals(StringPool.BLANK)) {
1772                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
1773                                    }
1774                                    else {
1775                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
1776                                    }
1777                            }
1778    
1779                            if (orderByComparator != null) {
1780                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1781                                            orderByComparator);
1782                            }
1783    
1784                            else {
1785                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
1786                            }
1787    
1788                            String sql = query.toString();
1789    
1790                            Session session = null;
1791    
1792                            try {
1793                                    session = openSession();
1794    
1795                                    Query q = session.createQuery(sql);
1796    
1797                                    QueryPos qPos = QueryPos.getInstance(q);
1798    
1799                                    qPos.add(groupId);
1800    
1801                                    qPos.add(userId);
1802    
1803                                    if (ppPaymentStatus != null) {
1804                                            qPos.add(ppPaymentStatus);
1805                                    }
1806    
1807                                    list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
1808                                                    start, end);
1809                            }
1810                            catch (Exception e) {
1811                                    throw processException(e);
1812                            }
1813                            finally {
1814                                    if (list == null) {
1815                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1816                                    }
1817                                    else {
1818                                            cacheResult(list);
1819    
1820                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1821                                    }
1822    
1823                                    closeSession(session);
1824                            }
1825                    }
1826    
1827                    return list;
1828            }
1829    
1830            /**
1831             * Returns the first shopping order in the ordered set where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1832             *
1833             * @param groupId the group ID
1834             * @param userId the user ID
1835             * @param ppPaymentStatus the pp payment status
1836             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1837             * @return the first matching shopping order
1838             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
1839             * @throws SystemException if a system exception occurred
1840             */
1841            public ShoppingOrder findByG_U_PPPS_First(long groupId, long userId,
1842                    String ppPaymentStatus, OrderByComparator orderByComparator)
1843                    throws NoSuchOrderException, SystemException {
1844                    ShoppingOrder shoppingOrder = fetchByG_U_PPPS_First(groupId, userId,
1845                                    ppPaymentStatus, orderByComparator);
1846    
1847                    if (shoppingOrder != null) {
1848                            return shoppingOrder;
1849                    }
1850    
1851                    StringBundler msg = new StringBundler(8);
1852    
1853                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1854    
1855                    msg.append("groupId=");
1856                    msg.append(groupId);
1857    
1858                    msg.append(", userId=");
1859                    msg.append(userId);
1860    
1861                    msg.append(", ppPaymentStatus=");
1862                    msg.append(ppPaymentStatus);
1863    
1864                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1865    
1866                    throw new NoSuchOrderException(msg.toString());
1867            }
1868    
1869            /**
1870             * Returns the first shopping order in the ordered set where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1871             *
1872             * @param groupId the group ID
1873             * @param userId the user ID
1874             * @param ppPaymentStatus the pp payment status
1875             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1876             * @return the first matching shopping order, or <code>null</code> if a matching shopping order could not be found
1877             * @throws SystemException if a system exception occurred
1878             */
1879            public ShoppingOrder fetchByG_U_PPPS_First(long groupId, long userId,
1880                    String ppPaymentStatus, OrderByComparator orderByComparator)
1881                    throws SystemException {
1882                    List<ShoppingOrder> list = findByG_U_PPPS(groupId, userId,
1883                                    ppPaymentStatus, 0, 1, orderByComparator);
1884    
1885                    if (!list.isEmpty()) {
1886                            return list.get(0);
1887                    }
1888    
1889                    return null;
1890            }
1891    
1892            /**
1893             * Returns the last shopping order in the ordered set where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1894             *
1895             * @param groupId the group ID
1896             * @param userId the user ID
1897             * @param ppPaymentStatus the pp payment status
1898             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1899             * @return the last matching shopping order
1900             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a matching shopping order could not be found
1901             * @throws SystemException if a system exception occurred
1902             */
1903            public ShoppingOrder findByG_U_PPPS_Last(long groupId, long userId,
1904                    String ppPaymentStatus, OrderByComparator orderByComparator)
1905                    throws NoSuchOrderException, SystemException {
1906                    ShoppingOrder shoppingOrder = fetchByG_U_PPPS_Last(groupId, userId,
1907                                    ppPaymentStatus, orderByComparator);
1908    
1909                    if (shoppingOrder != null) {
1910                            return shoppingOrder;
1911                    }
1912    
1913                    StringBundler msg = new StringBundler(8);
1914    
1915                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1916    
1917                    msg.append("groupId=");
1918                    msg.append(groupId);
1919    
1920                    msg.append(", userId=");
1921                    msg.append(userId);
1922    
1923                    msg.append(", ppPaymentStatus=");
1924                    msg.append(ppPaymentStatus);
1925    
1926                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1927    
1928                    throw new NoSuchOrderException(msg.toString());
1929            }
1930    
1931            /**
1932             * Returns the last shopping order in the ordered set where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1933             *
1934             * @param groupId the group ID
1935             * @param userId the user ID
1936             * @param ppPaymentStatus the pp payment status
1937             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1938             * @return the last matching shopping order, or <code>null</code> if a matching shopping order could not be found
1939             * @throws SystemException if a system exception occurred
1940             */
1941            public ShoppingOrder fetchByG_U_PPPS_Last(long groupId, long userId,
1942                    String ppPaymentStatus, OrderByComparator orderByComparator)
1943                    throws SystemException {
1944                    int count = countByG_U_PPPS(groupId, userId, ppPaymentStatus);
1945    
1946                    List<ShoppingOrder> list = findByG_U_PPPS(groupId, userId,
1947                                    ppPaymentStatus, count - 1, count, orderByComparator);
1948    
1949                    if (!list.isEmpty()) {
1950                            return list.get(0);
1951                    }
1952    
1953                    return null;
1954            }
1955    
1956            /**
1957             * Returns the shopping orders before and after the current shopping order in the ordered set where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
1958             *
1959             * @param orderId the primary key of the current shopping order
1960             * @param groupId the group ID
1961             * @param userId the user ID
1962             * @param ppPaymentStatus the pp payment status
1963             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1964             * @return the previous, current, and next shopping order
1965             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
1966             * @throws SystemException if a system exception occurred
1967             */
1968            public ShoppingOrder[] findByG_U_PPPS_PrevAndNext(long orderId,
1969                    long groupId, long userId, String ppPaymentStatus,
1970                    OrderByComparator orderByComparator)
1971                    throws NoSuchOrderException, SystemException {
1972                    ShoppingOrder shoppingOrder = findByPrimaryKey(orderId);
1973    
1974                    Session session = null;
1975    
1976                    try {
1977                            session = openSession();
1978    
1979                            ShoppingOrder[] array = new ShoppingOrderImpl[3];
1980    
1981                            array[0] = getByG_U_PPPS_PrevAndNext(session, shoppingOrder,
1982                                            groupId, userId, ppPaymentStatus, orderByComparator, true);
1983    
1984                            array[1] = shoppingOrder;
1985    
1986                            array[2] = getByG_U_PPPS_PrevAndNext(session, shoppingOrder,
1987                                            groupId, userId, ppPaymentStatus, orderByComparator, false);
1988    
1989                            return array;
1990                    }
1991                    catch (Exception e) {
1992                            throw processException(e);
1993                    }
1994                    finally {
1995                            closeSession(session);
1996                    }
1997            }
1998    
1999            protected ShoppingOrder getByG_U_PPPS_PrevAndNext(Session session,
2000                    ShoppingOrder shoppingOrder, long groupId, long userId,
2001                    String ppPaymentStatus, OrderByComparator orderByComparator,
2002                    boolean previous) {
2003                    StringBundler query = null;
2004    
2005                    if (orderByComparator != null) {
2006                            query = new StringBundler(6 +
2007                                            (orderByComparator.getOrderByFields().length * 6));
2008                    }
2009                    else {
2010                            query = new StringBundler(3);
2011                    }
2012    
2013                    query.append(_SQL_SELECT_SHOPPINGORDER_WHERE);
2014    
2015                    query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
2016    
2017                    query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
2018    
2019                    if (ppPaymentStatus == null) {
2020                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
2021                    }
2022                    else {
2023                            if (ppPaymentStatus.equals(StringPool.BLANK)) {
2024                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
2025                            }
2026                            else {
2027                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
2028                            }
2029                    }
2030    
2031                    if (orderByComparator != null) {
2032                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2033    
2034                            if (orderByConditionFields.length > 0) {
2035                                    query.append(WHERE_AND);
2036                            }
2037    
2038                            for (int i = 0; i < orderByConditionFields.length; i++) {
2039                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2040                                    query.append(orderByConditionFields[i]);
2041    
2042                                    if ((i + 1) < orderByConditionFields.length) {
2043                                            if (orderByComparator.isAscending() ^ previous) {
2044                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2045                                            }
2046                                            else {
2047                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2048                                            }
2049                                    }
2050                                    else {
2051                                            if (orderByComparator.isAscending() ^ previous) {
2052                                                    query.append(WHERE_GREATER_THAN);
2053                                            }
2054                                            else {
2055                                                    query.append(WHERE_LESSER_THAN);
2056                                            }
2057                                    }
2058                            }
2059    
2060                            query.append(ORDER_BY_CLAUSE);
2061    
2062                            String[] orderByFields = orderByComparator.getOrderByFields();
2063    
2064                            for (int i = 0; i < orderByFields.length; i++) {
2065                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2066                                    query.append(orderByFields[i]);
2067    
2068                                    if ((i + 1) < orderByFields.length) {
2069                                            if (orderByComparator.isAscending() ^ previous) {
2070                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2071                                            }
2072                                            else {
2073                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2074                                            }
2075                                    }
2076                                    else {
2077                                            if (orderByComparator.isAscending() ^ previous) {
2078                                                    query.append(ORDER_BY_ASC);
2079                                            }
2080                                            else {
2081                                                    query.append(ORDER_BY_DESC);
2082                                            }
2083                                    }
2084                            }
2085                    }
2086    
2087                    else {
2088                            query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
2089                    }
2090    
2091                    String sql = query.toString();
2092    
2093                    Query q = session.createQuery(sql);
2094    
2095                    q.setFirstResult(0);
2096                    q.setMaxResults(2);
2097    
2098                    QueryPos qPos = QueryPos.getInstance(q);
2099    
2100                    qPos.add(groupId);
2101    
2102                    qPos.add(userId);
2103    
2104                    if (ppPaymentStatus != null) {
2105                            qPos.add(ppPaymentStatus);
2106                    }
2107    
2108                    if (orderByComparator != null) {
2109                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingOrder);
2110    
2111                            for (Object value : values) {
2112                                    qPos.add(value);
2113                            }
2114                    }
2115    
2116                    List<ShoppingOrder> list = q.list();
2117    
2118                    if (list.size() == 2) {
2119                            return list.get(1);
2120                    }
2121                    else {
2122                            return null;
2123                    }
2124            }
2125    
2126            /**
2127             * Returns all the shopping orders that the user has permission to view where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
2128             *
2129             * @param groupId the group ID
2130             * @param userId the user ID
2131             * @param ppPaymentStatus the pp payment status
2132             * @return the matching shopping orders that the user has permission to view
2133             * @throws SystemException if a system exception occurred
2134             */
2135            public List<ShoppingOrder> filterFindByG_U_PPPS(long groupId, long userId,
2136                    String ppPaymentStatus) throws SystemException {
2137                    return filterFindByG_U_PPPS(groupId, userId, ppPaymentStatus,
2138                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2139            }
2140    
2141            /**
2142             * Returns a range of all the shopping orders that the user has permission to view where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
2143             *
2144             * <p>
2145             * 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.
2146             * </p>
2147             *
2148             * @param groupId the group ID
2149             * @param userId the user ID
2150             * @param ppPaymentStatus the pp payment status
2151             * @param start the lower bound of the range of shopping orders
2152             * @param end the upper bound of the range of shopping orders (not inclusive)
2153             * @return the range of matching shopping orders that the user has permission to view
2154             * @throws SystemException if a system exception occurred
2155             */
2156            public List<ShoppingOrder> filterFindByG_U_PPPS(long groupId, long userId,
2157                    String ppPaymentStatus, int start, int end) throws SystemException {
2158                    return filterFindByG_U_PPPS(groupId, userId, ppPaymentStatus, start,
2159                            end, null);
2160            }
2161    
2162            /**
2163             * Returns an ordered range of all the shopping orders that the user has permissions to view where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
2164             *
2165             * <p>
2166             * 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.
2167             * </p>
2168             *
2169             * @param groupId the group ID
2170             * @param userId the user ID
2171             * @param ppPaymentStatus the pp payment status
2172             * @param start the lower bound of the range of shopping orders
2173             * @param end the upper bound of the range of shopping orders (not inclusive)
2174             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2175             * @return the ordered range of matching shopping orders that the user has permission to view
2176             * @throws SystemException if a system exception occurred
2177             */
2178            public List<ShoppingOrder> filterFindByG_U_PPPS(long groupId, long userId,
2179                    String ppPaymentStatus, int start, int end,
2180                    OrderByComparator orderByComparator) throws SystemException {
2181                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2182                            return findByG_U_PPPS(groupId, userId, ppPaymentStatus, start, end,
2183                                    orderByComparator);
2184                    }
2185    
2186                    StringBundler query = null;
2187    
2188                    if (orderByComparator != null) {
2189                            query = new StringBundler(5 +
2190                                            (orderByComparator.getOrderByFields().length * 3));
2191                    }
2192                    else {
2193                            query = new StringBundler(5);
2194                    }
2195    
2196                    if (getDB().isSupportsInlineDistinct()) {
2197                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_WHERE);
2198                    }
2199                    else {
2200                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_1);
2201                    }
2202    
2203                    query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
2204    
2205                    query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
2206    
2207                    if (ppPaymentStatus == null) {
2208                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
2209                    }
2210                    else {
2211                            if (ppPaymentStatus.equals(StringPool.BLANK)) {
2212                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
2213                            }
2214                            else {
2215                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
2216                            }
2217                    }
2218    
2219                    if (!getDB().isSupportsInlineDistinct()) {
2220                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_2);
2221                    }
2222    
2223                    if (orderByComparator != null) {
2224                            if (getDB().isSupportsInlineDistinct()) {
2225                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2226                                            orderByComparator);
2227                            }
2228                            else {
2229                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2230                                            orderByComparator);
2231                            }
2232                    }
2233    
2234                    else {
2235                            if (getDB().isSupportsInlineDistinct()) {
2236                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
2237                            }
2238                            else {
2239                                    query.append(ShoppingOrderModelImpl.ORDER_BY_SQL);
2240                            }
2241                    }
2242    
2243                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2244                                    ShoppingOrder.class.getName(),
2245                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2246    
2247                    Session session = null;
2248    
2249                    try {
2250                            session = openSession();
2251    
2252                            SQLQuery q = session.createSQLQuery(sql);
2253    
2254                            if (getDB().isSupportsInlineDistinct()) {
2255                                    q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingOrderImpl.class);
2256                            }
2257                            else {
2258                                    q.addEntity(_FILTER_ENTITY_TABLE, ShoppingOrderImpl.class);
2259                            }
2260    
2261                            QueryPos qPos = QueryPos.getInstance(q);
2262    
2263                            qPos.add(groupId);
2264    
2265                            qPos.add(userId);
2266    
2267                            if (ppPaymentStatus != null) {
2268                                    qPos.add(ppPaymentStatus);
2269                            }
2270    
2271                            return (List<ShoppingOrder>)QueryUtil.list(q, getDialect(), start,
2272                                    end);
2273                    }
2274                    catch (Exception e) {
2275                            throw processException(e);
2276                    }
2277                    finally {
2278                            closeSession(session);
2279                    }
2280            }
2281    
2282            /**
2283             * Returns the shopping orders before and after the current shopping order in the ordered set of shopping orders that the user has permission to view where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
2284             *
2285             * @param orderId the primary key of the current shopping order
2286             * @param groupId the group ID
2287             * @param userId the user ID
2288             * @param ppPaymentStatus the pp payment status
2289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2290             * @return the previous, current, and next shopping order
2291             * @throws com.liferay.portlet.shopping.NoSuchOrderException if a shopping order with the primary key could not be found
2292             * @throws SystemException if a system exception occurred
2293             */
2294            public ShoppingOrder[] filterFindByG_U_PPPS_PrevAndNext(long orderId,
2295                    long groupId, long userId, String ppPaymentStatus,
2296                    OrderByComparator orderByComparator)
2297                    throws NoSuchOrderException, SystemException {
2298                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2299                            return findByG_U_PPPS_PrevAndNext(orderId, groupId, userId,
2300                                    ppPaymentStatus, orderByComparator);
2301                    }
2302    
2303                    ShoppingOrder shoppingOrder = findByPrimaryKey(orderId);
2304    
2305                    Session session = null;
2306    
2307                    try {
2308                            session = openSession();
2309    
2310                            ShoppingOrder[] array = new ShoppingOrderImpl[3];
2311    
2312                            array[0] = filterGetByG_U_PPPS_PrevAndNext(session, shoppingOrder,
2313                                            groupId, userId, ppPaymentStatus, orderByComparator, true);
2314    
2315                            array[1] = shoppingOrder;
2316    
2317                            array[2] = filterGetByG_U_PPPS_PrevAndNext(session, shoppingOrder,
2318                                            groupId, userId, ppPaymentStatus, orderByComparator, false);
2319    
2320                            return array;
2321                    }
2322                    catch (Exception e) {
2323                            throw processException(e);
2324                    }
2325                    finally {
2326                            closeSession(session);
2327                    }
2328            }
2329    
2330            protected ShoppingOrder filterGetByG_U_PPPS_PrevAndNext(Session session,
2331                    ShoppingOrder shoppingOrder, long groupId, long userId,
2332                    String ppPaymentStatus, OrderByComparator orderByComparator,
2333                    boolean previous) {
2334                    StringBundler query = null;
2335    
2336                    if (orderByComparator != null) {
2337                            query = new StringBundler(6 +
2338                                            (orderByComparator.getOrderByFields().length * 6));
2339                    }
2340                    else {
2341                            query = new StringBundler(3);
2342                    }
2343    
2344                    if (getDB().isSupportsInlineDistinct()) {
2345                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_WHERE);
2346                    }
2347                    else {
2348                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_1);
2349                    }
2350    
2351                    query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
2352    
2353                    query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
2354    
2355                    if (ppPaymentStatus == null) {
2356                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
2357                    }
2358                    else {
2359                            if (ppPaymentStatus.equals(StringPool.BLANK)) {
2360                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
2361                            }
2362                            else {
2363                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
2364                            }
2365                    }
2366    
2367                    if (!getDB().isSupportsInlineDistinct()) {
2368                            query.append(_FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_2);
2369                    }
2370    
2371                    if (orderByComparator != null) {
2372                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2373    
2374                            if (orderByConditionFields.length > 0) {
2375                                    query.append(WHERE_AND);
2376                            }
2377    
2378                            for (int i = 0; i < orderByConditionFields.length; i++) {
2379                                    if (getDB().isSupportsInlineDistinct()) {
2380                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2381                                    }
2382                                    else {
2383                                            query.append(_ORDER_BY_ENTITY_TABLE);
2384                                    }
2385    
2386                                    query.append(orderByConditionFields[i]);
2387    
2388                                    if ((i + 1) < orderByConditionFields.length) {
2389                                            if (orderByComparator.isAscending() ^ previous) {
2390                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2391                                            }
2392                                            else {
2393                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2394                                            }
2395                                    }
2396                                    else {
2397                                            if (orderByComparator.isAscending() ^ previous) {
2398                                                    query.append(WHERE_GREATER_THAN);
2399                                            }
2400                                            else {
2401                                                    query.append(WHERE_LESSER_THAN);
2402                                            }
2403                                    }
2404                            }
2405    
2406                            query.append(ORDER_BY_CLAUSE);
2407    
2408                            String[] orderByFields = orderByComparator.getOrderByFields();
2409    
2410                            for (int i = 0; i < orderByFields.length; i++) {
2411                                    if (getDB().isSupportsInlineDistinct()) {
2412                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2413                                    }
2414                                    else {
2415                                            query.append(_ORDER_BY_ENTITY_TABLE);
2416                                    }
2417    
2418                                    query.append(orderByFields[i]);
2419    
2420                                    if ((i + 1) < orderByFields.length) {
2421                                            if (orderByComparator.isAscending() ^ previous) {
2422                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2423                                            }
2424                                            else {
2425                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2426                                            }
2427                                    }
2428                                    else {
2429                                            if (orderByComparator.isAscending() ^ previous) {
2430                                                    query.append(ORDER_BY_ASC);
2431                                            }
2432                                            else {
2433                                                    query.append(ORDER_BY_DESC);
2434                                            }
2435                                    }
2436                            }
2437                    }
2438    
2439                    else {
2440                            if (getDB().isSupportsInlineDistinct()) {
2441                                    query.append(ShoppingOrderModelImpl.ORDER_BY_JPQL);
2442                            }
2443                            else {
2444                                    query.append(ShoppingOrderModelImpl.ORDER_BY_SQL);
2445                            }
2446                    }
2447    
2448                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2449                                    ShoppingOrder.class.getName(),
2450                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2451    
2452                    SQLQuery q = session.createSQLQuery(sql);
2453    
2454                    q.setFirstResult(0);
2455                    q.setMaxResults(2);
2456    
2457                    if (getDB().isSupportsInlineDistinct()) {
2458                            q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingOrderImpl.class);
2459                    }
2460                    else {
2461                            q.addEntity(_FILTER_ENTITY_TABLE, ShoppingOrderImpl.class);
2462                    }
2463    
2464                    QueryPos qPos = QueryPos.getInstance(q);
2465    
2466                    qPos.add(groupId);
2467    
2468                    qPos.add(userId);
2469    
2470                    if (ppPaymentStatus != null) {
2471                            qPos.add(ppPaymentStatus);
2472                    }
2473    
2474                    if (orderByComparator != null) {
2475                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingOrder);
2476    
2477                            for (Object value : values) {
2478                                    qPos.add(value);
2479                            }
2480                    }
2481    
2482                    List<ShoppingOrder> list = q.list();
2483    
2484                    if (list.size() == 2) {
2485                            return list.get(1);
2486                    }
2487                    else {
2488                            return null;
2489                    }
2490            }
2491    
2492            /**
2493             * Returns all the shopping orders.
2494             *
2495             * @return the shopping orders
2496             * @throws SystemException if a system exception occurred
2497             */
2498            public List<ShoppingOrder> findAll() throws SystemException {
2499                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2500            }
2501    
2502            /**
2503             * Returns a range of all the shopping orders.
2504             *
2505             * <p>
2506             * 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.
2507             * </p>
2508             *
2509             * @param start the lower bound of the range of shopping orders
2510             * @param end the upper bound of the range of shopping orders (not inclusive)
2511             * @return the range of shopping orders
2512             * @throws SystemException if a system exception occurred
2513             */
2514            public List<ShoppingOrder> findAll(int start, int end)
2515                    throws SystemException {
2516                    return findAll(start, end, null);
2517            }
2518    
2519            /**
2520             * Returns an ordered range of all the shopping orders.
2521             *
2522             * <p>
2523             * 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.
2524             * </p>
2525             *
2526             * @param start the lower bound of the range of shopping orders
2527             * @param end the upper bound of the range of shopping orders (not inclusive)
2528             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2529             * @return the ordered range of shopping orders
2530             * @throws SystemException if a system exception occurred
2531             */
2532            public List<ShoppingOrder> findAll(int start, int end,
2533                    OrderByComparator orderByComparator) throws SystemException {
2534                    FinderPath finderPath = null;
2535                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2536    
2537                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2538                                    (orderByComparator == null)) {
2539                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2540                            finderArgs = FINDER_ARGS_EMPTY;
2541                    }
2542                    else {
2543                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2544                            finderArgs = new Object[] { start, end, orderByComparator };
2545                    }
2546    
2547                    List<ShoppingOrder> list = (List<ShoppingOrder>)FinderCacheUtil.getResult(finderPath,
2548                                    finderArgs, this);
2549    
2550                    if (list == null) {
2551                            StringBundler query = null;
2552                            String sql = null;
2553    
2554                            if (orderByComparator != null) {
2555                                    query = new StringBundler(2 +
2556                                                    (orderByComparator.getOrderByFields().length * 3));
2557    
2558                                    query.append(_SQL_SELECT_SHOPPINGORDER);
2559    
2560                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2561                                            orderByComparator);
2562    
2563                                    sql = query.toString();
2564                            }
2565                            else {
2566                                    sql = _SQL_SELECT_SHOPPINGORDER.concat(ShoppingOrderModelImpl.ORDER_BY_JPQL);
2567                            }
2568    
2569                            Session session = null;
2570    
2571                            try {
2572                                    session = openSession();
2573    
2574                                    Query q = session.createQuery(sql);
2575    
2576                                    if (orderByComparator == null) {
2577                                            list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
2578                                                            start, end, false);
2579    
2580                                            Collections.sort(list);
2581                                    }
2582                                    else {
2583                                            list = (List<ShoppingOrder>)QueryUtil.list(q, getDialect(),
2584                                                            start, end);
2585                                    }
2586                            }
2587                            catch (Exception e) {
2588                                    throw processException(e);
2589                            }
2590                            finally {
2591                                    if (list == null) {
2592                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2593                                    }
2594                                    else {
2595                                            cacheResult(list);
2596    
2597                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2598                                    }
2599    
2600                                    closeSession(session);
2601                            }
2602                    }
2603    
2604                    return list;
2605            }
2606    
2607            /**
2608             * Removes all the shopping orders where groupId = &#63; from the database.
2609             *
2610             * @param groupId the group ID
2611             * @throws SystemException if a system exception occurred
2612             */
2613            public void removeByGroupId(long groupId) throws SystemException {
2614                    for (ShoppingOrder shoppingOrder : findByGroupId(groupId)) {
2615                            remove(shoppingOrder);
2616                    }
2617            }
2618    
2619            /**
2620             * Removes the shopping order where number = &#63; from the database.
2621             *
2622             * @param number the number
2623             * @return the shopping order that was removed
2624             * @throws SystemException if a system exception occurred
2625             */
2626            public ShoppingOrder removeByNumber(String number)
2627                    throws NoSuchOrderException, SystemException {
2628                    ShoppingOrder shoppingOrder = findByNumber(number);
2629    
2630                    return remove(shoppingOrder);
2631            }
2632    
2633            /**
2634             * Removes the shopping order where ppTxnId = &#63; from the database.
2635             *
2636             * @param ppTxnId the pp txn ID
2637             * @return the shopping order that was removed
2638             * @throws SystemException if a system exception occurred
2639             */
2640            public ShoppingOrder removeByPPTxnId(String ppTxnId)
2641                    throws NoSuchOrderException, SystemException {
2642                    ShoppingOrder shoppingOrder = findByPPTxnId(ppTxnId);
2643    
2644                    return remove(shoppingOrder);
2645            }
2646    
2647            /**
2648             * Removes all the shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63; from the database.
2649             *
2650             * @param groupId the group ID
2651             * @param userId the user ID
2652             * @param ppPaymentStatus the pp payment status
2653             * @throws SystemException if a system exception occurred
2654             */
2655            public void removeByG_U_PPPS(long groupId, long userId,
2656                    String ppPaymentStatus) throws SystemException {
2657                    for (ShoppingOrder shoppingOrder : findByG_U_PPPS(groupId, userId,
2658                                    ppPaymentStatus)) {
2659                            remove(shoppingOrder);
2660                    }
2661            }
2662    
2663            /**
2664             * Removes all the shopping orders from the database.
2665             *
2666             * @throws SystemException if a system exception occurred
2667             */
2668            public void removeAll() throws SystemException {
2669                    for (ShoppingOrder shoppingOrder : findAll()) {
2670                            remove(shoppingOrder);
2671                    }
2672            }
2673    
2674            /**
2675             * Returns the number of shopping orders where groupId = &#63;.
2676             *
2677             * @param groupId the group ID
2678             * @return the number of matching shopping orders
2679             * @throws SystemException if a system exception occurred
2680             */
2681            public int countByGroupId(long groupId) throws SystemException {
2682                    Object[] finderArgs = new Object[] { groupId };
2683    
2684                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2685                                    finderArgs, this);
2686    
2687                    if (count == null) {
2688                            StringBundler query = new StringBundler(2);
2689    
2690                            query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
2691    
2692                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2693    
2694                            String sql = query.toString();
2695    
2696                            Session session = null;
2697    
2698                            try {
2699                                    session = openSession();
2700    
2701                                    Query q = session.createQuery(sql);
2702    
2703                                    QueryPos qPos = QueryPos.getInstance(q);
2704    
2705                                    qPos.add(groupId);
2706    
2707                                    count = (Long)q.uniqueResult();
2708                            }
2709                            catch (Exception e) {
2710                                    throw processException(e);
2711                            }
2712                            finally {
2713                                    if (count == null) {
2714                                            count = Long.valueOf(0);
2715                                    }
2716    
2717                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2718                                            finderArgs, count);
2719    
2720                                    closeSession(session);
2721                            }
2722                    }
2723    
2724                    return count.intValue();
2725            }
2726    
2727            /**
2728             * Returns the number of shopping orders that the user has permission to view where groupId = &#63;.
2729             *
2730             * @param groupId the group ID
2731             * @return the number of matching shopping orders that the user has permission to view
2732             * @throws SystemException if a system exception occurred
2733             */
2734            public int filterCountByGroupId(long groupId) throws SystemException {
2735                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2736                            return countByGroupId(groupId);
2737                    }
2738    
2739                    StringBundler query = new StringBundler(2);
2740    
2741                    query.append(_FILTER_SQL_COUNT_SHOPPINGORDER_WHERE);
2742    
2743                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2744    
2745                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2746                                    ShoppingOrder.class.getName(),
2747                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2748    
2749                    Session session = null;
2750    
2751                    try {
2752                            session = openSession();
2753    
2754                            SQLQuery q = session.createSQLQuery(sql);
2755    
2756                            q.addScalar(COUNT_COLUMN_NAME,
2757                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2758    
2759                            QueryPos qPos = QueryPos.getInstance(q);
2760    
2761                            qPos.add(groupId);
2762    
2763                            Long count = (Long)q.uniqueResult();
2764    
2765                            return count.intValue();
2766                    }
2767                    catch (Exception e) {
2768                            throw processException(e);
2769                    }
2770                    finally {
2771                            closeSession(session);
2772                    }
2773            }
2774    
2775            /**
2776             * Returns the number of shopping orders where number = &#63;.
2777             *
2778             * @param number the number
2779             * @return the number of matching shopping orders
2780             * @throws SystemException if a system exception occurred
2781             */
2782            public int countByNumber(String number) throws SystemException {
2783                    Object[] finderArgs = new Object[] { number };
2784    
2785                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NUMBER,
2786                                    finderArgs, this);
2787    
2788                    if (count == null) {
2789                            StringBundler query = new StringBundler(2);
2790    
2791                            query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
2792    
2793                            if (number == null) {
2794                                    query.append(_FINDER_COLUMN_NUMBER_NUMBER_1);
2795                            }
2796                            else {
2797                                    if (number.equals(StringPool.BLANK)) {
2798                                            query.append(_FINDER_COLUMN_NUMBER_NUMBER_3);
2799                                    }
2800                                    else {
2801                                            query.append(_FINDER_COLUMN_NUMBER_NUMBER_2);
2802                                    }
2803                            }
2804    
2805                            String sql = query.toString();
2806    
2807                            Session session = null;
2808    
2809                            try {
2810                                    session = openSession();
2811    
2812                                    Query q = session.createQuery(sql);
2813    
2814                                    QueryPos qPos = QueryPos.getInstance(q);
2815    
2816                                    if (number != null) {
2817                                            qPos.add(number);
2818                                    }
2819    
2820                                    count = (Long)q.uniqueResult();
2821                            }
2822                            catch (Exception e) {
2823                                    throw processException(e);
2824                            }
2825                            finally {
2826                                    if (count == null) {
2827                                            count = Long.valueOf(0);
2828                                    }
2829    
2830                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NUMBER,
2831                                            finderArgs, count);
2832    
2833                                    closeSession(session);
2834                            }
2835                    }
2836    
2837                    return count.intValue();
2838            }
2839    
2840            /**
2841             * Returns the number of shopping orders where ppTxnId = &#63;.
2842             *
2843             * @param ppTxnId the pp txn ID
2844             * @return the number of matching shopping orders
2845             * @throws SystemException if a system exception occurred
2846             */
2847            public int countByPPTxnId(String ppTxnId) throws SystemException {
2848                    Object[] finderArgs = new Object[] { ppTxnId };
2849    
2850                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PPTXNID,
2851                                    finderArgs, this);
2852    
2853                    if (count == null) {
2854                            StringBundler query = new StringBundler(2);
2855    
2856                            query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
2857    
2858                            if (ppTxnId == null) {
2859                                    query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_1);
2860                            }
2861                            else {
2862                                    if (ppTxnId.equals(StringPool.BLANK)) {
2863                                            query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_3);
2864                                    }
2865                                    else {
2866                                            query.append(_FINDER_COLUMN_PPTXNID_PPTXNID_2);
2867                                    }
2868                            }
2869    
2870                            String sql = query.toString();
2871    
2872                            Session session = null;
2873    
2874                            try {
2875                                    session = openSession();
2876    
2877                                    Query q = session.createQuery(sql);
2878    
2879                                    QueryPos qPos = QueryPos.getInstance(q);
2880    
2881                                    if (ppTxnId != null) {
2882                                            qPos.add(ppTxnId);
2883                                    }
2884    
2885                                    count = (Long)q.uniqueResult();
2886                            }
2887                            catch (Exception e) {
2888                                    throw processException(e);
2889                            }
2890                            finally {
2891                                    if (count == null) {
2892                                            count = Long.valueOf(0);
2893                                    }
2894    
2895                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PPTXNID,
2896                                            finderArgs, count);
2897    
2898                                    closeSession(session);
2899                            }
2900                    }
2901    
2902                    return count.intValue();
2903            }
2904    
2905            /**
2906             * Returns the number of shopping orders where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
2907             *
2908             * @param groupId the group ID
2909             * @param userId the user ID
2910             * @param ppPaymentStatus the pp payment status
2911             * @return the number of matching shopping orders
2912             * @throws SystemException if a system exception occurred
2913             */
2914            public int countByG_U_PPPS(long groupId, long userId, String ppPaymentStatus)
2915                    throws SystemException {
2916                    Object[] finderArgs = new Object[] { groupId, userId, ppPaymentStatus };
2917    
2918                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_PPPS,
2919                                    finderArgs, this);
2920    
2921                    if (count == null) {
2922                            StringBundler query = new StringBundler(4);
2923    
2924                            query.append(_SQL_COUNT_SHOPPINGORDER_WHERE);
2925    
2926                            query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
2927    
2928                            query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
2929    
2930                            if (ppPaymentStatus == null) {
2931                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
2932                            }
2933                            else {
2934                                    if (ppPaymentStatus.equals(StringPool.BLANK)) {
2935                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
2936                                    }
2937                                    else {
2938                                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
2939                                    }
2940                            }
2941    
2942                            String sql = query.toString();
2943    
2944                            Session session = null;
2945    
2946                            try {
2947                                    session = openSession();
2948    
2949                                    Query q = session.createQuery(sql);
2950    
2951                                    QueryPos qPos = QueryPos.getInstance(q);
2952    
2953                                    qPos.add(groupId);
2954    
2955                                    qPos.add(userId);
2956    
2957                                    if (ppPaymentStatus != null) {
2958                                            qPos.add(ppPaymentStatus);
2959                                    }
2960    
2961                                    count = (Long)q.uniqueResult();
2962                            }
2963                            catch (Exception e) {
2964                                    throw processException(e);
2965                            }
2966                            finally {
2967                                    if (count == null) {
2968                                            count = Long.valueOf(0);
2969                                    }
2970    
2971                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_PPPS,
2972                                            finderArgs, count);
2973    
2974                                    closeSession(session);
2975                            }
2976                    }
2977    
2978                    return count.intValue();
2979            }
2980    
2981            /**
2982             * Returns the number of shopping orders that the user has permission to view where groupId = &#63; and userId = &#63; and ppPaymentStatus = &#63;.
2983             *
2984             * @param groupId the group ID
2985             * @param userId the user ID
2986             * @param ppPaymentStatus the pp payment status
2987             * @return the number of matching shopping orders that the user has permission to view
2988             * @throws SystemException if a system exception occurred
2989             */
2990            public int filterCountByG_U_PPPS(long groupId, long userId,
2991                    String ppPaymentStatus) throws SystemException {
2992                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2993                            return countByG_U_PPPS(groupId, userId, ppPaymentStatus);
2994                    }
2995    
2996                    StringBundler query = new StringBundler(4);
2997    
2998                    query.append(_FILTER_SQL_COUNT_SHOPPINGORDER_WHERE);
2999    
3000                    query.append(_FINDER_COLUMN_G_U_PPPS_GROUPID_2);
3001    
3002                    query.append(_FINDER_COLUMN_G_U_PPPS_USERID_2);
3003    
3004                    if (ppPaymentStatus == null) {
3005                            query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1);
3006                    }
3007                    else {
3008                            if (ppPaymentStatus.equals(StringPool.BLANK)) {
3009                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3);
3010                            }
3011                            else {
3012                                    query.append(_FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2);
3013                            }
3014                    }
3015    
3016                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3017                                    ShoppingOrder.class.getName(),
3018                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3019    
3020                    Session session = null;
3021    
3022                    try {
3023                            session = openSession();
3024    
3025                            SQLQuery q = session.createSQLQuery(sql);
3026    
3027                            q.addScalar(COUNT_COLUMN_NAME,
3028                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3029    
3030                            QueryPos qPos = QueryPos.getInstance(q);
3031    
3032                            qPos.add(groupId);
3033    
3034                            qPos.add(userId);
3035    
3036                            if (ppPaymentStatus != null) {
3037                                    qPos.add(ppPaymentStatus);
3038                            }
3039    
3040                            Long count = (Long)q.uniqueResult();
3041    
3042                            return count.intValue();
3043                    }
3044                    catch (Exception e) {
3045                            throw processException(e);
3046                    }
3047                    finally {
3048                            closeSession(session);
3049                    }
3050            }
3051    
3052            /**
3053             * Returns the number of shopping orders.
3054             *
3055             * @return the number of shopping orders
3056             * @throws SystemException if a system exception occurred
3057             */
3058            public int countAll() throws SystemException {
3059                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3060                                    FINDER_ARGS_EMPTY, this);
3061    
3062                    if (count == null) {
3063                            Session session = null;
3064    
3065                            try {
3066                                    session = openSession();
3067    
3068                                    Query q = session.createQuery(_SQL_COUNT_SHOPPINGORDER);
3069    
3070                                    count = (Long)q.uniqueResult();
3071                            }
3072                            catch (Exception e) {
3073                                    throw processException(e);
3074                            }
3075                            finally {
3076                                    if (count == null) {
3077                                            count = Long.valueOf(0);
3078                                    }
3079    
3080                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3081                                            FINDER_ARGS_EMPTY, count);
3082    
3083                                    closeSession(session);
3084                            }
3085                    }
3086    
3087                    return count.intValue();
3088            }
3089    
3090            /**
3091             * Initializes the shopping order persistence.
3092             */
3093            public void afterPropertiesSet() {
3094                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3095                                            com.liferay.portal.util.PropsUtil.get(
3096                                                    "value.object.listener.com.liferay.portlet.shopping.model.ShoppingOrder")));
3097    
3098                    if (listenerClassNames.length > 0) {
3099                            try {
3100                                    List<ModelListener<ShoppingOrder>> listenersList = new ArrayList<ModelListener<ShoppingOrder>>();
3101    
3102                                    for (String listenerClassName : listenerClassNames) {
3103                                            Class<?> clazz = getClass();
3104    
3105                                            listenersList.add((ModelListener<ShoppingOrder>)InstanceFactory.newInstance(
3106                                                            clazz.getClassLoader(), listenerClassName));
3107                                    }
3108    
3109                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3110                            }
3111                            catch (Exception e) {
3112                                    _log.error(e);
3113                            }
3114                    }
3115            }
3116    
3117            public void destroy() {
3118                    EntityCacheUtil.removeCache(ShoppingOrderImpl.class.getName());
3119                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3120                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3121            }
3122    
3123            @BeanReference(type = ShoppingCartPersistence.class)
3124            protected ShoppingCartPersistence shoppingCartPersistence;
3125            @BeanReference(type = ShoppingCategoryPersistence.class)
3126            protected ShoppingCategoryPersistence shoppingCategoryPersistence;
3127            @BeanReference(type = ShoppingCouponPersistence.class)
3128            protected ShoppingCouponPersistence shoppingCouponPersistence;
3129            @BeanReference(type = ShoppingItemPersistence.class)
3130            protected ShoppingItemPersistence shoppingItemPersistence;
3131            @BeanReference(type = ShoppingItemFieldPersistence.class)
3132            protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
3133            @BeanReference(type = ShoppingItemPricePersistence.class)
3134            protected ShoppingItemPricePersistence shoppingItemPricePersistence;
3135            @BeanReference(type = ShoppingOrderPersistence.class)
3136            protected ShoppingOrderPersistence shoppingOrderPersistence;
3137            @BeanReference(type = ShoppingOrderItemPersistence.class)
3138            protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
3139            @BeanReference(type = CompanyPersistence.class)
3140            protected CompanyPersistence companyPersistence;
3141            @BeanReference(type = ResourcePersistence.class)
3142            protected ResourcePersistence resourcePersistence;
3143            @BeanReference(type = SubscriptionPersistence.class)
3144            protected SubscriptionPersistence subscriptionPersistence;
3145            @BeanReference(type = UserPersistence.class)
3146            protected UserPersistence userPersistence;
3147            @BeanReference(type = MBMessagePersistence.class)
3148            protected MBMessagePersistence mbMessagePersistence;
3149            private static final String _SQL_SELECT_SHOPPINGORDER = "SELECT shoppingOrder FROM ShoppingOrder shoppingOrder";
3150            private static final String _SQL_SELECT_SHOPPINGORDER_WHERE = "SELECT shoppingOrder FROM ShoppingOrder shoppingOrder WHERE ";
3151            private static final String _SQL_COUNT_SHOPPINGORDER = "SELECT COUNT(shoppingOrder) FROM ShoppingOrder shoppingOrder";
3152            private static final String _SQL_COUNT_SHOPPINGORDER_WHERE = "SELECT COUNT(shoppingOrder) FROM ShoppingOrder shoppingOrder WHERE ";
3153            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "shoppingOrder.groupId = ?";
3154            private static final String _FINDER_COLUMN_NUMBER_NUMBER_1 = "shoppingOrder.number IS NULL";
3155            private static final String _FINDER_COLUMN_NUMBER_NUMBER_2 = "shoppingOrder.number = ?";
3156            private static final String _FINDER_COLUMN_NUMBER_NUMBER_3 = "(shoppingOrder.number IS NULL OR shoppingOrder.number = ?)";
3157            private static final String _FINDER_COLUMN_PPTXNID_PPTXNID_1 = "shoppingOrder.ppTxnId IS NULL";
3158            private static final String _FINDER_COLUMN_PPTXNID_PPTXNID_2 = "shoppingOrder.ppTxnId = ?";
3159            private static final String _FINDER_COLUMN_PPTXNID_PPTXNID_3 = "(shoppingOrder.ppTxnId IS NULL OR shoppingOrder.ppTxnId = ?)";
3160            private static final String _FINDER_COLUMN_G_U_PPPS_GROUPID_2 = "shoppingOrder.groupId = ? AND ";
3161            private static final String _FINDER_COLUMN_G_U_PPPS_USERID_2 = "shoppingOrder.userId = ? AND ";
3162            private static final String _FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_1 = "shoppingOrder.ppPaymentStatus IS NULL";
3163            private static final String _FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_2 = "shoppingOrder.ppPaymentStatus = ?";
3164            private static final String _FINDER_COLUMN_G_U_PPPS_PPPAYMENTSTATUS_3 = "(shoppingOrder.ppPaymentStatus IS NULL OR shoppingOrder.ppPaymentStatus = ?)";
3165            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "shoppingOrder.orderId";
3166            private static final String _FILTER_SQL_SELECT_SHOPPINGORDER_WHERE = "SELECT DISTINCT {shoppingOrder.*} FROM ShoppingOrder shoppingOrder WHERE ";
3167            private static final String _FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_1 =
3168                    "SELECT {ShoppingOrder.*} FROM (SELECT DISTINCT shoppingOrder.orderId FROM ShoppingOrder shoppingOrder WHERE ";
3169            private static final String _FILTER_SQL_SELECT_SHOPPINGORDER_NO_INLINE_DISTINCT_WHERE_2 =
3170                    ") TEMP_TABLE INNER JOIN ShoppingOrder ON TEMP_TABLE.orderId = ShoppingOrder.orderId";
3171            private static final String _FILTER_SQL_COUNT_SHOPPINGORDER_WHERE = "SELECT COUNT(DISTINCT shoppingOrder.orderId) AS COUNT_VALUE FROM ShoppingOrder shoppingOrder WHERE ";
3172            private static final String _FILTER_ENTITY_ALIAS = "shoppingOrder";
3173            private static final String _FILTER_ENTITY_TABLE = "ShoppingOrder";
3174            private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingOrder.";
3175            private static final String _ORDER_BY_ENTITY_TABLE = "ShoppingOrder.";
3176            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingOrder exists with the primary key ";
3177            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingOrder exists with the key {";
3178            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3179            private static Log _log = LogFactoryUtil.getLog(ShoppingOrderPersistenceImpl.class);
3180            private static ShoppingOrder _nullShoppingOrder = new ShoppingOrderImpl() {
3181                            @Override
3182                            public Object clone() {
3183                                    return this;
3184                            }
3185    
3186                            @Override
3187                            public CacheModel<ShoppingOrder> toCacheModel() {
3188                                    return _nullShoppingOrderCacheModel;
3189                            }
3190                    };
3191    
3192            private static CacheModel<ShoppingOrder> _nullShoppingOrderCacheModel = new CacheModel<ShoppingOrder>() {
3193                            public ShoppingOrder toEntityModel() {
3194                                    return _nullShoppingOrder;
3195                            }
3196                    };
3197    }