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