001    /**
002     * Copyright (c) 2000-2010 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.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
025    import com.liferay.portal.kernel.dao.orm.FinderPath;
026    import com.liferay.portal.kernel.dao.orm.Query;
027    import com.liferay.portal.kernel.dao.orm.QueryPos;
028    import com.liferay.portal.kernel.dao.orm.QueryUtil;
029    import com.liferay.portal.kernel.dao.orm.SQLQuery;
030    import com.liferay.portal.kernel.dao.orm.Session;
031    import com.liferay.portal.kernel.exception.SystemException;
032    import com.liferay.portal.kernel.log.Log;
033    import com.liferay.portal.kernel.log.LogFactoryUtil;
034    import com.liferay.portal.kernel.util.GetterUtil;
035    import com.liferay.portal.kernel.util.InstanceFactory;
036    import com.liferay.portal.kernel.util.OrderByComparator;
037    import com.liferay.portal.kernel.util.StringBundler;
038    import com.liferay.portal.kernel.util.StringPool;
039    import com.liferay.portal.kernel.util.StringUtil;
040    import com.liferay.portal.kernel.util.Validator;
041    import com.liferay.portal.model.ModelListener;
042    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043    import com.liferay.portal.service.persistence.BatchSessionUtil;
044    import com.liferay.portal.service.persistence.ImagePersistence;
045    import com.liferay.portal.service.persistence.ResourcePersistence;
046    import com.liferay.portal.service.persistence.UserPersistence;
047    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048    
049    import com.liferay.portlet.shopping.NoSuchItemException;
050    import com.liferay.portlet.shopping.model.ShoppingItem;
051    import com.liferay.portlet.shopping.model.impl.ShoppingItemImpl;
052    import com.liferay.portlet.shopping.model.impl.ShoppingItemModelImpl;
053    
054    import java.io.Serializable;
055    
056    import java.util.ArrayList;
057    import java.util.Collections;
058    import java.util.List;
059    
060    /**
061     * The persistence implementation for the shopping item service.
062     *
063     * <p>
064     * Never modify or reference this class directly. Always use {@link ShoppingItemUtil} to access the shopping item persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
065     * </p>
066     *
067     * <p>
068     * Caching information and settings can be found in <code>portal.properties</code>
069     * </p>
070     *
071     * @author Brian Wing Shun Chan
072     * @see ShoppingItemPersistence
073     * @see ShoppingItemUtil
074     * @generated
075     */
076    public class ShoppingItemPersistenceImpl extends BasePersistenceImpl<ShoppingItem>
077            implements ShoppingItemPersistence {
078            public static final String FINDER_CLASS_NAME_ENTITY = ShoppingItemImpl.class.getName();
079            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
080                    ".List";
081            public static final FinderPath FINDER_PATH_FETCH_BY_SMALLIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
082                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED,
083                            FINDER_CLASS_NAME_ENTITY, "fetchBySmallImageId",
084                            new String[] { Long.class.getName() });
085            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
086                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
087                            "countBySmallImageId", new String[] { Long.class.getName() });
088            public static final FinderPath FINDER_PATH_FETCH_BY_MEDIUMIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
089                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED,
090                            FINDER_CLASS_NAME_ENTITY, "fetchByMediumImageId",
091                            new String[] { Long.class.getName() });
092            public static final FinderPath FINDER_PATH_COUNT_BY_MEDIUMIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
093                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
094                            "countByMediumImageId", new String[] { Long.class.getName() });
095            public static final FinderPath FINDER_PATH_FETCH_BY_LARGEIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
096                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED,
097                            FINDER_CLASS_NAME_ENTITY, "fetchByLargeImageId",
098                            new String[] { Long.class.getName() });
099            public static final FinderPath FINDER_PATH_COUNT_BY_LARGEIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
100                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101                            "countByLargeImageId", new String[] { Long.class.getName() });
102            public static final FinderPath FINDER_PATH_FIND_BY_G_C = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
103                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104                            "findByG_C",
105                            new String[] {
106                                    Long.class.getName(), Long.class.getName(),
107                                    
108                            "java.lang.Integer", "java.lang.Integer",
109                                    "com.liferay.portal.kernel.util.OrderByComparator"
110                            });
111            public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
112                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113                            "countByG_C",
114                            new String[] { Long.class.getName(), Long.class.getName() });
115            public static final FinderPath FINDER_PATH_FETCH_BY_C_S = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
116                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED,
117                            FINDER_CLASS_NAME_ENTITY, "fetchByC_S",
118                            new String[] { Long.class.getName(), String.class.getName() });
119            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
120                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
121                            "countByC_S",
122                            new String[] { Long.class.getName(), String.class.getName() });
123            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
124                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
125                            "findAll", new String[0]);
126            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
127                            ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
128                            "countAll", new String[0]);
129    
130            /**
131             * Caches the shopping item in the entity cache if it is enabled.
132             *
133             * @param shoppingItem the shopping item to cache
134             */
135            public void cacheResult(ShoppingItem shoppingItem) {
136                    EntityCacheUtil.putResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
137                            ShoppingItemImpl.class, shoppingItem.getPrimaryKey(), shoppingItem);
138    
139                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
140                            new Object[] { new Long(shoppingItem.getSmallImageId()) },
141                            shoppingItem);
142    
143                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
144                            new Object[] { new Long(shoppingItem.getMediumImageId()) },
145                            shoppingItem);
146    
147                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
148                            new Object[] { new Long(shoppingItem.getLargeImageId()) },
149                            shoppingItem);
150    
151                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
152                            new Object[] {
153                                    new Long(shoppingItem.getCompanyId()),
154                                    
155                            shoppingItem.getSku()
156                            }, shoppingItem);
157            }
158    
159            /**
160             * Caches the shopping items in the entity cache if it is enabled.
161             *
162             * @param shoppingItems the shopping items to cache
163             */
164            public void cacheResult(List<ShoppingItem> shoppingItems) {
165                    for (ShoppingItem shoppingItem : shoppingItems) {
166                            if (EntityCacheUtil.getResult(
167                                                    ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
168                                                    ShoppingItemImpl.class, shoppingItem.getPrimaryKey(),
169                                                    this) == null) {
170                                    cacheResult(shoppingItem);
171                            }
172                    }
173            }
174    
175            /**
176             * Clears the cache for all shopping items.
177             *
178             * <p>
179             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
180             * </p>
181             */
182            public void clearCache() {
183                    CacheRegistryUtil.clear(ShoppingItemImpl.class.getName());
184                    EntityCacheUtil.clearCache(ShoppingItemImpl.class.getName());
185                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
186                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
187            }
188    
189            /**
190             * Clears the cache for the shopping item.
191             *
192             * <p>
193             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
194             * </p>
195             */
196            public void clearCache(ShoppingItem shoppingItem) {
197                    EntityCacheUtil.removeResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
198                            ShoppingItemImpl.class, shoppingItem.getPrimaryKey());
199    
200                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
201                            new Object[] { new Long(shoppingItem.getSmallImageId()) });
202    
203                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
204                            new Object[] { new Long(shoppingItem.getMediumImageId()) });
205    
206                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
207                            new Object[] { new Long(shoppingItem.getLargeImageId()) });
208    
209                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_S,
210                            new Object[] {
211                                    new Long(shoppingItem.getCompanyId()),
212                                    
213                            shoppingItem.getSku()
214                            });
215            }
216    
217            /**
218             * Creates a new shopping item with the primary key. Does not add the shopping item to the database.
219             *
220             * @param itemId the primary key for the new shopping item
221             * @return the new shopping item
222             */
223            public ShoppingItem create(long itemId) {
224                    ShoppingItem shoppingItem = new ShoppingItemImpl();
225    
226                    shoppingItem.setNew(true);
227                    shoppingItem.setPrimaryKey(itemId);
228    
229                    return shoppingItem;
230            }
231    
232            /**
233             * Removes the shopping item with the primary key from the database. Also notifies the appropriate model listeners.
234             *
235             * @param primaryKey the primary key of the shopping item to remove
236             * @return the shopping item that was removed
237             * @throws com.liferay.portal.NoSuchModelException if a shopping item with the primary key could not be found
238             * @throws SystemException if a system exception occurred
239             */
240            public ShoppingItem remove(Serializable primaryKey)
241                    throws NoSuchModelException, SystemException {
242                    return remove(((Long)primaryKey).longValue());
243            }
244    
245            /**
246             * Removes the shopping item with the primary key from the database. Also notifies the appropriate model listeners.
247             *
248             * @param itemId the primary key of the shopping item to remove
249             * @return the shopping item that was removed
250             * @throws com.liferay.portlet.shopping.NoSuchItemException if a shopping item with the primary key could not be found
251             * @throws SystemException if a system exception occurred
252             */
253            public ShoppingItem remove(long itemId)
254                    throws NoSuchItemException, SystemException {
255                    Session session = null;
256    
257                    try {
258                            session = openSession();
259    
260                            ShoppingItem shoppingItem = (ShoppingItem)session.get(ShoppingItemImpl.class,
261                                            new Long(itemId));
262    
263                            if (shoppingItem == null) {
264                                    if (_log.isWarnEnabled()) {
265                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + itemId);
266                                    }
267    
268                                    throw new NoSuchItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
269                                            itemId);
270                            }
271    
272                            return remove(shoppingItem);
273                    }
274                    catch (NoSuchItemException nsee) {
275                            throw nsee;
276                    }
277                    catch (Exception e) {
278                            throw processException(e);
279                    }
280                    finally {
281                            closeSession(session);
282                    }
283            }
284    
285            protected ShoppingItem removeImpl(ShoppingItem shoppingItem)
286                    throws SystemException {
287                    shoppingItem = toUnwrappedModel(shoppingItem);
288    
289                    Session session = null;
290    
291                    try {
292                            session = openSession();
293    
294                            BatchSessionUtil.delete(session, shoppingItem);
295                    }
296                    catch (Exception e) {
297                            throw processException(e);
298                    }
299                    finally {
300                            closeSession(session);
301                    }
302    
303                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
304    
305                    ShoppingItemModelImpl shoppingItemModelImpl = (ShoppingItemModelImpl)shoppingItem;
306    
307                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
308                            new Object[] {
309                                    new Long(shoppingItemModelImpl.getOriginalSmallImageId())
310                            });
311    
312                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
313                            new Object[] {
314                                    new Long(shoppingItemModelImpl.getOriginalMediumImageId())
315                            });
316    
317                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
318                            new Object[] {
319                                    new Long(shoppingItemModelImpl.getOriginalLargeImageId())
320                            });
321    
322                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_S,
323                            new Object[] {
324                                    new Long(shoppingItemModelImpl.getOriginalCompanyId()),
325                                    
326                            shoppingItemModelImpl.getOriginalSku()
327                            });
328    
329                    EntityCacheUtil.removeResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
330                            ShoppingItemImpl.class, shoppingItem.getPrimaryKey());
331    
332                    return shoppingItem;
333            }
334    
335            public ShoppingItem updateImpl(
336                    com.liferay.portlet.shopping.model.ShoppingItem shoppingItem,
337                    boolean merge) throws SystemException {
338                    shoppingItem = toUnwrappedModel(shoppingItem);
339    
340                    boolean isNew = shoppingItem.isNew();
341    
342                    ShoppingItemModelImpl shoppingItemModelImpl = (ShoppingItemModelImpl)shoppingItem;
343    
344                    Session session = null;
345    
346                    try {
347                            session = openSession();
348    
349                            BatchSessionUtil.update(session, shoppingItem, merge);
350    
351                            shoppingItem.setNew(false);
352                    }
353                    catch (Exception e) {
354                            throw processException(e);
355                    }
356                    finally {
357                            closeSession(session);
358                    }
359    
360                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
361    
362                    EntityCacheUtil.putResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
363                            ShoppingItemImpl.class, shoppingItem.getPrimaryKey(), shoppingItem);
364    
365                    if (!isNew &&
366                                    (shoppingItem.getSmallImageId() != shoppingItemModelImpl.getOriginalSmallImageId())) {
367                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
368                                    new Object[] {
369                                            new Long(shoppingItemModelImpl.getOriginalSmallImageId())
370                                    });
371                    }
372    
373                    if (isNew ||
374                                    (shoppingItem.getSmallImageId() != shoppingItemModelImpl.getOriginalSmallImageId())) {
375                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
376                                    new Object[] { new Long(shoppingItem.getSmallImageId()) },
377                                    shoppingItem);
378                    }
379    
380                    if (!isNew &&
381                                    (shoppingItem.getMediumImageId() != shoppingItemModelImpl.getOriginalMediumImageId())) {
382                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
383                                    new Object[] {
384                                            new Long(shoppingItemModelImpl.getOriginalMediumImageId())
385                                    });
386                    }
387    
388                    if (isNew ||
389                                    (shoppingItem.getMediumImageId() != shoppingItemModelImpl.getOriginalMediumImageId())) {
390                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
391                                    new Object[] { new Long(shoppingItem.getMediumImageId()) },
392                                    shoppingItem);
393                    }
394    
395                    if (!isNew &&
396                                    (shoppingItem.getLargeImageId() != shoppingItemModelImpl.getOriginalLargeImageId())) {
397                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
398                                    new Object[] {
399                                            new Long(shoppingItemModelImpl.getOriginalLargeImageId())
400                                    });
401                    }
402    
403                    if (isNew ||
404                                    (shoppingItem.getLargeImageId() != shoppingItemModelImpl.getOriginalLargeImageId())) {
405                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
406                                    new Object[] { new Long(shoppingItem.getLargeImageId()) },
407                                    shoppingItem);
408                    }
409    
410                    if (!isNew &&
411                                    ((shoppingItem.getCompanyId() != shoppingItemModelImpl.getOriginalCompanyId()) ||
412                                    !Validator.equals(shoppingItem.getSku(),
413                                            shoppingItemModelImpl.getOriginalSku()))) {
414                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_S,
415                                    new Object[] {
416                                            new Long(shoppingItemModelImpl.getOriginalCompanyId()),
417                                            
418                                    shoppingItemModelImpl.getOriginalSku()
419                                    });
420                    }
421    
422                    if (isNew ||
423                                    ((shoppingItem.getCompanyId() != shoppingItemModelImpl.getOriginalCompanyId()) ||
424                                    !Validator.equals(shoppingItem.getSku(),
425                                            shoppingItemModelImpl.getOriginalSku()))) {
426                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
427                                    new Object[] {
428                                            new Long(shoppingItem.getCompanyId()),
429                                            
430                                    shoppingItem.getSku()
431                                    }, shoppingItem);
432                    }
433    
434                    return shoppingItem;
435            }
436    
437            protected ShoppingItem toUnwrappedModel(ShoppingItem shoppingItem) {
438                    if (shoppingItem instanceof ShoppingItemImpl) {
439                            return shoppingItem;
440                    }
441    
442                    ShoppingItemImpl shoppingItemImpl = new ShoppingItemImpl();
443    
444                    shoppingItemImpl.setNew(shoppingItem.isNew());
445                    shoppingItemImpl.setPrimaryKey(shoppingItem.getPrimaryKey());
446    
447                    shoppingItemImpl.setItemId(shoppingItem.getItemId());
448                    shoppingItemImpl.setGroupId(shoppingItem.getGroupId());
449                    shoppingItemImpl.setCompanyId(shoppingItem.getCompanyId());
450                    shoppingItemImpl.setUserId(shoppingItem.getUserId());
451                    shoppingItemImpl.setUserName(shoppingItem.getUserName());
452                    shoppingItemImpl.setCreateDate(shoppingItem.getCreateDate());
453                    shoppingItemImpl.setModifiedDate(shoppingItem.getModifiedDate());
454                    shoppingItemImpl.setCategoryId(shoppingItem.getCategoryId());
455                    shoppingItemImpl.setSku(shoppingItem.getSku());
456                    shoppingItemImpl.setName(shoppingItem.getName());
457                    shoppingItemImpl.setDescription(shoppingItem.getDescription());
458                    shoppingItemImpl.setProperties(shoppingItem.getProperties());
459                    shoppingItemImpl.setFields(shoppingItem.isFields());
460                    shoppingItemImpl.setFieldsQuantities(shoppingItem.getFieldsQuantities());
461                    shoppingItemImpl.setMinQuantity(shoppingItem.getMinQuantity());
462                    shoppingItemImpl.setMaxQuantity(shoppingItem.getMaxQuantity());
463                    shoppingItemImpl.setPrice(shoppingItem.getPrice());
464                    shoppingItemImpl.setDiscount(shoppingItem.getDiscount());
465                    shoppingItemImpl.setTaxable(shoppingItem.isTaxable());
466                    shoppingItemImpl.setShipping(shoppingItem.getShipping());
467                    shoppingItemImpl.setUseShippingFormula(shoppingItem.isUseShippingFormula());
468                    shoppingItemImpl.setRequiresShipping(shoppingItem.isRequiresShipping());
469                    shoppingItemImpl.setStockQuantity(shoppingItem.getStockQuantity());
470                    shoppingItemImpl.setFeatured(shoppingItem.isFeatured());
471                    shoppingItemImpl.setSale(shoppingItem.isSale());
472                    shoppingItemImpl.setSmallImage(shoppingItem.isSmallImage());
473                    shoppingItemImpl.setSmallImageId(shoppingItem.getSmallImageId());
474                    shoppingItemImpl.setSmallImageURL(shoppingItem.getSmallImageURL());
475                    shoppingItemImpl.setMediumImage(shoppingItem.isMediumImage());
476                    shoppingItemImpl.setMediumImageId(shoppingItem.getMediumImageId());
477                    shoppingItemImpl.setMediumImageURL(shoppingItem.getMediumImageURL());
478                    shoppingItemImpl.setLargeImage(shoppingItem.isLargeImage());
479                    shoppingItemImpl.setLargeImageId(shoppingItem.getLargeImageId());
480                    shoppingItemImpl.setLargeImageURL(shoppingItem.getLargeImageURL());
481    
482                    return shoppingItemImpl;
483            }
484    
485            /**
486             * Finds the shopping item with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
487             *
488             * @param primaryKey the primary key of the shopping item to find
489             * @return the shopping item
490             * @throws com.liferay.portal.NoSuchModelException if a shopping item with the primary key could not be found
491             * @throws SystemException if a system exception occurred
492             */
493            public ShoppingItem findByPrimaryKey(Serializable primaryKey)
494                    throws NoSuchModelException, SystemException {
495                    return findByPrimaryKey(((Long)primaryKey).longValue());
496            }
497    
498            /**
499             * Finds the shopping item with the primary key or throws a {@link com.liferay.portlet.shopping.NoSuchItemException} if it could not be found.
500             *
501             * @param itemId the primary key of the shopping item to find
502             * @return the shopping item
503             * @throws com.liferay.portlet.shopping.NoSuchItemException if a shopping item with the primary key could not be found
504             * @throws SystemException if a system exception occurred
505             */
506            public ShoppingItem findByPrimaryKey(long itemId)
507                    throws NoSuchItemException, SystemException {
508                    ShoppingItem shoppingItem = fetchByPrimaryKey(itemId);
509    
510                    if (shoppingItem == null) {
511                            if (_log.isWarnEnabled()) {
512                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + itemId);
513                            }
514    
515                            throw new NoSuchItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
516                                    itemId);
517                    }
518    
519                    return shoppingItem;
520            }
521    
522            /**
523             * Finds the shopping item with the primary key or returns <code>null</code> if it could not be found.
524             *
525             * @param primaryKey the primary key of the shopping item to find
526             * @return the shopping item, or <code>null</code> if a shopping item with the primary key could not be found
527             * @throws SystemException if a system exception occurred
528             */
529            public ShoppingItem fetchByPrimaryKey(Serializable primaryKey)
530                    throws SystemException {
531                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
532            }
533    
534            /**
535             * Finds the shopping item with the primary key or returns <code>null</code> if it could not be found.
536             *
537             * @param itemId the primary key of the shopping item to find
538             * @return the shopping item, or <code>null</code> if a shopping item with the primary key could not be found
539             * @throws SystemException if a system exception occurred
540             */
541            public ShoppingItem fetchByPrimaryKey(long itemId)
542                    throws SystemException {
543                    ShoppingItem shoppingItem = (ShoppingItem)EntityCacheUtil.getResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
544                                    ShoppingItemImpl.class, itemId, this);
545    
546                    if (shoppingItem == null) {
547                            Session session = null;
548    
549                            try {
550                                    session = openSession();
551    
552                                    shoppingItem = (ShoppingItem)session.get(ShoppingItemImpl.class,
553                                                    new Long(itemId));
554                            }
555                            catch (Exception e) {
556                                    throw processException(e);
557                            }
558                            finally {
559                                    if (shoppingItem != null) {
560                                            cacheResult(shoppingItem);
561                                    }
562    
563                                    closeSession(session);
564                            }
565                    }
566    
567                    return shoppingItem;
568            }
569    
570            /**
571             * Finds the shopping item where smallImageId = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchItemException} if it could not be found.
572             *
573             * @param smallImageId the small image id to search with
574             * @return the matching shopping item
575             * @throws com.liferay.portlet.shopping.NoSuchItemException if a matching shopping item could not be found
576             * @throws SystemException if a system exception occurred
577             */
578            public ShoppingItem findBySmallImageId(long smallImageId)
579                    throws NoSuchItemException, SystemException {
580                    ShoppingItem shoppingItem = fetchBySmallImageId(smallImageId);
581    
582                    if (shoppingItem == null) {
583                            StringBundler msg = new StringBundler(4);
584    
585                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
586    
587                            msg.append("smallImageId=");
588                            msg.append(smallImageId);
589    
590                            msg.append(StringPool.CLOSE_CURLY_BRACE);
591    
592                            if (_log.isWarnEnabled()) {
593                                    _log.warn(msg.toString());
594                            }
595    
596                            throw new NoSuchItemException(msg.toString());
597                    }
598    
599                    return shoppingItem;
600            }
601    
602            /**
603             * Finds the shopping item where smallImageId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
604             *
605             * @param smallImageId the small image id to search with
606             * @return the matching shopping item, or <code>null</code> if a matching shopping item could not be found
607             * @throws SystemException if a system exception occurred
608             */
609            public ShoppingItem fetchBySmallImageId(long smallImageId)
610                    throws SystemException {
611                    return fetchBySmallImageId(smallImageId, true);
612            }
613    
614            /**
615             * Finds the shopping item where smallImageId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
616             *
617             * @param smallImageId the small image id to search with
618             * @return the matching shopping item, or <code>null</code> if a matching shopping item could not be found
619             * @throws SystemException if a system exception occurred
620             */
621            public ShoppingItem fetchBySmallImageId(long smallImageId,
622                    boolean retrieveFromCache) throws SystemException {
623                    Object[] finderArgs = new Object[] { smallImageId };
624    
625                    Object result = null;
626    
627                    if (retrieveFromCache) {
628                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
629                                            finderArgs, this);
630                    }
631    
632                    if (result == null) {
633                            Session session = null;
634    
635                            try {
636                                    session = openSession();
637    
638                                    StringBundler query = new StringBundler(3);
639    
640                                    query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
641    
642                                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
643    
644                                    query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
645    
646                                    String sql = query.toString();
647    
648                                    Query q = session.createQuery(sql);
649    
650                                    QueryPos qPos = QueryPos.getInstance(q);
651    
652                                    qPos.add(smallImageId);
653    
654                                    List<ShoppingItem> list = q.list();
655    
656                                    result = list;
657    
658                                    ShoppingItem shoppingItem = null;
659    
660                                    if (list.isEmpty()) {
661                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
662                                                    finderArgs, list);
663                                    }
664                                    else {
665                                            shoppingItem = list.get(0);
666    
667                                            cacheResult(shoppingItem);
668    
669                                            if ((shoppingItem.getSmallImageId() != smallImageId)) {
670                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
671                                                            finderArgs, shoppingItem);
672                                            }
673                                    }
674    
675                                    return shoppingItem;
676                            }
677                            catch (Exception e) {
678                                    throw processException(e);
679                            }
680                            finally {
681                                    if (result == null) {
682                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
683                                                    finderArgs, new ArrayList<ShoppingItem>());
684                                    }
685    
686                                    closeSession(session);
687                            }
688                    }
689                    else {
690                            if (result instanceof List<?>) {
691                                    return null;
692                            }
693                            else {
694                                    return (ShoppingItem)result;
695                            }
696                    }
697            }
698    
699            /**
700             * Finds the shopping item where mediumImageId = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchItemException} if it could not be found.
701             *
702             * @param mediumImageId the medium image id to search with
703             * @return the matching shopping item
704             * @throws com.liferay.portlet.shopping.NoSuchItemException if a matching shopping item could not be found
705             * @throws SystemException if a system exception occurred
706             */
707            public ShoppingItem findByMediumImageId(long mediumImageId)
708                    throws NoSuchItemException, SystemException {
709                    ShoppingItem shoppingItem = fetchByMediumImageId(mediumImageId);
710    
711                    if (shoppingItem == null) {
712                            StringBundler msg = new StringBundler(4);
713    
714                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
715    
716                            msg.append("mediumImageId=");
717                            msg.append(mediumImageId);
718    
719                            msg.append(StringPool.CLOSE_CURLY_BRACE);
720    
721                            if (_log.isWarnEnabled()) {
722                                    _log.warn(msg.toString());
723                            }
724    
725                            throw new NoSuchItemException(msg.toString());
726                    }
727    
728                    return shoppingItem;
729            }
730    
731            /**
732             * Finds the shopping item where mediumImageId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
733             *
734             * @param mediumImageId the medium image id to search with
735             * @return the matching shopping item, or <code>null</code> if a matching shopping item could not be found
736             * @throws SystemException if a system exception occurred
737             */
738            public ShoppingItem fetchByMediumImageId(long mediumImageId)
739                    throws SystemException {
740                    return fetchByMediumImageId(mediumImageId, true);
741            }
742    
743            /**
744             * Finds the shopping item where mediumImageId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
745             *
746             * @param mediumImageId the medium image id to search with
747             * @return the matching shopping item, or <code>null</code> if a matching shopping item could not be found
748             * @throws SystemException if a system exception occurred
749             */
750            public ShoppingItem fetchByMediumImageId(long mediumImageId,
751                    boolean retrieveFromCache) throws SystemException {
752                    Object[] finderArgs = new Object[] { mediumImageId };
753    
754                    Object result = null;
755    
756                    if (retrieveFromCache) {
757                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
758                                            finderArgs, this);
759                    }
760    
761                    if (result == null) {
762                            Session session = null;
763    
764                            try {
765                                    session = openSession();
766    
767                                    StringBundler query = new StringBundler(3);
768    
769                                    query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
770    
771                                    query.append(_FINDER_COLUMN_MEDIUMIMAGEID_MEDIUMIMAGEID_2);
772    
773                                    query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
774    
775                                    String sql = query.toString();
776    
777                                    Query q = session.createQuery(sql);
778    
779                                    QueryPos qPos = QueryPos.getInstance(q);
780    
781                                    qPos.add(mediumImageId);
782    
783                                    List<ShoppingItem> list = q.list();
784    
785                                    result = list;
786    
787                                    ShoppingItem shoppingItem = null;
788    
789                                    if (list.isEmpty()) {
790                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
791                                                    finderArgs, list);
792                                    }
793                                    else {
794                                            shoppingItem = list.get(0);
795    
796                                            cacheResult(shoppingItem);
797    
798                                            if ((shoppingItem.getMediumImageId() != mediumImageId)) {
799                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
800                                                            finderArgs, shoppingItem);
801                                            }
802                                    }
803    
804                                    return shoppingItem;
805                            }
806                            catch (Exception e) {
807                                    throw processException(e);
808                            }
809                            finally {
810                                    if (result == null) {
811                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
812                                                    finderArgs, new ArrayList<ShoppingItem>());
813                                    }
814    
815                                    closeSession(session);
816                            }
817                    }
818                    else {
819                            if (result instanceof List<?>) {
820                                    return null;
821                            }
822                            else {
823                                    return (ShoppingItem)result;
824                            }
825                    }
826            }
827    
828            /**
829             * Finds the shopping item where largeImageId = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchItemException} if it could not be found.
830             *
831             * @param largeImageId the large image id to search with
832             * @return the matching shopping item
833             * @throws com.liferay.portlet.shopping.NoSuchItemException if a matching shopping item could not be found
834             * @throws SystemException if a system exception occurred
835             */
836            public ShoppingItem findByLargeImageId(long largeImageId)
837                    throws NoSuchItemException, SystemException {
838                    ShoppingItem shoppingItem = fetchByLargeImageId(largeImageId);
839    
840                    if (shoppingItem == null) {
841                            StringBundler msg = new StringBundler(4);
842    
843                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
844    
845                            msg.append("largeImageId=");
846                            msg.append(largeImageId);
847    
848                            msg.append(StringPool.CLOSE_CURLY_BRACE);
849    
850                            if (_log.isWarnEnabled()) {
851                                    _log.warn(msg.toString());
852                            }
853    
854                            throw new NoSuchItemException(msg.toString());
855                    }
856    
857                    return shoppingItem;
858            }
859    
860            /**
861             * Finds the shopping item where largeImageId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
862             *
863             * @param largeImageId the large image id to search with
864             * @return the matching shopping item, or <code>null</code> if a matching shopping item could not be found
865             * @throws SystemException if a system exception occurred
866             */
867            public ShoppingItem fetchByLargeImageId(long largeImageId)
868                    throws SystemException {
869                    return fetchByLargeImageId(largeImageId, true);
870            }
871    
872            /**
873             * Finds the shopping item where largeImageId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
874             *
875             * @param largeImageId the large image id to search with
876             * @return the matching shopping item, or <code>null</code> if a matching shopping item could not be found
877             * @throws SystemException if a system exception occurred
878             */
879            public ShoppingItem fetchByLargeImageId(long largeImageId,
880                    boolean retrieveFromCache) throws SystemException {
881                    Object[] finderArgs = new Object[] { largeImageId };
882    
883                    Object result = null;
884    
885                    if (retrieveFromCache) {
886                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
887                                            finderArgs, this);
888                    }
889    
890                    if (result == null) {
891                            Session session = null;
892    
893                            try {
894                                    session = openSession();
895    
896                                    StringBundler query = new StringBundler(3);
897    
898                                    query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
899    
900                                    query.append(_FINDER_COLUMN_LARGEIMAGEID_LARGEIMAGEID_2);
901    
902                                    query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
903    
904                                    String sql = query.toString();
905    
906                                    Query q = session.createQuery(sql);
907    
908                                    QueryPos qPos = QueryPos.getInstance(q);
909    
910                                    qPos.add(largeImageId);
911    
912                                    List<ShoppingItem> list = q.list();
913    
914                                    result = list;
915    
916                                    ShoppingItem shoppingItem = null;
917    
918                                    if (list.isEmpty()) {
919                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
920                                                    finderArgs, list);
921                                    }
922                                    else {
923                                            shoppingItem = list.get(0);
924    
925                                            cacheResult(shoppingItem);
926    
927                                            if ((shoppingItem.getLargeImageId() != largeImageId)) {
928                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
929                                                            finderArgs, shoppingItem);
930                                            }
931                                    }
932    
933                                    return shoppingItem;
934                            }
935                            catch (Exception e) {
936                                    throw processException(e);
937                            }
938                            finally {
939                                    if (result == null) {
940                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
941                                                    finderArgs, new ArrayList<ShoppingItem>());
942                                    }
943    
944                                    closeSession(session);
945                            }
946                    }
947                    else {
948                            if (result instanceof List<?>) {
949                                    return null;
950                            }
951                            else {
952                                    return (ShoppingItem)result;
953                            }
954                    }
955            }
956    
957            /**
958             * Finds all the shopping items where groupId = &#63; and categoryId = &#63;.
959             *
960             * @param groupId the group id to search with
961             * @param categoryId the category id to search with
962             * @return the matching shopping items
963             * @throws SystemException if a system exception occurred
964             */
965            public List<ShoppingItem> findByG_C(long groupId, long categoryId)
966                    throws SystemException {
967                    return findByG_C(groupId, categoryId, QueryUtil.ALL_POS,
968                            QueryUtil.ALL_POS, null);
969            }
970    
971            /**
972             * Finds a range of all the shopping items where groupId = &#63; and categoryId = &#63;.
973             *
974             * <p>
975             * 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.
976             * </p>
977             *
978             * @param groupId the group id to search with
979             * @param categoryId the category id to search with
980             * @param start the lower bound of the range of shopping items to return
981             * @param end the upper bound of the range of shopping items to return (not inclusive)
982             * @return the range of matching shopping items
983             * @throws SystemException if a system exception occurred
984             */
985            public List<ShoppingItem> findByG_C(long groupId, long categoryId,
986                    int start, int end) throws SystemException {
987                    return findByG_C(groupId, categoryId, start, end, null);
988            }
989    
990            /**
991             * Finds an ordered range of all the shopping items where groupId = &#63; and categoryId = &#63;.
992             *
993             * <p>
994             * 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.
995             * </p>
996             *
997             * @param groupId the group id to search with
998             * @param categoryId the category id to search with
999             * @param start the lower bound of the range of shopping items to return
1000             * @param end the upper bound of the range of shopping items to return (not inclusive)
1001             * @param orderByComparator the comparator to order the results by
1002             * @return the ordered range of matching shopping items
1003             * @throws SystemException if a system exception occurred
1004             */
1005            public List<ShoppingItem> findByG_C(long groupId, long categoryId,
1006                    int start, int end, OrderByComparator orderByComparator)
1007                    throws SystemException {
1008                    Object[] finderArgs = new Object[] {
1009                                    groupId, categoryId,
1010                                    
1011                                    String.valueOf(start), String.valueOf(end),
1012                                    String.valueOf(orderByComparator)
1013                            };
1014    
1015                    List<ShoppingItem> list = (List<ShoppingItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C,
1016                                    finderArgs, this);
1017    
1018                    if (list == null) {
1019                            Session session = null;
1020    
1021                            try {
1022                                    session = openSession();
1023    
1024                                    StringBundler query = null;
1025    
1026                                    if (orderByComparator != null) {
1027                                            query = new StringBundler(4 +
1028                                                            (orderByComparator.getOrderByFields().length * 3));
1029                                    }
1030                                    else {
1031                                            query = new StringBundler(4);
1032                                    }
1033    
1034                                    query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
1035    
1036                                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1037    
1038                                    query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1039    
1040                                    if (orderByComparator != null) {
1041                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1042                                                    orderByComparator);
1043                                    }
1044    
1045                                    else {
1046                                            query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
1047                                    }
1048    
1049                                    String sql = query.toString();
1050    
1051                                    Query q = session.createQuery(sql);
1052    
1053                                    QueryPos qPos = QueryPos.getInstance(q);
1054    
1055                                    qPos.add(groupId);
1056    
1057                                    qPos.add(categoryId);
1058    
1059                                    list = (List<ShoppingItem>)QueryUtil.list(q, getDialect(),
1060                                                    start, end);
1061                            }
1062                            catch (Exception e) {
1063                                    throw processException(e);
1064                            }
1065                            finally {
1066                                    if (list == null) {
1067                                            list = new ArrayList<ShoppingItem>();
1068                                    }
1069    
1070                                    cacheResult(list);
1071    
1072                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C, finderArgs,
1073                                            list);
1074    
1075                                    closeSession(session);
1076                            }
1077                    }
1078    
1079                    return list;
1080            }
1081    
1082            /**
1083             * Finds the first shopping item in the ordered set where groupId = &#63; and categoryId = &#63;.
1084             *
1085             * <p>
1086             * 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.
1087             * </p>
1088             *
1089             * @param groupId the group id to search with
1090             * @param categoryId the category id to search with
1091             * @param orderByComparator the comparator to order the set by
1092             * @return the first matching shopping item
1093             * @throws com.liferay.portlet.shopping.NoSuchItemException if a matching shopping item could not be found
1094             * @throws SystemException if a system exception occurred
1095             */
1096            public ShoppingItem findByG_C_First(long groupId, long categoryId,
1097                    OrderByComparator orderByComparator)
1098                    throws NoSuchItemException, SystemException {
1099                    List<ShoppingItem> list = findByG_C(groupId, categoryId, 0, 1,
1100                                    orderByComparator);
1101    
1102                    if (list.isEmpty()) {
1103                            StringBundler msg = new StringBundler(6);
1104    
1105                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1106    
1107                            msg.append("groupId=");
1108                            msg.append(groupId);
1109    
1110                            msg.append(", categoryId=");
1111                            msg.append(categoryId);
1112    
1113                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1114    
1115                            throw new NoSuchItemException(msg.toString());
1116                    }
1117                    else {
1118                            return list.get(0);
1119                    }
1120            }
1121    
1122            /**
1123             * Finds the last shopping item in the ordered set where groupId = &#63; and categoryId = &#63;.
1124             *
1125             * <p>
1126             * 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.
1127             * </p>
1128             *
1129             * @param groupId the group id to search with
1130             * @param categoryId the category id to search with
1131             * @param orderByComparator the comparator to order the set by
1132             * @return the last matching shopping item
1133             * @throws com.liferay.portlet.shopping.NoSuchItemException if a matching shopping item could not be found
1134             * @throws SystemException if a system exception occurred
1135             */
1136            public ShoppingItem findByG_C_Last(long groupId, long categoryId,
1137                    OrderByComparator orderByComparator)
1138                    throws NoSuchItemException, SystemException {
1139                    int count = countByG_C(groupId, categoryId);
1140    
1141                    List<ShoppingItem> list = findByG_C(groupId, categoryId, count - 1,
1142                                    count, orderByComparator);
1143    
1144                    if (list.isEmpty()) {
1145                            StringBundler msg = new StringBundler(6);
1146    
1147                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1148    
1149                            msg.append("groupId=");
1150                            msg.append(groupId);
1151    
1152                            msg.append(", categoryId=");
1153                            msg.append(categoryId);
1154    
1155                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1156    
1157                            throw new NoSuchItemException(msg.toString());
1158                    }
1159                    else {
1160                            return list.get(0);
1161                    }
1162            }
1163    
1164            /**
1165             * Finds the shopping items before and after the current shopping item in the ordered set where groupId = &#63; and categoryId = &#63;.
1166             *
1167             * <p>
1168             * 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.
1169             * </p>
1170             *
1171             * @param itemId the primary key of the current shopping item
1172             * @param groupId the group id to search with
1173             * @param categoryId the category id to search with
1174             * @param orderByComparator the comparator to order the set by
1175             * @return the previous, current, and next shopping item
1176             * @throws com.liferay.portlet.shopping.NoSuchItemException if a shopping item with the primary key could not be found
1177             * @throws SystemException if a system exception occurred
1178             */
1179            public ShoppingItem[] findByG_C_PrevAndNext(long itemId, long groupId,
1180                    long categoryId, OrderByComparator orderByComparator)
1181                    throws NoSuchItemException, SystemException {
1182                    ShoppingItem shoppingItem = findByPrimaryKey(itemId);
1183    
1184                    Session session = null;
1185    
1186                    try {
1187                            session = openSession();
1188    
1189                            ShoppingItem[] array = new ShoppingItemImpl[3];
1190    
1191                            array[0] = getByG_C_PrevAndNext(session, shoppingItem, groupId,
1192                                            categoryId, orderByComparator, true);
1193    
1194                            array[1] = shoppingItem;
1195    
1196                            array[2] = getByG_C_PrevAndNext(session, shoppingItem, groupId,
1197                                            categoryId, orderByComparator, false);
1198    
1199                            return array;
1200                    }
1201                    catch (Exception e) {
1202                            throw processException(e);
1203                    }
1204                    finally {
1205                            closeSession(session);
1206                    }
1207            }
1208    
1209            protected ShoppingItem getByG_C_PrevAndNext(Session session,
1210                    ShoppingItem shoppingItem, long groupId, long categoryId,
1211                    OrderByComparator orderByComparator, boolean previous) {
1212                    StringBundler query = null;
1213    
1214                    if (orderByComparator != null) {
1215                            query = new StringBundler(6 +
1216                                            (orderByComparator.getOrderByFields().length * 6));
1217                    }
1218                    else {
1219                            query = new StringBundler(3);
1220                    }
1221    
1222                    query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
1223    
1224                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1225    
1226                    query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1227    
1228                    if (orderByComparator != null) {
1229                            String[] orderByFields = orderByComparator.getOrderByFields();
1230    
1231                            if (orderByFields.length > 0) {
1232                                    query.append(WHERE_AND);
1233                            }
1234    
1235                            for (int i = 0; i < orderByFields.length; i++) {
1236                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1237                                    query.append(orderByFields[i]);
1238    
1239                                    if ((i + 1) < orderByFields.length) {
1240                                            if (orderByComparator.isAscending() ^ previous) {
1241                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1242                                            }
1243                                            else {
1244                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1245                                            }
1246                                    }
1247                                    else {
1248                                            if (orderByComparator.isAscending() ^ previous) {
1249                                                    query.append(WHERE_GREATER_THAN);
1250                                            }
1251                                            else {
1252                                                    query.append(WHERE_LESSER_THAN);
1253                                            }
1254                                    }
1255                            }
1256    
1257                            query.append(ORDER_BY_CLAUSE);
1258    
1259                            for (int i = 0; i < orderByFields.length; i++) {
1260                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1261                                    query.append(orderByFields[i]);
1262    
1263                                    if ((i + 1) < orderByFields.length) {
1264                                            if (orderByComparator.isAscending() ^ previous) {
1265                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1266                                            }
1267                                            else {
1268                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1269                                            }
1270                                    }
1271                                    else {
1272                                            if (orderByComparator.isAscending() ^ previous) {
1273                                                    query.append(ORDER_BY_ASC);
1274                                            }
1275                                            else {
1276                                                    query.append(ORDER_BY_DESC);
1277                                            }
1278                                    }
1279                            }
1280                    }
1281    
1282                    else {
1283                            query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
1284                    }
1285    
1286                    String sql = query.toString();
1287    
1288                    Query q = session.createQuery(sql);
1289    
1290                    q.setFirstResult(0);
1291                    q.setMaxResults(2);
1292    
1293                    QueryPos qPos = QueryPos.getInstance(q);
1294    
1295                    qPos.add(groupId);
1296    
1297                    qPos.add(categoryId);
1298    
1299                    if (orderByComparator != null) {
1300                            Object[] values = orderByComparator.getOrderByValues(shoppingItem);
1301    
1302                            for (Object value : values) {
1303                                    qPos.add(value);
1304                            }
1305                    }
1306    
1307                    List<ShoppingItem> list = q.list();
1308    
1309                    if (list.size() == 2) {
1310                            return list.get(1);
1311                    }
1312                    else {
1313                            return null;
1314                    }
1315            }
1316    
1317            /**
1318             * Filters by the user's permissions and finds all the shopping items where groupId = &#63; and categoryId = &#63;.
1319             *
1320             * @param groupId the group id to search with
1321             * @param categoryId the category id to search with
1322             * @return the matching shopping items that the user has permission to view
1323             * @throws SystemException if a system exception occurred
1324             */
1325            public List<ShoppingItem> filterFindByG_C(long groupId, long categoryId)
1326                    throws SystemException {
1327                    return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS,
1328                            QueryUtil.ALL_POS, null);
1329            }
1330    
1331            /**
1332             * Filters by the user's permissions and finds a range of all the shopping items where groupId = &#63; and categoryId = &#63;.
1333             *
1334             * <p>
1335             * 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.
1336             * </p>
1337             *
1338             * @param groupId the group id to search with
1339             * @param categoryId the category id to search with
1340             * @param start the lower bound of the range of shopping items to return
1341             * @param end the upper bound of the range of shopping items to return (not inclusive)
1342             * @return the range of matching shopping items that the user has permission to view
1343             * @throws SystemException if a system exception occurred
1344             */
1345            public List<ShoppingItem> filterFindByG_C(long groupId, long categoryId,
1346                    int start, int end) throws SystemException {
1347                    return filterFindByG_C(groupId, categoryId, start, end, null);
1348            }
1349    
1350            /**
1351             * Filters by the user's permissions and finds an ordered range of all the shopping items where groupId = &#63; and categoryId = &#63;.
1352             *
1353             * <p>
1354             * 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.
1355             * </p>
1356             *
1357             * @param groupId the group id to search with
1358             * @param categoryId the category id to search with
1359             * @param start the lower bound of the range of shopping items to return
1360             * @param end the upper bound of the range of shopping items to return (not inclusive)
1361             * @param orderByComparator the comparator to order the results by
1362             * @return the ordered range of matching shopping items that the user has permission to view
1363             * @throws SystemException if a system exception occurred
1364             */
1365            public List<ShoppingItem> filterFindByG_C(long groupId, long categoryId,
1366                    int start, int end, OrderByComparator orderByComparator)
1367                    throws SystemException {
1368                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1369                            return findByG_C(groupId, categoryId, start, end, orderByComparator);
1370                    }
1371    
1372                    Session session = null;
1373    
1374                    try {
1375                            session = openSession();
1376    
1377                            StringBundler query = null;
1378    
1379                            if (orderByComparator != null) {
1380                                    query = new StringBundler(4 +
1381                                                    (orderByComparator.getOrderByFields().length * 3));
1382                            }
1383                            else {
1384                                    query = new StringBundler(4);
1385                            }
1386    
1387                            if (getDB().isSupportsInlineDistinct()) {
1388                                    query.append(_FILTER_SQL_SELECT_SHOPPINGITEM_WHERE);
1389                            }
1390                            else {
1391                                    query.append(_FILTER_SQL_SELECT_SHOPPINGITEM_NO_INLINE_DISTINCT_WHERE);
1392                            }
1393    
1394                            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1395    
1396                            query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1397    
1398                            if (orderByComparator != null) {
1399                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1400                                            orderByComparator);
1401                            }
1402    
1403                            else {
1404                                    query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
1405                            }
1406    
1407                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1408                                            ShoppingItem.class.getName(), _FILTER_COLUMN_PK,
1409                                            _FILTER_COLUMN_USERID, groupId);
1410    
1411                            SQLQuery q = session.createSQLQuery(sql);
1412    
1413                            q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingItemImpl.class);
1414    
1415                            QueryPos qPos = QueryPos.getInstance(q);
1416    
1417                            qPos.add(groupId);
1418    
1419                            qPos.add(categoryId);
1420    
1421                            return (List<ShoppingItem>)QueryUtil.list(q, getDialect(), start,
1422                                    end);
1423                    }
1424                    catch (Exception e) {
1425                            throw processException(e);
1426                    }
1427                    finally {
1428                            closeSession(session);
1429                    }
1430            }
1431    
1432            /**
1433             * Finds the shopping item where companyId = &#63; and sku = &#63; or throws a {@link com.liferay.portlet.shopping.NoSuchItemException} if it could not be found.
1434             *
1435             * @param companyId the company id to search with
1436             * @param sku the sku to search with
1437             * @return the matching shopping item
1438             * @throws com.liferay.portlet.shopping.NoSuchItemException if a matching shopping item could not be found
1439             * @throws SystemException if a system exception occurred
1440             */
1441            public ShoppingItem findByC_S(long companyId, String sku)
1442                    throws NoSuchItemException, SystemException {
1443                    ShoppingItem shoppingItem = fetchByC_S(companyId, sku);
1444    
1445                    if (shoppingItem == null) {
1446                            StringBundler msg = new StringBundler(6);
1447    
1448                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1449    
1450                            msg.append("companyId=");
1451                            msg.append(companyId);
1452    
1453                            msg.append(", sku=");
1454                            msg.append(sku);
1455    
1456                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1457    
1458                            if (_log.isWarnEnabled()) {
1459                                    _log.warn(msg.toString());
1460                            }
1461    
1462                            throw new NoSuchItemException(msg.toString());
1463                    }
1464    
1465                    return shoppingItem;
1466            }
1467    
1468            /**
1469             * Finds the shopping item where companyId = &#63; and sku = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1470             *
1471             * @param companyId the company id to search with
1472             * @param sku the sku to search with
1473             * @return the matching shopping item, or <code>null</code> if a matching shopping item could not be found
1474             * @throws SystemException if a system exception occurred
1475             */
1476            public ShoppingItem fetchByC_S(long companyId, String sku)
1477                    throws SystemException {
1478                    return fetchByC_S(companyId, sku, true);
1479            }
1480    
1481            /**
1482             * Finds the shopping item where companyId = &#63; and sku = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1483             *
1484             * @param companyId the company id to search with
1485             * @param sku the sku to search with
1486             * @return the matching shopping item, or <code>null</code> if a matching shopping item could not be found
1487             * @throws SystemException if a system exception occurred
1488             */
1489            public ShoppingItem fetchByC_S(long companyId, String sku,
1490                    boolean retrieveFromCache) throws SystemException {
1491                    Object[] finderArgs = new Object[] { companyId, sku };
1492    
1493                    Object result = null;
1494    
1495                    if (retrieveFromCache) {
1496                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_S,
1497                                            finderArgs, this);
1498                    }
1499    
1500                    if (result == null) {
1501                            Session session = null;
1502    
1503                            try {
1504                                    session = openSession();
1505    
1506                                    StringBundler query = new StringBundler(4);
1507    
1508                                    query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
1509    
1510                                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
1511    
1512                                    if (sku == null) {
1513                                            query.append(_FINDER_COLUMN_C_S_SKU_1);
1514                                    }
1515                                    else {
1516                                            if (sku.equals(StringPool.BLANK)) {
1517                                                    query.append(_FINDER_COLUMN_C_S_SKU_3);
1518                                            }
1519                                            else {
1520                                                    query.append(_FINDER_COLUMN_C_S_SKU_2);
1521                                            }
1522                                    }
1523    
1524                                    query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
1525    
1526                                    String sql = query.toString();
1527    
1528                                    Query q = session.createQuery(sql);
1529    
1530                                    QueryPos qPos = QueryPos.getInstance(q);
1531    
1532                                    qPos.add(companyId);
1533    
1534                                    if (sku != null) {
1535                                            qPos.add(sku);
1536                                    }
1537    
1538                                    List<ShoppingItem> list = q.list();
1539    
1540                                    result = list;
1541    
1542                                    ShoppingItem shoppingItem = null;
1543    
1544                                    if (list.isEmpty()) {
1545                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
1546                                                    finderArgs, list);
1547                                    }
1548                                    else {
1549                                            shoppingItem = list.get(0);
1550    
1551                                            cacheResult(shoppingItem);
1552    
1553                                            if ((shoppingItem.getCompanyId() != companyId) ||
1554                                                            (shoppingItem.getSku() == null) ||
1555                                                            !shoppingItem.getSku().equals(sku)) {
1556                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
1557                                                            finderArgs, shoppingItem);
1558                                            }
1559                                    }
1560    
1561                                    return shoppingItem;
1562                            }
1563                            catch (Exception e) {
1564                                    throw processException(e);
1565                            }
1566                            finally {
1567                                    if (result == null) {
1568                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
1569                                                    finderArgs, new ArrayList<ShoppingItem>());
1570                                    }
1571    
1572                                    closeSession(session);
1573                            }
1574                    }
1575                    else {
1576                            if (result instanceof List<?>) {
1577                                    return null;
1578                            }
1579                            else {
1580                                    return (ShoppingItem)result;
1581                            }
1582                    }
1583            }
1584    
1585            /**
1586             * Finds all the shopping items.
1587             *
1588             * @return the shopping items
1589             * @throws SystemException if a system exception occurred
1590             */
1591            public List<ShoppingItem> findAll() throws SystemException {
1592                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1593            }
1594    
1595            /**
1596             * Finds a range of all the shopping items.
1597             *
1598             * <p>
1599             * 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.
1600             * </p>
1601             *
1602             * @param start the lower bound of the range of shopping items to return
1603             * @param end the upper bound of the range of shopping items to return (not inclusive)
1604             * @return the range of shopping items
1605             * @throws SystemException if a system exception occurred
1606             */
1607            public List<ShoppingItem> findAll(int start, int end)
1608                    throws SystemException {
1609                    return findAll(start, end, null);
1610            }
1611    
1612            /**
1613             * Finds an ordered range of all the shopping items.
1614             *
1615             * <p>
1616             * 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.
1617             * </p>
1618             *
1619             * @param start the lower bound of the range of shopping items to return
1620             * @param end the upper bound of the range of shopping items to return (not inclusive)
1621             * @param orderByComparator the comparator to order the results by
1622             * @return the ordered range of shopping items
1623             * @throws SystemException if a system exception occurred
1624             */
1625            public List<ShoppingItem> findAll(int start, int end,
1626                    OrderByComparator orderByComparator) throws SystemException {
1627                    Object[] finderArgs = new Object[] {
1628                                    String.valueOf(start), String.valueOf(end),
1629                                    String.valueOf(orderByComparator)
1630                            };
1631    
1632                    List<ShoppingItem> list = (List<ShoppingItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1633                                    finderArgs, this);
1634    
1635                    if (list == null) {
1636                            Session session = null;
1637    
1638                            try {
1639                                    session = openSession();
1640    
1641                                    StringBundler query = null;
1642                                    String sql = null;
1643    
1644                                    if (orderByComparator != null) {
1645                                            query = new StringBundler(2 +
1646                                                            (orderByComparator.getOrderByFields().length * 3));
1647    
1648                                            query.append(_SQL_SELECT_SHOPPINGITEM);
1649    
1650                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1651                                                    orderByComparator);
1652    
1653                                            sql = query.toString();
1654                                    }
1655                                    else {
1656                                            sql = _SQL_SELECT_SHOPPINGITEM.concat(ShoppingItemModelImpl.ORDER_BY_JPQL);
1657                                    }
1658    
1659                                    Query q = session.createQuery(sql);
1660    
1661                                    if (orderByComparator == null) {
1662                                            list = (List<ShoppingItem>)QueryUtil.list(q, getDialect(),
1663                                                            start, end, false);
1664    
1665                                            Collections.sort(list);
1666                                    }
1667                                    else {
1668                                            list = (List<ShoppingItem>)QueryUtil.list(q, getDialect(),
1669                                                            start, end);
1670                                    }
1671                            }
1672                            catch (Exception e) {
1673                                    throw processException(e);
1674                            }
1675                            finally {
1676                                    if (list == null) {
1677                                            list = new ArrayList<ShoppingItem>();
1678                                    }
1679    
1680                                    cacheResult(list);
1681    
1682                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1683    
1684                                    closeSession(session);
1685                            }
1686                    }
1687    
1688                    return list;
1689            }
1690    
1691            /**
1692             * Removes the shopping item where smallImageId = &#63; from the database.
1693             *
1694             * @param smallImageId the small image id to search with
1695             * @throws SystemException if a system exception occurred
1696             */
1697            public void removeBySmallImageId(long smallImageId)
1698                    throws NoSuchItemException, SystemException {
1699                    ShoppingItem shoppingItem = findBySmallImageId(smallImageId);
1700    
1701                    remove(shoppingItem);
1702            }
1703    
1704            /**
1705             * Removes the shopping item where mediumImageId = &#63; from the database.
1706             *
1707             * @param mediumImageId the medium image id to search with
1708             * @throws SystemException if a system exception occurred
1709             */
1710            public void removeByMediumImageId(long mediumImageId)
1711                    throws NoSuchItemException, SystemException {
1712                    ShoppingItem shoppingItem = findByMediumImageId(mediumImageId);
1713    
1714                    remove(shoppingItem);
1715            }
1716    
1717            /**
1718             * Removes the shopping item where largeImageId = &#63; from the database.
1719             *
1720             * @param largeImageId the large image id to search with
1721             * @throws SystemException if a system exception occurred
1722             */
1723            public void removeByLargeImageId(long largeImageId)
1724                    throws NoSuchItemException, SystemException {
1725                    ShoppingItem shoppingItem = findByLargeImageId(largeImageId);
1726    
1727                    remove(shoppingItem);
1728            }
1729    
1730            /**
1731             * Removes all the shopping items where groupId = &#63; and categoryId = &#63; from the database.
1732             *
1733             * @param groupId the group id to search with
1734             * @param categoryId the category id to search with
1735             * @throws SystemException if a system exception occurred
1736             */
1737            public void removeByG_C(long groupId, long categoryId)
1738                    throws SystemException {
1739                    for (ShoppingItem shoppingItem : findByG_C(groupId, categoryId)) {
1740                            remove(shoppingItem);
1741                    }
1742            }
1743    
1744            /**
1745             * Removes the shopping item where companyId = &#63; and sku = &#63; from the database.
1746             *
1747             * @param companyId the company id to search with
1748             * @param sku the sku to search with
1749             * @throws SystemException if a system exception occurred
1750             */
1751            public void removeByC_S(long companyId, String sku)
1752                    throws NoSuchItemException, SystemException {
1753                    ShoppingItem shoppingItem = findByC_S(companyId, sku);
1754    
1755                    remove(shoppingItem);
1756            }
1757    
1758            /**
1759             * Removes all the shopping items from the database.
1760             *
1761             * @throws SystemException if a system exception occurred
1762             */
1763            public void removeAll() throws SystemException {
1764                    for (ShoppingItem shoppingItem : findAll()) {
1765                            remove(shoppingItem);
1766                    }
1767            }
1768    
1769            /**
1770             * Counts all the shopping items where smallImageId = &#63;.
1771             *
1772             * @param smallImageId the small image id to search with
1773             * @return the number of matching shopping items
1774             * @throws SystemException if a system exception occurred
1775             */
1776            public int countBySmallImageId(long smallImageId) throws SystemException {
1777                    Object[] finderArgs = new Object[] { smallImageId };
1778    
1779                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1780                                    finderArgs, this);
1781    
1782                    if (count == null) {
1783                            Session session = null;
1784    
1785                            try {
1786                                    session = openSession();
1787    
1788                                    StringBundler query = new StringBundler(2);
1789    
1790                                    query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
1791    
1792                                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
1793    
1794                                    String sql = query.toString();
1795    
1796                                    Query q = session.createQuery(sql);
1797    
1798                                    QueryPos qPos = QueryPos.getInstance(q);
1799    
1800                                    qPos.add(smallImageId);
1801    
1802                                    count = (Long)q.uniqueResult();
1803                            }
1804                            catch (Exception e) {
1805                                    throw processException(e);
1806                            }
1807                            finally {
1808                                    if (count == null) {
1809                                            count = Long.valueOf(0);
1810                                    }
1811    
1812                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1813                                            finderArgs, count);
1814    
1815                                    closeSession(session);
1816                            }
1817                    }
1818    
1819                    return count.intValue();
1820            }
1821    
1822            /**
1823             * Counts all the shopping items where mediumImageId = &#63;.
1824             *
1825             * @param mediumImageId the medium image id to search with
1826             * @return the number of matching shopping items
1827             * @throws SystemException if a system exception occurred
1828             */
1829            public int countByMediumImageId(long mediumImageId)
1830                    throws SystemException {
1831                    Object[] finderArgs = new Object[] { mediumImageId };
1832    
1833                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MEDIUMIMAGEID,
1834                                    finderArgs, this);
1835    
1836                    if (count == null) {
1837                            Session session = null;
1838    
1839                            try {
1840                                    session = openSession();
1841    
1842                                    StringBundler query = new StringBundler(2);
1843    
1844                                    query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
1845    
1846                                    query.append(_FINDER_COLUMN_MEDIUMIMAGEID_MEDIUMIMAGEID_2);
1847    
1848                                    String sql = query.toString();
1849    
1850                                    Query q = session.createQuery(sql);
1851    
1852                                    QueryPos qPos = QueryPos.getInstance(q);
1853    
1854                                    qPos.add(mediumImageId);
1855    
1856                                    count = (Long)q.uniqueResult();
1857                            }
1858                            catch (Exception e) {
1859                                    throw processException(e);
1860                            }
1861                            finally {
1862                                    if (count == null) {
1863                                            count = Long.valueOf(0);
1864                                    }
1865    
1866                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MEDIUMIMAGEID,
1867                                            finderArgs, count);
1868    
1869                                    closeSession(session);
1870                            }
1871                    }
1872    
1873                    return count.intValue();
1874            }
1875    
1876            /**
1877             * Counts all the shopping items where largeImageId = &#63;.
1878             *
1879             * @param largeImageId the large image id to search with
1880             * @return the number of matching shopping items
1881             * @throws SystemException if a system exception occurred
1882             */
1883            public int countByLargeImageId(long largeImageId) throws SystemException {
1884                    Object[] finderArgs = new Object[] { largeImageId };
1885    
1886                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LARGEIMAGEID,
1887                                    finderArgs, this);
1888    
1889                    if (count == null) {
1890                            Session session = null;
1891    
1892                            try {
1893                                    session = openSession();
1894    
1895                                    StringBundler query = new StringBundler(2);
1896    
1897                                    query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
1898    
1899                                    query.append(_FINDER_COLUMN_LARGEIMAGEID_LARGEIMAGEID_2);
1900    
1901                                    String sql = query.toString();
1902    
1903                                    Query q = session.createQuery(sql);
1904    
1905                                    QueryPos qPos = QueryPos.getInstance(q);
1906    
1907                                    qPos.add(largeImageId);
1908    
1909                                    count = (Long)q.uniqueResult();
1910                            }
1911                            catch (Exception e) {
1912                                    throw processException(e);
1913                            }
1914                            finally {
1915                                    if (count == null) {
1916                                            count = Long.valueOf(0);
1917                                    }
1918    
1919                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LARGEIMAGEID,
1920                                            finderArgs, count);
1921    
1922                                    closeSession(session);
1923                            }
1924                    }
1925    
1926                    return count.intValue();
1927            }
1928    
1929            /**
1930             * Counts all the shopping items where groupId = &#63; and categoryId = &#63;.
1931             *
1932             * @param groupId the group id to search with
1933             * @param categoryId the category id to search with
1934             * @return the number of matching shopping items
1935             * @throws SystemException if a system exception occurred
1936             */
1937            public int countByG_C(long groupId, long categoryId)
1938                    throws SystemException {
1939                    Object[] finderArgs = new Object[] { groupId, categoryId };
1940    
1941                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
1942                                    finderArgs, this);
1943    
1944                    if (count == null) {
1945                            Session session = null;
1946    
1947                            try {
1948                                    session = openSession();
1949    
1950                                    StringBundler query = new StringBundler(3);
1951    
1952                                    query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
1953    
1954                                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1955    
1956                                    query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1957    
1958                                    String sql = query.toString();
1959    
1960                                    Query q = session.createQuery(sql);
1961    
1962                                    QueryPos qPos = QueryPos.getInstance(q);
1963    
1964                                    qPos.add(groupId);
1965    
1966                                    qPos.add(categoryId);
1967    
1968                                    count = (Long)q.uniqueResult();
1969                            }
1970                            catch (Exception e) {
1971                                    throw processException(e);
1972                            }
1973                            finally {
1974                                    if (count == null) {
1975                                            count = Long.valueOf(0);
1976                                    }
1977    
1978                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
1979                                            count);
1980    
1981                                    closeSession(session);
1982                            }
1983                    }
1984    
1985                    return count.intValue();
1986            }
1987    
1988            /**
1989             * Filters by the user's permissions and counts all the shopping items where groupId = &#63; and categoryId = &#63;.
1990             *
1991             * @param groupId the group id to search with
1992             * @param categoryId the category id to search with
1993             * @return the number of matching shopping items that the user has permission to view
1994             * @throws SystemException if a system exception occurred
1995             */
1996            public int filterCountByG_C(long groupId, long categoryId)
1997                    throws SystemException {
1998                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1999                            return countByG_C(groupId, categoryId);
2000                    }
2001    
2002                    Session session = null;
2003    
2004                    try {
2005                            session = openSession();
2006    
2007                            StringBundler query = new StringBundler(3);
2008    
2009                            query.append(_FILTER_SQL_COUNT_SHOPPINGITEM_WHERE);
2010    
2011                            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2012    
2013                            query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2014    
2015                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2016                                            ShoppingItem.class.getName(), _FILTER_COLUMN_PK,
2017                                            _FILTER_COLUMN_USERID, groupId);
2018    
2019                            SQLQuery q = session.createSQLQuery(sql);
2020    
2021                            q.addScalar(COUNT_COLUMN_NAME,
2022                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2023    
2024                            QueryPos qPos = QueryPos.getInstance(q);
2025    
2026                            qPos.add(groupId);
2027    
2028                            qPos.add(categoryId);
2029    
2030                            Long count = (Long)q.uniqueResult();
2031    
2032                            return count.intValue();
2033                    }
2034                    catch (Exception e) {
2035                            throw processException(e);
2036                    }
2037                    finally {
2038                            closeSession(session);
2039                    }
2040            }
2041    
2042            /**
2043             * Counts all the shopping items where companyId = &#63; and sku = &#63;.
2044             *
2045             * @param companyId the company id to search with
2046             * @param sku the sku to search with
2047             * @return the number of matching shopping items
2048             * @throws SystemException if a system exception occurred
2049             */
2050            public int countByC_S(long companyId, String sku) throws SystemException {
2051                    Object[] finderArgs = new Object[] { companyId, sku };
2052    
2053                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_S,
2054                                    finderArgs, this);
2055    
2056                    if (count == null) {
2057                            Session session = null;
2058    
2059                            try {
2060                                    session = openSession();
2061    
2062                                    StringBundler query = new StringBundler(3);
2063    
2064                                    query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
2065    
2066                                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
2067    
2068                                    if (sku == null) {
2069                                            query.append(_FINDER_COLUMN_C_S_SKU_1);
2070                                    }
2071                                    else {
2072                                            if (sku.equals(StringPool.BLANK)) {
2073                                                    query.append(_FINDER_COLUMN_C_S_SKU_3);
2074                                            }
2075                                            else {
2076                                                    query.append(_FINDER_COLUMN_C_S_SKU_2);
2077                                            }
2078                                    }
2079    
2080                                    String sql = query.toString();
2081    
2082                                    Query q = session.createQuery(sql);
2083    
2084                                    QueryPos qPos = QueryPos.getInstance(q);
2085    
2086                                    qPos.add(companyId);
2087    
2088                                    if (sku != null) {
2089                                            qPos.add(sku);
2090                                    }
2091    
2092                                    count = (Long)q.uniqueResult();
2093                            }
2094                            catch (Exception e) {
2095                                    throw processException(e);
2096                            }
2097                            finally {
2098                                    if (count == null) {
2099                                            count = Long.valueOf(0);
2100                                    }
2101    
2102                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_S, finderArgs,
2103                                            count);
2104    
2105                                    closeSession(session);
2106                            }
2107                    }
2108    
2109                    return count.intValue();
2110            }
2111    
2112            /**
2113             * Counts all the shopping items.
2114             *
2115             * @return the number of shopping items
2116             * @throws SystemException if a system exception occurred
2117             */
2118            public int countAll() throws SystemException {
2119                    Object[] finderArgs = new Object[0];
2120    
2121                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2122                                    finderArgs, this);
2123    
2124                    if (count == null) {
2125                            Session session = null;
2126    
2127                            try {
2128                                    session = openSession();
2129    
2130                                    Query q = session.createQuery(_SQL_COUNT_SHOPPINGITEM);
2131    
2132                                    count = (Long)q.uniqueResult();
2133                            }
2134                            catch (Exception e) {
2135                                    throw processException(e);
2136                            }
2137                            finally {
2138                                    if (count == null) {
2139                                            count = Long.valueOf(0);
2140                                    }
2141    
2142                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2143                                            count);
2144    
2145                                    closeSession(session);
2146                            }
2147                    }
2148    
2149                    return count.intValue();
2150            }
2151    
2152            /**
2153             * Gets all the shopping item prices associated with the shopping item.
2154             *
2155             * @param pk the primary key of the shopping item to get the associated shopping item prices for
2156             * @return the shopping item prices associated with the shopping item
2157             * @throws SystemException if a system exception occurred
2158             */
2159            public List<com.liferay.portlet.shopping.model.ShoppingItemPrice> getShoppingItemPrices(
2160                    long pk) throws SystemException {
2161                    return getShoppingItemPrices(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2162            }
2163    
2164            /**
2165             * Gets a range of all the shopping item prices associated with the shopping item.
2166             *
2167             * <p>
2168             * 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.
2169             * </p>
2170             *
2171             * @param pk the primary key of the shopping item to get the associated shopping item prices for
2172             * @param start the lower bound of the range of shopping items to return
2173             * @param end the upper bound of the range of shopping items to return (not inclusive)
2174             * @return the range of shopping item prices associated with the shopping item
2175             * @throws SystemException if a system exception occurred
2176             */
2177            public List<com.liferay.portlet.shopping.model.ShoppingItemPrice> getShoppingItemPrices(
2178                    long pk, int start, int end) throws SystemException {
2179                    return getShoppingItemPrices(pk, start, end, null);
2180            }
2181    
2182            public static final FinderPath FINDER_PATH_GET_SHOPPINGITEMPRICES = new FinderPath(com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
2183                            com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
2184                            com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistenceImpl.FINDER_CLASS_NAME_LIST,
2185                            "getShoppingItemPrices",
2186                            new String[] {
2187                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2188                                    "com.liferay.portal.kernel.util.OrderByComparator"
2189                            });
2190    
2191            /**
2192             * Gets an ordered range of all the shopping item prices associated with the shopping item.
2193             *
2194             * <p>
2195             * 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.
2196             * </p>
2197             *
2198             * @param pk the primary key of the shopping item to get the associated shopping item prices for
2199             * @param start the lower bound of the range of shopping items to return
2200             * @param end the upper bound of the range of shopping items to return (not inclusive)
2201             * @param orderByComparator the comparator to order the results by
2202             * @return the ordered range of shopping item prices associated with the shopping item
2203             * @throws SystemException if a system exception occurred
2204             */
2205            public List<com.liferay.portlet.shopping.model.ShoppingItemPrice> getShoppingItemPrices(
2206                    long pk, int start, int end, OrderByComparator orderByComparator)
2207                    throws SystemException {
2208                    Object[] finderArgs = new Object[] {
2209                                    pk, String.valueOf(start), String.valueOf(end),
2210                                    String.valueOf(orderByComparator)
2211                            };
2212    
2213                    List<com.liferay.portlet.shopping.model.ShoppingItemPrice> list = (List<com.liferay.portlet.shopping.model.ShoppingItemPrice>)FinderCacheUtil.getResult(FINDER_PATH_GET_SHOPPINGITEMPRICES,
2214                                    finderArgs, this);
2215    
2216                    if (list == null) {
2217                            Session session = null;
2218    
2219                            try {
2220                                    session = openSession();
2221    
2222                                    String sql = null;
2223    
2224                                    if (orderByComparator != null) {
2225                                            sql = _SQL_GETSHOPPINGITEMPRICES.concat(ORDER_BY_CLAUSE)
2226                                                                                                            .concat(orderByComparator.getOrderBy());
2227                                    }
2228                                    else {
2229                                            sql = _SQL_GETSHOPPINGITEMPRICES.concat(com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.ORDER_BY_SQL);
2230                                    }
2231    
2232                                    SQLQuery q = session.createSQLQuery(sql);
2233    
2234                                    q.addEntity("ShoppingItemPrice",
2235                                            com.liferay.portlet.shopping.model.impl.ShoppingItemPriceImpl.class);
2236    
2237                                    QueryPos qPos = QueryPos.getInstance(q);
2238    
2239                                    qPos.add(pk);
2240    
2241                                    list = (List<com.liferay.portlet.shopping.model.ShoppingItemPrice>)QueryUtil.list(q,
2242                                                    getDialect(), start, end);
2243                            }
2244                            catch (Exception e) {
2245                                    throw processException(e);
2246                            }
2247                            finally {
2248                                    if (list == null) {
2249                                            list = new ArrayList<com.liferay.portlet.shopping.model.ShoppingItemPrice>();
2250                                    }
2251    
2252                                    shoppingItemPricePersistence.cacheResult(list);
2253    
2254                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SHOPPINGITEMPRICES,
2255                                            finderArgs, list);
2256    
2257                                    closeSession(session);
2258                            }
2259                    }
2260    
2261                    return list;
2262            }
2263    
2264            public static final FinderPath FINDER_PATH_GET_SHOPPINGITEMPRICES_SIZE = new FinderPath(com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
2265                            com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
2266                            com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistenceImpl.FINDER_CLASS_NAME_LIST,
2267                            "getShoppingItemPricesSize", new String[] { Long.class.getName() });
2268    
2269            /**
2270             * Gets the number of shopping item prices associated with the shopping item.
2271             *
2272             * @param pk the primary key of the shopping item to get the number of associated shopping item prices for
2273             * @return the number of shopping item prices associated with the shopping item
2274             * @throws SystemException if a system exception occurred
2275             */
2276            public int getShoppingItemPricesSize(long pk) throws SystemException {
2277                    Object[] finderArgs = new Object[] { pk };
2278    
2279                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SHOPPINGITEMPRICES_SIZE,
2280                                    finderArgs, this);
2281    
2282                    if (count == null) {
2283                            Session session = null;
2284    
2285                            try {
2286                                    session = openSession();
2287    
2288                                    SQLQuery q = session.createSQLQuery(_SQL_GETSHOPPINGITEMPRICESSIZE);
2289    
2290                                    q.addScalar(COUNT_COLUMN_NAME,
2291                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
2292    
2293                                    QueryPos qPos = QueryPos.getInstance(q);
2294    
2295                                    qPos.add(pk);
2296    
2297                                    count = (Long)q.uniqueResult();
2298                            }
2299                            catch (Exception e) {
2300                                    throw processException(e);
2301                            }
2302                            finally {
2303                                    if (count == null) {
2304                                            count = Long.valueOf(0);
2305                                    }
2306    
2307                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SHOPPINGITEMPRICES_SIZE,
2308                                            finderArgs, count);
2309    
2310                                    closeSession(session);
2311                            }
2312                    }
2313    
2314                    return count.intValue();
2315            }
2316    
2317            public static final FinderPath FINDER_PATH_CONTAINS_SHOPPINGITEMPRICE = new FinderPath(com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
2318                            com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
2319                            com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistenceImpl.FINDER_CLASS_NAME_LIST,
2320                            "containsShoppingItemPrice",
2321                            new String[] { Long.class.getName(), Long.class.getName() });
2322    
2323            /**
2324             * Determines whether the shopping item price is associated with the shopping item.
2325             *
2326             * @param pk the primary key of the shopping item
2327             * @param shoppingItemPricePK the primary key of the shopping item price
2328             * @return whether the shopping item price is associated with the shopping item
2329             * @throws SystemException if a system exception occurred
2330             */
2331            public boolean containsShoppingItemPrice(long pk, long shoppingItemPricePK)
2332                    throws SystemException {
2333                    Object[] finderArgs = new Object[] { pk, shoppingItemPricePK };
2334    
2335                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SHOPPINGITEMPRICE,
2336                                    finderArgs, this);
2337    
2338                    if (value == null) {
2339                            try {
2340                                    value = Boolean.valueOf(containsShoppingItemPrice.contains(pk,
2341                                                            shoppingItemPricePK));
2342                            }
2343                            catch (Exception e) {
2344                                    throw processException(e);
2345                            }
2346                            finally {
2347                                    if (value == null) {
2348                                            value = Boolean.FALSE;
2349                                    }
2350    
2351                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SHOPPINGITEMPRICE,
2352                                            finderArgs, value);
2353                            }
2354                    }
2355    
2356                    return value.booleanValue();
2357            }
2358    
2359            /**
2360             * Determines whether the shopping item has any shopping item prices associated with it.
2361             *
2362             * @param pk the primary key of the shopping item to check for associations with shopping item prices
2363             * @return whether the shopping item has any shopping item prices associated with it
2364             * @throws SystemException if a system exception occurred
2365             */
2366            public boolean containsShoppingItemPrices(long pk)
2367                    throws SystemException {
2368                    if (getShoppingItemPricesSize(pk) > 0) {
2369                            return true;
2370                    }
2371                    else {
2372                            return false;
2373                    }
2374            }
2375    
2376            /**
2377             * Initializes the shopping item persistence.
2378             */
2379            public void afterPropertiesSet() {
2380                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2381                                            com.liferay.portal.util.PropsUtil.get(
2382                                                    "value.object.listener.com.liferay.portlet.shopping.model.ShoppingItem")));
2383    
2384                    if (listenerClassNames.length > 0) {
2385                            try {
2386                                    List<ModelListener<ShoppingItem>> listenersList = new ArrayList<ModelListener<ShoppingItem>>();
2387    
2388                                    for (String listenerClassName : listenerClassNames) {
2389                                            listenersList.add((ModelListener<ShoppingItem>)InstanceFactory.newInstance(
2390                                                            listenerClassName));
2391                                    }
2392    
2393                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2394                            }
2395                            catch (Exception e) {
2396                                    _log.error(e);
2397                            }
2398                    }
2399    
2400                    containsShoppingItemPrice = new ContainsShoppingItemPrice(this);
2401            }
2402    
2403            public void destroy() {
2404                    EntityCacheUtil.removeCache(ShoppingItemImpl.class.getName());
2405                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2406                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
2407            }
2408    
2409            @BeanReference(type = ShoppingCartPersistence.class)
2410            protected ShoppingCartPersistence shoppingCartPersistence;
2411            @BeanReference(type = ShoppingCategoryPersistence.class)
2412            protected ShoppingCategoryPersistence shoppingCategoryPersistence;
2413            @BeanReference(type = ShoppingCouponPersistence.class)
2414            protected ShoppingCouponPersistence shoppingCouponPersistence;
2415            @BeanReference(type = ShoppingItemPersistence.class)
2416            protected ShoppingItemPersistence shoppingItemPersistence;
2417            @BeanReference(type = ShoppingItemFieldPersistence.class)
2418            protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
2419            @BeanReference(type = ShoppingItemPricePersistence.class)
2420            protected ShoppingItemPricePersistence shoppingItemPricePersistence;
2421            @BeanReference(type = ShoppingOrderPersistence.class)
2422            protected ShoppingOrderPersistence shoppingOrderPersistence;
2423            @BeanReference(type = ShoppingOrderItemPersistence.class)
2424            protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
2425            @BeanReference(type = ImagePersistence.class)
2426            protected ImagePersistence imagePersistence;
2427            @BeanReference(type = ResourcePersistence.class)
2428            protected ResourcePersistence resourcePersistence;
2429            @BeanReference(type = UserPersistence.class)
2430            protected UserPersistence userPersistence;
2431            protected ContainsShoppingItemPrice containsShoppingItemPrice;
2432    
2433            protected class ContainsShoppingItemPrice {
2434                    protected ContainsShoppingItemPrice(
2435                            ShoppingItemPersistenceImpl persistenceImpl) {
2436                            super();
2437    
2438                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2439                                            _SQL_CONTAINSSHOPPINGITEMPRICE,
2440                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2441                                            RowMapper.COUNT);
2442                    }
2443    
2444                    protected boolean contains(long itemId, long itemPriceId) {
2445                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2446                                                    new Long(itemId), new Long(itemPriceId)
2447                                            });
2448    
2449                            if (results.size() > 0) {
2450                                    Integer count = results.get(0);
2451    
2452                                    if (count.intValue() > 0) {
2453                                            return true;
2454                                    }
2455                            }
2456    
2457                            return false;
2458                    }
2459    
2460                    private MappingSqlQuery<Integer> _mappingSqlQuery;
2461            }
2462    
2463            private static final String _SQL_SELECT_SHOPPINGITEM = "SELECT shoppingItem FROM ShoppingItem shoppingItem";
2464            private static final String _SQL_SELECT_SHOPPINGITEM_WHERE = "SELECT shoppingItem FROM ShoppingItem shoppingItem WHERE ";
2465            private static final String _SQL_COUNT_SHOPPINGITEM = "SELECT COUNT(shoppingItem) FROM ShoppingItem shoppingItem";
2466            private static final String _SQL_COUNT_SHOPPINGITEM_WHERE = "SELECT COUNT(shoppingItem) FROM ShoppingItem shoppingItem WHERE ";
2467            private static final String _SQL_GETSHOPPINGITEMPRICES = "SELECT {ShoppingItemPrice.*} FROM ShoppingItemPrice INNER JOIN ShoppingItem ON (ShoppingItem.itemId = ShoppingItemPrice.itemId) WHERE (ShoppingItem.itemId = ?)";
2468            private static final String _SQL_GETSHOPPINGITEMPRICESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM ShoppingItemPrice WHERE itemId = ?";
2469            private static final String _SQL_CONTAINSSHOPPINGITEMPRICE = "SELECT COUNT(*) AS COUNT_VALUE FROM ShoppingItemPrice WHERE itemId = ? AND itemPriceId = ?";
2470            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "shoppingItem.smallImageId = ?";
2471            private static final String _FINDER_COLUMN_MEDIUMIMAGEID_MEDIUMIMAGEID_2 = "shoppingItem.mediumImageId = ?";
2472            private static final String _FINDER_COLUMN_LARGEIMAGEID_LARGEIMAGEID_2 = "shoppingItem.largeImageId = ?";
2473            private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "shoppingItem.groupId = ? AND ";
2474            private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "shoppingItem.categoryId = ?";
2475            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "shoppingItem.companyId = ? AND ";
2476            private static final String _FINDER_COLUMN_C_S_SKU_1 = "shoppingItem.sku IS NULL";
2477            private static final String _FINDER_COLUMN_C_S_SKU_2 = "shoppingItem.sku = ?";
2478            private static final String _FINDER_COLUMN_C_S_SKU_3 = "(shoppingItem.sku IS NULL OR shoppingItem.sku = ?)";
2479            private static final String _FILTER_SQL_SELECT_SHOPPINGITEM_WHERE = "SELECT DISTINCT {shoppingItem.*} FROM ShoppingItem shoppingItem WHERE ";
2480            private static final String _FILTER_SQL_SELECT_SHOPPINGITEM_NO_INLINE_DISTINCT_WHERE =
2481                    "SELECT {shoppingItem.*} FROM (SELECT DISTINCT itemId FROM ShoppingItem) shoppingItem2 INNER JOIN ShoppingItem shoppingItem ON (shoppingItem2.itemId = shoppingItem.itemId) WHERE ";
2482            private static final String _FILTER_SQL_COUNT_SHOPPINGITEM_WHERE = "SELECT COUNT(DISTINCT shoppingItem.itemId) AS COUNT_VALUE FROM ShoppingItem shoppingItem WHERE ";
2483            private static final String _FILTER_COLUMN_PK = "shoppingItem.itemId";
2484            private static final String _FILTER_COLUMN_USERID = "shoppingItem.userId";
2485            private static final String _FILTER_ENTITY_ALIAS = "shoppingItem";
2486            private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingItem.";
2487            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingItem exists with the primary key ";
2488            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingItem exists with the key {";
2489            private static Log _log = LogFactoryUtil.getLog(ShoppingItemPersistenceImpl.class);
2490    }