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