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