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