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