001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.shopping.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.ResourcePersistence;
040    import com.liferay.portal.service.persistence.UserPersistence;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.shopping.NoSuchCouponException;
044    import com.liferay.portlet.shopping.model.ShoppingCoupon;
045    import com.liferay.portlet.shopping.model.impl.ShoppingCouponImpl;
046    import com.liferay.portlet.shopping.model.impl.ShoppingCouponModelImpl;
047    
048    import java.io.Serializable;
049    
050    import java.util.ArrayList;
051    import java.util.Collections;
052    import java.util.List;
053    
054    /**
055     * The persistence for the shopping coupon service.
056     *
057     * <p>
058     * Never modify this class directly. Modify <code>service.xml</code> and rerun ServiceBuilder to regnerate this class.
059     * </p>
060     *
061     * <p>
062     * Caching information and settings can be found in <code>portal.properties</code>
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see ShoppingCouponPersistence
067     * @see ShoppingCouponUtil
068     * @generated
069     */
070    public class ShoppingCouponPersistenceImpl extends BasePersistenceImpl<ShoppingCoupon>
071            implements ShoppingCouponPersistence {
072            public static final String FINDER_CLASS_NAME_ENTITY = ShoppingCouponImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
074                    ".List";
075            public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
076                            ShoppingCouponModelImpl.FINDER_CACHE_ENABLED,
077                            FINDER_CLASS_NAME_LIST, "findByGroupId",
078                            new String[] {
079                                    Long.class.getName(),
080                                    
081                            "java.lang.Integer", "java.lang.Integer",
082                                    "com.liferay.portal.kernel.util.OrderByComparator"
083                            });
084            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
085                            ShoppingCouponModelImpl.FINDER_CACHE_ENABLED,
086                            FINDER_CLASS_NAME_LIST, "countByGroupId",
087                            new String[] { Long.class.getName() });
088            public static final FinderPath FINDER_PATH_FETCH_BY_CODE = new FinderPath(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
089                            ShoppingCouponModelImpl.FINDER_CACHE_ENABLED,
090                            FINDER_CLASS_NAME_ENTITY, "fetchByCode",
091                            new String[] { String.class.getName() });
092            public static final FinderPath FINDER_PATH_COUNT_BY_CODE = new FinderPath(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
093                            ShoppingCouponModelImpl.FINDER_CACHE_ENABLED,
094                            FINDER_CLASS_NAME_LIST, "countByCode",
095                            new String[] { String.class.getName() });
096            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
097                            ShoppingCouponModelImpl.FINDER_CACHE_ENABLED,
098                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
099            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
100                            ShoppingCouponModelImpl.FINDER_CACHE_ENABLED,
101                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
102    
103            /**
104             * Caches the shopping coupon in the entity cache if it is enabled.
105             *
106             * @param shoppingCoupon the shopping coupon to cache
107             */
108            public void cacheResult(ShoppingCoupon shoppingCoupon) {
109                    EntityCacheUtil.putResult(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
110                            ShoppingCouponImpl.class, shoppingCoupon.getPrimaryKey(),
111                            shoppingCoupon);
112    
113                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CODE,
114                            new Object[] { shoppingCoupon.getCode() }, shoppingCoupon);
115            }
116    
117            /**
118             * Caches the shopping coupons in the entity cache if it is enabled.
119             *
120             * @param shoppingCoupons the shopping coupons to cache
121             */
122            public void cacheResult(List<ShoppingCoupon> shoppingCoupons) {
123                    for (ShoppingCoupon shoppingCoupon : shoppingCoupons) {
124                            if (EntityCacheUtil.getResult(
125                                                    ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
126                                                    ShoppingCouponImpl.class,
127                                                    shoppingCoupon.getPrimaryKey(), this) == null) {
128                                    cacheResult(shoppingCoupon);
129                            }
130                    }
131            }
132    
133            /**
134             * Clears the cache for all shopping coupons.
135             *
136             * <p>
137             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
138             * </p>
139             */
140            public void clearCache() {
141                    CacheRegistryUtil.clear(ShoppingCouponImpl.class.getName());
142                    EntityCacheUtil.clearCache(ShoppingCouponImpl.class.getName());
143                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
144                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
145            }
146    
147            /**
148             * Clears the cache for the shopping coupon.
149             *
150             * <p>
151             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
152             * </p>
153             */
154            public void clearCache(ShoppingCoupon shoppingCoupon) {
155                    EntityCacheUtil.removeResult(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
156                            ShoppingCouponImpl.class, shoppingCoupon.getPrimaryKey());
157    
158                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CODE,
159                            new Object[] { shoppingCoupon.getCode() });
160            }
161    
162            /**
163             * Creates a new shopping coupon with the primary key.
164             *
165             * @param couponId the primary key for the new shopping coupon
166             * @return the new shopping coupon
167             */
168            public ShoppingCoupon create(long couponId) {
169                    ShoppingCoupon shoppingCoupon = new ShoppingCouponImpl();
170    
171                    shoppingCoupon.setNew(true);
172                    shoppingCoupon.setPrimaryKey(couponId);
173    
174                    return shoppingCoupon;
175            }
176    
177            /**
178             * Removes the shopping coupon with the primary key from the database. Also notifies the appropriate model listeners.
179             *
180             * @param primaryKey the primary key of the shopping coupon to remove
181             * @return the shopping coupon that was removed
182             * @throws com.liferay.portal.NoSuchModelException if a shopping coupon with the primary key could not be found
183             * @throws SystemException if a system exception occurred
184             */
185            public ShoppingCoupon remove(Serializable primaryKey)
186                    throws NoSuchModelException, SystemException {
187                    return remove(((Long)primaryKey).longValue());
188            }
189    
190            /**
191             * Removes the shopping coupon with the primary key from the database. Also notifies the appropriate model listeners.
192             *
193             * @param couponId the primary key of the shopping coupon to remove
194             * @return the shopping coupon that was removed
195             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a shopping coupon with the primary key could not be found
196             * @throws SystemException if a system exception occurred
197             */
198            public ShoppingCoupon remove(long couponId)
199                    throws NoSuchCouponException, SystemException {
200                    Session session = null;
201    
202                    try {
203                            session = openSession();
204    
205                            ShoppingCoupon shoppingCoupon = (ShoppingCoupon)session.get(ShoppingCouponImpl.class,
206                                            new Long(couponId));
207    
208                            if (shoppingCoupon == null) {
209                                    if (_log.isWarnEnabled()) {
210                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + couponId);
211                                    }
212    
213                                    throw new NoSuchCouponException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
214                                            couponId);
215                            }
216    
217                            return remove(shoppingCoupon);
218                    }
219                    catch (NoSuchCouponException nsee) {
220                            throw nsee;
221                    }
222                    catch (Exception e) {
223                            throw processException(e);
224                    }
225                    finally {
226                            closeSession(session);
227                    }
228            }
229    
230            protected ShoppingCoupon removeImpl(ShoppingCoupon shoppingCoupon)
231                    throws SystemException {
232                    shoppingCoupon = toUnwrappedModel(shoppingCoupon);
233    
234                    Session session = null;
235    
236                    try {
237                            session = openSession();
238    
239                            if (shoppingCoupon.isCachedModel() || BatchSessionUtil.isEnabled()) {
240                                    Object staleObject = session.get(ShoppingCouponImpl.class,
241                                                    shoppingCoupon.getPrimaryKeyObj());
242    
243                                    if (staleObject != null) {
244                                            session.evict(staleObject);
245                                    }
246                            }
247    
248                            session.delete(shoppingCoupon);
249    
250                            session.flush();
251                    }
252                    catch (Exception e) {
253                            throw processException(e);
254                    }
255                    finally {
256                            closeSession(session);
257                    }
258    
259                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
260    
261                    ShoppingCouponModelImpl shoppingCouponModelImpl = (ShoppingCouponModelImpl)shoppingCoupon;
262    
263                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CODE,
264                            new Object[] { shoppingCouponModelImpl.getOriginalCode() });
265    
266                    EntityCacheUtil.removeResult(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
267                            ShoppingCouponImpl.class, shoppingCoupon.getPrimaryKey());
268    
269                    return shoppingCoupon;
270            }
271    
272            public ShoppingCoupon updateImpl(
273                    com.liferay.portlet.shopping.model.ShoppingCoupon shoppingCoupon,
274                    boolean merge) throws SystemException {
275                    shoppingCoupon = toUnwrappedModel(shoppingCoupon);
276    
277                    boolean isNew = shoppingCoupon.isNew();
278    
279                    ShoppingCouponModelImpl shoppingCouponModelImpl = (ShoppingCouponModelImpl)shoppingCoupon;
280    
281                    Session session = null;
282    
283                    try {
284                            session = openSession();
285    
286                            BatchSessionUtil.update(session, shoppingCoupon, merge);
287    
288                            shoppingCoupon.setNew(false);
289                    }
290                    catch (Exception e) {
291                            throw processException(e);
292                    }
293                    finally {
294                            closeSession(session);
295                    }
296    
297                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
298    
299                    EntityCacheUtil.putResult(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
300                            ShoppingCouponImpl.class, shoppingCoupon.getPrimaryKey(),
301                            shoppingCoupon);
302    
303                    if (!isNew &&
304                                    (!Validator.equals(shoppingCoupon.getCode(),
305                                            shoppingCouponModelImpl.getOriginalCode()))) {
306                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CODE,
307                                    new Object[] { shoppingCouponModelImpl.getOriginalCode() });
308                    }
309    
310                    if (isNew ||
311                                    (!Validator.equals(shoppingCoupon.getCode(),
312                                            shoppingCouponModelImpl.getOriginalCode()))) {
313                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CODE,
314                                    new Object[] { shoppingCoupon.getCode() }, shoppingCoupon);
315                    }
316    
317                    return shoppingCoupon;
318            }
319    
320            protected ShoppingCoupon toUnwrappedModel(ShoppingCoupon shoppingCoupon) {
321                    if (shoppingCoupon instanceof ShoppingCouponImpl) {
322                            return shoppingCoupon;
323                    }
324    
325                    ShoppingCouponImpl shoppingCouponImpl = new ShoppingCouponImpl();
326    
327                    shoppingCouponImpl.setNew(shoppingCoupon.isNew());
328                    shoppingCouponImpl.setPrimaryKey(shoppingCoupon.getPrimaryKey());
329    
330                    shoppingCouponImpl.setCouponId(shoppingCoupon.getCouponId());
331                    shoppingCouponImpl.setGroupId(shoppingCoupon.getGroupId());
332                    shoppingCouponImpl.setCompanyId(shoppingCoupon.getCompanyId());
333                    shoppingCouponImpl.setUserId(shoppingCoupon.getUserId());
334                    shoppingCouponImpl.setUserName(shoppingCoupon.getUserName());
335                    shoppingCouponImpl.setCreateDate(shoppingCoupon.getCreateDate());
336                    shoppingCouponImpl.setModifiedDate(shoppingCoupon.getModifiedDate());
337                    shoppingCouponImpl.setCode(shoppingCoupon.getCode());
338                    shoppingCouponImpl.setName(shoppingCoupon.getName());
339                    shoppingCouponImpl.setDescription(shoppingCoupon.getDescription());
340                    shoppingCouponImpl.setStartDate(shoppingCoupon.getStartDate());
341                    shoppingCouponImpl.setEndDate(shoppingCoupon.getEndDate());
342                    shoppingCouponImpl.setActive(shoppingCoupon.isActive());
343                    shoppingCouponImpl.setLimitCategories(shoppingCoupon.getLimitCategories());
344                    shoppingCouponImpl.setLimitSkus(shoppingCoupon.getLimitSkus());
345                    shoppingCouponImpl.setMinOrder(shoppingCoupon.getMinOrder());
346                    shoppingCouponImpl.setDiscount(shoppingCoupon.getDiscount());
347                    shoppingCouponImpl.setDiscountType(shoppingCoupon.getDiscountType());
348    
349                    return shoppingCouponImpl;
350            }
351    
352            /**
353             * Finds the shopping coupon with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
354             *
355             * @param primaryKey the primary key of the shopping coupon to find
356             * @return the shopping coupon
357             * @throws com.liferay.portal.NoSuchModelException if a shopping coupon with the primary key could not be found
358             * @throws SystemException if a system exception occurred
359             */
360            public ShoppingCoupon findByPrimaryKey(Serializable primaryKey)
361                    throws NoSuchModelException, SystemException {
362                    return findByPrimaryKey(((Long)primaryKey).longValue());
363            }
364    
365            /**
366             * Finds the shopping coupon with the primary key or throws a {@link com.liferay.portlet.shopping.NoSuchCouponException} if it could not be found.
367             *
368             * @param couponId the primary key of the shopping coupon to find
369             * @return the shopping coupon
370             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a shopping coupon with the primary key could not be found
371             * @throws SystemException if a system exception occurred
372             */
373            public ShoppingCoupon findByPrimaryKey(long couponId)
374                    throws NoSuchCouponException, SystemException {
375                    ShoppingCoupon shoppingCoupon = fetchByPrimaryKey(couponId);
376    
377                    if (shoppingCoupon == null) {
378                            if (_log.isWarnEnabled()) {
379                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + couponId);
380                            }
381    
382                            throw new NoSuchCouponException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
383                                    couponId);
384                    }
385    
386                    return shoppingCoupon;
387            }
388    
389            /**
390             * Finds the shopping coupon with the primary key or returns <code>null</code> if it could not be found.
391             *
392             * @param primaryKey the primary key of the shopping coupon to find
393             * @return the shopping coupon, or <code>null</code> if a shopping coupon with the primary key could not be found
394             * @throws SystemException if a system exception occurred
395             */
396            public ShoppingCoupon fetchByPrimaryKey(Serializable primaryKey)
397                    throws SystemException {
398                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
399            }
400    
401            /**
402             * Finds the shopping coupon with the primary key or returns <code>null</code> if it could not be found.
403             *
404             * @param couponId the primary key of the shopping coupon to find
405             * @return the shopping coupon, or <code>null</code> if a shopping coupon with the primary key could not be found
406             * @throws SystemException if a system exception occurred
407             */
408            public ShoppingCoupon fetchByPrimaryKey(long couponId)
409                    throws SystemException {
410                    ShoppingCoupon shoppingCoupon = (ShoppingCoupon)EntityCacheUtil.getResult(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
411                                    ShoppingCouponImpl.class, couponId, this);
412    
413                    if (shoppingCoupon == null) {
414                            Session session = null;
415    
416                            try {
417                                    session = openSession();
418    
419                                    shoppingCoupon = (ShoppingCoupon)session.get(ShoppingCouponImpl.class,
420                                                    new Long(couponId));
421                            }
422                            catch (Exception e) {
423                                    throw processException(e);
424                            }
425                            finally {
426                                    if (shoppingCoupon != null) {
427                                            cacheResult(shoppingCoupon);
428                                    }
429    
430                                    closeSession(session);
431                            }
432                    }
433    
434                    return shoppingCoupon;
435            }
436    
437            /**
438             * Finds all the shopping coupons where groupId = &#63;.
439             *
440             * @param groupId the group id to search with
441             * @return the matching shopping coupons
442             * @throws SystemException if a system exception occurred
443             */
444            public List<ShoppingCoupon> findByGroupId(long groupId)
445                    throws SystemException {
446                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
447            }
448    
449            /**
450             * Finds a range of all the shopping coupons where groupId = &#63;.
451             *
452             * <p>
453             * 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.
454             * </p>
455             *
456             * @param groupId the group id to search with
457             * @param start the lower bound of the range of shopping coupons to return
458             * @param end the upper bound of the range of shopping coupons to return (not inclusive)
459             * @return the range of matching shopping coupons
460             * @throws SystemException if a system exception occurred
461             */
462            public List<ShoppingCoupon> findByGroupId(long groupId, int start, int end)
463                    throws SystemException {
464                    return findByGroupId(groupId, start, end, null);
465            }
466    
467            /**
468             * Finds an ordered range of all the shopping coupons where groupId = &#63;.
469             *
470             * <p>
471             * 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.
472             * </p>
473             *
474             * @param groupId the group id to search with
475             * @param start the lower bound of the range of shopping coupons to return
476             * @param end the upper bound of the range of shopping coupons to return (not inclusive)
477             * @param orderByComparator the comparator to order the results by
478             * @return the ordered range of matching shopping coupons
479             * @throws SystemException if a system exception occurred
480             */
481            public List<ShoppingCoupon> findByGroupId(long groupId, int start, int end,
482                    OrderByComparator orderByComparator) throws SystemException {
483                    Object[] finderArgs = new Object[] {
484                                    groupId,
485                                    
486                                    String.valueOf(start), String.valueOf(end),
487                                    String.valueOf(orderByComparator)
488                            };
489    
490                    List<ShoppingCoupon> list = (List<ShoppingCoupon>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
491                                    finderArgs, this);
492    
493                    if (list == null) {
494                            Session session = null;
495    
496                            try {
497                                    session = openSession();
498    
499                                    StringBundler query = null;
500    
501                                    if (orderByComparator != null) {
502                                            query = new StringBundler(3 +
503                                                            (orderByComparator.getOrderByFields().length * 3));
504                                    }
505                                    else {
506                                            query = new StringBundler(3);
507                                    }
508    
509                                    query.append(_SQL_SELECT_SHOPPINGCOUPON_WHERE);
510    
511                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
512    
513                                    if (orderByComparator != null) {
514                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
515                                                    orderByComparator);
516                                    }
517    
518                                    else {
519                                            query.append(ShoppingCouponModelImpl.ORDER_BY_JPQL);
520                                    }
521    
522                                    String sql = query.toString();
523    
524                                    Query q = session.createQuery(sql);
525    
526                                    QueryPos qPos = QueryPos.getInstance(q);
527    
528                                    qPos.add(groupId);
529    
530                                    list = (List<ShoppingCoupon>)QueryUtil.list(q, getDialect(),
531                                                    start, end);
532                            }
533                            catch (Exception e) {
534                                    throw processException(e);
535                            }
536                            finally {
537                                    if (list == null) {
538                                            list = new ArrayList<ShoppingCoupon>();
539                                    }
540    
541                                    cacheResult(list);
542    
543                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
544                                            finderArgs, list);
545    
546                                    closeSession(session);
547                            }
548                    }
549    
550                    return list;
551            }
552    
553            /**
554             * Finds the first shopping coupon in the ordered set where groupId = &#63;.
555             *
556             * <p>
557             * 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.
558             * </p>
559             *
560             * @param groupId the group id to search with
561             * @param orderByComparator the comparator to order the set by
562             * @return the first matching shopping coupon
563             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a matching shopping coupon could not be found
564             * @throws SystemException if a system exception occurred
565             */
566            public ShoppingCoupon findByGroupId_First(long groupId,
567                    OrderByComparator orderByComparator)
568                    throws NoSuchCouponException, SystemException {
569                    List<ShoppingCoupon> list = findByGroupId(groupId, 0, 1,
570                                    orderByComparator);
571    
572                    if (list.isEmpty()) {
573                            StringBundler msg = new StringBundler(4);
574    
575                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
576    
577                            msg.append("groupId=");
578                            msg.append(groupId);
579    
580                            msg.append(StringPool.CLOSE_CURLY_BRACE);
581    
582                            throw new NoSuchCouponException(msg.toString());
583                    }
584                    else {
585                            return list.get(0);
586                    }
587            }
588    
589            /**
590             * Finds the last shopping coupon in the ordered set where groupId = &#63;.
591             *
592             * <p>
593             * 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.
594             * </p>
595             *
596             * @param groupId the group id to search with
597             * @param orderByComparator the comparator to order the set by
598             * @return the last matching shopping coupon
599             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a matching shopping coupon could not be found
600             * @throws SystemException if a system exception occurred
601             */
602            public ShoppingCoupon findByGroupId_Last(long groupId,
603                    OrderByComparator orderByComparator)
604                    throws NoSuchCouponException, SystemException {
605                    int count = countByGroupId(groupId);
606    
607                    List<ShoppingCoupon> list = findByGroupId(groupId, count - 1, count,
608                                    orderByComparator);
609    
610                    if (list.isEmpty()) {
611                            StringBundler msg = new StringBundler(4);
612    
613                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
614    
615                            msg.append("groupId=");
616                            msg.append(groupId);
617    
618                            msg.append(StringPool.CLOSE_CURLY_BRACE);
619    
620                            throw new NoSuchCouponException(msg.toString());
621                    }
622                    else {
623                            return list.get(0);
624                    }
625            }
626    
627            /**
628             * Finds the shopping coupons before and after the current shopping coupon in the ordered set where groupId = &#63;.
629             *
630             * <p>
631             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
632             * </p>
633             *
634             * @param couponId the primary key of the current shopping coupon
635             * @param groupId the group id to search with
636             * @param orderByComparator the comparator to order the set by
637             * @return the previous, current, and next shopping coupon
638             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a shopping coupon with the primary key could not be found
639             * @throws SystemException if a system exception occurred
640             */
641            public ShoppingCoupon[] findByGroupId_PrevAndNext(long couponId,
642                    long groupId, OrderByComparator orderByComparator)
643                    throws NoSuchCouponException, SystemException {
644                    ShoppingCoupon shoppingCoupon = findByPrimaryKey(couponId);
645    
646                    Session session = null;
647    
648                    try {
649                            session = openSession();
650    
651                            ShoppingCoupon[] array = new ShoppingCouponImpl[3];
652    
653                            array[0] = getByGroupId_PrevAndNext(session, shoppingCoupon,
654                                            groupId, orderByComparator, true);
655    
656                            array[1] = shoppingCoupon;
657    
658                            array[2] = getByGroupId_PrevAndNext(session, shoppingCoupon,
659                                            groupId, orderByComparator, false);
660    
661                            return array;
662                    }
663                    catch (Exception e) {
664                            throw processException(e);
665                    }
666                    finally {
667                            closeSession(session);
668                    }
669            }
670    
671            protected ShoppingCoupon getByGroupId_PrevAndNext(Session session,
672                    ShoppingCoupon shoppingCoupon, long groupId,
673                    OrderByComparator orderByComparator, boolean previous) {
674                    StringBundler query = null;
675    
676                    if (orderByComparator != null) {
677                            query = new StringBundler(6 +
678                                            (orderByComparator.getOrderByFields().length * 6));
679                    }
680                    else {
681                            query = new StringBundler(3);
682                    }
683    
684                    query.append(_SQL_SELECT_SHOPPINGCOUPON_WHERE);
685    
686                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
687    
688                    if (orderByComparator != null) {
689                            String[] orderByFields = orderByComparator.getOrderByFields();
690    
691                            if (orderByFields.length > 0) {
692                                    query.append(WHERE_AND);
693                            }
694    
695                            for (int i = 0; i < orderByFields.length; i++) {
696                                    query.append(_ORDER_BY_ENTITY_ALIAS);
697                                    query.append(orderByFields[i]);
698    
699                                    if ((i + 1) < orderByFields.length) {
700                                            if (orderByComparator.isAscending() ^ previous) {
701                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
702                                            }
703                                            else {
704                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
705                                            }
706                                    }
707                                    else {
708                                            if (orderByComparator.isAscending() ^ previous) {
709                                                    query.append(WHERE_GREATER_THAN);
710                                            }
711                                            else {
712                                                    query.append(WHERE_LESSER_THAN);
713                                            }
714                                    }
715                            }
716    
717                            query.append(ORDER_BY_CLAUSE);
718    
719                            for (int i = 0; i < orderByFields.length; i++) {
720                                    query.append(_ORDER_BY_ENTITY_ALIAS);
721                                    query.append(orderByFields[i]);
722    
723                                    if ((i + 1) < orderByFields.length) {
724                                            if (orderByComparator.isAscending() ^ previous) {
725                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
726                                            }
727                                            else {
728                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
729                                            }
730                                    }
731                                    else {
732                                            if (orderByComparator.isAscending() ^ previous) {
733                                                    query.append(ORDER_BY_ASC);
734                                            }
735                                            else {
736                                                    query.append(ORDER_BY_DESC);
737                                            }
738                                    }
739                            }
740                    }
741    
742                    else {
743                            query.append(ShoppingCouponModelImpl.ORDER_BY_JPQL);
744                    }
745    
746                    String sql = query.toString();
747    
748                    Query q = session.createQuery(sql);
749    
750                    q.setFirstResult(0);
751                    q.setMaxResults(2);
752    
753                    QueryPos qPos = QueryPos.getInstance(q);
754    
755                    qPos.add(groupId);
756    
757                    if (orderByComparator != null) {
758                            Object[] values = orderByComparator.getOrderByValues(shoppingCoupon);
759    
760                            for (Object value : values) {
761                                    qPos.add(value);
762                            }
763                    }
764    
765                    List<ShoppingCoupon> list = q.list();
766    
767                    if (list.size() == 2) {
768                            return list.get(1);
769                    }
770                    else {
771                            return null;
772                    }
773            }
774    
775            /**
776             * Finds the shopping coupon where code = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchCouponException} if it could not be found.
777             *
778             * @param code the code to search with
779             * @return the matching shopping coupon
780             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a matching shopping coupon could not be found
781             * @throws SystemException if a system exception occurred
782             */
783            public ShoppingCoupon findByCode(String code)
784                    throws NoSuchCouponException, SystemException {
785                    ShoppingCoupon shoppingCoupon = fetchByCode(code);
786    
787                    if (shoppingCoupon == null) {
788                            StringBundler msg = new StringBundler(4);
789    
790                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
791    
792                            msg.append("code=");
793                            msg.append(code);
794    
795                            msg.append(StringPool.CLOSE_CURLY_BRACE);
796    
797                            if (_log.isWarnEnabled()) {
798                                    _log.warn(msg.toString());
799                            }
800    
801                            throw new NoSuchCouponException(msg.toString());
802                    }
803    
804                    return shoppingCoupon;
805            }
806    
807            /**
808             * Finds the shopping coupon where code = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
809             *
810             * @param code the code to search with
811             * @return the matching shopping coupon, or <code>null</code> if a matching shopping coupon could not be found
812             * @throws SystemException if a system exception occurred
813             */
814            public ShoppingCoupon fetchByCode(String code) throws SystemException {
815                    return fetchByCode(code, true);
816            }
817    
818            /**
819             * Finds the shopping coupon where code = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
820             *
821             * @param code the code to search with
822             * @return the matching shopping coupon, or <code>null</code> if a matching shopping coupon could not be found
823             * @throws SystemException if a system exception occurred
824             */
825            public ShoppingCoupon fetchByCode(String code, boolean retrieveFromCache)
826                    throws SystemException {
827                    Object[] finderArgs = new Object[] { code };
828    
829                    Object result = null;
830    
831                    if (retrieveFromCache) {
832                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CODE,
833                                            finderArgs, this);
834                    }
835    
836                    if (result == null) {
837                            Session session = null;
838    
839                            try {
840                                    session = openSession();
841    
842                                    StringBundler query = new StringBundler(3);
843    
844                                    query.append(_SQL_SELECT_SHOPPINGCOUPON_WHERE);
845    
846                                    if (code == null) {
847                                            query.append(_FINDER_COLUMN_CODE_CODE_1);
848                                    }
849                                    else {
850                                            if (code.equals(StringPool.BLANK)) {
851                                                    query.append(_FINDER_COLUMN_CODE_CODE_3);
852                                            }
853                                            else {
854                                                    query.append(_FINDER_COLUMN_CODE_CODE_2);
855                                            }
856                                    }
857    
858                                    query.append(ShoppingCouponModelImpl.ORDER_BY_JPQL);
859    
860                                    String sql = query.toString();
861    
862                                    Query q = session.createQuery(sql);
863    
864                                    QueryPos qPos = QueryPos.getInstance(q);
865    
866                                    if (code != null) {
867                                            qPos.add(code);
868                                    }
869    
870                                    List<ShoppingCoupon> list = q.list();
871    
872                                    result = list;
873    
874                                    ShoppingCoupon shoppingCoupon = null;
875    
876                                    if (list.isEmpty()) {
877                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CODE,
878                                                    finderArgs, list);
879                                    }
880                                    else {
881                                            shoppingCoupon = list.get(0);
882    
883                                            cacheResult(shoppingCoupon);
884    
885                                            if ((shoppingCoupon.getCode() == null) ||
886                                                            !shoppingCoupon.getCode().equals(code)) {
887                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CODE,
888                                                            finderArgs, shoppingCoupon);
889                                            }
890                                    }
891    
892                                    return shoppingCoupon;
893                            }
894                            catch (Exception e) {
895                                    throw processException(e);
896                            }
897                            finally {
898                                    if (result == null) {
899                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CODE,
900                                                    finderArgs, new ArrayList<ShoppingCoupon>());
901                                    }
902    
903                                    closeSession(session);
904                            }
905                    }
906                    else {
907                            if (result instanceof List<?>) {
908                                    return null;
909                            }
910                            else {
911                                    return (ShoppingCoupon)result;
912                            }
913                    }
914            }
915    
916            /**
917             * Finds all the shopping coupons.
918             *
919             * @return the shopping coupons
920             * @throws SystemException if a system exception occurred
921             */
922            public List<ShoppingCoupon> findAll() throws SystemException {
923                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
924            }
925    
926            /**
927             * Finds a range of all the shopping coupons.
928             *
929             * <p>
930             * 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.
931             * </p>
932             *
933             * @param start the lower bound of the range of shopping coupons to return
934             * @param end the upper bound of the range of shopping coupons to return (not inclusive)
935             * @return the range of shopping coupons
936             * @throws SystemException if a system exception occurred
937             */
938            public List<ShoppingCoupon> findAll(int start, int end)
939                    throws SystemException {
940                    return findAll(start, end, null);
941            }
942    
943            /**
944             * Finds an ordered range of all the shopping coupons.
945             *
946             * <p>
947             * 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.
948             * </p>
949             *
950             * @param start the lower bound of the range of shopping coupons to return
951             * @param end the upper bound of the range of shopping coupons to return (not inclusive)
952             * @param orderByComparator the comparator to order the results by
953             * @return the ordered range of shopping coupons
954             * @throws SystemException if a system exception occurred
955             */
956            public List<ShoppingCoupon> findAll(int start, int end,
957                    OrderByComparator orderByComparator) throws SystemException {
958                    Object[] finderArgs = new Object[] {
959                                    String.valueOf(start), String.valueOf(end),
960                                    String.valueOf(orderByComparator)
961                            };
962    
963                    List<ShoppingCoupon> list = (List<ShoppingCoupon>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
964                                    finderArgs, this);
965    
966                    if (list == null) {
967                            Session session = null;
968    
969                            try {
970                                    session = openSession();
971    
972                                    StringBundler query = null;
973                                    String sql = null;
974    
975                                    if (orderByComparator != null) {
976                                            query = new StringBundler(2 +
977                                                            (orderByComparator.getOrderByFields().length * 3));
978    
979                                            query.append(_SQL_SELECT_SHOPPINGCOUPON);
980    
981                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
982                                                    orderByComparator);
983    
984                                            sql = query.toString();
985                                    }
986                                    else {
987                                            sql = _SQL_SELECT_SHOPPINGCOUPON.concat(ShoppingCouponModelImpl.ORDER_BY_JPQL);
988                                    }
989    
990                                    Query q = session.createQuery(sql);
991    
992                                    if (orderByComparator == null) {
993                                            list = (List<ShoppingCoupon>)QueryUtil.list(q,
994                                                            getDialect(), start, end, false);
995    
996                                            Collections.sort(list);
997                                    }
998                                    else {
999                                            list = (List<ShoppingCoupon>)QueryUtil.list(q,
1000                                                            getDialect(), start, end);
1001                                    }
1002                            }
1003                            catch (Exception e) {
1004                                    throw processException(e);
1005                            }
1006                            finally {
1007                                    if (list == null) {
1008                                            list = new ArrayList<ShoppingCoupon>();
1009                                    }
1010    
1011                                    cacheResult(list);
1012    
1013                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1014    
1015                                    closeSession(session);
1016                            }
1017                    }
1018    
1019                    return list;
1020            }
1021    
1022            /**
1023             * Removes all the shopping coupons where groupId = &#63; from the database.
1024             *
1025             * @param groupId the group id to search with
1026             * @throws SystemException if a system exception occurred
1027             */
1028            public void removeByGroupId(long groupId) throws SystemException {
1029                    for (ShoppingCoupon shoppingCoupon : findByGroupId(groupId)) {
1030                            remove(shoppingCoupon);
1031                    }
1032            }
1033    
1034            /**
1035             * Removes the shopping coupon where code = &#63; from the database.
1036             *
1037             * @param code the code to search with
1038             * @throws SystemException if a system exception occurred
1039             */
1040            public void removeByCode(String code)
1041                    throws NoSuchCouponException, SystemException {
1042                    ShoppingCoupon shoppingCoupon = findByCode(code);
1043    
1044                    remove(shoppingCoupon);
1045            }
1046    
1047            /**
1048             * Removes all the shopping coupons from the database.
1049             *
1050             * @throws SystemException if a system exception occurred
1051             */
1052            public void removeAll() throws SystemException {
1053                    for (ShoppingCoupon shoppingCoupon : findAll()) {
1054                            remove(shoppingCoupon);
1055                    }
1056            }
1057    
1058            /**
1059             * Counts all the shopping coupons where groupId = &#63;.
1060             *
1061             * @param groupId the group id to search with
1062             * @return the number of matching shopping coupons
1063             * @throws SystemException if a system exception occurred
1064             */
1065            public int countByGroupId(long groupId) throws SystemException {
1066                    Object[] finderArgs = new Object[] { groupId };
1067    
1068                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1069                                    finderArgs, this);
1070    
1071                    if (count == null) {
1072                            Session session = null;
1073    
1074                            try {
1075                                    session = openSession();
1076    
1077                                    StringBundler query = new StringBundler(2);
1078    
1079                                    query.append(_SQL_COUNT_SHOPPINGCOUPON_WHERE);
1080    
1081                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1082    
1083                                    String sql = query.toString();
1084    
1085                                    Query q = session.createQuery(sql);
1086    
1087                                    QueryPos qPos = QueryPos.getInstance(q);
1088    
1089                                    qPos.add(groupId);
1090    
1091                                    count = (Long)q.uniqueResult();
1092                            }
1093                            catch (Exception e) {
1094                                    throw processException(e);
1095                            }
1096                            finally {
1097                                    if (count == null) {
1098                                            count = Long.valueOf(0);
1099                                    }
1100    
1101                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1102                                            finderArgs, count);
1103    
1104                                    closeSession(session);
1105                            }
1106                    }
1107    
1108                    return count.intValue();
1109            }
1110    
1111            /**
1112             * Counts all the shopping coupons where code = &#63;.
1113             *
1114             * @param code the code to search with
1115             * @return the number of matching shopping coupons
1116             * @throws SystemException if a system exception occurred
1117             */
1118            public int countByCode(String code) throws SystemException {
1119                    Object[] finderArgs = new Object[] { code };
1120    
1121                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CODE,
1122                                    finderArgs, this);
1123    
1124                    if (count == null) {
1125                            Session session = null;
1126    
1127                            try {
1128                                    session = openSession();
1129    
1130                                    StringBundler query = new StringBundler(2);
1131    
1132                                    query.append(_SQL_COUNT_SHOPPINGCOUPON_WHERE);
1133    
1134                                    if (code == null) {
1135                                            query.append(_FINDER_COLUMN_CODE_CODE_1);
1136                                    }
1137                                    else {
1138                                            if (code.equals(StringPool.BLANK)) {
1139                                                    query.append(_FINDER_COLUMN_CODE_CODE_3);
1140                                            }
1141                                            else {
1142                                                    query.append(_FINDER_COLUMN_CODE_CODE_2);
1143                                            }
1144                                    }
1145    
1146                                    String sql = query.toString();
1147    
1148                                    Query q = session.createQuery(sql);
1149    
1150                                    QueryPos qPos = QueryPos.getInstance(q);
1151    
1152                                    if (code != null) {
1153                                            qPos.add(code);
1154                                    }
1155    
1156                                    count = (Long)q.uniqueResult();
1157                            }
1158                            catch (Exception e) {
1159                                    throw processException(e);
1160                            }
1161                            finally {
1162                                    if (count == null) {
1163                                            count = Long.valueOf(0);
1164                                    }
1165    
1166                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CODE,
1167                                            finderArgs, count);
1168    
1169                                    closeSession(session);
1170                            }
1171                    }
1172    
1173                    return count.intValue();
1174            }
1175    
1176            /**
1177             * Counts all the shopping coupons.
1178             *
1179             * @return the number of shopping coupons
1180             * @throws SystemException if a system exception occurred
1181             */
1182            public int countAll() throws SystemException {
1183                    Object[] finderArgs = new Object[0];
1184    
1185                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1186                                    finderArgs, this);
1187    
1188                    if (count == null) {
1189                            Session session = null;
1190    
1191                            try {
1192                                    session = openSession();
1193    
1194                                    Query q = session.createQuery(_SQL_COUNT_SHOPPINGCOUPON);
1195    
1196                                    count = (Long)q.uniqueResult();
1197                            }
1198                            catch (Exception e) {
1199                                    throw processException(e);
1200                            }
1201                            finally {
1202                                    if (count == null) {
1203                                            count = Long.valueOf(0);
1204                                    }
1205    
1206                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1207                                            count);
1208    
1209                                    closeSession(session);
1210                            }
1211                    }
1212    
1213                    return count.intValue();
1214            }
1215    
1216            /**
1217             * Initializes the shopping coupon persistence.
1218             */
1219            public void afterPropertiesSet() {
1220                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1221                                            com.liferay.portal.util.PropsUtil.get(
1222                                                    "value.object.listener.com.liferay.portlet.shopping.model.ShoppingCoupon")));
1223    
1224                    if (listenerClassNames.length > 0) {
1225                            try {
1226                                    List<ModelListener<ShoppingCoupon>> listenersList = new ArrayList<ModelListener<ShoppingCoupon>>();
1227    
1228                                    for (String listenerClassName : listenerClassNames) {
1229                                            listenersList.add((ModelListener<ShoppingCoupon>)InstanceFactory.newInstance(
1230                                                            listenerClassName));
1231                                    }
1232    
1233                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1234                            }
1235                            catch (Exception e) {
1236                                    _log.error(e);
1237                            }
1238                    }
1239            }
1240    
1241            @BeanReference(type = ShoppingCartPersistence.class)
1242            protected ShoppingCartPersistence shoppingCartPersistence;
1243            @BeanReference(type = ShoppingCategoryPersistence.class)
1244            protected ShoppingCategoryPersistence shoppingCategoryPersistence;
1245            @BeanReference(type = ShoppingCouponPersistence.class)
1246            protected ShoppingCouponPersistence shoppingCouponPersistence;
1247            @BeanReference(type = ShoppingItemPersistence.class)
1248            protected ShoppingItemPersistence shoppingItemPersistence;
1249            @BeanReference(type = ShoppingItemFieldPersistence.class)
1250            protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
1251            @BeanReference(type = ShoppingItemPricePersistence.class)
1252            protected ShoppingItemPricePersistence shoppingItemPricePersistence;
1253            @BeanReference(type = ShoppingOrderPersistence.class)
1254            protected ShoppingOrderPersistence shoppingOrderPersistence;
1255            @BeanReference(type = ShoppingOrderItemPersistence.class)
1256            protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
1257            @BeanReference(type = ResourcePersistence.class)
1258            protected ResourcePersistence resourcePersistence;
1259            @BeanReference(type = UserPersistence.class)
1260            protected UserPersistence userPersistence;
1261            private static final String _SQL_SELECT_SHOPPINGCOUPON = "SELECT shoppingCoupon FROM ShoppingCoupon shoppingCoupon";
1262            private static final String _SQL_SELECT_SHOPPINGCOUPON_WHERE = "SELECT shoppingCoupon FROM ShoppingCoupon shoppingCoupon WHERE ";
1263            private static final String _SQL_COUNT_SHOPPINGCOUPON = "SELECT COUNT(shoppingCoupon) FROM ShoppingCoupon shoppingCoupon";
1264            private static final String _SQL_COUNT_SHOPPINGCOUPON_WHERE = "SELECT COUNT(shoppingCoupon) FROM ShoppingCoupon shoppingCoupon WHERE ";
1265            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "shoppingCoupon.groupId = ?";
1266            private static final String _FINDER_COLUMN_CODE_CODE_1 = "shoppingCoupon.code IS NULL";
1267            private static final String _FINDER_COLUMN_CODE_CODE_2 = "shoppingCoupon.code = ?";
1268            private static final String _FINDER_COLUMN_CODE_CODE_3 = "(shoppingCoupon.code IS NULL OR shoppingCoupon.code = ?)";
1269            private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingCoupon.";
1270            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingCoupon exists with the primary key ";
1271            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingCoupon exists with the key {";
1272            private static Log _log = LogFactoryUtil.getLog(ShoppingCouponPersistenceImpl.class);
1273    }