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