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