001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.shopping.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.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.model.CacheModel;
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.NoSuchCartException;
044    import com.liferay.portlet.shopping.model.ShoppingCart;
045    import com.liferay.portlet.shopping.model.impl.ShoppingCartImpl;
046    import com.liferay.portlet.shopping.model.impl.ShoppingCartModelImpl;
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 cart service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see ShoppingCartPersistence
063     * @see ShoppingCartUtil
064     * @generated
065     */
066    public class ShoppingCartPersistenceImpl extends BasePersistenceImpl<ShoppingCart>
067            implements ShoppingCartPersistence {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link ShoppingCartUtil} to access the shopping cart persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
072             */
073            public static final String FINDER_CLASS_NAME_ENTITY = ShoppingCartImpl.class.getName();
074            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List1";
076            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List2";
078            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
079                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, ShoppingCartImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
081                            new String[] {
082                                    Long.class.getName(),
083                                    
084                            "java.lang.Integer", "java.lang.Integer",
085                                    "com.liferay.portal.kernel.util.OrderByComparator"
086                            });
087            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
088                    new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
089                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, ShoppingCartImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
091                            new String[] { Long.class.getName() },
092                            ShoppingCartModelImpl.GROUPID_COLUMN_BITMASK);
093            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
094                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, Long.class,
095                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
096                            new String[] { Long.class.getName() });
097            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
098                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, ShoppingCartImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
100                            new String[] {
101                                    Long.class.getName(),
102                                    
103                            "java.lang.Integer", "java.lang.Integer",
104                                    "com.liferay.portal.kernel.util.OrderByComparator"
105                            });
106            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
107                    new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
108                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, ShoppingCartImpl.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
110                            new String[] { Long.class.getName() },
111                            ShoppingCartModelImpl.USERID_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
113                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
115                            new String[] { Long.class.getName() });
116            public static final FinderPath FINDER_PATH_FETCH_BY_G_U = new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
117                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, ShoppingCartImpl.class,
118                            FINDER_CLASS_NAME_ENTITY, "fetchByG_U",
119                            new String[] { Long.class.getName(), Long.class.getName() },
120                            ShoppingCartModelImpl.GROUPID_COLUMN_BITMASK |
121                            ShoppingCartModelImpl.USERID_COLUMN_BITMASK);
122            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
123                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, Long.class,
124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
125                            new String[] { Long.class.getName(), Long.class.getName() });
126            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
127                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, ShoppingCartImpl.class,
128                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
129            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
130                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, ShoppingCartImpl.class,
131                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
132            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
133                            ShoppingCartModelImpl.FINDER_CACHE_ENABLED, Long.class,
134                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
135    
136            /**
137             * Caches the shopping cart in the entity cache if it is enabled.
138             *
139             * @param shoppingCart the shopping cart
140             */
141            public void cacheResult(ShoppingCart shoppingCart) {
142                    EntityCacheUtil.putResult(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
143                            ShoppingCartImpl.class, shoppingCart.getPrimaryKey(), shoppingCart);
144    
145                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
146                            new Object[] {
147                                    Long.valueOf(shoppingCart.getGroupId()),
148                                    Long.valueOf(shoppingCart.getUserId())
149                            }, shoppingCart);
150    
151                    shoppingCart.resetOriginalValues();
152            }
153    
154            /**
155             * Caches the shopping carts in the entity cache if it is enabled.
156             *
157             * @param shoppingCarts the shopping carts
158             */
159            public void cacheResult(List<ShoppingCart> shoppingCarts) {
160                    for (ShoppingCart shoppingCart : shoppingCarts) {
161                            if (EntityCacheUtil.getResult(
162                                                    ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
163                                                    ShoppingCartImpl.class, shoppingCart.getPrimaryKey()) == null) {
164                                    cacheResult(shoppingCart);
165                            }
166                            else {
167                                    shoppingCart.resetOriginalValues();
168                            }
169                    }
170            }
171    
172            /**
173             * Clears the cache for all shopping carts.
174             *
175             * <p>
176             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
177             * </p>
178             */
179            @Override
180            public void clearCache() {
181                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
182                            CacheRegistryUtil.clear(ShoppingCartImpl.class.getName());
183                    }
184    
185                    EntityCacheUtil.clearCache(ShoppingCartImpl.class.getName());
186    
187                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
188                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
189                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
190            }
191    
192            /**
193             * Clears the cache for the shopping cart.
194             *
195             * <p>
196             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
197             * </p>
198             */
199            @Override
200            public void clearCache(ShoppingCart shoppingCart) {
201                    EntityCacheUtil.removeResult(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
202                            ShoppingCartImpl.class, shoppingCart.getPrimaryKey());
203    
204                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
205                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
206    
207                    clearUniqueFindersCache(shoppingCart);
208            }
209    
210            @Override
211            public void clearCache(List<ShoppingCart> shoppingCarts) {
212                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
213                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
214    
215                    for (ShoppingCart shoppingCart : shoppingCarts) {
216                            EntityCacheUtil.removeResult(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
217                                    ShoppingCartImpl.class, shoppingCart.getPrimaryKey());
218    
219                            clearUniqueFindersCache(shoppingCart);
220                    }
221            }
222    
223            protected void cacheUniqueFindersCache(ShoppingCart shoppingCart) {
224                    if (shoppingCart.isNew()) {
225                            Object[] args = new Object[] {
226                                            Long.valueOf(shoppingCart.getGroupId()),
227                                            Long.valueOf(shoppingCart.getUserId())
228                                    };
229    
230                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, args,
231                                    Long.valueOf(1));
232                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U, args,
233                                    shoppingCart);
234                    }
235                    else {
236                            ShoppingCartModelImpl shoppingCartModelImpl = (ShoppingCartModelImpl)shoppingCart;
237    
238                            if ((shoppingCartModelImpl.getColumnBitmask() &
239                                            FINDER_PATH_FETCH_BY_G_U.getColumnBitmask()) != 0) {
240                                    Object[] args = new Object[] {
241                                                    Long.valueOf(shoppingCart.getGroupId()),
242                                                    Long.valueOf(shoppingCart.getUserId())
243                                            };
244    
245                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, args,
246                                            Long.valueOf(1));
247                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U, args,
248                                            shoppingCart);
249                            }
250                    }
251            }
252    
253            protected void clearUniqueFindersCache(ShoppingCart shoppingCart) {
254                    ShoppingCartModelImpl shoppingCartModelImpl = (ShoppingCartModelImpl)shoppingCart;
255    
256                    Object[] args = new Object[] {
257                                    Long.valueOf(shoppingCart.getGroupId()),
258                                    Long.valueOf(shoppingCart.getUserId())
259                            };
260    
261                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
262                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U, args);
263    
264                    if ((shoppingCartModelImpl.getColumnBitmask() &
265                                    FINDER_PATH_FETCH_BY_G_U.getColumnBitmask()) != 0) {
266                            args = new Object[] {
267                                            Long.valueOf(shoppingCartModelImpl.getOriginalGroupId()),
268                                            Long.valueOf(shoppingCartModelImpl.getOriginalUserId())
269                                    };
270    
271                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
272                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U, args);
273                    }
274            }
275    
276            /**
277             * Creates a new shopping cart with the primary key. Does not add the shopping cart to the database.
278             *
279             * @param cartId the primary key for the new shopping cart
280             * @return the new shopping cart
281             */
282            public ShoppingCart create(long cartId) {
283                    ShoppingCart shoppingCart = new ShoppingCartImpl();
284    
285                    shoppingCart.setNew(true);
286                    shoppingCart.setPrimaryKey(cartId);
287    
288                    return shoppingCart;
289            }
290    
291            /**
292             * Removes the shopping cart with the primary key from the database. Also notifies the appropriate model listeners.
293             *
294             * @param cartId the primary key of the shopping cart
295             * @return the shopping cart that was removed
296             * @throws com.liferay.portlet.shopping.NoSuchCartException if a shopping cart with the primary key could not be found
297             * @throws SystemException if a system exception occurred
298             */
299            public ShoppingCart remove(long cartId)
300                    throws NoSuchCartException, SystemException {
301                    return remove(Long.valueOf(cartId));
302            }
303    
304            /**
305             * Removes the shopping cart with the primary key from the database. Also notifies the appropriate model listeners.
306             *
307             * @param primaryKey the primary key of the shopping cart
308             * @return the shopping cart that was removed
309             * @throws com.liferay.portlet.shopping.NoSuchCartException if a shopping cart with the primary key could not be found
310             * @throws SystemException if a system exception occurred
311             */
312            @Override
313            public ShoppingCart remove(Serializable primaryKey)
314                    throws NoSuchCartException, SystemException {
315                    Session session = null;
316    
317                    try {
318                            session = openSession();
319    
320                            ShoppingCart shoppingCart = (ShoppingCart)session.get(ShoppingCartImpl.class,
321                                            primaryKey);
322    
323                            if (shoppingCart == null) {
324                                    if (_log.isWarnEnabled()) {
325                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
326                                    }
327    
328                                    throw new NoSuchCartException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
329                                            primaryKey);
330                            }
331    
332                            return remove(shoppingCart);
333                    }
334                    catch (NoSuchCartException nsee) {
335                            throw nsee;
336                    }
337                    catch (Exception e) {
338                            throw processException(e);
339                    }
340                    finally {
341                            closeSession(session);
342                    }
343            }
344    
345            @Override
346            protected ShoppingCart removeImpl(ShoppingCart shoppingCart)
347                    throws SystemException {
348                    shoppingCart = toUnwrappedModel(shoppingCart);
349    
350                    Session session = null;
351    
352                    try {
353                            session = openSession();
354    
355                            BatchSessionUtil.delete(session, shoppingCart);
356                    }
357                    catch (Exception e) {
358                            throw processException(e);
359                    }
360                    finally {
361                            closeSession(session);
362                    }
363    
364                    clearCache(shoppingCart);
365    
366                    return shoppingCart;
367            }
368    
369            @Override
370            public ShoppingCart updateImpl(
371                    com.liferay.portlet.shopping.model.ShoppingCart shoppingCart,
372                    boolean merge) throws SystemException {
373                    shoppingCart = toUnwrappedModel(shoppingCart);
374    
375                    boolean isNew = shoppingCart.isNew();
376    
377                    ShoppingCartModelImpl shoppingCartModelImpl = (ShoppingCartModelImpl)shoppingCart;
378    
379                    Session session = null;
380    
381                    try {
382                            session = openSession();
383    
384                            BatchSessionUtil.update(session, shoppingCart, merge);
385    
386                            shoppingCart.setNew(false);
387                    }
388                    catch (Exception e) {
389                            throw processException(e);
390                    }
391                    finally {
392                            closeSession(session);
393                    }
394    
395                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
396    
397                    if (isNew || !ShoppingCartModelImpl.COLUMN_BITMASK_ENABLED) {
398                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
399                    }
400    
401                    else {
402                            if ((shoppingCartModelImpl.getColumnBitmask() &
403                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
404                                    Object[] args = new Object[] {
405                                                    Long.valueOf(shoppingCartModelImpl.getOriginalGroupId())
406                                            };
407    
408                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
409                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
410                                            args);
411    
412                                    args = new Object[] {
413                                                    Long.valueOf(shoppingCartModelImpl.getGroupId())
414                                            };
415    
416                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
417                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
418                                            args);
419                            }
420    
421                            if ((shoppingCartModelImpl.getColumnBitmask() &
422                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
423                                    Object[] args = new Object[] {
424                                                    Long.valueOf(shoppingCartModelImpl.getOriginalUserId())
425                                            };
426    
427                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
428                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
429                                            args);
430    
431                                    args = new Object[] {
432                                                    Long.valueOf(shoppingCartModelImpl.getUserId())
433                                            };
434    
435                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
436                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
437                                            args);
438                            }
439                    }
440    
441                    EntityCacheUtil.putResult(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
442                            ShoppingCartImpl.class, shoppingCart.getPrimaryKey(), shoppingCart);
443    
444                    clearUniqueFindersCache(shoppingCart);
445                    cacheUniqueFindersCache(shoppingCart);
446    
447                    return shoppingCart;
448            }
449    
450            protected ShoppingCart toUnwrappedModel(ShoppingCart shoppingCart) {
451                    if (shoppingCart instanceof ShoppingCartImpl) {
452                            return shoppingCart;
453                    }
454    
455                    ShoppingCartImpl shoppingCartImpl = new ShoppingCartImpl();
456    
457                    shoppingCartImpl.setNew(shoppingCart.isNew());
458                    shoppingCartImpl.setPrimaryKey(shoppingCart.getPrimaryKey());
459    
460                    shoppingCartImpl.setCartId(shoppingCart.getCartId());
461                    shoppingCartImpl.setGroupId(shoppingCart.getGroupId());
462                    shoppingCartImpl.setCompanyId(shoppingCart.getCompanyId());
463                    shoppingCartImpl.setUserId(shoppingCart.getUserId());
464                    shoppingCartImpl.setUserName(shoppingCart.getUserName());
465                    shoppingCartImpl.setCreateDate(shoppingCart.getCreateDate());
466                    shoppingCartImpl.setModifiedDate(shoppingCart.getModifiedDate());
467                    shoppingCartImpl.setItemIds(shoppingCart.getItemIds());
468                    shoppingCartImpl.setCouponCodes(shoppingCart.getCouponCodes());
469                    shoppingCartImpl.setAltShipping(shoppingCart.getAltShipping());
470                    shoppingCartImpl.setInsure(shoppingCart.isInsure());
471    
472                    return shoppingCartImpl;
473            }
474    
475            /**
476             * Returns the shopping cart with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
477             *
478             * @param primaryKey the primary key of the shopping cart
479             * @return the shopping cart
480             * @throws com.liferay.portal.NoSuchModelException if a shopping cart with the primary key could not be found
481             * @throws SystemException if a system exception occurred
482             */
483            @Override
484            public ShoppingCart findByPrimaryKey(Serializable primaryKey)
485                    throws NoSuchModelException, SystemException {
486                    return findByPrimaryKey(((Long)primaryKey).longValue());
487            }
488    
489            /**
490             * Returns the shopping cart with the primary key or throws a {@link com.liferay.portlet.shopping.NoSuchCartException} if it could not be found.
491             *
492             * @param cartId the primary key of the shopping cart
493             * @return the shopping cart
494             * @throws com.liferay.portlet.shopping.NoSuchCartException if a shopping cart with the primary key could not be found
495             * @throws SystemException if a system exception occurred
496             */
497            public ShoppingCart findByPrimaryKey(long cartId)
498                    throws NoSuchCartException, SystemException {
499                    ShoppingCart shoppingCart = fetchByPrimaryKey(cartId);
500    
501                    if (shoppingCart == null) {
502                            if (_log.isWarnEnabled()) {
503                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + cartId);
504                            }
505    
506                            throw new NoSuchCartException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
507                                    cartId);
508                    }
509    
510                    return shoppingCart;
511            }
512    
513            /**
514             * Returns the shopping cart with the primary key or returns <code>null</code> if it could not be found.
515             *
516             * @param primaryKey the primary key of the shopping cart
517             * @return the shopping cart, or <code>null</code> if a shopping cart with the primary key could not be found
518             * @throws SystemException if a system exception occurred
519             */
520            @Override
521            public ShoppingCart fetchByPrimaryKey(Serializable primaryKey)
522                    throws SystemException {
523                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
524            }
525    
526            /**
527             * Returns the shopping cart with the primary key or returns <code>null</code> if it could not be found.
528             *
529             * @param cartId the primary key of the shopping cart
530             * @return the shopping cart, or <code>null</code> if a shopping cart with the primary key could not be found
531             * @throws SystemException if a system exception occurred
532             */
533            public ShoppingCart fetchByPrimaryKey(long cartId)
534                    throws SystemException {
535                    ShoppingCart shoppingCart = (ShoppingCart)EntityCacheUtil.getResult(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
536                                    ShoppingCartImpl.class, cartId);
537    
538                    if (shoppingCart == _nullShoppingCart) {
539                            return null;
540                    }
541    
542                    if (shoppingCart == null) {
543                            Session session = null;
544    
545                            boolean hasException = false;
546    
547                            try {
548                                    session = openSession();
549    
550                                    shoppingCart = (ShoppingCart)session.get(ShoppingCartImpl.class,
551                                                    Long.valueOf(cartId));
552                            }
553                            catch (Exception e) {
554                                    hasException = true;
555    
556                                    throw processException(e);
557                            }
558                            finally {
559                                    if (shoppingCart != null) {
560                                            cacheResult(shoppingCart);
561                                    }
562                                    else if (!hasException) {
563                                            EntityCacheUtil.putResult(ShoppingCartModelImpl.ENTITY_CACHE_ENABLED,
564                                                    ShoppingCartImpl.class, cartId, _nullShoppingCart);
565                                    }
566    
567                                    closeSession(session);
568                            }
569                    }
570    
571                    return shoppingCart;
572            }
573    
574            /**
575             * Returns all the shopping carts where groupId = &#63;.
576             *
577             * @param groupId the group ID
578             * @return the matching shopping carts
579             * @throws SystemException if a system exception occurred
580             */
581            public List<ShoppingCart> findByGroupId(long groupId)
582                    throws SystemException {
583                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
584            }
585    
586            /**
587             * Returns a range of all the shopping carts where groupId = &#63;.
588             *
589             * <p>
590             * 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.
591             * </p>
592             *
593             * @param groupId the group ID
594             * @param start the lower bound of the range of shopping carts
595             * @param end the upper bound of the range of shopping carts (not inclusive)
596             * @return the range of matching shopping carts
597             * @throws SystemException if a system exception occurred
598             */
599            public List<ShoppingCart> findByGroupId(long groupId, int start, int end)
600                    throws SystemException {
601                    return findByGroupId(groupId, start, end, null);
602            }
603    
604            /**
605             * Returns an ordered range of all the shopping carts where groupId = &#63;.
606             *
607             * <p>
608             * 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.
609             * </p>
610             *
611             * @param groupId the group ID
612             * @param start the lower bound of the range of shopping carts
613             * @param end the upper bound of the range of shopping carts (not inclusive)
614             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
615             * @return the ordered range of matching shopping carts
616             * @throws SystemException if a system exception occurred
617             */
618            public List<ShoppingCart> findByGroupId(long groupId, int start, int end,
619                    OrderByComparator orderByComparator) throws SystemException {
620                    FinderPath finderPath = null;
621                    Object[] finderArgs = null;
622    
623                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
624                                    (orderByComparator == null)) {
625                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
626                            finderArgs = new Object[] { groupId };
627                    }
628                    else {
629                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
630                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
631                    }
632    
633                    List<ShoppingCart> list = (List<ShoppingCart>)FinderCacheUtil.getResult(finderPath,
634                                    finderArgs, this);
635    
636                    if ((list != null) && !list.isEmpty()) {
637                            for (ShoppingCart shoppingCart : list) {
638                                    if ((groupId != shoppingCart.getGroupId())) {
639                                            list = null;
640    
641                                            break;
642                                    }
643                            }
644                    }
645    
646                    if (list == null) {
647                            StringBundler query = null;
648    
649                            if (orderByComparator != null) {
650                                    query = new StringBundler(3 +
651                                                    (orderByComparator.getOrderByFields().length * 3));
652                            }
653                            else {
654                                    query = new StringBundler(2);
655                            }
656    
657                            query.append(_SQL_SELECT_SHOPPINGCART_WHERE);
658    
659                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
660    
661                            if (orderByComparator != null) {
662                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
663                                            orderByComparator);
664                            }
665    
666                            String sql = query.toString();
667    
668                            Session session = null;
669    
670                            try {
671                                    session = openSession();
672    
673                                    Query q = session.createQuery(sql);
674    
675                                    QueryPos qPos = QueryPos.getInstance(q);
676    
677                                    qPos.add(groupId);
678    
679                                    list = (List<ShoppingCart>)QueryUtil.list(q, getDialect(),
680                                                    start, end);
681                            }
682                            catch (Exception e) {
683                                    throw processException(e);
684                            }
685                            finally {
686                                    if (list == null) {
687                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
688                                    }
689                                    else {
690                                            cacheResult(list);
691    
692                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
693                                    }
694    
695                                    closeSession(session);
696                            }
697                    }
698    
699                    return list;
700            }
701    
702            /**
703             * Returns the first shopping cart in the ordered set where groupId = &#63;.
704             *
705             * @param groupId the group ID
706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
707             * @return the first matching shopping cart
708             * @throws com.liferay.portlet.shopping.NoSuchCartException if a matching shopping cart could not be found
709             * @throws SystemException if a system exception occurred
710             */
711            public ShoppingCart findByGroupId_First(long groupId,
712                    OrderByComparator orderByComparator)
713                    throws NoSuchCartException, SystemException {
714                    ShoppingCart shoppingCart = fetchByGroupId_First(groupId,
715                                    orderByComparator);
716    
717                    if (shoppingCart != null) {
718                            return shoppingCart;
719                    }
720    
721                    StringBundler msg = new StringBundler(4);
722    
723                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
724    
725                    msg.append("groupId=");
726                    msg.append(groupId);
727    
728                    msg.append(StringPool.CLOSE_CURLY_BRACE);
729    
730                    throw new NoSuchCartException(msg.toString());
731            }
732    
733            /**
734             * Returns the first shopping cart in the ordered set where groupId = &#63;.
735             *
736             * @param groupId the group ID
737             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
738             * @return the first matching shopping cart, or <code>null</code> if a matching shopping cart could not be found
739             * @throws SystemException if a system exception occurred
740             */
741            public ShoppingCart fetchByGroupId_First(long groupId,
742                    OrderByComparator orderByComparator) throws SystemException {
743                    List<ShoppingCart> list = findByGroupId(groupId, 0, 1, orderByComparator);
744    
745                    if (!list.isEmpty()) {
746                            return list.get(0);
747                    }
748    
749                    return null;
750            }
751    
752            /**
753             * Returns the last shopping cart in the ordered set where groupId = &#63;.
754             *
755             * @param groupId the group ID
756             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
757             * @return the last matching shopping cart
758             * @throws com.liferay.portlet.shopping.NoSuchCartException if a matching shopping cart could not be found
759             * @throws SystemException if a system exception occurred
760             */
761            public ShoppingCart findByGroupId_Last(long groupId,
762                    OrderByComparator orderByComparator)
763                    throws NoSuchCartException, SystemException {
764                    ShoppingCart shoppingCart = fetchByGroupId_Last(groupId,
765                                    orderByComparator);
766    
767                    if (shoppingCart != null) {
768                            return shoppingCart;
769                    }
770    
771                    StringBundler msg = new StringBundler(4);
772    
773                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
774    
775                    msg.append("groupId=");
776                    msg.append(groupId);
777    
778                    msg.append(StringPool.CLOSE_CURLY_BRACE);
779    
780                    throw new NoSuchCartException(msg.toString());
781            }
782    
783            /**
784             * Returns the last shopping cart in the ordered set where groupId = &#63;.
785             *
786             * @param groupId the group ID
787             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
788             * @return the last matching shopping cart, or <code>null</code> if a matching shopping cart could not be found
789             * @throws SystemException if a system exception occurred
790             */
791            public ShoppingCart fetchByGroupId_Last(long groupId,
792                    OrderByComparator orderByComparator) throws SystemException {
793                    int count = countByGroupId(groupId);
794    
795                    List<ShoppingCart> list = findByGroupId(groupId, count - 1, count,
796                                    orderByComparator);
797    
798                    if (!list.isEmpty()) {
799                            return list.get(0);
800                    }
801    
802                    return null;
803            }
804    
805            /**
806             * Returns the shopping carts before and after the current shopping cart in the ordered set where groupId = &#63;.
807             *
808             * @param cartId the primary key of the current shopping cart
809             * @param groupId the group ID
810             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
811             * @return the previous, current, and next shopping cart
812             * @throws com.liferay.portlet.shopping.NoSuchCartException if a shopping cart with the primary key could not be found
813             * @throws SystemException if a system exception occurred
814             */
815            public ShoppingCart[] findByGroupId_PrevAndNext(long cartId, long groupId,
816                    OrderByComparator orderByComparator)
817                    throws NoSuchCartException, SystemException {
818                    ShoppingCart shoppingCart = findByPrimaryKey(cartId);
819    
820                    Session session = null;
821    
822                    try {
823                            session = openSession();
824    
825                            ShoppingCart[] array = new ShoppingCartImpl[3];
826    
827                            array[0] = getByGroupId_PrevAndNext(session, shoppingCart, groupId,
828                                            orderByComparator, true);
829    
830                            array[1] = shoppingCart;
831    
832                            array[2] = getByGroupId_PrevAndNext(session, shoppingCart, groupId,
833                                            orderByComparator, false);
834    
835                            return array;
836                    }
837                    catch (Exception e) {
838                            throw processException(e);
839                    }
840                    finally {
841                            closeSession(session);
842                    }
843            }
844    
845            protected ShoppingCart getByGroupId_PrevAndNext(Session session,
846                    ShoppingCart shoppingCart, long groupId,
847                    OrderByComparator orderByComparator, boolean previous) {
848                    StringBundler query = null;
849    
850                    if (orderByComparator != null) {
851                            query = new StringBundler(6 +
852                                            (orderByComparator.getOrderByFields().length * 6));
853                    }
854                    else {
855                            query = new StringBundler(3);
856                    }
857    
858                    query.append(_SQL_SELECT_SHOPPINGCART_WHERE);
859    
860                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
861    
862                    if (orderByComparator != null) {
863                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
864    
865                            if (orderByConditionFields.length > 0) {
866                                    query.append(WHERE_AND);
867                            }
868    
869                            for (int i = 0; i < orderByConditionFields.length; i++) {
870                                    query.append(_ORDER_BY_ENTITY_ALIAS);
871                                    query.append(orderByConditionFields[i]);
872    
873                                    if ((i + 1) < orderByConditionFields.length) {
874                                            if (orderByComparator.isAscending() ^ previous) {
875                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
876                                            }
877                                            else {
878                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
879                                            }
880                                    }
881                                    else {
882                                            if (orderByComparator.isAscending() ^ previous) {
883                                                    query.append(WHERE_GREATER_THAN);
884                                            }
885                                            else {
886                                                    query.append(WHERE_LESSER_THAN);
887                                            }
888                                    }
889                            }
890    
891                            query.append(ORDER_BY_CLAUSE);
892    
893                            String[] orderByFields = orderByComparator.getOrderByFields();
894    
895                            for (int i = 0; i < orderByFields.length; i++) {
896                                    query.append(_ORDER_BY_ENTITY_ALIAS);
897                                    query.append(orderByFields[i]);
898    
899                                    if ((i + 1) < orderByFields.length) {
900                                            if (orderByComparator.isAscending() ^ previous) {
901                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
902                                            }
903                                            else {
904                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
905                                            }
906                                    }
907                                    else {
908                                            if (orderByComparator.isAscending() ^ previous) {
909                                                    query.append(ORDER_BY_ASC);
910                                            }
911                                            else {
912                                                    query.append(ORDER_BY_DESC);
913                                            }
914                                    }
915                            }
916                    }
917    
918                    String sql = query.toString();
919    
920                    Query q = session.createQuery(sql);
921    
922                    q.setFirstResult(0);
923                    q.setMaxResults(2);
924    
925                    QueryPos qPos = QueryPos.getInstance(q);
926    
927                    qPos.add(groupId);
928    
929                    if (orderByComparator != null) {
930                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingCart);
931    
932                            for (Object value : values) {
933                                    qPos.add(value);
934                            }
935                    }
936    
937                    List<ShoppingCart> list = q.list();
938    
939                    if (list.size() == 2) {
940                            return list.get(1);
941                    }
942                    else {
943                            return null;
944                    }
945            }
946    
947            /**
948             * Returns all the shopping carts where userId = &#63;.
949             *
950             * @param userId the user ID
951             * @return the matching shopping carts
952             * @throws SystemException if a system exception occurred
953             */
954            public List<ShoppingCart> findByUserId(long userId)
955                    throws SystemException {
956                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
957            }
958    
959            /**
960             * Returns a range of all the shopping carts where userId = &#63;.
961             *
962             * <p>
963             * 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.
964             * </p>
965             *
966             * @param userId the user ID
967             * @param start the lower bound of the range of shopping carts
968             * @param end the upper bound of the range of shopping carts (not inclusive)
969             * @return the range of matching shopping carts
970             * @throws SystemException if a system exception occurred
971             */
972            public List<ShoppingCart> findByUserId(long userId, int start, int end)
973                    throws SystemException {
974                    return findByUserId(userId, start, end, null);
975            }
976    
977            /**
978             * Returns an ordered range of all the shopping carts where userId = &#63;.
979             *
980             * <p>
981             * 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.
982             * </p>
983             *
984             * @param userId the user ID
985             * @param start the lower bound of the range of shopping carts
986             * @param end the upper bound of the range of shopping carts (not inclusive)
987             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
988             * @return the ordered range of matching shopping carts
989             * @throws SystemException if a system exception occurred
990             */
991            public List<ShoppingCart> findByUserId(long userId, int start, int end,
992                    OrderByComparator orderByComparator) throws SystemException {
993                    FinderPath finderPath = null;
994                    Object[] finderArgs = null;
995    
996                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
997                                    (orderByComparator == null)) {
998                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
999                            finderArgs = new Object[] { userId };
1000                    }
1001                    else {
1002                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1003                            finderArgs = new Object[] { userId, start, end, orderByComparator };
1004                    }
1005    
1006                    List<ShoppingCart> list = (List<ShoppingCart>)FinderCacheUtil.getResult(finderPath,
1007                                    finderArgs, this);
1008    
1009                    if ((list != null) && !list.isEmpty()) {
1010                            for (ShoppingCart shoppingCart : list) {
1011                                    if ((userId != shoppingCart.getUserId())) {
1012                                            list = null;
1013    
1014                                            break;
1015                                    }
1016                            }
1017                    }
1018    
1019                    if (list == null) {
1020                            StringBundler query = null;
1021    
1022                            if (orderByComparator != null) {
1023                                    query = new StringBundler(3 +
1024                                                    (orderByComparator.getOrderByFields().length * 3));
1025                            }
1026                            else {
1027                                    query = new StringBundler(2);
1028                            }
1029    
1030                            query.append(_SQL_SELECT_SHOPPINGCART_WHERE);
1031    
1032                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1033    
1034                            if (orderByComparator != null) {
1035                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1036                                            orderByComparator);
1037                            }
1038    
1039                            String sql = query.toString();
1040    
1041                            Session session = null;
1042    
1043                            try {
1044                                    session = openSession();
1045    
1046                                    Query q = session.createQuery(sql);
1047    
1048                                    QueryPos qPos = QueryPos.getInstance(q);
1049    
1050                                    qPos.add(userId);
1051    
1052                                    list = (List<ShoppingCart>)QueryUtil.list(q, getDialect(),
1053                                                    start, end);
1054                            }
1055                            catch (Exception e) {
1056                                    throw processException(e);
1057                            }
1058                            finally {
1059                                    if (list == null) {
1060                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1061                                    }
1062                                    else {
1063                                            cacheResult(list);
1064    
1065                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1066                                    }
1067    
1068                                    closeSession(session);
1069                            }
1070                    }
1071    
1072                    return list;
1073            }
1074    
1075            /**
1076             * Returns the first shopping cart in the ordered set where userId = &#63;.
1077             *
1078             * @param userId the user ID
1079             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1080             * @return the first matching shopping cart
1081             * @throws com.liferay.portlet.shopping.NoSuchCartException if a matching shopping cart could not be found
1082             * @throws SystemException if a system exception occurred
1083             */
1084            public ShoppingCart findByUserId_First(long userId,
1085                    OrderByComparator orderByComparator)
1086                    throws NoSuchCartException, SystemException {
1087                    ShoppingCart shoppingCart = fetchByUserId_First(userId,
1088                                    orderByComparator);
1089    
1090                    if (shoppingCart != null) {
1091                            return shoppingCart;
1092                    }
1093    
1094                    StringBundler msg = new StringBundler(4);
1095    
1096                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1097    
1098                    msg.append("userId=");
1099                    msg.append(userId);
1100    
1101                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1102    
1103                    throw new NoSuchCartException(msg.toString());
1104            }
1105    
1106            /**
1107             * Returns the first shopping cart in the ordered set where userId = &#63;.
1108             *
1109             * @param userId the user ID
1110             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1111             * @return the first matching shopping cart, or <code>null</code> if a matching shopping cart could not be found
1112             * @throws SystemException if a system exception occurred
1113             */
1114            public ShoppingCart fetchByUserId_First(long userId,
1115                    OrderByComparator orderByComparator) throws SystemException {
1116                    List<ShoppingCart> list = findByUserId(userId, 0, 1, orderByComparator);
1117    
1118                    if (!list.isEmpty()) {
1119                            return list.get(0);
1120                    }
1121    
1122                    return null;
1123            }
1124    
1125            /**
1126             * Returns the last shopping cart in the ordered set where userId = &#63;.
1127             *
1128             * @param userId the user ID
1129             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1130             * @return the last matching shopping cart
1131             * @throws com.liferay.portlet.shopping.NoSuchCartException if a matching shopping cart could not be found
1132             * @throws SystemException if a system exception occurred
1133             */
1134            public ShoppingCart findByUserId_Last(long userId,
1135                    OrderByComparator orderByComparator)
1136                    throws NoSuchCartException, SystemException {
1137                    ShoppingCart shoppingCart = fetchByUserId_Last(userId, orderByComparator);
1138    
1139                    if (shoppingCart != null) {
1140                            return shoppingCart;
1141                    }
1142    
1143                    StringBundler msg = new StringBundler(4);
1144    
1145                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1146    
1147                    msg.append("userId=");
1148                    msg.append(userId);
1149    
1150                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1151    
1152                    throw new NoSuchCartException(msg.toString());
1153            }
1154    
1155            /**
1156             * Returns the last shopping cart in the ordered set where userId = &#63;.
1157             *
1158             * @param userId the user ID
1159             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1160             * @return the last matching shopping cart, or <code>null</code> if a matching shopping cart could not be found
1161             * @throws SystemException if a system exception occurred
1162             */
1163            public ShoppingCart fetchByUserId_Last(long userId,
1164                    OrderByComparator orderByComparator) throws SystemException {
1165                    int count = countByUserId(userId);
1166    
1167                    List<ShoppingCart> list = findByUserId(userId, count - 1, count,
1168                                    orderByComparator);
1169    
1170                    if (!list.isEmpty()) {
1171                            return list.get(0);
1172                    }
1173    
1174                    return null;
1175            }
1176    
1177            /**
1178             * Returns the shopping carts before and after the current shopping cart in the ordered set where userId = &#63;.
1179             *
1180             * @param cartId the primary key of the current shopping cart
1181             * @param userId the user ID
1182             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1183             * @return the previous, current, and next shopping cart
1184             * @throws com.liferay.portlet.shopping.NoSuchCartException if a shopping cart with the primary key could not be found
1185             * @throws SystemException if a system exception occurred
1186             */
1187            public ShoppingCart[] findByUserId_PrevAndNext(long cartId, long userId,
1188                    OrderByComparator orderByComparator)
1189                    throws NoSuchCartException, SystemException {
1190                    ShoppingCart shoppingCart = findByPrimaryKey(cartId);
1191    
1192                    Session session = null;
1193    
1194                    try {
1195                            session = openSession();
1196    
1197                            ShoppingCart[] array = new ShoppingCartImpl[3];
1198    
1199                            array[0] = getByUserId_PrevAndNext(session, shoppingCart, userId,
1200                                            orderByComparator, true);
1201    
1202                            array[1] = shoppingCart;
1203    
1204                            array[2] = getByUserId_PrevAndNext(session, shoppingCart, userId,
1205                                            orderByComparator, false);
1206    
1207                            return array;
1208                    }
1209                    catch (Exception e) {
1210                            throw processException(e);
1211                    }
1212                    finally {
1213                            closeSession(session);
1214                    }
1215            }
1216    
1217            protected ShoppingCart getByUserId_PrevAndNext(Session session,
1218                    ShoppingCart shoppingCart, long userId,
1219                    OrderByComparator orderByComparator, boolean previous) {
1220                    StringBundler query = null;
1221    
1222                    if (orderByComparator != null) {
1223                            query = new StringBundler(6 +
1224                                            (orderByComparator.getOrderByFields().length * 6));
1225                    }
1226                    else {
1227                            query = new StringBundler(3);
1228                    }
1229    
1230                    query.append(_SQL_SELECT_SHOPPINGCART_WHERE);
1231    
1232                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1233    
1234                    if (orderByComparator != null) {
1235                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1236    
1237                            if (orderByConditionFields.length > 0) {
1238                                    query.append(WHERE_AND);
1239                            }
1240    
1241                            for (int i = 0; i < orderByConditionFields.length; i++) {
1242                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1243                                    query.append(orderByConditionFields[i]);
1244    
1245                                    if ((i + 1) < orderByConditionFields.length) {
1246                                            if (orderByComparator.isAscending() ^ previous) {
1247                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1248                                            }
1249                                            else {
1250                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1251                                            }
1252                                    }
1253                                    else {
1254                                            if (orderByComparator.isAscending() ^ previous) {
1255                                                    query.append(WHERE_GREATER_THAN);
1256                                            }
1257                                            else {
1258                                                    query.append(WHERE_LESSER_THAN);
1259                                            }
1260                                    }
1261                            }
1262    
1263                            query.append(ORDER_BY_CLAUSE);
1264    
1265                            String[] orderByFields = orderByComparator.getOrderByFields();
1266    
1267                            for (int i = 0; i < orderByFields.length; i++) {
1268                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1269                                    query.append(orderByFields[i]);
1270    
1271                                    if ((i + 1) < orderByFields.length) {
1272                                            if (orderByComparator.isAscending() ^ previous) {
1273                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1274                                            }
1275                                            else {
1276                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1277                                            }
1278                                    }
1279                                    else {
1280                                            if (orderByComparator.isAscending() ^ previous) {
1281                                                    query.append(ORDER_BY_ASC);
1282                                            }
1283                                            else {
1284                                                    query.append(ORDER_BY_DESC);
1285                                            }
1286                                    }
1287                            }
1288                    }
1289    
1290                    String sql = query.toString();
1291    
1292                    Query q = session.createQuery(sql);
1293    
1294                    q.setFirstResult(0);
1295                    q.setMaxResults(2);
1296    
1297                    QueryPos qPos = QueryPos.getInstance(q);
1298    
1299                    qPos.add(userId);
1300    
1301                    if (orderByComparator != null) {
1302                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingCart);
1303    
1304                            for (Object value : values) {
1305                                    qPos.add(value);
1306                            }
1307                    }
1308    
1309                    List<ShoppingCart> list = q.list();
1310    
1311                    if (list.size() == 2) {
1312                            return list.get(1);
1313                    }
1314                    else {
1315                            return null;
1316                    }
1317            }
1318    
1319            /**
1320             * Returns the shopping cart where groupId = &#63; and userId = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchCartException} if it could not be found.
1321             *
1322             * @param groupId the group ID
1323             * @param userId the user ID
1324             * @return the matching shopping cart
1325             * @throws com.liferay.portlet.shopping.NoSuchCartException if a matching shopping cart could not be found
1326             * @throws SystemException if a system exception occurred
1327             */
1328            public ShoppingCart findByG_U(long groupId, long userId)
1329                    throws NoSuchCartException, SystemException {
1330                    ShoppingCart shoppingCart = fetchByG_U(groupId, userId);
1331    
1332                    if (shoppingCart == null) {
1333                            StringBundler msg = new StringBundler(6);
1334    
1335                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1336    
1337                            msg.append("groupId=");
1338                            msg.append(groupId);
1339    
1340                            msg.append(", userId=");
1341                            msg.append(userId);
1342    
1343                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1344    
1345                            if (_log.isWarnEnabled()) {
1346                                    _log.warn(msg.toString());
1347                            }
1348    
1349                            throw new NoSuchCartException(msg.toString());
1350                    }
1351    
1352                    return shoppingCart;
1353            }
1354    
1355            /**
1356             * Returns the shopping cart where groupId = &#63; and userId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1357             *
1358             * @param groupId the group ID
1359             * @param userId the user ID
1360             * @return the matching shopping cart, or <code>null</code> if a matching shopping cart could not be found
1361             * @throws SystemException if a system exception occurred
1362             */
1363            public ShoppingCart fetchByG_U(long groupId, long userId)
1364                    throws SystemException {
1365                    return fetchByG_U(groupId, userId, true);
1366            }
1367    
1368            /**
1369             * Returns the shopping cart where groupId = &#63; and userId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1370             *
1371             * @param groupId the group ID
1372             * @param userId the user ID
1373             * @param retrieveFromCache whether to use the finder cache
1374             * @return the matching shopping cart, or <code>null</code> if a matching shopping cart could not be found
1375             * @throws SystemException if a system exception occurred
1376             */
1377            public ShoppingCart fetchByG_U(long groupId, long userId,
1378                    boolean retrieveFromCache) throws SystemException {
1379                    Object[] finderArgs = new Object[] { groupId, userId };
1380    
1381                    Object result = null;
1382    
1383                    if (retrieveFromCache) {
1384                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_U,
1385                                            finderArgs, this);
1386                    }
1387    
1388                    if (result instanceof ShoppingCart) {
1389                            ShoppingCart shoppingCart = (ShoppingCart)result;
1390    
1391                            if ((groupId != shoppingCart.getGroupId()) ||
1392                                            (userId != shoppingCart.getUserId())) {
1393                                    result = null;
1394                            }
1395                    }
1396    
1397                    if (result == null) {
1398                            StringBundler query = new StringBundler(3);
1399    
1400                            query.append(_SQL_SELECT_SHOPPINGCART_WHERE);
1401    
1402                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1403    
1404                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1405    
1406                            String sql = query.toString();
1407    
1408                            Session session = null;
1409    
1410                            try {
1411                                    session = openSession();
1412    
1413                                    Query q = session.createQuery(sql);
1414    
1415                                    QueryPos qPos = QueryPos.getInstance(q);
1416    
1417                                    qPos.add(groupId);
1418    
1419                                    qPos.add(userId);
1420    
1421                                    List<ShoppingCart> list = q.list();
1422    
1423                                    result = list;
1424    
1425                                    ShoppingCart shoppingCart = null;
1426    
1427                                    if (list.isEmpty()) {
1428                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
1429                                                    finderArgs, list);
1430                                    }
1431                                    else {
1432                                            shoppingCart = list.get(0);
1433    
1434                                            cacheResult(shoppingCart);
1435    
1436                                            if ((shoppingCart.getGroupId() != groupId) ||
1437                                                            (shoppingCart.getUserId() != userId)) {
1438                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
1439                                                            finderArgs, shoppingCart);
1440                                            }
1441                                    }
1442    
1443                                    return shoppingCart;
1444                            }
1445                            catch (Exception e) {
1446                                    throw processException(e);
1447                            }
1448                            finally {
1449                                    if (result == null) {
1450                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
1451                                                    finderArgs);
1452                                    }
1453    
1454                                    closeSession(session);
1455                            }
1456                    }
1457                    else {
1458                            if (result instanceof List<?>) {
1459                                    return null;
1460                            }
1461                            else {
1462                                    return (ShoppingCart)result;
1463                            }
1464                    }
1465            }
1466    
1467            /**
1468             * Returns all the shopping carts.
1469             *
1470             * @return the shopping carts
1471             * @throws SystemException if a system exception occurred
1472             */
1473            public List<ShoppingCart> findAll() throws SystemException {
1474                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1475            }
1476    
1477            /**
1478             * Returns a range of all the shopping carts.
1479             *
1480             * <p>
1481             * 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.
1482             * </p>
1483             *
1484             * @param start the lower bound of the range of shopping carts
1485             * @param end the upper bound of the range of shopping carts (not inclusive)
1486             * @return the range of shopping carts
1487             * @throws SystemException if a system exception occurred
1488             */
1489            public List<ShoppingCart> findAll(int start, int end)
1490                    throws SystemException {
1491                    return findAll(start, end, null);
1492            }
1493    
1494            /**
1495             * Returns an ordered range of all the shopping carts.
1496             *
1497             * <p>
1498             * 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.
1499             * </p>
1500             *
1501             * @param start the lower bound of the range of shopping carts
1502             * @param end the upper bound of the range of shopping carts (not inclusive)
1503             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1504             * @return the ordered range of shopping carts
1505             * @throws SystemException if a system exception occurred
1506             */
1507            public List<ShoppingCart> findAll(int start, int end,
1508                    OrderByComparator orderByComparator) throws SystemException {
1509                    FinderPath finderPath = null;
1510                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1511    
1512                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1513                                    (orderByComparator == null)) {
1514                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1515                            finderArgs = FINDER_ARGS_EMPTY;
1516                    }
1517                    else {
1518                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1519                            finderArgs = new Object[] { start, end, orderByComparator };
1520                    }
1521    
1522                    List<ShoppingCart> list = (List<ShoppingCart>)FinderCacheUtil.getResult(finderPath,
1523                                    finderArgs, this);
1524    
1525                    if (list == null) {
1526                            StringBundler query = null;
1527                            String sql = null;
1528    
1529                            if (orderByComparator != null) {
1530                                    query = new StringBundler(2 +
1531                                                    (orderByComparator.getOrderByFields().length * 3));
1532    
1533                                    query.append(_SQL_SELECT_SHOPPINGCART);
1534    
1535                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1536                                            orderByComparator);
1537    
1538                                    sql = query.toString();
1539                            }
1540                            else {
1541                                    sql = _SQL_SELECT_SHOPPINGCART;
1542                            }
1543    
1544                            Session session = null;
1545    
1546                            try {
1547                                    session = openSession();
1548    
1549                                    Query q = session.createQuery(sql);
1550    
1551                                    if (orderByComparator == null) {
1552                                            list = (List<ShoppingCart>)QueryUtil.list(q, getDialect(),
1553                                                            start, end, false);
1554    
1555                                            Collections.sort(list);
1556                                    }
1557                                    else {
1558                                            list = (List<ShoppingCart>)QueryUtil.list(q, getDialect(),
1559                                                            start, end);
1560                                    }
1561                            }
1562                            catch (Exception e) {
1563                                    throw processException(e);
1564                            }
1565                            finally {
1566                                    if (list == null) {
1567                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1568                                    }
1569                                    else {
1570                                            cacheResult(list);
1571    
1572                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1573                                    }
1574    
1575                                    closeSession(session);
1576                            }
1577                    }
1578    
1579                    return list;
1580            }
1581    
1582            /**
1583             * Removes all the shopping carts where groupId = &#63; from the database.
1584             *
1585             * @param groupId the group ID
1586             * @throws SystemException if a system exception occurred
1587             */
1588            public void removeByGroupId(long groupId) throws SystemException {
1589                    for (ShoppingCart shoppingCart : findByGroupId(groupId)) {
1590                            remove(shoppingCart);
1591                    }
1592            }
1593    
1594            /**
1595             * Removes all the shopping carts where userId = &#63; from the database.
1596             *
1597             * @param userId the user ID
1598             * @throws SystemException if a system exception occurred
1599             */
1600            public void removeByUserId(long userId) throws SystemException {
1601                    for (ShoppingCart shoppingCart : findByUserId(userId)) {
1602                            remove(shoppingCart);
1603                    }
1604            }
1605    
1606            /**
1607             * Removes the shopping cart where groupId = &#63; and userId = &#63; from the database.
1608             *
1609             * @param groupId the group ID
1610             * @param userId the user ID
1611             * @return the shopping cart that was removed
1612             * @throws SystemException if a system exception occurred
1613             */
1614            public ShoppingCart removeByG_U(long groupId, long userId)
1615                    throws NoSuchCartException, SystemException {
1616                    ShoppingCart shoppingCart = findByG_U(groupId, userId);
1617    
1618                    return remove(shoppingCart);
1619            }
1620    
1621            /**
1622             * Removes all the shopping carts from the database.
1623             *
1624             * @throws SystemException if a system exception occurred
1625             */
1626            public void removeAll() throws SystemException {
1627                    for (ShoppingCart shoppingCart : findAll()) {
1628                            remove(shoppingCart);
1629                    }
1630            }
1631    
1632            /**
1633             * Returns the number of shopping carts where groupId = &#63;.
1634             *
1635             * @param groupId the group ID
1636             * @return the number of matching shopping carts
1637             * @throws SystemException if a system exception occurred
1638             */
1639            public int countByGroupId(long groupId) throws SystemException {
1640                    Object[] finderArgs = new Object[] { groupId };
1641    
1642                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1643                                    finderArgs, this);
1644    
1645                    if (count == null) {
1646                            StringBundler query = new StringBundler(2);
1647    
1648                            query.append(_SQL_COUNT_SHOPPINGCART_WHERE);
1649    
1650                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1651    
1652                            String sql = query.toString();
1653    
1654                            Session session = null;
1655    
1656                            try {
1657                                    session = openSession();
1658    
1659                                    Query q = session.createQuery(sql);
1660    
1661                                    QueryPos qPos = QueryPos.getInstance(q);
1662    
1663                                    qPos.add(groupId);
1664    
1665                                    count = (Long)q.uniqueResult();
1666                            }
1667                            catch (Exception e) {
1668                                    throw processException(e);
1669                            }
1670                            finally {
1671                                    if (count == null) {
1672                                            count = Long.valueOf(0);
1673                                    }
1674    
1675                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1676                                            finderArgs, count);
1677    
1678                                    closeSession(session);
1679                            }
1680                    }
1681    
1682                    return count.intValue();
1683            }
1684    
1685            /**
1686             * Returns the number of shopping carts where userId = &#63;.
1687             *
1688             * @param userId the user ID
1689             * @return the number of matching shopping carts
1690             * @throws SystemException if a system exception occurred
1691             */
1692            public int countByUserId(long userId) throws SystemException {
1693                    Object[] finderArgs = new Object[] { userId };
1694    
1695                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1696                                    finderArgs, this);
1697    
1698                    if (count == null) {
1699                            StringBundler query = new StringBundler(2);
1700    
1701                            query.append(_SQL_COUNT_SHOPPINGCART_WHERE);
1702    
1703                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1704    
1705                            String sql = query.toString();
1706    
1707                            Session session = null;
1708    
1709                            try {
1710                                    session = openSession();
1711    
1712                                    Query q = session.createQuery(sql);
1713    
1714                                    QueryPos qPos = QueryPos.getInstance(q);
1715    
1716                                    qPos.add(userId);
1717    
1718                                    count = (Long)q.uniqueResult();
1719                            }
1720                            catch (Exception e) {
1721                                    throw processException(e);
1722                            }
1723                            finally {
1724                                    if (count == null) {
1725                                            count = Long.valueOf(0);
1726                                    }
1727    
1728                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1729                                            finderArgs, count);
1730    
1731                                    closeSession(session);
1732                            }
1733                    }
1734    
1735                    return count.intValue();
1736            }
1737    
1738            /**
1739             * Returns the number of shopping carts where groupId = &#63; and userId = &#63;.
1740             *
1741             * @param groupId the group ID
1742             * @param userId the user ID
1743             * @return the number of matching shopping carts
1744             * @throws SystemException if a system exception occurred
1745             */
1746            public int countByG_U(long groupId, long userId) throws SystemException {
1747                    Object[] finderArgs = new Object[] { groupId, userId };
1748    
1749                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
1750                                    finderArgs, this);
1751    
1752                    if (count == null) {
1753                            StringBundler query = new StringBundler(3);
1754    
1755                            query.append(_SQL_COUNT_SHOPPINGCART_WHERE);
1756    
1757                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1758    
1759                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1760    
1761                            String sql = query.toString();
1762    
1763                            Session session = null;
1764    
1765                            try {
1766                                    session = openSession();
1767    
1768                                    Query q = session.createQuery(sql);
1769    
1770                                    QueryPos qPos = QueryPos.getInstance(q);
1771    
1772                                    qPos.add(groupId);
1773    
1774                                    qPos.add(userId);
1775    
1776                                    count = (Long)q.uniqueResult();
1777                            }
1778                            catch (Exception e) {
1779                                    throw processException(e);
1780                            }
1781                            finally {
1782                                    if (count == null) {
1783                                            count = Long.valueOf(0);
1784                                    }
1785    
1786                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
1787                                            count);
1788    
1789                                    closeSession(session);
1790                            }
1791                    }
1792    
1793                    return count.intValue();
1794            }
1795    
1796            /**
1797             * Returns the number of shopping carts.
1798             *
1799             * @return the number of shopping carts
1800             * @throws SystemException if a system exception occurred
1801             */
1802            public int countAll() throws SystemException {
1803                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1804                                    FINDER_ARGS_EMPTY, this);
1805    
1806                    if (count == null) {
1807                            Session session = null;
1808    
1809                            try {
1810                                    session = openSession();
1811    
1812                                    Query q = session.createQuery(_SQL_COUNT_SHOPPINGCART);
1813    
1814                                    count = (Long)q.uniqueResult();
1815                            }
1816                            catch (Exception e) {
1817                                    throw processException(e);
1818                            }
1819                            finally {
1820                                    if (count == null) {
1821                                            count = Long.valueOf(0);
1822                                    }
1823    
1824                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1825                                            FINDER_ARGS_EMPTY, count);
1826    
1827                                    closeSession(session);
1828                            }
1829                    }
1830    
1831                    return count.intValue();
1832            }
1833    
1834            /**
1835             * Initializes the shopping cart persistence.
1836             */
1837            public void afterPropertiesSet() {
1838                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1839                                            com.liferay.portal.util.PropsUtil.get(
1840                                                    "value.object.listener.com.liferay.portlet.shopping.model.ShoppingCart")));
1841    
1842                    if (listenerClassNames.length > 0) {
1843                            try {
1844                                    List<ModelListener<ShoppingCart>> listenersList = new ArrayList<ModelListener<ShoppingCart>>();
1845    
1846                                    for (String listenerClassName : listenerClassNames) {
1847                                            Class<?> clazz = getClass();
1848    
1849                                            listenersList.add((ModelListener<ShoppingCart>)InstanceFactory.newInstance(
1850                                                            clazz.getClassLoader(), listenerClassName));
1851                                    }
1852    
1853                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1854                            }
1855                            catch (Exception e) {
1856                                    _log.error(e);
1857                            }
1858                    }
1859            }
1860    
1861            public void destroy() {
1862                    EntityCacheUtil.removeCache(ShoppingCartImpl.class.getName());
1863                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1864                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1865            }
1866    
1867            @BeanReference(type = ShoppingCartPersistence.class)
1868            protected ShoppingCartPersistence shoppingCartPersistence;
1869            @BeanReference(type = ShoppingCategoryPersistence.class)
1870            protected ShoppingCategoryPersistence shoppingCategoryPersistence;
1871            @BeanReference(type = ShoppingCouponPersistence.class)
1872            protected ShoppingCouponPersistence shoppingCouponPersistence;
1873            @BeanReference(type = ShoppingItemPersistence.class)
1874            protected ShoppingItemPersistence shoppingItemPersistence;
1875            @BeanReference(type = ShoppingItemFieldPersistence.class)
1876            protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
1877            @BeanReference(type = ShoppingItemPricePersistence.class)
1878            protected ShoppingItemPricePersistence shoppingItemPricePersistence;
1879            @BeanReference(type = ShoppingOrderPersistence.class)
1880            protected ShoppingOrderPersistence shoppingOrderPersistence;
1881            @BeanReference(type = ShoppingOrderItemPersistence.class)
1882            protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
1883            @BeanReference(type = ResourcePersistence.class)
1884            protected ResourcePersistence resourcePersistence;
1885            @BeanReference(type = UserPersistence.class)
1886            protected UserPersistence userPersistence;
1887            private static final String _SQL_SELECT_SHOPPINGCART = "SELECT shoppingCart FROM ShoppingCart shoppingCart";
1888            private static final String _SQL_SELECT_SHOPPINGCART_WHERE = "SELECT shoppingCart FROM ShoppingCart shoppingCart WHERE ";
1889            private static final String _SQL_COUNT_SHOPPINGCART = "SELECT COUNT(shoppingCart) FROM ShoppingCart shoppingCart";
1890            private static final String _SQL_COUNT_SHOPPINGCART_WHERE = "SELECT COUNT(shoppingCart) FROM ShoppingCart shoppingCart WHERE ";
1891            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "shoppingCart.groupId = ?";
1892            private static final String _FINDER_COLUMN_USERID_USERID_2 = "shoppingCart.userId = ?";
1893            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "shoppingCart.groupId = ? AND ";
1894            private static final String _FINDER_COLUMN_G_U_USERID_2 = "shoppingCart.userId = ?";
1895            private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingCart.";
1896            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingCart exists with the primary key ";
1897            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingCart exists with the key {";
1898            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1899            private static Log _log = LogFactoryUtil.getLog(ShoppingCartPersistenceImpl.class);
1900            private static ShoppingCart _nullShoppingCart = new ShoppingCartImpl() {
1901                            @Override
1902                            public Object clone() {
1903                                    return this;
1904                            }
1905    
1906                            @Override
1907                            public CacheModel<ShoppingCart> toCacheModel() {
1908                                    return _nullShoppingCartCacheModel;
1909                            }
1910                    };
1911    
1912            private static CacheModel<ShoppingCart> _nullShoppingCartCacheModel = new CacheModel<ShoppingCart>() {
1913                            public ShoppingCart toEntityModel() {
1914                                    return _nullShoppingCart;
1915                            }
1916                    };
1917    }