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.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 implementation for the shopping coupon service.
056     *
057     * <p>
058     * Never modify or reference this class directly. Always use {@link ShoppingCouponUtil} to access the shopping coupon persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate 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. Does not add the shopping coupon to the database.
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                            BatchSessionUtil.delete(session, shoppingCoupon);
240                    }
241                    catch (Exception e) {
242                            throw processException(e);
243                    }
244                    finally {
245                            closeSession(session);
246                    }
247    
248                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
249    
250                    ShoppingCouponModelImpl shoppingCouponModelImpl = (ShoppingCouponModelImpl)shoppingCoupon;
251    
252                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CODE,
253                            new Object[] { shoppingCouponModelImpl.getCode() });
254    
255                    EntityCacheUtil.removeResult(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
256                            ShoppingCouponImpl.class, shoppingCoupon.getPrimaryKey());
257    
258                    return shoppingCoupon;
259            }
260    
261            public ShoppingCoupon updateImpl(
262                    com.liferay.portlet.shopping.model.ShoppingCoupon shoppingCoupon,
263                    boolean merge) throws SystemException {
264                    shoppingCoupon = toUnwrappedModel(shoppingCoupon);
265    
266                    boolean isNew = shoppingCoupon.isNew();
267    
268                    ShoppingCouponModelImpl shoppingCouponModelImpl = (ShoppingCouponModelImpl)shoppingCoupon;
269    
270                    Session session = null;
271    
272                    try {
273                            session = openSession();
274    
275                            BatchSessionUtil.update(session, shoppingCoupon, merge);
276    
277                            shoppingCoupon.setNew(false);
278                    }
279                    catch (Exception e) {
280                            throw processException(e);
281                    }
282                    finally {
283                            closeSession(session);
284                    }
285    
286                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
287    
288                    EntityCacheUtil.putResult(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
289                            ShoppingCouponImpl.class, shoppingCoupon.getPrimaryKey(),
290                            shoppingCoupon);
291    
292                    if (!isNew &&
293                                    (!Validator.equals(shoppingCoupon.getCode(),
294                                            shoppingCouponModelImpl.getOriginalCode()))) {
295                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CODE,
296                                    new Object[] { shoppingCouponModelImpl.getOriginalCode() });
297                    }
298    
299                    if (isNew ||
300                                    (!Validator.equals(shoppingCoupon.getCode(),
301                                            shoppingCouponModelImpl.getOriginalCode()))) {
302                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CODE,
303                                    new Object[] { shoppingCoupon.getCode() }, shoppingCoupon);
304                    }
305    
306                    return shoppingCoupon;
307            }
308    
309            protected ShoppingCoupon toUnwrappedModel(ShoppingCoupon shoppingCoupon) {
310                    if (shoppingCoupon instanceof ShoppingCouponImpl) {
311                            return shoppingCoupon;
312                    }
313    
314                    ShoppingCouponImpl shoppingCouponImpl = new ShoppingCouponImpl();
315    
316                    shoppingCouponImpl.setNew(shoppingCoupon.isNew());
317                    shoppingCouponImpl.setPrimaryKey(shoppingCoupon.getPrimaryKey());
318    
319                    shoppingCouponImpl.setCouponId(shoppingCoupon.getCouponId());
320                    shoppingCouponImpl.setGroupId(shoppingCoupon.getGroupId());
321                    shoppingCouponImpl.setCompanyId(shoppingCoupon.getCompanyId());
322                    shoppingCouponImpl.setUserId(shoppingCoupon.getUserId());
323                    shoppingCouponImpl.setUserName(shoppingCoupon.getUserName());
324                    shoppingCouponImpl.setCreateDate(shoppingCoupon.getCreateDate());
325                    shoppingCouponImpl.setModifiedDate(shoppingCoupon.getModifiedDate());
326                    shoppingCouponImpl.setCode(shoppingCoupon.getCode());
327                    shoppingCouponImpl.setName(shoppingCoupon.getName());
328                    shoppingCouponImpl.setDescription(shoppingCoupon.getDescription());
329                    shoppingCouponImpl.setStartDate(shoppingCoupon.getStartDate());
330                    shoppingCouponImpl.setEndDate(shoppingCoupon.getEndDate());
331                    shoppingCouponImpl.setActive(shoppingCoupon.isActive());
332                    shoppingCouponImpl.setLimitCategories(shoppingCoupon.getLimitCategories());
333                    shoppingCouponImpl.setLimitSkus(shoppingCoupon.getLimitSkus());
334                    shoppingCouponImpl.setMinOrder(shoppingCoupon.getMinOrder());
335                    shoppingCouponImpl.setDiscount(shoppingCoupon.getDiscount());
336                    shoppingCouponImpl.setDiscountType(shoppingCoupon.getDiscountType());
337    
338                    return shoppingCouponImpl;
339            }
340    
341            /**
342             * Finds the shopping coupon with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
343             *
344             * @param primaryKey the primary key of the shopping coupon to find
345             * @return the shopping coupon
346             * @throws com.liferay.portal.NoSuchModelException if a shopping coupon with the primary key could not be found
347             * @throws SystemException if a system exception occurred
348             */
349            public ShoppingCoupon findByPrimaryKey(Serializable primaryKey)
350                    throws NoSuchModelException, SystemException {
351                    return findByPrimaryKey(((Long)primaryKey).longValue());
352            }
353    
354            /**
355             * Finds the shopping coupon with the primary key or throws a {@link com.liferay.portlet.shopping.NoSuchCouponException} if it could not be found.
356             *
357             * @param couponId the primary key of the shopping coupon to find
358             * @return the shopping coupon
359             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a shopping coupon with the primary key could not be found
360             * @throws SystemException if a system exception occurred
361             */
362            public ShoppingCoupon findByPrimaryKey(long couponId)
363                    throws NoSuchCouponException, SystemException {
364                    ShoppingCoupon shoppingCoupon = fetchByPrimaryKey(couponId);
365    
366                    if (shoppingCoupon == null) {
367                            if (_log.isWarnEnabled()) {
368                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + couponId);
369                            }
370    
371                            throw new NoSuchCouponException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
372                                    couponId);
373                    }
374    
375                    return shoppingCoupon;
376            }
377    
378            /**
379             * Finds the shopping coupon with the primary key or returns <code>null</code> if it could not be found.
380             *
381             * @param primaryKey the primary key of the shopping coupon to find
382             * @return the shopping coupon, or <code>null</code> if a shopping coupon with the primary key could not be found
383             * @throws SystemException if a system exception occurred
384             */
385            public ShoppingCoupon fetchByPrimaryKey(Serializable primaryKey)
386                    throws SystemException {
387                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
388            }
389    
390            /**
391             * Finds the shopping coupon with the primary key or returns <code>null</code> if it could not be found.
392             *
393             * @param couponId the primary key of the shopping coupon to find
394             * @return the shopping coupon, or <code>null</code> if a shopping coupon with the primary key could not be found
395             * @throws SystemException if a system exception occurred
396             */
397            public ShoppingCoupon fetchByPrimaryKey(long couponId)
398                    throws SystemException {
399                    ShoppingCoupon shoppingCoupon = (ShoppingCoupon)EntityCacheUtil.getResult(ShoppingCouponModelImpl.ENTITY_CACHE_ENABLED,
400                                    ShoppingCouponImpl.class, couponId, this);
401    
402                    if (shoppingCoupon == null) {
403                            Session session = null;
404    
405                            try {
406                                    session = openSession();
407    
408                                    shoppingCoupon = (ShoppingCoupon)session.get(ShoppingCouponImpl.class,
409                                                    new Long(couponId));
410                            }
411                            catch (Exception e) {
412                                    throw processException(e);
413                            }
414                            finally {
415                                    if (shoppingCoupon != null) {
416                                            cacheResult(shoppingCoupon);
417                                    }
418    
419                                    closeSession(session);
420                            }
421                    }
422    
423                    return shoppingCoupon;
424            }
425    
426            /**
427             * Finds all the shopping coupons where groupId = &#63;.
428             *
429             * @param groupId the group id to search with
430             * @return the matching shopping coupons
431             * @throws SystemException if a system exception occurred
432             */
433            public List<ShoppingCoupon> findByGroupId(long groupId)
434                    throws SystemException {
435                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
436            }
437    
438            /**
439             * Finds a range of all the shopping coupons where groupId = &#63;.
440             *
441             * <p>
442             * 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.
443             * </p>
444             *
445             * @param groupId the group id to search with
446             * @param start the lower bound of the range of shopping coupons to return
447             * @param end the upper bound of the range of shopping coupons to return (not inclusive)
448             * @return the range of matching shopping coupons
449             * @throws SystemException if a system exception occurred
450             */
451            public List<ShoppingCoupon> findByGroupId(long groupId, int start, int end)
452                    throws SystemException {
453                    return findByGroupId(groupId, start, end, null);
454            }
455    
456            /**
457             * Finds an ordered range of all the shopping coupons where groupId = &#63;.
458             *
459             * <p>
460             * 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.
461             * </p>
462             *
463             * @param groupId the group id to search with
464             * @param start the lower bound of the range of shopping coupons to return
465             * @param end the upper bound of the range of shopping coupons to return (not inclusive)
466             * @param orderByComparator the comparator to order the results by
467             * @return the ordered range of matching shopping coupons
468             * @throws SystemException if a system exception occurred
469             */
470            public List<ShoppingCoupon> findByGroupId(long groupId, int start, int end,
471                    OrderByComparator orderByComparator) throws SystemException {
472                    Object[] finderArgs = new Object[] {
473                                    groupId,
474                                    
475                                    String.valueOf(start), String.valueOf(end),
476                                    String.valueOf(orderByComparator)
477                            };
478    
479                    List<ShoppingCoupon> list = (List<ShoppingCoupon>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
480                                    finderArgs, this);
481    
482                    if (list == null) {
483                            StringBundler query = null;
484    
485                            if (orderByComparator != null) {
486                                    query = new StringBundler(3 +
487                                                    (orderByComparator.getOrderByFields().length * 3));
488                            }
489                            else {
490                                    query = new StringBundler(3);
491                            }
492    
493                            query.append(_SQL_SELECT_SHOPPINGCOUPON_WHERE);
494    
495                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
496    
497                            if (orderByComparator != null) {
498                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
499                                            orderByComparator);
500                            }
501    
502                            else {
503                                    query.append(ShoppingCouponModelImpl.ORDER_BY_JPQL);
504                            }
505    
506                            String sql = query.toString();
507    
508                            Session session = null;
509    
510                            try {
511                                    session = openSession();
512    
513                                    Query q = session.createQuery(sql);
514    
515                                    QueryPos qPos = QueryPos.getInstance(q);
516    
517                                    qPos.add(groupId);
518    
519                                    list = (List<ShoppingCoupon>)QueryUtil.list(q, getDialect(),
520                                                    start, end);
521                            }
522                            catch (Exception e) {
523                                    throw processException(e);
524                            }
525                            finally {
526                                    if (list == null) {
527                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_GROUPID,
528                                                    finderArgs);
529                                    }
530                                    else {
531                                            cacheResult(list);
532    
533                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
534                                                    finderArgs, list);
535                                    }
536    
537                                    closeSession(session);
538                            }
539                    }
540    
541                    return list;
542            }
543    
544            /**
545             * Finds the first shopping coupon in the ordered set where groupId = &#63;.
546             *
547             * <p>
548             * 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.
549             * </p>
550             *
551             * @param groupId the group id to search with
552             * @param orderByComparator the comparator to order the set by
553             * @return the first matching shopping coupon
554             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a matching shopping coupon could not be found
555             * @throws SystemException if a system exception occurred
556             */
557            public ShoppingCoupon findByGroupId_First(long groupId,
558                    OrderByComparator orderByComparator)
559                    throws NoSuchCouponException, SystemException {
560                    List<ShoppingCoupon> list = findByGroupId(groupId, 0, 1,
561                                    orderByComparator);
562    
563                    if (list.isEmpty()) {
564                            StringBundler msg = new StringBundler(4);
565    
566                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
567    
568                            msg.append("groupId=");
569                            msg.append(groupId);
570    
571                            msg.append(StringPool.CLOSE_CURLY_BRACE);
572    
573                            throw new NoSuchCouponException(msg.toString());
574                    }
575                    else {
576                            return list.get(0);
577                    }
578            }
579    
580            /**
581             * Finds the last shopping coupon in the ordered set where groupId = &#63;.
582             *
583             * <p>
584             * 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.
585             * </p>
586             *
587             * @param groupId the group id to search with
588             * @param orderByComparator the comparator to order the set by
589             * @return the last matching shopping coupon
590             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a matching shopping coupon could not be found
591             * @throws SystemException if a system exception occurred
592             */
593            public ShoppingCoupon findByGroupId_Last(long groupId,
594                    OrderByComparator orderByComparator)
595                    throws NoSuchCouponException, SystemException {
596                    int count = countByGroupId(groupId);
597    
598                    List<ShoppingCoupon> list = findByGroupId(groupId, count - 1, count,
599                                    orderByComparator);
600    
601                    if (list.isEmpty()) {
602                            StringBundler msg = new StringBundler(4);
603    
604                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
605    
606                            msg.append("groupId=");
607                            msg.append(groupId);
608    
609                            msg.append(StringPool.CLOSE_CURLY_BRACE);
610    
611                            throw new NoSuchCouponException(msg.toString());
612                    }
613                    else {
614                            return list.get(0);
615                    }
616            }
617    
618            /**
619             * Finds the shopping coupons before and after the current shopping coupon in the ordered set where groupId = &#63;.
620             *
621             * <p>
622             * 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.
623             * </p>
624             *
625             * @param couponId the primary key of the current shopping coupon
626             * @param groupId the group id to search with
627             * @param orderByComparator the comparator to order the set by
628             * @return the previous, current, and next shopping coupon
629             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a shopping coupon with the primary key could not be found
630             * @throws SystemException if a system exception occurred
631             */
632            public ShoppingCoupon[] findByGroupId_PrevAndNext(long couponId,
633                    long groupId, OrderByComparator orderByComparator)
634                    throws NoSuchCouponException, SystemException {
635                    ShoppingCoupon shoppingCoupon = findByPrimaryKey(couponId);
636    
637                    Session session = null;
638    
639                    try {
640                            session = openSession();
641    
642                            ShoppingCoupon[] array = new ShoppingCouponImpl[3];
643    
644                            array[0] = getByGroupId_PrevAndNext(session, shoppingCoupon,
645                                            groupId, orderByComparator, true);
646    
647                            array[1] = shoppingCoupon;
648    
649                            array[2] = getByGroupId_PrevAndNext(session, shoppingCoupon,
650                                            groupId, orderByComparator, false);
651    
652                            return array;
653                    }
654                    catch (Exception e) {
655                            throw processException(e);
656                    }
657                    finally {
658                            closeSession(session);
659                    }
660            }
661    
662            protected ShoppingCoupon getByGroupId_PrevAndNext(Session session,
663                    ShoppingCoupon shoppingCoupon, long groupId,
664                    OrderByComparator orderByComparator, boolean previous) {
665                    StringBundler query = null;
666    
667                    if (orderByComparator != null) {
668                            query = new StringBundler(6 +
669                                            (orderByComparator.getOrderByFields().length * 6));
670                    }
671                    else {
672                            query = new StringBundler(3);
673                    }
674    
675                    query.append(_SQL_SELECT_SHOPPINGCOUPON_WHERE);
676    
677                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
678    
679                    if (orderByComparator != null) {
680                            String[] orderByFields = orderByComparator.getOrderByFields();
681    
682                            if (orderByFields.length > 0) {
683                                    query.append(WHERE_AND);
684                            }
685    
686                            for (int i = 0; i < orderByFields.length; i++) {
687                                    query.append(_ORDER_BY_ENTITY_ALIAS);
688                                    query.append(orderByFields[i]);
689    
690                                    if ((i + 1) < orderByFields.length) {
691                                            if (orderByComparator.isAscending() ^ previous) {
692                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
693                                            }
694                                            else {
695                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
696                                            }
697                                    }
698                                    else {
699                                            if (orderByComparator.isAscending() ^ previous) {
700                                                    query.append(WHERE_GREATER_THAN);
701                                            }
702                                            else {
703                                                    query.append(WHERE_LESSER_THAN);
704                                            }
705                                    }
706                            }
707    
708                            query.append(ORDER_BY_CLAUSE);
709    
710                            for (int i = 0; i < orderByFields.length; i++) {
711                                    query.append(_ORDER_BY_ENTITY_ALIAS);
712                                    query.append(orderByFields[i]);
713    
714                                    if ((i + 1) < orderByFields.length) {
715                                            if (orderByComparator.isAscending() ^ previous) {
716                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
717                                            }
718                                            else {
719                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
720                                            }
721                                    }
722                                    else {
723                                            if (orderByComparator.isAscending() ^ previous) {
724                                                    query.append(ORDER_BY_ASC);
725                                            }
726                                            else {
727                                                    query.append(ORDER_BY_DESC);
728                                            }
729                                    }
730                            }
731                    }
732    
733                    else {
734                            query.append(ShoppingCouponModelImpl.ORDER_BY_JPQL);
735                    }
736    
737                    String sql = query.toString();
738    
739                    Query q = session.createQuery(sql);
740    
741                    q.setFirstResult(0);
742                    q.setMaxResults(2);
743    
744                    QueryPos qPos = QueryPos.getInstance(q);
745    
746                    qPos.add(groupId);
747    
748                    if (orderByComparator != null) {
749                            Object[] values = orderByComparator.getOrderByValues(shoppingCoupon);
750    
751                            for (Object value : values) {
752                                    qPos.add(value);
753                            }
754                    }
755    
756                    List<ShoppingCoupon> list = q.list();
757    
758                    if (list.size() == 2) {
759                            return list.get(1);
760                    }
761                    else {
762                            return null;
763                    }
764            }
765    
766            /**
767             * Finds the shopping coupon where code = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchCouponException} if it could not be found.
768             *
769             * @param code the code to search with
770             * @return the matching shopping coupon
771             * @throws com.liferay.portlet.shopping.NoSuchCouponException if a matching shopping coupon could not be found
772             * @throws SystemException if a system exception occurred
773             */
774            public ShoppingCoupon findByCode(String code)
775                    throws NoSuchCouponException, SystemException {
776                    ShoppingCoupon shoppingCoupon = fetchByCode(code);
777    
778                    if (shoppingCoupon == null) {
779                            StringBundler msg = new StringBundler(4);
780    
781                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
782    
783                            msg.append("code=");
784                            msg.append(code);
785    
786                            msg.append(StringPool.CLOSE_CURLY_BRACE);
787    
788                            if (_log.isWarnEnabled()) {
789                                    _log.warn(msg.toString());
790                            }
791    
792                            throw new NoSuchCouponException(msg.toString());
793                    }
794    
795                    return shoppingCoupon;
796            }
797    
798            /**
799             * Finds the shopping coupon where code = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
800             *
801             * @param code the code to search with
802             * @return the matching shopping coupon, or <code>null</code> if a matching shopping coupon could not be found
803             * @throws SystemException if a system exception occurred
804             */
805            public ShoppingCoupon fetchByCode(String code) throws SystemException {
806                    return fetchByCode(code, true);
807            }
808    
809            /**
810             * Finds the shopping coupon where code = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
811             *
812             * @param code the code to search with
813             * @return the matching shopping coupon, or <code>null</code> if a matching shopping coupon could not be found
814             * @throws SystemException if a system exception occurred
815             */
816            public ShoppingCoupon fetchByCode(String code, boolean retrieveFromCache)
817                    throws SystemException {
818                    Object[] finderArgs = new Object[] { code };
819    
820                    Object result = null;
821    
822                    if (retrieveFromCache) {
823                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CODE,
824                                            finderArgs, this);
825                    }
826    
827                    if (result == null) {
828                            StringBundler query = new StringBundler(3);
829    
830                            query.append(_SQL_SELECT_SHOPPINGCOUPON_WHERE);
831    
832                            if (code == null) {
833                                    query.append(_FINDER_COLUMN_CODE_CODE_1);
834                            }
835                            else {
836                                    if (code.equals(StringPool.BLANK)) {
837                                            query.append(_FINDER_COLUMN_CODE_CODE_3);
838                                    }
839                                    else {
840                                            query.append(_FINDER_COLUMN_CODE_CODE_2);
841                                    }
842                            }
843    
844                            query.append(ShoppingCouponModelImpl.ORDER_BY_JPQL);
845    
846                            String sql = query.toString();
847    
848                            Session session = null;
849    
850                            try {
851                                    session = openSession();
852    
853                                    Query q = session.createQuery(sql);
854    
855                                    QueryPos qPos = QueryPos.getInstance(q);
856    
857                                    if (code != null) {
858                                            qPos.add(code);
859                                    }
860    
861                                    List<ShoppingCoupon> list = q.list();
862    
863                                    result = list;
864    
865                                    ShoppingCoupon shoppingCoupon = null;
866    
867                                    if (list.isEmpty()) {
868                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CODE,
869                                                    finderArgs, list);
870                                    }
871                                    else {
872                                            shoppingCoupon = list.get(0);
873    
874                                            cacheResult(shoppingCoupon);
875    
876                                            if ((shoppingCoupon.getCode() == null) ||
877                                                            !shoppingCoupon.getCode().equals(code)) {
878                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CODE,
879                                                            finderArgs, shoppingCoupon);
880                                            }
881                                    }
882    
883                                    return shoppingCoupon;
884                            }
885                            catch (Exception e) {
886                                    throw processException(e);
887                            }
888                            finally {
889                                    if (result == null) {
890                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CODE,
891                                                    finderArgs);
892                                    }
893    
894                                    closeSession(session);
895                            }
896                    }
897                    else {
898                            if (result instanceof List<?>) {
899                                    return null;
900                            }
901                            else {
902                                    return (ShoppingCoupon)result;
903                            }
904                    }
905            }
906    
907            /**
908             * Finds all the shopping coupons.
909             *
910             * @return the shopping coupons
911             * @throws SystemException if a system exception occurred
912             */
913            public List<ShoppingCoupon> findAll() throws SystemException {
914                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
915            }
916    
917            /**
918             * Finds a range of all the shopping coupons.
919             *
920             * <p>
921             * 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.
922             * </p>
923             *
924             * @param start the lower bound of the range of shopping coupons to return
925             * @param end the upper bound of the range of shopping coupons to return (not inclusive)
926             * @return the range of shopping coupons
927             * @throws SystemException if a system exception occurred
928             */
929            public List<ShoppingCoupon> findAll(int start, int end)
930                    throws SystemException {
931                    return findAll(start, end, null);
932            }
933    
934            /**
935             * Finds an ordered range of all the shopping coupons.
936             *
937             * <p>
938             * 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.
939             * </p>
940             *
941             * @param start the lower bound of the range of shopping coupons to return
942             * @param end the upper bound of the range of shopping coupons to return (not inclusive)
943             * @param orderByComparator the comparator to order the results by
944             * @return the ordered range of shopping coupons
945             * @throws SystemException if a system exception occurred
946             */
947            public List<ShoppingCoupon> findAll(int start, int end,
948                    OrderByComparator orderByComparator) throws SystemException {
949                    Object[] finderArgs = new Object[] {
950                                    String.valueOf(start), String.valueOf(end),
951                                    String.valueOf(orderByComparator)
952                            };
953    
954                    List<ShoppingCoupon> list = (List<ShoppingCoupon>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
955                                    finderArgs, this);
956    
957                    if (list == null) {
958                            StringBundler query = null;
959                            String sql = null;
960    
961                            if (orderByComparator != null) {
962                                    query = new StringBundler(2 +
963                                                    (orderByComparator.getOrderByFields().length * 3));
964    
965                                    query.append(_SQL_SELECT_SHOPPINGCOUPON);
966    
967                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
968                                            orderByComparator);
969    
970                                    sql = query.toString();
971                            }
972                            else {
973                                    sql = _SQL_SELECT_SHOPPINGCOUPON.concat(ShoppingCouponModelImpl.ORDER_BY_JPQL);
974                            }
975    
976                            Session session = null;
977    
978                            try {
979                                    session = openSession();
980    
981                                    Query q = session.createQuery(sql);
982    
983                                    if (orderByComparator == null) {
984                                            list = (List<ShoppingCoupon>)QueryUtil.list(q,
985                                                            getDialect(), start, end, false);
986    
987                                            Collections.sort(list);
988                                    }
989                                    else {
990                                            list = (List<ShoppingCoupon>)QueryUtil.list(q,
991                                                            getDialect(), start, end);
992                                    }
993                            }
994                            catch (Exception e) {
995                                    throw processException(e);
996                            }
997                            finally {
998                                    if (list == null) {
999                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
1000                                                    finderArgs);
1001                                    }
1002                                    else {
1003                                            cacheResult(list);
1004    
1005                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
1006                                                    list);
1007                                    }
1008    
1009                                    closeSession(session);
1010                            }
1011                    }
1012    
1013                    return list;
1014            }
1015    
1016            /**
1017             * Removes all the shopping coupons where groupId = &#63; from the database.
1018             *
1019             * @param groupId the group id to search with
1020             * @throws SystemException if a system exception occurred
1021             */
1022            public void removeByGroupId(long groupId) throws SystemException {
1023                    for (ShoppingCoupon shoppingCoupon : findByGroupId(groupId)) {
1024                            remove(shoppingCoupon);
1025                    }
1026            }
1027    
1028            /**
1029             * Removes the shopping coupon where code = &#63; from the database.
1030             *
1031             * @param code the code to search with
1032             * @throws SystemException if a system exception occurred
1033             */
1034            public void removeByCode(String code)
1035                    throws NoSuchCouponException, SystemException {
1036                    ShoppingCoupon shoppingCoupon = findByCode(code);
1037    
1038                    remove(shoppingCoupon);
1039            }
1040    
1041            /**
1042             * Removes all the shopping coupons from the database.
1043             *
1044             * @throws SystemException if a system exception occurred
1045             */
1046            public void removeAll() throws SystemException {
1047                    for (ShoppingCoupon shoppingCoupon : findAll()) {
1048                            remove(shoppingCoupon);
1049                    }
1050            }
1051    
1052            /**
1053             * Counts all the shopping coupons where groupId = &#63;.
1054             *
1055             * @param groupId the group id to search with
1056             * @return the number of matching shopping coupons
1057             * @throws SystemException if a system exception occurred
1058             */
1059            public int countByGroupId(long groupId) throws SystemException {
1060                    Object[] finderArgs = new Object[] { groupId };
1061    
1062                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1063                                    finderArgs, this);
1064    
1065                    if (count == null) {
1066                            StringBundler query = new StringBundler(2);
1067    
1068                            query.append(_SQL_COUNT_SHOPPINGCOUPON_WHERE);
1069    
1070                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1071    
1072                            String sql = query.toString();
1073    
1074                            Session session = null;
1075    
1076                            try {
1077                                    session = openSession();
1078    
1079                                    Query q = session.createQuery(sql);
1080    
1081                                    QueryPos qPos = QueryPos.getInstance(q);
1082    
1083                                    qPos.add(groupId);
1084    
1085                                    count = (Long)q.uniqueResult();
1086                            }
1087                            catch (Exception e) {
1088                                    throw processException(e);
1089                            }
1090                            finally {
1091                                    if (count == null) {
1092                                            count = Long.valueOf(0);
1093                                    }
1094    
1095                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1096                                            finderArgs, count);
1097    
1098                                    closeSession(session);
1099                            }
1100                    }
1101    
1102                    return count.intValue();
1103            }
1104    
1105            /**
1106             * Counts all the shopping coupons where code = &#63;.
1107             *
1108             * @param code the code to search with
1109             * @return the number of matching shopping coupons
1110             * @throws SystemException if a system exception occurred
1111             */
1112            public int countByCode(String code) throws SystemException {
1113                    Object[] finderArgs = new Object[] { code };
1114    
1115                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CODE,
1116                                    finderArgs, this);
1117    
1118                    if (count == null) {
1119                            StringBundler query = new StringBundler(2);
1120    
1121                            query.append(_SQL_COUNT_SHOPPINGCOUPON_WHERE);
1122    
1123                            if (code == null) {
1124                                    query.append(_FINDER_COLUMN_CODE_CODE_1);
1125                            }
1126                            else {
1127                                    if (code.equals(StringPool.BLANK)) {
1128                                            query.append(_FINDER_COLUMN_CODE_CODE_3);
1129                                    }
1130                                    else {
1131                                            query.append(_FINDER_COLUMN_CODE_CODE_2);
1132                                    }
1133                            }
1134    
1135                            String sql = query.toString();
1136    
1137                            Session session = null;
1138    
1139                            try {
1140                                    session = openSession();
1141    
1142                                    Query q = session.createQuery(sql);
1143    
1144                                    QueryPos qPos = QueryPos.getInstance(q);
1145    
1146                                    if (code != null) {
1147                                            qPos.add(code);
1148                                    }
1149    
1150                                    count = (Long)q.uniqueResult();
1151                            }
1152                            catch (Exception e) {
1153                                    throw processException(e);
1154                            }
1155                            finally {
1156                                    if (count == null) {
1157                                            count = Long.valueOf(0);
1158                                    }
1159    
1160                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CODE,
1161                                            finderArgs, count);
1162    
1163                                    closeSession(session);
1164                            }
1165                    }
1166    
1167                    return count.intValue();
1168            }
1169    
1170            /**
1171             * Counts all the shopping coupons.
1172             *
1173             * @return the number of shopping coupons
1174             * @throws SystemException if a system exception occurred
1175             */
1176            public int countAll() throws SystemException {
1177                    Object[] finderArgs = new Object[0];
1178    
1179                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1180                                    finderArgs, this);
1181    
1182                    if (count == null) {
1183                            Session session = null;
1184    
1185                            try {
1186                                    session = openSession();
1187    
1188                                    Query q = session.createQuery(_SQL_COUNT_SHOPPINGCOUPON);
1189    
1190                                    count = (Long)q.uniqueResult();
1191                            }
1192                            catch (Exception e) {
1193                                    throw processException(e);
1194                            }
1195                            finally {
1196                                    if (count == null) {
1197                                            count = Long.valueOf(0);
1198                                    }
1199    
1200                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1201                                            count);
1202    
1203                                    closeSession(session);
1204                            }
1205                    }
1206    
1207                    return count.intValue();
1208            }
1209    
1210            /**
1211             * Initializes the shopping coupon persistence.
1212             */
1213            public void afterPropertiesSet() {
1214                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1215                                            com.liferay.portal.util.PropsUtil.get(
1216                                                    "value.object.listener.com.liferay.portlet.shopping.model.ShoppingCoupon")));
1217    
1218                    if (listenerClassNames.length > 0) {
1219                            try {
1220                                    List<ModelListener<ShoppingCoupon>> listenersList = new ArrayList<ModelListener<ShoppingCoupon>>();
1221    
1222                                    for (String listenerClassName : listenerClassNames) {
1223                                            listenersList.add((ModelListener<ShoppingCoupon>)InstanceFactory.newInstance(
1224                                                            listenerClassName));
1225                                    }
1226    
1227                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1228                            }
1229                            catch (Exception e) {
1230                                    _log.error(e);
1231                            }
1232                    }
1233            }
1234    
1235            public void destroy() {
1236                    EntityCacheUtil.removeCache(ShoppingCouponImpl.class.getName());
1237                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1238                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
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    }