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