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