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