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