1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.shopping.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.kernel.annotation.BeanReference;
19  import com.liferay.portal.kernel.cache.CacheRegistry;
20  import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
21  import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
22  import com.liferay.portal.kernel.dao.jdbc.RowMapper;
23  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
25  import com.liferay.portal.kernel.dao.orm.FinderPath;
26  import com.liferay.portal.kernel.dao.orm.Query;
27  import com.liferay.portal.kernel.dao.orm.QueryPos;
28  import com.liferay.portal.kernel.dao.orm.QueryUtil;
29  import com.liferay.portal.kernel.dao.orm.SQLQuery;
30  import com.liferay.portal.kernel.dao.orm.Session;
31  import com.liferay.portal.kernel.dao.orm.Type;
32  import com.liferay.portal.kernel.exception.SystemException;
33  import com.liferay.portal.kernel.log.Log;
34  import com.liferay.portal.kernel.log.LogFactoryUtil;
35  import com.liferay.portal.kernel.util.GetterUtil;
36  import com.liferay.portal.kernel.util.InstanceFactory;
37  import com.liferay.portal.kernel.util.OrderByComparator;
38  import com.liferay.portal.kernel.util.StringBundler;
39  import com.liferay.portal.kernel.util.StringPool;
40  import com.liferay.portal.kernel.util.StringUtil;
41  import com.liferay.portal.kernel.util.Validator;
42  import com.liferay.portal.model.ModelListener;
43  import com.liferay.portal.security.permission.InlineSQLHelperUtil;
44  import com.liferay.portal.service.persistence.BatchSessionUtil;
45  import com.liferay.portal.service.persistence.ImagePersistence;
46  import com.liferay.portal.service.persistence.ResourcePersistence;
47  import com.liferay.portal.service.persistence.UserPersistence;
48  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
49  
50  import com.liferay.portlet.shopping.NoSuchItemException;
51  import com.liferay.portlet.shopping.model.ShoppingItem;
52  import com.liferay.portlet.shopping.model.impl.ShoppingItemImpl;
53  import com.liferay.portlet.shopping.model.impl.ShoppingItemModelImpl;
54  
55  import java.io.Serializable;
56  
57  import java.sql.Types;
58  
59  import java.util.ArrayList;
60  import java.util.Collections;
61  import java.util.List;
62  
63  /**
64   * <a href="ShoppingItemPersistenceImpl.java.html"><b><i>View Source</i></b></a>
65   *
66   * <p>
67   * ServiceBuilder generated this class. Modifications in this class will be
68   * overwritten the next time is generated.
69   * </p>
70   *
71   * @author    Brian Wing Shun Chan
72   * @see       ShoppingItemPersistence
73   * @see       ShoppingItemUtil
74   * @generated
75   */
76  public class ShoppingItemPersistenceImpl extends BasePersistenceImpl<ShoppingItem>
77      implements ShoppingItemPersistence {
78      public static final String FINDER_CLASS_NAME_ENTITY = ShoppingItemImpl.class.getName();
79      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
80          ".List";
81      public static final FinderPath FINDER_PATH_FETCH_BY_SMALLIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
82              ShoppingItemModelImpl.FINDER_CACHE_ENABLED,
83              FINDER_CLASS_NAME_ENTITY, "fetchBySmallImageId",
84              new String[] { Long.class.getName() });
85      public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
86              ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
87              "countBySmallImageId", new String[] { Long.class.getName() });
88      public static final FinderPath FINDER_PATH_FETCH_BY_MEDIUMIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
89              ShoppingItemModelImpl.FINDER_CACHE_ENABLED,
90              FINDER_CLASS_NAME_ENTITY, "fetchByMediumImageId",
91              new String[] { Long.class.getName() });
92      public static final FinderPath FINDER_PATH_COUNT_BY_MEDIUMIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
93              ShoppingItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
94              "countByMediumImageId", new String[] { Long.class.getName() });
95      public static final FinderPath FINDER_PATH_FETCH_BY_LARGEIMAGEID = new FinderPath(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
96              ShoppingItemModelImpl.FINDER_CACHE_ENABLED,
97              FINDER_CLASS_NAME_ENTITY, "fetchByLargeImageId",
98              new String[] { Long.class.getName() });
99      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     public void cacheResult(ShoppingItem shoppingItem) {
131         EntityCacheUtil.putResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
132             ShoppingItemImpl.class, shoppingItem.getPrimaryKey(), shoppingItem);
133 
134         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
135             new Object[] { new Long(shoppingItem.getSmallImageId()) },
136             shoppingItem);
137 
138         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
139             new Object[] { new Long(shoppingItem.getMediumImageId()) },
140             shoppingItem);
141 
142         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
143             new Object[] { new Long(shoppingItem.getLargeImageId()) },
144             shoppingItem);
145 
146         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
147             new Object[] {
148                 new Long(shoppingItem.getCompanyId()),
149                 
150             shoppingItem.getSku()
151             }, shoppingItem);
152     }
153 
154     public void cacheResult(List<ShoppingItem> shoppingItems) {
155         for (ShoppingItem shoppingItem : shoppingItems) {
156             if (EntityCacheUtil.getResult(
157                         ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
158                         ShoppingItemImpl.class, shoppingItem.getPrimaryKey(),
159                         this) == null) {
160                 cacheResult(shoppingItem);
161             }
162         }
163     }
164 
165     public void clearCache() {
166         CacheRegistry.clear(ShoppingItemImpl.class.getName());
167         EntityCacheUtil.clearCache(ShoppingItemImpl.class.getName());
168         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
169         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
170     }
171 
172     public void clearCache(ShoppingItem shoppingItem) {
173         EntityCacheUtil.removeResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
174             ShoppingItemImpl.class, shoppingItem.getPrimaryKey());
175 
176         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
177             new Object[] { new Long(shoppingItem.getSmallImageId()) });
178 
179         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
180             new Object[] { new Long(shoppingItem.getMediumImageId()) });
181 
182         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
183             new Object[] { new Long(shoppingItem.getLargeImageId()) });
184 
185         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_S,
186             new Object[] {
187                 new Long(shoppingItem.getCompanyId()),
188                 
189             shoppingItem.getSku()
190             });
191     }
192 
193     public ShoppingItem create(long itemId) {
194         ShoppingItem shoppingItem = new ShoppingItemImpl();
195 
196         shoppingItem.setNew(true);
197         shoppingItem.setPrimaryKey(itemId);
198 
199         return shoppingItem;
200     }
201 
202     public ShoppingItem remove(Serializable primaryKey)
203         throws NoSuchModelException, SystemException {
204         return remove(((Long)primaryKey).longValue());
205     }
206 
207     public ShoppingItem remove(long itemId)
208         throws NoSuchItemException, SystemException {
209         Session session = null;
210 
211         try {
212             session = openSession();
213 
214             ShoppingItem shoppingItem = (ShoppingItem)session.get(ShoppingItemImpl.class,
215                     new Long(itemId));
216 
217             if (shoppingItem == null) {
218                 if (_log.isWarnEnabled()) {
219                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + itemId);
220                 }
221 
222                 throw new NoSuchItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
223                     itemId);
224             }
225 
226             return remove(shoppingItem);
227         }
228         catch (NoSuchItemException nsee) {
229             throw nsee;
230         }
231         catch (Exception e) {
232             throw processException(e);
233         }
234         finally {
235             closeSession(session);
236         }
237     }
238 
239     public ShoppingItem remove(ShoppingItem shoppingItem)
240         throws SystemException {
241         for (ModelListener<ShoppingItem> listener : listeners) {
242             listener.onBeforeRemove(shoppingItem);
243         }
244 
245         shoppingItem = removeImpl(shoppingItem);
246 
247         for (ModelListener<ShoppingItem> listener : listeners) {
248             listener.onAfterRemove(shoppingItem);
249         }
250 
251         return shoppingItem;
252     }
253 
254     protected ShoppingItem removeImpl(ShoppingItem shoppingItem)
255         throws SystemException {
256         shoppingItem = toUnwrappedModel(shoppingItem);
257 
258         Session session = null;
259 
260         try {
261             session = openSession();
262 
263             if (shoppingItem.isCachedModel() || BatchSessionUtil.isEnabled()) {
264                 Object staleObject = session.get(ShoppingItemImpl.class,
265                         shoppingItem.getPrimaryKeyObj());
266 
267                 if (staleObject != null) {
268                     session.evict(staleObject);
269                 }
270             }
271 
272             session.delete(shoppingItem);
273 
274             session.flush();
275         }
276         catch (Exception e) {
277             throw processException(e);
278         }
279         finally {
280             closeSession(session);
281         }
282 
283         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
284 
285         ShoppingItemModelImpl shoppingItemModelImpl = (ShoppingItemModelImpl)shoppingItem;
286 
287         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
288             new Object[] {
289                 new Long(shoppingItemModelImpl.getOriginalSmallImageId())
290             });
291 
292         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
293             new Object[] {
294                 new Long(shoppingItemModelImpl.getOriginalMediumImageId())
295             });
296 
297         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
298             new Object[] {
299                 new Long(shoppingItemModelImpl.getOriginalLargeImageId())
300             });
301 
302         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_S,
303             new Object[] {
304                 new Long(shoppingItemModelImpl.getOriginalCompanyId()),
305                 
306             shoppingItemModelImpl.getOriginalSku()
307             });
308 
309         EntityCacheUtil.removeResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
310             ShoppingItemImpl.class, shoppingItem.getPrimaryKey());
311 
312         return shoppingItem;
313     }
314 
315     public ShoppingItem updateImpl(
316         com.liferay.portlet.shopping.model.ShoppingItem shoppingItem,
317         boolean merge) throws SystemException {
318         shoppingItem = toUnwrappedModel(shoppingItem);
319 
320         boolean isNew = shoppingItem.isNew();
321 
322         ShoppingItemModelImpl shoppingItemModelImpl = (ShoppingItemModelImpl)shoppingItem;
323 
324         Session session = null;
325 
326         try {
327             session = openSession();
328 
329             BatchSessionUtil.update(session, shoppingItem, merge);
330 
331             shoppingItem.setNew(false);
332         }
333         catch (Exception e) {
334             throw processException(e);
335         }
336         finally {
337             closeSession(session);
338         }
339 
340         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
341 
342         EntityCacheUtil.putResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
343             ShoppingItemImpl.class, shoppingItem.getPrimaryKey(), shoppingItem);
344 
345         if (!isNew &&
346                 (shoppingItem.getSmallImageId() != shoppingItemModelImpl.getOriginalSmallImageId())) {
347             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
348                 new Object[] {
349                     new Long(shoppingItemModelImpl.getOriginalSmallImageId())
350                 });
351         }
352 
353         if (isNew ||
354                 (shoppingItem.getSmallImageId() != shoppingItemModelImpl.getOriginalSmallImageId())) {
355             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
356                 new Object[] { new Long(shoppingItem.getSmallImageId()) },
357                 shoppingItem);
358         }
359 
360         if (!isNew &&
361                 (shoppingItem.getMediumImageId() != shoppingItemModelImpl.getOriginalMediumImageId())) {
362             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
363                 new Object[] {
364                     new Long(shoppingItemModelImpl.getOriginalMediumImageId())
365                 });
366         }
367 
368         if (isNew ||
369                 (shoppingItem.getMediumImageId() != shoppingItemModelImpl.getOriginalMediumImageId())) {
370             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
371                 new Object[] { new Long(shoppingItem.getMediumImageId()) },
372                 shoppingItem);
373         }
374 
375         if (!isNew &&
376                 (shoppingItem.getLargeImageId() != shoppingItemModelImpl.getOriginalLargeImageId())) {
377             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
378                 new Object[] {
379                     new Long(shoppingItemModelImpl.getOriginalLargeImageId())
380                 });
381         }
382 
383         if (isNew ||
384                 (shoppingItem.getLargeImageId() != shoppingItemModelImpl.getOriginalLargeImageId())) {
385             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
386                 new Object[] { new Long(shoppingItem.getLargeImageId()) },
387                 shoppingItem);
388         }
389 
390         if (!isNew &&
391                 ((shoppingItem.getCompanyId() != shoppingItemModelImpl.getOriginalCompanyId()) ||
392                 !Validator.equals(shoppingItem.getSku(),
393                     shoppingItemModelImpl.getOriginalSku()))) {
394             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_S,
395                 new Object[] {
396                     new Long(shoppingItemModelImpl.getOriginalCompanyId()),
397                     
398                 shoppingItemModelImpl.getOriginalSku()
399                 });
400         }
401 
402         if (isNew ||
403                 ((shoppingItem.getCompanyId() != shoppingItemModelImpl.getOriginalCompanyId()) ||
404                 !Validator.equals(shoppingItem.getSku(),
405                     shoppingItemModelImpl.getOriginalSku()))) {
406             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
407                 new Object[] {
408                     new Long(shoppingItem.getCompanyId()),
409                     
410                 shoppingItem.getSku()
411                 }, shoppingItem);
412         }
413 
414         return shoppingItem;
415     }
416 
417     protected ShoppingItem toUnwrappedModel(ShoppingItem shoppingItem) {
418         if (shoppingItem instanceof ShoppingItemImpl) {
419             return shoppingItem;
420         }
421 
422         ShoppingItemImpl shoppingItemImpl = new ShoppingItemImpl();
423 
424         shoppingItemImpl.setNew(shoppingItem.isNew());
425         shoppingItemImpl.setPrimaryKey(shoppingItem.getPrimaryKey());
426 
427         shoppingItemImpl.setItemId(shoppingItem.getItemId());
428         shoppingItemImpl.setGroupId(shoppingItem.getGroupId());
429         shoppingItemImpl.setCompanyId(shoppingItem.getCompanyId());
430         shoppingItemImpl.setUserId(shoppingItem.getUserId());
431         shoppingItemImpl.setUserName(shoppingItem.getUserName());
432         shoppingItemImpl.setCreateDate(shoppingItem.getCreateDate());
433         shoppingItemImpl.setModifiedDate(shoppingItem.getModifiedDate());
434         shoppingItemImpl.setCategoryId(shoppingItem.getCategoryId());
435         shoppingItemImpl.setSku(shoppingItem.getSku());
436         shoppingItemImpl.setName(shoppingItem.getName());
437         shoppingItemImpl.setDescription(shoppingItem.getDescription());
438         shoppingItemImpl.setProperties(shoppingItem.getProperties());
439         shoppingItemImpl.setFields(shoppingItem.isFields());
440         shoppingItemImpl.setFieldsQuantities(shoppingItem.getFieldsQuantities());
441         shoppingItemImpl.setMinQuantity(shoppingItem.getMinQuantity());
442         shoppingItemImpl.setMaxQuantity(shoppingItem.getMaxQuantity());
443         shoppingItemImpl.setPrice(shoppingItem.getPrice());
444         shoppingItemImpl.setDiscount(shoppingItem.getDiscount());
445         shoppingItemImpl.setTaxable(shoppingItem.isTaxable());
446         shoppingItemImpl.setShipping(shoppingItem.getShipping());
447         shoppingItemImpl.setUseShippingFormula(shoppingItem.isUseShippingFormula());
448         shoppingItemImpl.setRequiresShipping(shoppingItem.isRequiresShipping());
449         shoppingItemImpl.setStockQuantity(shoppingItem.getStockQuantity());
450         shoppingItemImpl.setFeatured(shoppingItem.isFeatured());
451         shoppingItemImpl.setSale(shoppingItem.isSale());
452         shoppingItemImpl.setSmallImage(shoppingItem.isSmallImage());
453         shoppingItemImpl.setSmallImageId(shoppingItem.getSmallImageId());
454         shoppingItemImpl.setSmallImageURL(shoppingItem.getSmallImageURL());
455         shoppingItemImpl.setMediumImage(shoppingItem.isMediumImage());
456         shoppingItemImpl.setMediumImageId(shoppingItem.getMediumImageId());
457         shoppingItemImpl.setMediumImageURL(shoppingItem.getMediumImageURL());
458         shoppingItemImpl.setLargeImage(shoppingItem.isLargeImage());
459         shoppingItemImpl.setLargeImageId(shoppingItem.getLargeImageId());
460         shoppingItemImpl.setLargeImageURL(shoppingItem.getLargeImageURL());
461 
462         return shoppingItemImpl;
463     }
464 
465     public ShoppingItem findByPrimaryKey(Serializable primaryKey)
466         throws NoSuchModelException, SystemException {
467         return findByPrimaryKey(((Long)primaryKey).longValue());
468     }
469 
470     public ShoppingItem findByPrimaryKey(long itemId)
471         throws NoSuchItemException, SystemException {
472         ShoppingItem shoppingItem = fetchByPrimaryKey(itemId);
473 
474         if (shoppingItem == null) {
475             if (_log.isWarnEnabled()) {
476                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + itemId);
477             }
478 
479             throw new NoSuchItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
480                 itemId);
481         }
482 
483         return shoppingItem;
484     }
485 
486     public ShoppingItem fetchByPrimaryKey(Serializable primaryKey)
487         throws SystemException {
488         return fetchByPrimaryKey(((Long)primaryKey).longValue());
489     }
490 
491     public ShoppingItem fetchByPrimaryKey(long itemId)
492         throws SystemException {
493         ShoppingItem shoppingItem = (ShoppingItem)EntityCacheUtil.getResult(ShoppingItemModelImpl.ENTITY_CACHE_ENABLED,
494                 ShoppingItemImpl.class, itemId, this);
495 
496         if (shoppingItem == null) {
497             Session session = null;
498 
499             try {
500                 session = openSession();
501 
502                 shoppingItem = (ShoppingItem)session.get(ShoppingItemImpl.class,
503                         new Long(itemId));
504             }
505             catch (Exception e) {
506                 throw processException(e);
507             }
508             finally {
509                 if (shoppingItem != null) {
510                     cacheResult(shoppingItem);
511                 }
512 
513                 closeSession(session);
514             }
515         }
516 
517         return shoppingItem;
518     }
519 
520     public ShoppingItem findBySmallImageId(long smallImageId)
521         throws NoSuchItemException, SystemException {
522         ShoppingItem shoppingItem = fetchBySmallImageId(smallImageId);
523 
524         if (shoppingItem == null) {
525             StringBundler msg = new StringBundler(4);
526 
527             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
528 
529             msg.append("smallImageId=");
530             msg.append(smallImageId);
531 
532             msg.append(StringPool.CLOSE_CURLY_BRACE);
533 
534             if (_log.isWarnEnabled()) {
535                 _log.warn(msg.toString());
536             }
537 
538             throw new NoSuchItemException(msg.toString());
539         }
540 
541         return shoppingItem;
542     }
543 
544     public ShoppingItem fetchBySmallImageId(long smallImageId)
545         throws SystemException {
546         return fetchBySmallImageId(smallImageId, true);
547     }
548 
549     public ShoppingItem fetchBySmallImageId(long smallImageId,
550         boolean retrieveFromCache) throws SystemException {
551         Object[] finderArgs = new Object[] { new Long(smallImageId) };
552 
553         Object result = null;
554 
555         if (retrieveFromCache) {
556             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
557                     finderArgs, this);
558         }
559 
560         if (result == null) {
561             Session session = null;
562 
563             try {
564                 session = openSession();
565 
566                 StringBundler query = new StringBundler(3);
567 
568                 query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
569 
570                 query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
571 
572                 query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
573 
574                 String sql = query.toString();
575 
576                 Query q = session.createQuery(sql);
577 
578                 QueryPos qPos = QueryPos.getInstance(q);
579 
580                 qPos.add(smallImageId);
581 
582                 List<ShoppingItem> list = q.list();
583 
584                 result = list;
585 
586                 ShoppingItem shoppingItem = null;
587 
588                 if (list.isEmpty()) {
589                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
590                         finderArgs, list);
591                 }
592                 else {
593                     shoppingItem = list.get(0);
594 
595                     cacheResult(shoppingItem);
596 
597                     if ((shoppingItem.getSmallImageId() != smallImageId)) {
598                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
599                             finderArgs, shoppingItem);
600                     }
601                 }
602 
603                 return shoppingItem;
604             }
605             catch (Exception e) {
606                 throw processException(e);
607             }
608             finally {
609                 if (result == null) {
610                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
611                         finderArgs, new ArrayList<ShoppingItem>());
612                 }
613 
614                 closeSession(session);
615             }
616         }
617         else {
618             if (result instanceof List<?>) {
619                 return null;
620             }
621             else {
622                 return (ShoppingItem)result;
623             }
624         }
625     }
626 
627     public ShoppingItem findByMediumImageId(long mediumImageId)
628         throws NoSuchItemException, SystemException {
629         ShoppingItem shoppingItem = fetchByMediumImageId(mediumImageId);
630 
631         if (shoppingItem == null) {
632             StringBundler msg = new StringBundler(4);
633 
634             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
635 
636             msg.append("mediumImageId=");
637             msg.append(mediumImageId);
638 
639             msg.append(StringPool.CLOSE_CURLY_BRACE);
640 
641             if (_log.isWarnEnabled()) {
642                 _log.warn(msg.toString());
643             }
644 
645             throw new NoSuchItemException(msg.toString());
646         }
647 
648         return shoppingItem;
649     }
650 
651     public ShoppingItem fetchByMediumImageId(long mediumImageId)
652         throws SystemException {
653         return fetchByMediumImageId(mediumImageId, true);
654     }
655 
656     public ShoppingItem fetchByMediumImageId(long mediumImageId,
657         boolean retrieveFromCache) throws SystemException {
658         Object[] finderArgs = new Object[] { new Long(mediumImageId) };
659 
660         Object result = null;
661 
662         if (retrieveFromCache) {
663             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
664                     finderArgs, this);
665         }
666 
667         if (result == null) {
668             Session session = null;
669 
670             try {
671                 session = openSession();
672 
673                 StringBundler query = new StringBundler(3);
674 
675                 query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
676 
677                 query.append(_FINDER_COLUMN_MEDIUMIMAGEID_MEDIUMIMAGEID_2);
678 
679                 query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
680 
681                 String sql = query.toString();
682 
683                 Query q = session.createQuery(sql);
684 
685                 QueryPos qPos = QueryPos.getInstance(q);
686 
687                 qPos.add(mediumImageId);
688 
689                 List<ShoppingItem> list = q.list();
690 
691                 result = list;
692 
693                 ShoppingItem shoppingItem = null;
694 
695                 if (list.isEmpty()) {
696                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
697                         finderArgs, list);
698                 }
699                 else {
700                     shoppingItem = list.get(0);
701 
702                     cacheResult(shoppingItem);
703 
704                     if ((shoppingItem.getMediumImageId() != mediumImageId)) {
705                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
706                             finderArgs, shoppingItem);
707                     }
708                 }
709 
710                 return shoppingItem;
711             }
712             catch (Exception e) {
713                 throw processException(e);
714             }
715             finally {
716                 if (result == null) {
717                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MEDIUMIMAGEID,
718                         finderArgs, new ArrayList<ShoppingItem>());
719                 }
720 
721                 closeSession(session);
722             }
723         }
724         else {
725             if (result instanceof List<?>) {
726                 return null;
727             }
728             else {
729                 return (ShoppingItem)result;
730             }
731         }
732     }
733 
734     public ShoppingItem findByLargeImageId(long largeImageId)
735         throws NoSuchItemException, SystemException {
736         ShoppingItem shoppingItem = fetchByLargeImageId(largeImageId);
737 
738         if (shoppingItem == null) {
739             StringBundler msg = new StringBundler(4);
740 
741             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
742 
743             msg.append("largeImageId=");
744             msg.append(largeImageId);
745 
746             msg.append(StringPool.CLOSE_CURLY_BRACE);
747 
748             if (_log.isWarnEnabled()) {
749                 _log.warn(msg.toString());
750             }
751 
752             throw new NoSuchItemException(msg.toString());
753         }
754 
755         return shoppingItem;
756     }
757 
758     public ShoppingItem fetchByLargeImageId(long largeImageId)
759         throws SystemException {
760         return fetchByLargeImageId(largeImageId, true);
761     }
762 
763     public ShoppingItem fetchByLargeImageId(long largeImageId,
764         boolean retrieveFromCache) throws SystemException {
765         Object[] finderArgs = new Object[] { new Long(largeImageId) };
766 
767         Object result = null;
768 
769         if (retrieveFromCache) {
770             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
771                     finderArgs, this);
772         }
773 
774         if (result == null) {
775             Session session = null;
776 
777             try {
778                 session = openSession();
779 
780                 StringBundler query = new StringBundler(3);
781 
782                 query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
783 
784                 query.append(_FINDER_COLUMN_LARGEIMAGEID_LARGEIMAGEID_2);
785 
786                 query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
787 
788                 String sql = query.toString();
789 
790                 Query q = session.createQuery(sql);
791 
792                 QueryPos qPos = QueryPos.getInstance(q);
793 
794                 qPos.add(largeImageId);
795 
796                 List<ShoppingItem> list = q.list();
797 
798                 result = list;
799 
800                 ShoppingItem shoppingItem = null;
801 
802                 if (list.isEmpty()) {
803                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
804                         finderArgs, list);
805                 }
806                 else {
807                     shoppingItem = list.get(0);
808 
809                     cacheResult(shoppingItem);
810 
811                     if ((shoppingItem.getLargeImageId() != largeImageId)) {
812                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
813                             finderArgs, shoppingItem);
814                     }
815                 }
816 
817                 return shoppingItem;
818             }
819             catch (Exception e) {
820                 throw processException(e);
821             }
822             finally {
823                 if (result == null) {
824                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
825                         finderArgs, new ArrayList<ShoppingItem>());
826                 }
827 
828                 closeSession(session);
829             }
830         }
831         else {
832             if (result instanceof List<?>) {
833                 return null;
834             }
835             else {
836                 return (ShoppingItem)result;
837             }
838         }
839     }
840 
841     public List<ShoppingItem> findByG_C(long groupId, long categoryId)
842         throws SystemException {
843         return findByG_C(groupId, categoryId, QueryUtil.ALL_POS,
844             QueryUtil.ALL_POS, null);
845     }
846 
847     public List<ShoppingItem> findByG_C(long groupId, long categoryId,
848         int start, int end) throws SystemException {
849         return findByG_C(groupId, categoryId, start, end, null);
850     }
851 
852     public List<ShoppingItem> findByG_C(long groupId, long categoryId,
853         int start, int end, OrderByComparator orderByComparator)
854         throws SystemException {
855         Object[] finderArgs = new Object[] {
856                 new Long(groupId), new Long(categoryId),
857                 
858                 String.valueOf(start), String.valueOf(end),
859                 String.valueOf(orderByComparator)
860             };
861 
862         List<ShoppingItem> list = (List<ShoppingItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C,
863                 finderArgs, this);
864 
865         if (list == null) {
866             Session session = null;
867 
868             try {
869                 session = openSession();
870 
871                 StringBundler query = null;
872 
873                 if (orderByComparator != null) {
874                     query = new StringBundler(4 +
875                             (orderByComparator.getOrderByFields().length * 3));
876                 }
877                 else {
878                     query = new StringBundler(4);
879                 }
880 
881                 query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
882 
883                 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
884 
885                 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
886 
887                 if (orderByComparator != null) {
888                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
889                         orderByComparator);
890                 }
891 
892                 else {
893                     query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
894                 }
895 
896                 String sql = query.toString();
897 
898                 Query q = session.createQuery(sql);
899 
900                 QueryPos qPos = QueryPos.getInstance(q);
901 
902                 qPos.add(groupId);
903 
904                 qPos.add(categoryId);
905 
906                 list = (List<ShoppingItem>)QueryUtil.list(q, getDialect(),
907                         start, end);
908             }
909             catch (Exception e) {
910                 throw processException(e);
911             }
912             finally {
913                 if (list == null) {
914                     list = new ArrayList<ShoppingItem>();
915                 }
916 
917                 cacheResult(list);
918 
919                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C, finderArgs,
920                     list);
921 
922                 closeSession(session);
923             }
924         }
925 
926         return list;
927     }
928 
929     public ShoppingItem findByG_C_First(long groupId, long categoryId,
930         OrderByComparator orderByComparator)
931         throws NoSuchItemException, SystemException {
932         List<ShoppingItem> list = findByG_C(groupId, categoryId, 0, 1,
933                 orderByComparator);
934 
935         if (list.isEmpty()) {
936             StringBundler msg = new StringBundler(6);
937 
938             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
939 
940             msg.append("groupId=");
941             msg.append(groupId);
942 
943             msg.append(", categoryId=");
944             msg.append(categoryId);
945 
946             msg.append(StringPool.CLOSE_CURLY_BRACE);
947 
948             throw new NoSuchItemException(msg.toString());
949         }
950         else {
951             return list.get(0);
952         }
953     }
954 
955     public ShoppingItem findByG_C_Last(long groupId, long categoryId,
956         OrderByComparator orderByComparator)
957         throws NoSuchItemException, SystemException {
958         int count = countByG_C(groupId, categoryId);
959 
960         List<ShoppingItem> list = findByG_C(groupId, categoryId, count - 1,
961                 count, orderByComparator);
962 
963         if (list.isEmpty()) {
964             StringBundler msg = new StringBundler(6);
965 
966             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
967 
968             msg.append("groupId=");
969             msg.append(groupId);
970 
971             msg.append(", categoryId=");
972             msg.append(categoryId);
973 
974             msg.append(StringPool.CLOSE_CURLY_BRACE);
975 
976             throw new NoSuchItemException(msg.toString());
977         }
978         else {
979             return list.get(0);
980         }
981     }
982 
983     public ShoppingItem[] findByG_C_PrevAndNext(long itemId, long groupId,
984         long categoryId, OrderByComparator orderByComparator)
985         throws NoSuchItemException, SystemException {
986         ShoppingItem shoppingItem = findByPrimaryKey(itemId);
987 
988         Session session = null;
989 
990         try {
991             session = openSession();
992 
993             ShoppingItem[] array = new ShoppingItemImpl[3];
994 
995             array[0] = getByG_C_PrevAndNext(session, shoppingItem, groupId,
996                     categoryId, orderByComparator, true);
997 
998             array[1] = shoppingItem;
999 
1000            array[2] = getByG_C_PrevAndNext(session, shoppingItem, groupId,
1001                    categoryId, orderByComparator, false);
1002
1003            return array;
1004        }
1005        catch (Exception e) {
1006            throw processException(e);
1007        }
1008        finally {
1009            closeSession(session);
1010        }
1011    }
1012
1013    protected ShoppingItem getByG_C_PrevAndNext(Session session,
1014        ShoppingItem shoppingItem, long groupId, long categoryId,
1015        OrderByComparator orderByComparator, boolean previous) {
1016        StringBundler query = null;
1017
1018        if (orderByComparator != null) {
1019            query = new StringBundler(6 +
1020                    (orderByComparator.getOrderByFields().length * 6));
1021        }
1022        else {
1023            query = new StringBundler(3);
1024        }
1025
1026        query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
1027
1028        query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1029
1030        query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1031
1032        if (orderByComparator != null) {
1033            String[] orderByFields = orderByComparator.getOrderByFields();
1034
1035            if (orderByFields.length > 0) {
1036                query.append(WHERE_AND);
1037            }
1038
1039            for (int i = 0; i < orderByFields.length; i++) {
1040                query.append(_ORDER_BY_ENTITY_ALIAS);
1041                query.append(orderByFields[i]);
1042
1043                if ((i + 1) < orderByFields.length) {
1044                    if (orderByComparator.isAscending() ^ previous) {
1045                        query.append(WHERE_GREATER_THAN_HAS_NEXT);
1046                    }
1047                    else {
1048                        query.append(WHERE_LESSER_THAN_HAS_NEXT);
1049                    }
1050                }
1051                else {
1052                    if (orderByComparator.isAscending() ^ previous) {
1053                        query.append(WHERE_GREATER_THAN);
1054                    }
1055                    else {
1056                        query.append(WHERE_LESSER_THAN);
1057                    }
1058                }
1059            }
1060
1061            query.append(ORDER_BY_CLAUSE);
1062
1063            for (int i = 0; i < orderByFields.length; i++) {
1064                query.append(_ORDER_BY_ENTITY_ALIAS);
1065                query.append(orderByFields[i]);
1066
1067                if ((i + 1) < orderByFields.length) {
1068                    if (orderByComparator.isAscending() ^ previous) {
1069                        query.append(ORDER_BY_ASC_HAS_NEXT);
1070                    }
1071                    else {
1072                        query.append(ORDER_BY_DESC_HAS_NEXT);
1073                    }
1074                }
1075                else {
1076                    if (orderByComparator.isAscending() ^ previous) {
1077                        query.append(ORDER_BY_ASC);
1078                    }
1079                    else {
1080                        query.append(ORDER_BY_DESC);
1081                    }
1082                }
1083            }
1084        }
1085
1086        else {
1087            query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
1088        }
1089
1090        String sql = query.toString();
1091
1092        Query q = session.createQuery(sql);
1093
1094        q.setFirstResult(0);
1095        q.setMaxResults(2);
1096
1097        QueryPos qPos = QueryPos.getInstance(q);
1098
1099        qPos.add(groupId);
1100
1101        qPos.add(categoryId);
1102
1103        if (orderByComparator != null) {
1104            Object[] values = orderByComparator.getOrderByValues(shoppingItem);
1105
1106            for (Object value : values) {
1107                qPos.add(value);
1108            }
1109        }
1110
1111        List<ShoppingItem> list = q.list();
1112
1113        if (list.size() == 2) {
1114            return list.get(1);
1115        }
1116        else {
1117            return null;
1118        }
1119    }
1120
1121    public List<ShoppingItem> filterFindByG_C(long groupId, long categoryId)
1122        throws SystemException {
1123        return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS,
1124            QueryUtil.ALL_POS, null);
1125    }
1126
1127    public List<ShoppingItem> filterFindByG_C(long groupId, long categoryId,
1128        int start, int end) throws SystemException {
1129        return filterFindByG_C(groupId, categoryId, start, end, null);
1130    }
1131
1132    public List<ShoppingItem> filterFindByG_C(long groupId, long categoryId,
1133        int start, int end, OrderByComparator orderByComparator)
1134        throws SystemException {
1135        if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1136            return findByG_C(groupId, categoryId, start, end, orderByComparator);
1137        }
1138
1139        Session session = null;
1140
1141        try {
1142            session = openSession();
1143
1144            StringBundler query = null;
1145
1146            if (orderByComparator != null) {
1147                query = new StringBundler(4 +
1148                        (orderByComparator.getOrderByFields().length * 3));
1149            }
1150            else {
1151                query = new StringBundler(4);
1152            }
1153
1154            query.append(_FILTER_SQL_SELECT_SHOPPINGITEM_WHERE);
1155
1156            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1157
1158            query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1159
1160            if (orderByComparator != null) {
1161                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1162                    orderByComparator);
1163            }
1164
1165            else {
1166                query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
1167            }
1168
1169            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1170                    ShoppingItem.class.getName(), _FILTER_COLUMN_ITEMID,
1171                    _FILTER_COLUMN_USERID, groupId);
1172
1173            SQLQuery q = session.createSQLQuery(sql);
1174
1175            q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingItemImpl.class);
1176
1177            QueryPos qPos = QueryPos.getInstance(q);
1178
1179            qPos.add(groupId);
1180
1181            qPos.add(categoryId);
1182
1183            return (List<ShoppingItem>)QueryUtil.list(q, getDialect(), start,
1184                end);
1185        }
1186        catch (Exception e) {
1187            throw processException(e);
1188        }
1189        finally {
1190            closeSession(session);
1191        }
1192    }
1193
1194    public ShoppingItem findByC_S(long companyId, String sku)
1195        throws NoSuchItemException, SystemException {
1196        ShoppingItem shoppingItem = fetchByC_S(companyId, sku);
1197
1198        if (shoppingItem == null) {
1199            StringBundler msg = new StringBundler(6);
1200
1201            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1202
1203            msg.append("companyId=");
1204            msg.append(companyId);
1205
1206            msg.append(", sku=");
1207            msg.append(sku);
1208
1209            msg.append(StringPool.CLOSE_CURLY_BRACE);
1210
1211            if (_log.isWarnEnabled()) {
1212                _log.warn(msg.toString());
1213            }
1214
1215            throw new NoSuchItemException(msg.toString());
1216        }
1217
1218        return shoppingItem;
1219    }
1220
1221    public ShoppingItem fetchByC_S(long companyId, String sku)
1222        throws SystemException {
1223        return fetchByC_S(companyId, sku, true);
1224    }
1225
1226    public ShoppingItem fetchByC_S(long companyId, String sku,
1227        boolean retrieveFromCache) throws SystemException {
1228        Object[] finderArgs = new Object[] { new Long(companyId), sku };
1229
1230        Object result = null;
1231
1232        if (retrieveFromCache) {
1233            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_S,
1234                    finderArgs, this);
1235        }
1236
1237        if (result == null) {
1238            Session session = null;
1239
1240            try {
1241                session = openSession();
1242
1243                StringBundler query = new StringBundler(4);
1244
1245                query.append(_SQL_SELECT_SHOPPINGITEM_WHERE);
1246
1247                query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
1248
1249                if (sku == null) {
1250                    query.append(_FINDER_COLUMN_C_S_SKU_1);
1251                }
1252                else {
1253                    if (sku.equals(StringPool.BLANK)) {
1254                        query.append(_FINDER_COLUMN_C_S_SKU_3);
1255                    }
1256                    else {
1257                        query.append(_FINDER_COLUMN_C_S_SKU_2);
1258                    }
1259                }
1260
1261                query.append(ShoppingItemModelImpl.ORDER_BY_JPQL);
1262
1263                String sql = query.toString();
1264
1265                Query q = session.createQuery(sql);
1266
1267                QueryPos qPos = QueryPos.getInstance(q);
1268
1269                qPos.add(companyId);
1270
1271                if (sku != null) {
1272                    qPos.add(sku);
1273                }
1274
1275                List<ShoppingItem> list = q.list();
1276
1277                result = list;
1278
1279                ShoppingItem shoppingItem = null;
1280
1281                if (list.isEmpty()) {
1282                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
1283                        finderArgs, list);
1284                }
1285                else {
1286                    shoppingItem = list.get(0);
1287
1288                    cacheResult(shoppingItem);
1289
1290                    if ((shoppingItem.getCompanyId() != companyId) ||
1291                            (shoppingItem.getSku() == null) ||
1292                            !shoppingItem.getSku().equals(sku)) {
1293                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
1294                            finderArgs, shoppingItem);
1295                    }
1296                }
1297
1298                return shoppingItem;
1299            }
1300            catch (Exception e) {
1301                throw processException(e);
1302            }
1303            finally {
1304                if (result == null) {
1305                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_S,
1306                        finderArgs, new ArrayList<ShoppingItem>());
1307                }
1308
1309                closeSession(session);
1310            }
1311        }
1312        else {
1313            if (result instanceof List<?>) {
1314                return null;
1315            }
1316            else {
1317                return (ShoppingItem)result;
1318            }
1319        }
1320    }
1321
1322    public List<ShoppingItem> findAll() throws SystemException {
1323        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1324    }
1325
1326    public List<ShoppingItem> findAll(int start, int end)
1327        throws SystemException {
1328        return findAll(start, end, null);
1329    }
1330
1331    public List<ShoppingItem> findAll(int start, int end,
1332        OrderByComparator orderByComparator) throws SystemException {
1333        Object[] finderArgs = new Object[] {
1334                String.valueOf(start), String.valueOf(end),
1335                String.valueOf(orderByComparator)
1336            };
1337
1338        List<ShoppingItem> list = (List<ShoppingItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1339                finderArgs, this);
1340
1341        if (list == null) {
1342            Session session = null;
1343
1344            try {
1345                session = openSession();
1346
1347                StringBundler query = null;
1348                String sql = null;
1349
1350                if (orderByComparator != null) {
1351                    query = new StringBundler(2 +
1352                            (orderByComparator.getOrderByFields().length * 3));
1353
1354                    query.append(_SQL_SELECT_SHOPPINGITEM);
1355
1356                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1357                        orderByComparator);
1358
1359                    sql = query.toString();
1360                }
1361
1362                else {
1363                    sql = _SQL_SELECT_SHOPPINGITEM.concat(ShoppingItemModelImpl.ORDER_BY_JPQL);
1364                }
1365
1366                Query q = session.createQuery(sql);
1367
1368                if (orderByComparator == null) {
1369                    list = (List<ShoppingItem>)QueryUtil.list(q, getDialect(),
1370                            start, end, false);
1371
1372                    Collections.sort(list);
1373                }
1374                else {
1375                    list = (List<ShoppingItem>)QueryUtil.list(q, getDialect(),
1376                            start, end);
1377                }
1378            }
1379            catch (Exception e) {
1380                throw processException(e);
1381            }
1382            finally {
1383                if (list == null) {
1384                    list = new ArrayList<ShoppingItem>();
1385                }
1386
1387                cacheResult(list);
1388
1389                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1390
1391                closeSession(session);
1392            }
1393        }
1394
1395        return list;
1396    }
1397
1398    public void removeBySmallImageId(long smallImageId)
1399        throws NoSuchItemException, SystemException {
1400        ShoppingItem shoppingItem = findBySmallImageId(smallImageId);
1401
1402        remove(shoppingItem);
1403    }
1404
1405    public void removeByMediumImageId(long mediumImageId)
1406        throws NoSuchItemException, SystemException {
1407        ShoppingItem shoppingItem = findByMediumImageId(mediumImageId);
1408
1409        remove(shoppingItem);
1410    }
1411
1412    public void removeByLargeImageId(long largeImageId)
1413        throws NoSuchItemException, SystemException {
1414        ShoppingItem shoppingItem = findByLargeImageId(largeImageId);
1415
1416        remove(shoppingItem);
1417    }
1418
1419    public void removeByG_C(long groupId, long categoryId)
1420        throws SystemException {
1421        for (ShoppingItem shoppingItem : findByG_C(groupId, categoryId)) {
1422            remove(shoppingItem);
1423        }
1424    }
1425
1426    public void removeByC_S(long companyId, String sku)
1427        throws NoSuchItemException, SystemException {
1428        ShoppingItem shoppingItem = findByC_S(companyId, sku);
1429
1430        remove(shoppingItem);
1431    }
1432
1433    public void removeAll() throws SystemException {
1434        for (ShoppingItem shoppingItem : findAll()) {
1435            remove(shoppingItem);
1436        }
1437    }
1438
1439    public int countBySmallImageId(long smallImageId) throws SystemException {
1440        Object[] finderArgs = new Object[] { new Long(smallImageId) };
1441
1442        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1443                finderArgs, this);
1444
1445        if (count == null) {
1446            Session session = null;
1447
1448            try {
1449                session = openSession();
1450
1451                StringBundler query = new StringBundler(2);
1452
1453                query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
1454
1455                query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
1456
1457                String sql = query.toString();
1458
1459                Query q = session.createQuery(sql);
1460
1461                QueryPos qPos = QueryPos.getInstance(q);
1462
1463                qPos.add(smallImageId);
1464
1465                count = (Long)q.uniqueResult();
1466            }
1467            catch (Exception e) {
1468                throw processException(e);
1469            }
1470            finally {
1471                if (count == null) {
1472                    count = Long.valueOf(0);
1473                }
1474
1475                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1476                    finderArgs, count);
1477
1478                closeSession(session);
1479            }
1480        }
1481
1482        return count.intValue();
1483    }
1484
1485    public int countByMediumImageId(long mediumImageId)
1486        throws SystemException {
1487        Object[] finderArgs = new Object[] { new Long(mediumImageId) };
1488
1489        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MEDIUMIMAGEID,
1490                finderArgs, this);
1491
1492        if (count == null) {
1493            Session session = null;
1494
1495            try {
1496                session = openSession();
1497
1498                StringBundler query = new StringBundler(2);
1499
1500                query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
1501
1502                query.append(_FINDER_COLUMN_MEDIUMIMAGEID_MEDIUMIMAGEID_2);
1503
1504                String sql = query.toString();
1505
1506                Query q = session.createQuery(sql);
1507
1508                QueryPos qPos = QueryPos.getInstance(q);
1509
1510                qPos.add(mediumImageId);
1511
1512                count = (Long)q.uniqueResult();
1513            }
1514            catch (Exception e) {
1515                throw processException(e);
1516            }
1517            finally {
1518                if (count == null) {
1519                    count = Long.valueOf(0);
1520                }
1521
1522                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MEDIUMIMAGEID,
1523                    finderArgs, count);
1524
1525                closeSession(session);
1526            }
1527        }
1528
1529        return count.intValue();
1530    }
1531
1532    public int countByLargeImageId(long largeImageId) throws SystemException {
1533        Object[] finderArgs = new Object[] { new Long(largeImageId) };
1534
1535        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LARGEIMAGEID,
1536                finderArgs, this);
1537
1538        if (count == null) {
1539            Session session = null;
1540
1541            try {
1542                session = openSession();
1543
1544                StringBundler query = new StringBundler(2);
1545
1546                query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
1547
1548                query.append(_FINDER_COLUMN_LARGEIMAGEID_LARGEIMAGEID_2);
1549
1550                String sql = query.toString();
1551
1552                Query q = session.createQuery(sql);
1553
1554                QueryPos qPos = QueryPos.getInstance(q);
1555
1556                qPos.add(largeImageId);
1557
1558                count = (Long)q.uniqueResult();
1559            }
1560            catch (Exception e) {
1561                throw processException(e);
1562            }
1563            finally {
1564                if (count == null) {
1565                    count = Long.valueOf(0);
1566                }
1567
1568                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LARGEIMAGEID,
1569                    finderArgs, count);
1570
1571                closeSession(session);
1572            }
1573        }
1574
1575        return count.intValue();
1576    }
1577
1578    public int countByG_C(long groupId, long categoryId)
1579        throws SystemException {
1580        Object[] finderArgs = new Object[] {
1581                new Long(groupId), new Long(categoryId)
1582            };
1583
1584        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
1585                finderArgs, this);
1586
1587        if (count == null) {
1588            Session session = null;
1589
1590            try {
1591                session = openSession();
1592
1593                StringBundler query = new StringBundler(3);
1594
1595                query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
1596
1597                query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1598
1599                query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1600
1601                String sql = query.toString();
1602
1603                Query q = session.createQuery(sql);
1604
1605                QueryPos qPos = QueryPos.getInstance(q);
1606
1607                qPos.add(groupId);
1608
1609                qPos.add(categoryId);
1610
1611                count = (Long)q.uniqueResult();
1612            }
1613            catch (Exception e) {
1614                throw processException(e);
1615            }
1616            finally {
1617                if (count == null) {
1618                    count = Long.valueOf(0);
1619                }
1620
1621                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
1622                    count);
1623
1624                closeSession(session);
1625            }
1626        }
1627
1628        return count.intValue();
1629    }
1630
1631    public int filterCountByG_C(long groupId, long categoryId)
1632        throws SystemException {
1633        if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1634            return countByG_C(groupId, categoryId);
1635        }
1636
1637        Session session = null;
1638
1639        try {
1640            session = openSession();
1641
1642            StringBundler query = new StringBundler(3);
1643
1644            query.append(_FILTER_SQL_COUNT_SHOPPINGITEM_WHERE);
1645
1646            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1647
1648            query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1649
1650            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1651                    ShoppingItem.class.getName(), _FILTER_COLUMN_ITEMID,
1652                    _FILTER_COLUMN_USERID, groupId);
1653
1654            SQLQuery q = session.createSQLQuery(sql);
1655
1656            q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1657
1658            QueryPos qPos = QueryPos.getInstance(q);
1659
1660            qPos.add(groupId);
1661
1662            qPos.add(categoryId);
1663
1664            Long count = (Long)q.uniqueResult();
1665
1666            return count.intValue();
1667        }
1668        catch (Exception e) {
1669            throw processException(e);
1670        }
1671        finally {
1672            closeSession(session);
1673        }
1674    }
1675
1676    public int countByC_S(long companyId, String sku) throws SystemException {
1677        Object[] finderArgs = new Object[] { new Long(companyId), sku };
1678
1679        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_S,
1680                finderArgs, this);
1681
1682        if (count == null) {
1683            Session session = null;
1684
1685            try {
1686                session = openSession();
1687
1688                StringBundler query = new StringBundler(3);
1689
1690                query.append(_SQL_COUNT_SHOPPINGITEM_WHERE);
1691
1692                query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
1693
1694                if (sku == null) {
1695                    query.append(_FINDER_COLUMN_C_S_SKU_1);
1696                }
1697                else {
1698                    if (sku.equals(StringPool.BLANK)) {
1699                        query.append(_FINDER_COLUMN_C_S_SKU_3);
1700                    }
1701                    else {
1702                        query.append(_FINDER_COLUMN_C_S_SKU_2);
1703                    }
1704                }
1705
1706                String sql = query.toString();
1707
1708                Query q = session.createQuery(sql);
1709
1710                QueryPos qPos = QueryPos.getInstance(q);
1711
1712                qPos.add(companyId);
1713
1714                if (sku != null) {
1715                    qPos.add(sku);
1716                }
1717
1718                count = (Long)q.uniqueResult();
1719            }
1720            catch (Exception e) {
1721                throw processException(e);
1722            }
1723            finally {
1724                if (count == null) {
1725                    count = Long.valueOf(0);
1726                }
1727
1728                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_S, finderArgs,
1729                    count);
1730
1731                closeSession(session);
1732            }
1733        }
1734
1735        return count.intValue();
1736    }
1737
1738    public int countAll() throws SystemException {
1739        Object[] finderArgs = new Object[0];
1740
1741        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1742                finderArgs, this);
1743
1744        if (count == null) {
1745            Session session = null;
1746
1747            try {
1748                session = openSession();
1749
1750                Query q = session.createQuery(_SQL_COUNT_SHOPPINGITEM);
1751
1752                count = (Long)q.uniqueResult();
1753            }
1754            catch (Exception e) {
1755                throw processException(e);
1756            }
1757            finally {
1758                if (count == null) {
1759                    count = Long.valueOf(0);
1760                }
1761
1762                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1763                    count);
1764
1765                closeSession(session);
1766            }
1767        }
1768
1769        return count.intValue();
1770    }
1771
1772    public List<com.liferay.portlet.shopping.model.ShoppingItemPrice> getShoppingItemPrices(
1773        long pk) throws SystemException {
1774        return getShoppingItemPrices(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1775    }
1776
1777    public List<com.liferay.portlet.shopping.model.ShoppingItemPrice> getShoppingItemPrices(
1778        long pk, int start, int end) throws SystemException {
1779        return getShoppingItemPrices(pk, start, end, null);
1780    }
1781
1782    public static final FinderPath FINDER_PATH_GET_SHOPPINGITEMPRICES = new FinderPath(com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
1783            com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
1784            com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistenceImpl.FINDER_CLASS_NAME_LIST,
1785            "getShoppingItemPrices",
1786            new String[] {
1787                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1788                "com.liferay.portal.kernel.util.OrderByComparator"
1789            });
1790
1791    public List<com.liferay.portlet.shopping.model.ShoppingItemPrice> getShoppingItemPrices(
1792        long pk, int start, int end, OrderByComparator orderByComparator)
1793        throws SystemException {
1794        Object[] finderArgs = new Object[] {
1795                new Long(pk), String.valueOf(start), String.valueOf(end),
1796                String.valueOf(orderByComparator)
1797            };
1798
1799        List<com.liferay.portlet.shopping.model.ShoppingItemPrice> list = (List<com.liferay.portlet.shopping.model.ShoppingItemPrice>)FinderCacheUtil.getResult(FINDER_PATH_GET_SHOPPINGITEMPRICES,
1800                finderArgs, this);
1801
1802        if (list == null) {
1803            Session session = null;
1804
1805            try {
1806                session = openSession();
1807
1808                String sql = null;
1809
1810                if (orderByComparator != null) {
1811                    sql = _SQL_GETSHOPPINGITEMPRICES.concat(ORDER_BY_CLAUSE)
1812                                                    .concat(orderByComparator.getOrderBy());
1813                }
1814
1815                else {
1816                    sql = _SQL_GETSHOPPINGITEMPRICES.concat(com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.ORDER_BY_SQL);
1817                }
1818
1819                SQLQuery q = session.createSQLQuery(sql);
1820
1821                q.addEntity("ShoppingItemPrice",
1822                    com.liferay.portlet.shopping.model.impl.ShoppingItemPriceImpl.class);
1823
1824                QueryPos qPos = QueryPos.getInstance(q);
1825
1826                qPos.add(pk);
1827
1828                list = (List<com.liferay.portlet.shopping.model.ShoppingItemPrice>)QueryUtil.list(q,
1829                        getDialect(), start, end);
1830            }
1831            catch (Exception e) {
1832                throw processException(e);
1833            }
1834            finally {
1835                if (list == null) {
1836                    list = new ArrayList<com.liferay.portlet.shopping.model.ShoppingItemPrice>();
1837                }
1838
1839                shoppingItemPricePersistence.cacheResult(list);
1840
1841                FinderCacheUtil.putResult(FINDER_PATH_GET_SHOPPINGITEMPRICES,
1842                    finderArgs, list);
1843
1844                closeSession(session);
1845            }
1846        }
1847
1848        return list;
1849    }
1850
1851    public static final FinderPath FINDER_PATH_GET_SHOPPINGITEMPRICES_SIZE = new FinderPath(com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
1852            com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
1853            com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistenceImpl.FINDER_CLASS_NAME_LIST,
1854            "getShoppingItemPricesSize", new String[] { Long.class.getName() });
1855
1856    public int getShoppingItemPricesSize(long pk) throws SystemException {
1857        Object[] finderArgs = new Object[] { new Long(pk) };
1858
1859        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SHOPPINGITEMPRICES_SIZE,
1860                finderArgs, this);
1861
1862        if (count == null) {
1863            Session session = null;
1864
1865            try {
1866                session = openSession();
1867
1868                SQLQuery q = session.createSQLQuery(_SQL_GETSHOPPINGITEMPRICESSIZE);
1869
1870                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1871
1872                QueryPos qPos = QueryPos.getInstance(q);
1873
1874                qPos.add(pk);
1875
1876                count = (Long)q.uniqueResult();
1877            }
1878            catch (Exception e) {
1879                throw processException(e);
1880            }
1881            finally {
1882                if (count == null) {
1883                    count = Long.valueOf(0);
1884                }
1885
1886                FinderCacheUtil.putResult(FINDER_PATH_GET_SHOPPINGITEMPRICES_SIZE,
1887                    finderArgs, count);
1888
1889                closeSession(session);
1890            }
1891        }
1892
1893        return count.intValue();
1894    }
1895
1896    public static final FinderPath FINDER_PATH_CONTAINS_SHOPPINGITEMPRICE = new FinderPath(com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
1897            com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
1898            com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistenceImpl.FINDER_CLASS_NAME_LIST,
1899            "containsShoppingItemPrice",
1900            new String[] { Long.class.getName(), Long.class.getName() });
1901
1902    public boolean containsShoppingItemPrice(long pk, long shoppingItemPricePK)
1903        throws SystemException {
1904        Object[] finderArgs = new Object[] {
1905                new Long(pk),
1906                
1907                new Long(shoppingItemPricePK)
1908            };
1909
1910        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SHOPPINGITEMPRICE,
1911                finderArgs, this);
1912
1913        if (value == null) {
1914            try {
1915                value = Boolean.valueOf(containsShoppingItemPrice.contains(pk,
1916                            shoppingItemPricePK));
1917            }
1918            catch (Exception e) {
1919                throw processException(e);
1920            }
1921            finally {
1922                if (value == null) {
1923                    value = Boolean.FALSE;
1924                }
1925
1926                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SHOPPINGITEMPRICE,
1927                    finderArgs, value);
1928            }
1929        }
1930
1931        return value.booleanValue();
1932    }
1933
1934    public boolean containsShoppingItemPrices(long pk)
1935        throws SystemException {
1936        if (getShoppingItemPricesSize(pk) > 0) {
1937            return true;
1938        }
1939        else {
1940            return false;
1941        }
1942    }
1943
1944    public void afterPropertiesSet() {
1945        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1946                    com.liferay.portal.util.PropsUtil.get(
1947                        "value.object.listener.com.liferay.portlet.shopping.model.ShoppingItem")));
1948
1949        if (listenerClassNames.length > 0) {
1950            try {
1951                List<ModelListener<ShoppingItem>> listenersList = new ArrayList<ModelListener<ShoppingItem>>();
1952
1953                for (String listenerClassName : listenerClassNames) {
1954                    listenersList.add((ModelListener<ShoppingItem>)InstanceFactory.newInstance(
1955                            listenerClassName));
1956                }
1957
1958                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1959            }
1960            catch (Exception e) {
1961                _log.error(e);
1962            }
1963        }
1964
1965        containsShoppingItemPrice = new ContainsShoppingItemPrice(this);
1966    }
1967
1968    @BeanReference(type = ShoppingCartPersistence.class)
1969    protected ShoppingCartPersistence shoppingCartPersistence;
1970    @BeanReference(type = ShoppingCategoryPersistence.class)
1971    protected ShoppingCategoryPersistence shoppingCategoryPersistence;
1972    @BeanReference(type = ShoppingCouponPersistence.class)
1973    protected ShoppingCouponPersistence shoppingCouponPersistence;
1974    @BeanReference(type = ShoppingItemPersistence.class)
1975    protected ShoppingItemPersistence shoppingItemPersistence;
1976    @BeanReference(type = ShoppingItemFieldPersistence.class)
1977    protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
1978    @BeanReference(type = ShoppingItemPricePersistence.class)
1979    protected ShoppingItemPricePersistence shoppingItemPricePersistence;
1980    @BeanReference(type = ShoppingOrderPersistence.class)
1981    protected ShoppingOrderPersistence shoppingOrderPersistence;
1982    @BeanReference(type = ShoppingOrderItemPersistence.class)
1983    protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
1984    @BeanReference(type = ImagePersistence.class)
1985    protected ImagePersistence imagePersistence;
1986    @BeanReference(type = ResourcePersistence.class)
1987    protected ResourcePersistence resourcePersistence;
1988    @BeanReference(type = UserPersistence.class)
1989    protected UserPersistence userPersistence;
1990    protected ContainsShoppingItemPrice containsShoppingItemPrice;
1991
1992    protected class ContainsShoppingItemPrice {
1993        protected ContainsShoppingItemPrice(
1994            ShoppingItemPersistenceImpl persistenceImpl) {
1995            super();
1996
1997            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1998                    _SQL_CONTAINSSHOPPINGITEMPRICE,
1999                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
2000        }
2001
2002        protected boolean contains(long itemId, long itemPriceId) {
2003            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2004                        new Long(itemId), new Long(itemPriceId)
2005                    });
2006
2007            if (results.size() > 0) {
2008                Integer count = results.get(0);
2009
2010                if (count.intValue() > 0) {
2011                    return true;
2012                }
2013            }
2014
2015            return false;
2016        }
2017
2018        private MappingSqlQuery<Integer> _mappingSqlQuery;
2019    }
2020
2021    private static final String _SQL_SELECT_SHOPPINGITEM = "SELECT shoppingItem FROM ShoppingItem shoppingItem";
2022    private static final String _SQL_SELECT_SHOPPINGITEM_WHERE = "SELECT shoppingItem FROM ShoppingItem shoppingItem WHERE ";
2023    private static final String _SQL_COUNT_SHOPPINGITEM = "SELECT COUNT(shoppingItem) FROM ShoppingItem shoppingItem";
2024    private static final String _SQL_COUNT_SHOPPINGITEM_WHERE = "SELECT COUNT(shoppingItem) FROM ShoppingItem shoppingItem WHERE ";
2025    private static final String _SQL_GETSHOPPINGITEMPRICES = "SELECT {ShoppingItemPrice.*} FROM ShoppingItemPrice INNER JOIN ShoppingItem ON (ShoppingItem.itemId = ShoppingItemPrice.itemId) WHERE (ShoppingItem.itemId = ?)";
2026    private static final String _SQL_GETSHOPPINGITEMPRICESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM ShoppingItemPrice WHERE itemId = ?";
2027    private static final String _SQL_CONTAINSSHOPPINGITEMPRICE = "SELECT COUNT(*) AS COUNT_VALUE FROM ShoppingItemPrice WHERE itemId = ? AND itemPriceId = ?";
2028    private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "shoppingItem.smallImageId = ?";
2029    private static final String _FINDER_COLUMN_MEDIUMIMAGEID_MEDIUMIMAGEID_2 = "shoppingItem.mediumImageId = ?";
2030    private static final String _FINDER_COLUMN_LARGEIMAGEID_LARGEIMAGEID_2 = "shoppingItem.largeImageId = ?";
2031    private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "shoppingItem.groupId = ? AND ";
2032    private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "shoppingItem.categoryId = ?";
2033    private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "shoppingItem.companyId = ? AND ";
2034    private static final String _FINDER_COLUMN_C_S_SKU_1 = "shoppingItem.sku IS NULL";
2035    private static final String _FINDER_COLUMN_C_S_SKU_2 = "shoppingItem.sku = ?";
2036    private static final String _FINDER_COLUMN_C_S_SKU_3 = "(shoppingItem.sku IS NULL OR shoppingItem.sku = ?)";
2037    private static final String _FILTER_SQL_SELECT_SHOPPINGITEM_WHERE = "SELECT DISTINCT {shoppingItem.*} FROM ShoppingItem shoppingItem WHERE ";
2038    private static final String _FILTER_SQL_COUNT_SHOPPINGITEM_WHERE = "SELECT COUNT(DISTINCT shoppingItem.itemId) AS COUNT_VALUE FROM ShoppingItem shoppingItem WHERE ";
2039    private static final String _FILTER_COLUMN_ITEMID = "shoppingItem.itemId";
2040    private static final String _FILTER_COLUMN_USERID = "shoppingItem.userId";
2041    private static final String _FILTER_ENTITY_ALIAS = "shoppingItem";
2042    private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingItem.";
2043    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingItem exists with the primary key ";
2044    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingItem exists with the key {";
2045    private static Log _log = LogFactoryUtil.getLog(ShoppingItemPersistenceImpl.class);
2046}