001    /**
002     * Copyright (c) 2000-2011 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,
125                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
126            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ShoppingCategoryModelImpl.ENTITY_CACHE_ENABLED,
127                            ShoppingCategoryModelImpl.FINDER_CACHE_ENABLED,
128                            ShoppingCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
129                            "findAll", new String[0]);
130            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingCategoryModelImpl.ENTITY_CACHE_ENABLED,
131                            ShoppingCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
132                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
133    
134            /**
135             * Caches the shopping category in the entity cache if it is enabled.
136             *
137             * @param shoppingCategory the shopping category
138             */
139            public void cacheResult(ShoppingCategory shoppingCategory) {
140                    EntityCacheUtil.putResult(ShoppingCategoryModelImpl.ENTITY_CACHE_ENABLED,
141                            ShoppingCategoryImpl.class, shoppingCategory.getPrimaryKey(),
142                            shoppingCategory);
143    
144                    shoppingCategory.resetOriginalValues();
145            }
146    
147            /**
148             * Caches the shopping categories in the entity cache if it is enabled.
149             *
150             * @param shoppingCategories the shopping categories
151             */
152            public void cacheResult(List<ShoppingCategory> shoppingCategories) {
153                    for (ShoppingCategory shoppingCategory : shoppingCategories) {
154                            if (EntityCacheUtil.getResult(
155                                                    ShoppingCategoryModelImpl.ENTITY_CACHE_ENABLED,
156                                                    ShoppingCategoryImpl.class,
157                                                    shoppingCategory.getPrimaryKey()) == null) {
158                                    cacheResult(shoppingCategory);
159                            }
160                            else {
161                                    shoppingCategory.resetOriginalValues();
162                            }
163                    }
164            }
165    
166            /**
167             * Clears the cache for all shopping categories.
168             *
169             * <p>
170             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
171             * </p>
172             */
173            @Override
174            public void clearCache() {
175                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
176                            CacheRegistryUtil.clear(ShoppingCategoryImpl.class.getName());
177                    }
178    
179                    EntityCacheUtil.clearCache(ShoppingCategoryImpl.class.getName());
180    
181                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
182                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
183                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
184            }
185    
186            /**
187             * Clears the cache for the shopping category.
188             *
189             * <p>
190             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
191             * </p>
192             */
193            @Override
194            public void clearCache(ShoppingCategory shoppingCategory) {
195                    EntityCacheUtil.removeResult(ShoppingCategoryModelImpl.ENTITY_CACHE_ENABLED,
196                            ShoppingCategoryImpl.class, shoppingCategory.getPrimaryKey());
197    
198                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
199                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
200            }
201    
202            @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) {
575                            StringBundler query = null;
576    
577                            if (orderByComparator != null) {
578                                    query = new StringBundler(3 +
579                                                    (orderByComparator.getOrderByFields().length * 3));
580                            }
581                            else {
582                                    query = new StringBundler(3);
583                            }
584    
585                            query.append(_SQL_SELECT_SHOPPINGCATEGORY_WHERE);
586    
587                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
588    
589                            if (orderByComparator != null) {
590                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
591                                            orderByComparator);
592                            }
593    
594                            else {
595                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_JPQL);
596                            }
597    
598                            String sql = query.toString();
599    
600                            Session session = null;
601    
602                            try {
603                                    session = openSession();
604    
605                                    Query q = session.createQuery(sql);
606    
607                                    QueryPos qPos = QueryPos.getInstance(q);
608    
609                                    qPos.add(groupId);
610    
611                                    list = (List<ShoppingCategory>)QueryUtil.list(q, getDialect(),
612                                                    start, end);
613                            }
614                            catch (Exception e) {
615                                    throw processException(e);
616                            }
617                            finally {
618                                    if (list == null) {
619                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
620                                    }
621                                    else {
622                                            cacheResult(list);
623    
624                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
625                                    }
626    
627                                    closeSession(session);
628                            }
629                    }
630    
631                    return list;
632            }
633    
634            /**
635             * Returns the first shopping category in the ordered set where groupId = &#63;.
636             *
637             * <p>
638             * 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.
639             * </p>
640             *
641             * @param groupId the group ID
642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
643             * @return the first matching shopping category
644             * @throws com.liferay.portlet.shopping.NoSuchCategoryException if a matching shopping category could not be found
645             * @throws SystemException if a system exception occurred
646             */
647            public ShoppingCategory findByGroupId_First(long groupId,
648                    OrderByComparator orderByComparator)
649                    throws NoSuchCategoryException, SystemException {
650                    List<ShoppingCategory> list = findByGroupId(groupId, 0, 1,
651                                    orderByComparator);
652    
653                    if (list.isEmpty()) {
654                            StringBundler msg = new StringBundler(4);
655    
656                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
657    
658                            msg.append("groupId=");
659                            msg.append(groupId);
660    
661                            msg.append(StringPool.CLOSE_CURLY_BRACE);
662    
663                            throw new NoSuchCategoryException(msg.toString());
664                    }
665                    else {
666                            return list.get(0);
667                    }
668            }
669    
670            /**
671             * Returns the last shopping category in the ordered set where groupId = &#63;.
672             *
673             * <p>
674             * 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.
675             * </p>
676             *
677             * @param groupId the group ID
678             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
679             * @return the last matching shopping category
680             * @throws com.liferay.portlet.shopping.NoSuchCategoryException if a matching shopping category could not be found
681             * @throws SystemException if a system exception occurred
682             */
683            public ShoppingCategory findByGroupId_Last(long groupId,
684                    OrderByComparator orderByComparator)
685                    throws NoSuchCategoryException, SystemException {
686                    int count = countByGroupId(groupId);
687    
688                    List<ShoppingCategory> list = findByGroupId(groupId, count - 1, count,
689                                    orderByComparator);
690    
691                    if (list.isEmpty()) {
692                            StringBundler msg = new StringBundler(4);
693    
694                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
695    
696                            msg.append("groupId=");
697                            msg.append(groupId);
698    
699                            msg.append(StringPool.CLOSE_CURLY_BRACE);
700    
701                            throw new NoSuchCategoryException(msg.toString());
702                    }
703                    else {
704                            return list.get(0);
705                    }
706            }
707    
708            /**
709             * Returns the shopping categories before and after the current shopping category in the ordered set where groupId = &#63;.
710             *
711             * <p>
712             * 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.
713             * </p>
714             *
715             * @param categoryId the primary key of the current shopping category
716             * @param groupId the group ID
717             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
718             * @return the previous, current, and next shopping category
719             * @throws com.liferay.portlet.shopping.NoSuchCategoryException if a shopping category with the primary key could not be found
720             * @throws SystemException if a system exception occurred
721             */
722            public ShoppingCategory[] findByGroupId_PrevAndNext(long categoryId,
723                    long groupId, OrderByComparator orderByComparator)
724                    throws NoSuchCategoryException, SystemException {
725                    ShoppingCategory shoppingCategory = findByPrimaryKey(categoryId);
726    
727                    Session session = null;
728    
729                    try {
730                            session = openSession();
731    
732                            ShoppingCategory[] array = new ShoppingCategoryImpl[3];
733    
734                            array[0] = getByGroupId_PrevAndNext(session, shoppingCategory,
735                                            groupId, orderByComparator, true);
736    
737                            array[1] = shoppingCategory;
738    
739                            array[2] = getByGroupId_PrevAndNext(session, shoppingCategory,
740                                            groupId, orderByComparator, false);
741    
742                            return array;
743                    }
744                    catch (Exception e) {
745                            throw processException(e);
746                    }
747                    finally {
748                            closeSession(session);
749                    }
750            }
751    
752            protected ShoppingCategory getByGroupId_PrevAndNext(Session session,
753                    ShoppingCategory shoppingCategory, long groupId,
754                    OrderByComparator orderByComparator, boolean previous) {
755                    StringBundler query = null;
756    
757                    if (orderByComparator != null) {
758                            query = new StringBundler(6 +
759                                            (orderByComparator.getOrderByFields().length * 6));
760                    }
761                    else {
762                            query = new StringBundler(3);
763                    }
764    
765                    query.append(_SQL_SELECT_SHOPPINGCATEGORY_WHERE);
766    
767                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
768    
769                    if (orderByComparator != null) {
770                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
771    
772                            if (orderByConditionFields.length > 0) {
773                                    query.append(WHERE_AND);
774                            }
775    
776                            for (int i = 0; i < orderByConditionFields.length; i++) {
777                                    query.append(_ORDER_BY_ENTITY_ALIAS);
778                                    query.append(orderByConditionFields[i]);
779    
780                                    if ((i + 1) < orderByConditionFields.length) {
781                                            if (orderByComparator.isAscending() ^ previous) {
782                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
783                                            }
784                                            else {
785                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
786                                            }
787                                    }
788                                    else {
789                                            if (orderByComparator.isAscending() ^ previous) {
790                                                    query.append(WHERE_GREATER_THAN);
791                                            }
792                                            else {
793                                                    query.append(WHERE_LESSER_THAN);
794                                            }
795                                    }
796                            }
797    
798                            query.append(ORDER_BY_CLAUSE);
799    
800                            String[] orderByFields = orderByComparator.getOrderByFields();
801    
802                            for (int i = 0; i < orderByFields.length; i++) {
803                                    query.append(_ORDER_BY_ENTITY_ALIAS);
804                                    query.append(orderByFields[i]);
805    
806                                    if ((i + 1) < orderByFields.length) {
807                                            if (orderByComparator.isAscending() ^ previous) {
808                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
809                                            }
810                                            else {
811                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
812                                            }
813                                    }
814                                    else {
815                                            if (orderByComparator.isAscending() ^ previous) {
816                                                    query.append(ORDER_BY_ASC);
817                                            }
818                                            else {
819                                                    query.append(ORDER_BY_DESC);
820                                            }
821                                    }
822                            }
823                    }
824    
825                    else {
826                            query.append(ShoppingCategoryModelImpl.ORDER_BY_JPQL);
827                    }
828    
829                    String sql = query.toString();
830    
831                    Query q = session.createQuery(sql);
832    
833                    q.setFirstResult(0);
834                    q.setMaxResults(2);
835    
836                    QueryPos qPos = QueryPos.getInstance(q);
837    
838                    qPos.add(groupId);
839    
840                    if (orderByComparator != null) {
841                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingCategory);
842    
843                            for (Object value : values) {
844                                    qPos.add(value);
845                            }
846                    }
847    
848                    List<ShoppingCategory> list = q.list();
849    
850                    if (list.size() == 2) {
851                            return list.get(1);
852                    }
853                    else {
854                            return null;
855                    }
856            }
857    
858            /**
859             * Returns all the shopping categories that the user has permission to view where groupId = &#63;.
860             *
861             * @param groupId the group ID
862             * @return the matching shopping categories that the user has permission to view
863             * @throws SystemException if a system exception occurred
864             */
865            public List<ShoppingCategory> filterFindByGroupId(long groupId)
866                    throws SystemException {
867                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
868                            QueryUtil.ALL_POS, null);
869            }
870    
871            /**
872             * Returns a range of all the shopping categories that the user has permission to view where groupId = &#63;.
873             *
874             * <p>
875             * 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.
876             * </p>
877             *
878             * @param groupId the group ID
879             * @param start the lower bound of the range of shopping categories
880             * @param end the upper bound of the range of shopping categories (not inclusive)
881             * @return the range of matching shopping categories that the user has permission to view
882             * @throws SystemException if a system exception occurred
883             */
884            public List<ShoppingCategory> filterFindByGroupId(long groupId, int start,
885                    int end) throws SystemException {
886                    return filterFindByGroupId(groupId, start, end, null);
887            }
888    
889            /**
890             * Returns an ordered range of all the shopping categories that the user has permissions to view where groupId = &#63;.
891             *
892             * <p>
893             * 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.
894             * </p>
895             *
896             * @param groupId the group ID
897             * @param start the lower bound of the range of shopping categories
898             * @param end the upper bound of the range of shopping categories (not inclusive)
899             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
900             * @return the ordered range of matching shopping categories that the user has permission to view
901             * @throws SystemException if a system exception occurred
902             */
903            public List<ShoppingCategory> filterFindByGroupId(long groupId, int start,
904                    int end, OrderByComparator orderByComparator) throws SystemException {
905                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
906                            return findByGroupId(groupId, start, end, orderByComparator);
907                    }
908    
909                    StringBundler query = null;
910    
911                    if (orderByComparator != null) {
912                            query = new StringBundler(3 +
913                                            (orderByComparator.getOrderByFields().length * 3));
914                    }
915                    else {
916                            query = new StringBundler(3);
917                    }
918    
919                    if (getDB().isSupportsInlineDistinct()) {
920                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_WHERE);
921                    }
922                    else {
923                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
924                    }
925    
926                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
927    
928                    if (!getDB().isSupportsInlineDistinct()) {
929                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
930                    }
931    
932                    if (orderByComparator != null) {
933                            if (getDB().isSupportsInlineDistinct()) {
934                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
935                                            orderByComparator);
936                            }
937                            else {
938                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
939                                            orderByComparator);
940                            }
941                    }
942    
943                    else {
944                            if (getDB().isSupportsInlineDistinct()) {
945                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_JPQL);
946                            }
947                            else {
948                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_SQL);
949                            }
950                    }
951    
952                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
953                                    ShoppingCategory.class.getName(),
954                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
955    
956                    Session session = null;
957    
958                    try {
959                            session = openSession();
960    
961                            SQLQuery q = session.createSQLQuery(sql);
962    
963                            if (getDB().isSupportsInlineDistinct()) {
964                                    q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingCategoryImpl.class);
965                            }
966                            else {
967                                    q.addEntity(_FILTER_ENTITY_TABLE, ShoppingCategoryImpl.class);
968                            }
969    
970                            QueryPos qPos = QueryPos.getInstance(q);
971    
972                            qPos.add(groupId);
973    
974                            return (List<ShoppingCategory>)QueryUtil.list(q, getDialect(),
975                                    start, end);
976                    }
977                    catch (Exception e) {
978                            throw processException(e);
979                    }
980                    finally {
981                            closeSession(session);
982                    }
983            }
984    
985            /**
986             * 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;.
987             *
988             * @param categoryId the primary key of the current shopping category
989             * @param groupId the group ID
990             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
991             * @return the previous, current, and next shopping category
992             * @throws com.liferay.portlet.shopping.NoSuchCategoryException if a shopping category with the primary key could not be found
993             * @throws SystemException if a system exception occurred
994             */
995            public ShoppingCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
996                    long groupId, OrderByComparator orderByComparator)
997                    throws NoSuchCategoryException, SystemException {
998                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
999                            return findByGroupId_PrevAndNext(categoryId, groupId,
1000                                    orderByComparator);
1001                    }
1002    
1003                    ShoppingCategory shoppingCategory = findByPrimaryKey(categoryId);
1004    
1005                    Session session = null;
1006    
1007                    try {
1008                            session = openSession();
1009    
1010                            ShoppingCategory[] array = new ShoppingCategoryImpl[3];
1011    
1012                            array[0] = filterGetByGroupId_PrevAndNext(session,
1013                                            shoppingCategory, groupId, orderByComparator, true);
1014    
1015                            array[1] = shoppingCategory;
1016    
1017                            array[2] = filterGetByGroupId_PrevAndNext(session,
1018                                            shoppingCategory, groupId, orderByComparator, false);
1019    
1020                            return array;
1021                    }
1022                    catch (Exception e) {
1023                            throw processException(e);
1024                    }
1025                    finally {
1026                            closeSession(session);
1027                    }
1028            }
1029    
1030            protected ShoppingCategory filterGetByGroupId_PrevAndNext(Session session,
1031                    ShoppingCategory shoppingCategory, long groupId,
1032                    OrderByComparator orderByComparator, boolean previous) {
1033                    StringBundler query = null;
1034    
1035                    if (orderByComparator != null) {
1036                            query = new StringBundler(6 +
1037                                            (orderByComparator.getOrderByFields().length * 6));
1038                    }
1039                    else {
1040                            query = new StringBundler(3);
1041                    }
1042    
1043                    if (getDB().isSupportsInlineDistinct()) {
1044                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_WHERE);
1045                    }
1046                    else {
1047                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1048                    }
1049    
1050                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1051    
1052                    if (!getDB().isSupportsInlineDistinct()) {
1053                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1054                    }
1055    
1056                    if (orderByComparator != null) {
1057                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1058    
1059                            if (orderByConditionFields.length > 0) {
1060                                    query.append(WHERE_AND);
1061                            }
1062    
1063                            for (int i = 0; i < orderByConditionFields.length; i++) {
1064                                    if (getDB().isSupportsInlineDistinct()) {
1065                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1066                                    }
1067                                    else {
1068                                            query.append(_ORDER_BY_ENTITY_TABLE);
1069                                    }
1070    
1071                                    query.append(orderByConditionFields[i]);
1072    
1073                                    if ((i + 1) < orderByConditionFields.length) {
1074                                            if (orderByComparator.isAscending() ^ previous) {
1075                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1076                                            }
1077                                            else {
1078                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1079                                            }
1080                                    }
1081                                    else {
1082                                            if (orderByComparator.isAscending() ^ previous) {
1083                                                    query.append(WHERE_GREATER_THAN);
1084                                            }
1085                                            else {
1086                                                    query.append(WHERE_LESSER_THAN);
1087                                            }
1088                                    }
1089                            }
1090    
1091                            query.append(ORDER_BY_CLAUSE);
1092    
1093                            String[] orderByFields = orderByComparator.getOrderByFields();
1094    
1095                            for (int i = 0; i < orderByFields.length; i++) {
1096                                    if (getDB().isSupportsInlineDistinct()) {
1097                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1098                                    }
1099                                    else {
1100                                            query.append(_ORDER_BY_ENTITY_TABLE);
1101                                    }
1102    
1103                                    query.append(orderByFields[i]);
1104    
1105                                    if ((i + 1) < orderByFields.length) {
1106                                            if (orderByComparator.isAscending() ^ previous) {
1107                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1108                                            }
1109                                            else {
1110                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1111                                            }
1112                                    }
1113                                    else {
1114                                            if (orderByComparator.isAscending() ^ previous) {
1115                                                    query.append(ORDER_BY_ASC);
1116                                            }
1117                                            else {
1118                                                    query.append(ORDER_BY_DESC);
1119                                            }
1120                                    }
1121                            }
1122                    }
1123    
1124                    else {
1125                            if (getDB().isSupportsInlineDistinct()) {
1126                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_JPQL);
1127                            }
1128                            else {
1129                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_SQL);
1130                            }
1131                    }
1132    
1133                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1134                                    ShoppingCategory.class.getName(),
1135                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1136    
1137                    SQLQuery q = session.createSQLQuery(sql);
1138    
1139                    q.setFirstResult(0);
1140                    q.setMaxResults(2);
1141    
1142                    if (getDB().isSupportsInlineDistinct()) {
1143                            q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingCategoryImpl.class);
1144                    }
1145                    else {
1146                            q.addEntity(_FILTER_ENTITY_TABLE, ShoppingCategoryImpl.class);
1147                    }
1148    
1149                    QueryPos qPos = QueryPos.getInstance(q);
1150    
1151                    qPos.add(groupId);
1152    
1153                    if (orderByComparator != null) {
1154                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingCategory);
1155    
1156                            for (Object value : values) {
1157                                    qPos.add(value);
1158                            }
1159                    }
1160    
1161                    List<ShoppingCategory> list = q.list();
1162    
1163                    if (list.size() == 2) {
1164                            return list.get(1);
1165                    }
1166                    else {
1167                            return null;
1168                    }
1169            }
1170    
1171            /**
1172             * Returns all the shopping categories where groupId = &#63; and parentCategoryId = &#63;.
1173             *
1174             * @param groupId the group ID
1175             * @param parentCategoryId the parent category ID
1176             * @return the matching shopping categories
1177             * @throws SystemException if a system exception occurred
1178             */
1179            public List<ShoppingCategory> findByG_P(long groupId, long parentCategoryId)
1180                    throws SystemException {
1181                    return findByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS,
1182                            QueryUtil.ALL_POS, null);
1183            }
1184    
1185            /**
1186             * Returns a range of all the shopping categories where groupId = &#63; and parentCategoryId = &#63;.
1187             *
1188             * <p>
1189             * 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.
1190             * </p>
1191             *
1192             * @param groupId the group ID
1193             * @param parentCategoryId the parent category ID
1194             * @param start the lower bound of the range of shopping categories
1195             * @param end the upper bound of the range of shopping categories (not inclusive)
1196             * @return the range of matching shopping categories
1197             * @throws SystemException if a system exception occurred
1198             */
1199            public List<ShoppingCategory> findByG_P(long groupId,
1200                    long parentCategoryId, int start, int end) throws SystemException {
1201                    return findByG_P(groupId, parentCategoryId, start, end, null);
1202            }
1203    
1204            /**
1205             * Returns an ordered range of all the shopping categories where groupId = &#63; and parentCategoryId = &#63;.
1206             *
1207             * <p>
1208             * 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.
1209             * </p>
1210             *
1211             * @param groupId the group ID
1212             * @param parentCategoryId the parent category ID
1213             * @param start the lower bound of the range of shopping categories
1214             * @param end the upper bound of the range of shopping categories (not inclusive)
1215             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1216             * @return the ordered range of matching shopping categories
1217             * @throws SystemException if a system exception occurred
1218             */
1219            public List<ShoppingCategory> findByG_P(long groupId,
1220                    long parentCategoryId, int start, int end,
1221                    OrderByComparator orderByComparator) throws SystemException {
1222                    FinderPath finderPath = null;
1223                    Object[] finderArgs = null;
1224    
1225                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1226                                    (orderByComparator == null)) {
1227                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1228                            finderArgs = new Object[] { groupId, parentCategoryId };
1229                    }
1230                    else {
1231                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1232                            finderArgs = new Object[] {
1233                                            groupId, parentCategoryId,
1234                                            
1235                                            start, end, orderByComparator
1236                                    };
1237                    }
1238    
1239                    List<ShoppingCategory> list = (List<ShoppingCategory>)FinderCacheUtil.getResult(finderPath,
1240                                    finderArgs, this);
1241    
1242                    if (list == null) {
1243                            StringBundler query = null;
1244    
1245                            if (orderByComparator != null) {
1246                                    query = new StringBundler(4 +
1247                                                    (orderByComparator.getOrderByFields().length * 3));
1248                            }
1249                            else {
1250                                    query = new StringBundler(4);
1251                            }
1252    
1253                            query.append(_SQL_SELECT_SHOPPINGCATEGORY_WHERE);
1254    
1255                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1256    
1257                            query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
1258    
1259                            if (orderByComparator != null) {
1260                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1261                                            orderByComparator);
1262                            }
1263    
1264                            else {
1265                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_JPQL);
1266                            }
1267    
1268                            String sql = query.toString();
1269    
1270                            Session session = null;
1271    
1272                            try {
1273                                    session = openSession();
1274    
1275                                    Query q = session.createQuery(sql);
1276    
1277                                    QueryPos qPos = QueryPos.getInstance(q);
1278    
1279                                    qPos.add(groupId);
1280    
1281                                    qPos.add(parentCategoryId);
1282    
1283                                    list = (List<ShoppingCategory>)QueryUtil.list(q, getDialect(),
1284                                                    start, end);
1285                            }
1286                            catch (Exception e) {
1287                                    throw processException(e);
1288                            }
1289                            finally {
1290                                    if (list == null) {
1291                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1292                                    }
1293                                    else {
1294                                            cacheResult(list);
1295    
1296                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1297                                    }
1298    
1299                                    closeSession(session);
1300                            }
1301                    }
1302    
1303                    return list;
1304            }
1305    
1306            /**
1307             * Returns the first shopping category in the ordered set where groupId = &#63; and parentCategoryId = &#63;.
1308             *
1309             * <p>
1310             * 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.
1311             * </p>
1312             *
1313             * @param groupId the group ID
1314             * @param parentCategoryId the parent category ID
1315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1316             * @return the first matching shopping category
1317             * @throws com.liferay.portlet.shopping.NoSuchCategoryException if a matching shopping category could not be found
1318             * @throws SystemException if a system exception occurred
1319             */
1320            public ShoppingCategory findByG_P_First(long groupId,
1321                    long parentCategoryId, OrderByComparator orderByComparator)
1322                    throws NoSuchCategoryException, SystemException {
1323                    List<ShoppingCategory> list = findByG_P(groupId, parentCategoryId, 0,
1324                                    1, orderByComparator);
1325    
1326                    if (list.isEmpty()) {
1327                            StringBundler msg = new StringBundler(6);
1328    
1329                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1330    
1331                            msg.append("groupId=");
1332                            msg.append(groupId);
1333    
1334                            msg.append(", parentCategoryId=");
1335                            msg.append(parentCategoryId);
1336    
1337                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1338    
1339                            throw new NoSuchCategoryException(msg.toString());
1340                    }
1341                    else {
1342                            return list.get(0);
1343                    }
1344            }
1345    
1346            /**
1347             * Returns the last shopping category in the ordered set where groupId = &#63; and parentCategoryId = &#63;.
1348             *
1349             * <p>
1350             * 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.
1351             * </p>
1352             *
1353             * @param groupId the group ID
1354             * @param parentCategoryId the parent category ID
1355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1356             * @return the last matching shopping category
1357             * @throws com.liferay.portlet.shopping.NoSuchCategoryException if a matching shopping category could not be found
1358             * @throws SystemException if a system exception occurred
1359             */
1360            public ShoppingCategory findByG_P_Last(long groupId, long parentCategoryId,
1361                    OrderByComparator orderByComparator)
1362                    throws NoSuchCategoryException, SystemException {
1363                    int count = countByG_P(groupId, parentCategoryId);
1364    
1365                    List<ShoppingCategory> list = findByG_P(groupId, parentCategoryId,
1366                                    count - 1, count, orderByComparator);
1367    
1368                    if (list.isEmpty()) {
1369                            StringBundler msg = new StringBundler(6);
1370    
1371                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1372    
1373                            msg.append("groupId=");
1374                            msg.append(groupId);
1375    
1376                            msg.append(", parentCategoryId=");
1377                            msg.append(parentCategoryId);
1378    
1379                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1380    
1381                            throw new NoSuchCategoryException(msg.toString());
1382                    }
1383                    else {
1384                            return list.get(0);
1385                    }
1386            }
1387    
1388            /**
1389             * Returns the shopping categories before and after the current shopping category in the ordered set where groupId = &#63; and parentCategoryId = &#63;.
1390             *
1391             * <p>
1392             * 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.
1393             * </p>
1394             *
1395             * @param categoryId the primary key of the current shopping category
1396             * @param groupId the group ID
1397             * @param parentCategoryId the parent category ID
1398             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1399             * @return the previous, current, and next shopping category
1400             * @throws com.liferay.portlet.shopping.NoSuchCategoryException if a shopping category with the primary key could not be found
1401             * @throws SystemException if a system exception occurred
1402             */
1403            public ShoppingCategory[] findByG_P_PrevAndNext(long categoryId,
1404                    long groupId, long parentCategoryId, OrderByComparator orderByComparator)
1405                    throws NoSuchCategoryException, SystemException {
1406                    ShoppingCategory shoppingCategory = findByPrimaryKey(categoryId);
1407    
1408                    Session session = null;
1409    
1410                    try {
1411                            session = openSession();
1412    
1413                            ShoppingCategory[] array = new ShoppingCategoryImpl[3];
1414    
1415                            array[0] = getByG_P_PrevAndNext(session, shoppingCategory, groupId,
1416                                            parentCategoryId, orderByComparator, true);
1417    
1418                            array[1] = shoppingCategory;
1419    
1420                            array[2] = getByG_P_PrevAndNext(session, shoppingCategory, groupId,
1421                                            parentCategoryId, orderByComparator, false);
1422    
1423                            return array;
1424                    }
1425                    catch (Exception e) {
1426                            throw processException(e);
1427                    }
1428                    finally {
1429                            closeSession(session);
1430                    }
1431            }
1432    
1433            protected ShoppingCategory getByG_P_PrevAndNext(Session session,
1434                    ShoppingCategory shoppingCategory, long groupId, long parentCategoryId,
1435                    OrderByComparator orderByComparator, boolean previous) {
1436                    StringBundler query = null;
1437    
1438                    if (orderByComparator != null) {
1439                            query = new StringBundler(6 +
1440                                            (orderByComparator.getOrderByFields().length * 6));
1441                    }
1442                    else {
1443                            query = new StringBundler(3);
1444                    }
1445    
1446                    query.append(_SQL_SELECT_SHOPPINGCATEGORY_WHERE);
1447    
1448                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1449    
1450                    query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
1451    
1452                    if (orderByComparator != null) {
1453                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1454    
1455                            if (orderByConditionFields.length > 0) {
1456                                    query.append(WHERE_AND);
1457                            }
1458    
1459                            for (int i = 0; i < orderByConditionFields.length; i++) {
1460                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1461                                    query.append(orderByConditionFields[i]);
1462    
1463                                    if ((i + 1) < orderByConditionFields.length) {
1464                                            if (orderByComparator.isAscending() ^ previous) {
1465                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1466                                            }
1467                                            else {
1468                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1469                                            }
1470                                    }
1471                                    else {
1472                                            if (orderByComparator.isAscending() ^ previous) {
1473                                                    query.append(WHERE_GREATER_THAN);
1474                                            }
1475                                            else {
1476                                                    query.append(WHERE_LESSER_THAN);
1477                                            }
1478                                    }
1479                            }
1480    
1481                            query.append(ORDER_BY_CLAUSE);
1482    
1483                            String[] orderByFields = orderByComparator.getOrderByFields();
1484    
1485                            for (int i = 0; i < orderByFields.length; i++) {
1486                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1487                                    query.append(orderByFields[i]);
1488    
1489                                    if ((i + 1) < orderByFields.length) {
1490                                            if (orderByComparator.isAscending() ^ previous) {
1491                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1492                                            }
1493                                            else {
1494                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1495                                            }
1496                                    }
1497                                    else {
1498                                            if (orderByComparator.isAscending() ^ previous) {
1499                                                    query.append(ORDER_BY_ASC);
1500                                            }
1501                                            else {
1502                                                    query.append(ORDER_BY_DESC);
1503                                            }
1504                                    }
1505                            }
1506                    }
1507    
1508                    else {
1509                            query.append(ShoppingCategoryModelImpl.ORDER_BY_JPQL);
1510                    }
1511    
1512                    String sql = query.toString();
1513    
1514                    Query q = session.createQuery(sql);
1515    
1516                    q.setFirstResult(0);
1517                    q.setMaxResults(2);
1518    
1519                    QueryPos qPos = QueryPos.getInstance(q);
1520    
1521                    qPos.add(groupId);
1522    
1523                    qPos.add(parentCategoryId);
1524    
1525                    if (orderByComparator != null) {
1526                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingCategory);
1527    
1528                            for (Object value : values) {
1529                                    qPos.add(value);
1530                            }
1531                    }
1532    
1533                    List<ShoppingCategory> list = q.list();
1534    
1535                    if (list.size() == 2) {
1536                            return list.get(1);
1537                    }
1538                    else {
1539                            return null;
1540                    }
1541            }
1542    
1543            /**
1544             * Returns all the shopping categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63;.
1545             *
1546             * @param groupId the group ID
1547             * @param parentCategoryId the parent category ID
1548             * @return the matching shopping categories that the user has permission to view
1549             * @throws SystemException if a system exception occurred
1550             */
1551            public List<ShoppingCategory> filterFindByG_P(long groupId,
1552                    long parentCategoryId) throws SystemException {
1553                    return filterFindByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS,
1554                            QueryUtil.ALL_POS, null);
1555            }
1556    
1557            /**
1558             * Returns a range of all the shopping categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63;.
1559             *
1560             * <p>
1561             * 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.
1562             * </p>
1563             *
1564             * @param groupId the group ID
1565             * @param parentCategoryId the parent category ID
1566             * @param start the lower bound of the range of shopping categories
1567             * @param end the upper bound of the range of shopping categories (not inclusive)
1568             * @return the range of matching shopping categories that the user has permission to view
1569             * @throws SystemException if a system exception occurred
1570             */
1571            public List<ShoppingCategory> filterFindByG_P(long groupId,
1572                    long parentCategoryId, int start, int end) throws SystemException {
1573                    return filterFindByG_P(groupId, parentCategoryId, start, end, null);
1574            }
1575    
1576            /**
1577             * Returns an ordered range of all the shopping categories that the user has permissions to view where groupId = &#63; and parentCategoryId = &#63;.
1578             *
1579             * <p>
1580             * 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.
1581             * </p>
1582             *
1583             * @param groupId the group ID
1584             * @param parentCategoryId the parent category ID
1585             * @param start the lower bound of the range of shopping categories
1586             * @param end the upper bound of the range of shopping categories (not inclusive)
1587             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1588             * @return the ordered range of matching shopping categories that the user has permission to view
1589             * @throws SystemException if a system exception occurred
1590             */
1591            public List<ShoppingCategory> filterFindByG_P(long groupId,
1592                    long parentCategoryId, int start, int end,
1593                    OrderByComparator orderByComparator) throws SystemException {
1594                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1595                            return findByG_P(groupId, parentCategoryId, start, end,
1596                                    orderByComparator);
1597                    }
1598    
1599                    StringBundler query = null;
1600    
1601                    if (orderByComparator != null) {
1602                            query = new StringBundler(4 +
1603                                            (orderByComparator.getOrderByFields().length * 3));
1604                    }
1605                    else {
1606                            query = new StringBundler(4);
1607                    }
1608    
1609                    if (getDB().isSupportsInlineDistinct()) {
1610                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_WHERE);
1611                    }
1612                    else {
1613                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1614                    }
1615    
1616                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1617    
1618                    query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
1619    
1620                    if (!getDB().isSupportsInlineDistinct()) {
1621                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1622                    }
1623    
1624                    if (orderByComparator != null) {
1625                            if (getDB().isSupportsInlineDistinct()) {
1626                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1627                                            orderByComparator);
1628                            }
1629                            else {
1630                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1631                                            orderByComparator);
1632                            }
1633                    }
1634    
1635                    else {
1636                            if (getDB().isSupportsInlineDistinct()) {
1637                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_JPQL);
1638                            }
1639                            else {
1640                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_SQL);
1641                            }
1642                    }
1643    
1644                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1645                                    ShoppingCategory.class.getName(),
1646                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1647    
1648                    Session session = null;
1649    
1650                    try {
1651                            session = openSession();
1652    
1653                            SQLQuery q = session.createSQLQuery(sql);
1654    
1655                            if (getDB().isSupportsInlineDistinct()) {
1656                                    q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingCategoryImpl.class);
1657                            }
1658                            else {
1659                                    q.addEntity(_FILTER_ENTITY_TABLE, ShoppingCategoryImpl.class);
1660                            }
1661    
1662                            QueryPos qPos = QueryPos.getInstance(q);
1663    
1664                            qPos.add(groupId);
1665    
1666                            qPos.add(parentCategoryId);
1667    
1668                            return (List<ShoppingCategory>)QueryUtil.list(q, getDialect(),
1669                                    start, end);
1670                    }
1671                    catch (Exception e) {
1672                            throw processException(e);
1673                    }
1674                    finally {
1675                            closeSession(session);
1676                    }
1677            }
1678    
1679            /**
1680             * 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;.
1681             *
1682             * @param categoryId the primary key of the current shopping category
1683             * @param groupId the group ID
1684             * @param parentCategoryId the parent category ID
1685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1686             * @return the previous, current, and next shopping category
1687             * @throws com.liferay.portlet.shopping.NoSuchCategoryException if a shopping category with the primary key could not be found
1688             * @throws SystemException if a system exception occurred
1689             */
1690            public ShoppingCategory[] filterFindByG_P_PrevAndNext(long categoryId,
1691                    long groupId, long parentCategoryId, OrderByComparator orderByComparator)
1692                    throws NoSuchCategoryException, SystemException {
1693                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1694                            return findByG_P_PrevAndNext(categoryId, groupId, parentCategoryId,
1695                                    orderByComparator);
1696                    }
1697    
1698                    ShoppingCategory shoppingCategory = findByPrimaryKey(categoryId);
1699    
1700                    Session session = null;
1701    
1702                    try {
1703                            session = openSession();
1704    
1705                            ShoppingCategory[] array = new ShoppingCategoryImpl[3];
1706    
1707                            array[0] = filterGetByG_P_PrevAndNext(session, shoppingCategory,
1708                                            groupId, parentCategoryId, orderByComparator, true);
1709    
1710                            array[1] = shoppingCategory;
1711    
1712                            array[2] = filterGetByG_P_PrevAndNext(session, shoppingCategory,
1713                                            groupId, parentCategoryId, orderByComparator, false);
1714    
1715                            return array;
1716                    }
1717                    catch (Exception e) {
1718                            throw processException(e);
1719                    }
1720                    finally {
1721                            closeSession(session);
1722                    }
1723            }
1724    
1725            protected ShoppingCategory filterGetByG_P_PrevAndNext(Session session,
1726                    ShoppingCategory shoppingCategory, long groupId, long parentCategoryId,
1727                    OrderByComparator orderByComparator, boolean previous) {
1728                    StringBundler query = null;
1729    
1730                    if (orderByComparator != null) {
1731                            query = new StringBundler(6 +
1732                                            (orderByComparator.getOrderByFields().length * 6));
1733                    }
1734                    else {
1735                            query = new StringBundler(3);
1736                    }
1737    
1738                    if (getDB().isSupportsInlineDistinct()) {
1739                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_WHERE);
1740                    }
1741                    else {
1742                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1743                    }
1744    
1745                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1746    
1747                    query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
1748    
1749                    if (!getDB().isSupportsInlineDistinct()) {
1750                            query.append(_FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1751                    }
1752    
1753                    if (orderByComparator != null) {
1754                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1755    
1756                            if (orderByConditionFields.length > 0) {
1757                                    query.append(WHERE_AND);
1758                            }
1759    
1760                            for (int i = 0; i < orderByConditionFields.length; i++) {
1761                                    if (getDB().isSupportsInlineDistinct()) {
1762                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1763                                    }
1764                                    else {
1765                                            query.append(_ORDER_BY_ENTITY_TABLE);
1766                                    }
1767    
1768                                    query.append(orderByConditionFields[i]);
1769    
1770                                    if ((i + 1) < orderByConditionFields.length) {
1771                                            if (orderByComparator.isAscending() ^ previous) {
1772                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1773                                            }
1774                                            else {
1775                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1776                                            }
1777                                    }
1778                                    else {
1779                                            if (orderByComparator.isAscending() ^ previous) {
1780                                                    query.append(WHERE_GREATER_THAN);
1781                                            }
1782                                            else {
1783                                                    query.append(WHERE_LESSER_THAN);
1784                                            }
1785                                    }
1786                            }
1787    
1788                            query.append(ORDER_BY_CLAUSE);
1789    
1790                            String[] orderByFields = orderByComparator.getOrderByFields();
1791    
1792                            for (int i = 0; i < orderByFields.length; i++) {
1793                                    if (getDB().isSupportsInlineDistinct()) {
1794                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1795                                    }
1796                                    else {
1797                                            query.append(_ORDER_BY_ENTITY_TABLE);
1798                                    }
1799    
1800                                    query.append(orderByFields[i]);
1801    
1802                                    if ((i + 1) < orderByFields.length) {
1803                                            if (orderByComparator.isAscending() ^ previous) {
1804                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1805                                            }
1806                                            else {
1807                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1808                                            }
1809                                    }
1810                                    else {
1811                                            if (orderByComparator.isAscending() ^ previous) {
1812                                                    query.append(ORDER_BY_ASC);
1813                                            }
1814                                            else {
1815                                                    query.append(ORDER_BY_DESC);
1816                                            }
1817                                    }
1818                            }
1819                    }
1820    
1821                    else {
1822                            if (getDB().isSupportsInlineDistinct()) {
1823                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_JPQL);
1824                            }
1825                            else {
1826                                    query.append(ShoppingCategoryModelImpl.ORDER_BY_SQL);
1827                            }
1828                    }
1829    
1830                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1831                                    ShoppingCategory.class.getName(),
1832                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1833    
1834                    SQLQuery q = session.createSQLQuery(sql);
1835    
1836                    q.setFirstResult(0);
1837                    q.setMaxResults(2);
1838    
1839                    if (getDB().isSupportsInlineDistinct()) {
1840                            q.addEntity(_FILTER_ENTITY_ALIAS, ShoppingCategoryImpl.class);
1841                    }
1842                    else {
1843                            q.addEntity(_FILTER_ENTITY_TABLE, ShoppingCategoryImpl.class);
1844                    }
1845    
1846                    QueryPos qPos = QueryPos.getInstance(q);
1847    
1848                    qPos.add(groupId);
1849    
1850                    qPos.add(parentCategoryId);
1851    
1852                    if (orderByComparator != null) {
1853                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingCategory);
1854    
1855                            for (Object value : values) {
1856                                    qPos.add(value);
1857                            }
1858                    }
1859    
1860                    List<ShoppingCategory> list = q.list();
1861    
1862                    if (list.size() == 2) {
1863                            return list.get(1);
1864                    }
1865                    else {
1866                            return null;
1867                    }
1868            }
1869    
1870            /**
1871             * Returns all the shopping categories.
1872             *
1873             * @return the shopping categories
1874             * @throws SystemException if a system exception occurred
1875             */
1876            public List<ShoppingCategory> findAll() throws SystemException {
1877                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1878            }
1879    
1880            /**
1881             * Returns a range of all the shopping categories.
1882             *
1883             * <p>
1884             * 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.
1885             * </p>
1886             *
1887             * @param start the lower bound of the range of shopping categories
1888             * @param end the upper bound of the range of shopping categories (not inclusive)
1889             * @return the range of shopping categories
1890             * @throws SystemException if a system exception occurred
1891             */
1892            public List<ShoppingCategory> findAll(int start, int end)
1893                    throws SystemException {
1894                    return findAll(start, end, null);
1895            }
1896    
1897            /**
1898             * Returns an ordered range of all the shopping categories.
1899             *
1900             * <p>
1901             * 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.
1902             * </p>
1903             *
1904             * @param start the lower bound of the range of shopping categories
1905             * @param end the upper bound of the range of shopping categories (not inclusive)
1906             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1907             * @return the ordered range of shopping categories
1908             * @throws SystemException if a system exception occurred
1909             */
1910            public List<ShoppingCategory> findAll(int start, int end,
1911                    OrderByComparator orderByComparator) throws SystemException {
1912                    FinderPath finderPath = null;
1913                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1914    
1915                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1916                                    (orderByComparator == null)) {
1917                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1918                            finderArgs = FINDER_ARGS_EMPTY;
1919                    }
1920                    else {
1921                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1922                            finderArgs = new Object[] { start, end, orderByComparator };
1923                    }
1924    
1925                    List<ShoppingCategory> list = (List<ShoppingCategory>)FinderCacheUtil.getResult(finderPath,
1926                                    finderArgs, this);
1927    
1928                    if (list == null) {
1929                            StringBundler query = null;
1930                            String sql = null;
1931    
1932                            if (orderByComparator != null) {
1933                                    query = new StringBundler(2 +
1934                                                    (orderByComparator.getOrderByFields().length * 3));
1935    
1936                                    query.append(_SQL_SELECT_SHOPPINGCATEGORY);
1937    
1938                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1939                                            orderByComparator);
1940    
1941                                    sql = query.toString();
1942                            }
1943                            else {
1944                                    sql = _SQL_SELECT_SHOPPINGCATEGORY.concat(ShoppingCategoryModelImpl.ORDER_BY_JPQL);
1945                            }
1946    
1947                            Session session = null;
1948    
1949                            try {
1950                                    session = openSession();
1951    
1952                                    Query q = session.createQuery(sql);
1953    
1954                                    if (orderByComparator == null) {
1955                                            list = (List<ShoppingCategory>)QueryUtil.list(q,
1956                                                            getDialect(), start, end, false);
1957    
1958                                            Collections.sort(list);
1959                                    }
1960                                    else {
1961                                            list = (List<ShoppingCategory>)QueryUtil.list(q,
1962                                                            getDialect(), start, end);
1963                                    }
1964                            }
1965                            catch (Exception e) {
1966                                    throw processException(e);
1967                            }
1968                            finally {
1969                                    if (list == null) {
1970                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1971                                    }
1972                                    else {
1973                                            cacheResult(list);
1974    
1975                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1976                                    }
1977    
1978                                    closeSession(session);
1979                            }
1980                    }
1981    
1982                    return list;
1983            }
1984    
1985            /**
1986             * Removes all the shopping categories where groupId = &#63; from the database.
1987             *
1988             * @param groupId the group ID
1989             * @throws SystemException if a system exception occurred
1990             */
1991            public void removeByGroupId(long groupId) throws SystemException {
1992                    for (ShoppingCategory shoppingCategory : findByGroupId(groupId)) {
1993                            remove(shoppingCategory);
1994                    }
1995            }
1996    
1997            /**
1998             * Removes all the shopping categories where groupId = &#63; and parentCategoryId = &#63; from the database.
1999             *
2000             * @param groupId the group ID
2001             * @param parentCategoryId the parent category ID
2002             * @throws SystemException if a system exception occurred
2003             */
2004            public void removeByG_P(long groupId, long parentCategoryId)
2005                    throws SystemException {
2006                    for (ShoppingCategory shoppingCategory : findByG_P(groupId,
2007                                    parentCategoryId)) {
2008                            remove(shoppingCategory);
2009                    }
2010            }
2011    
2012            /**
2013             * Removes all the shopping categories from the database.
2014             *
2015             * @throws SystemException if a system exception occurred
2016             */
2017            public void removeAll() throws SystemException {
2018                    for (ShoppingCategory shoppingCategory : findAll()) {
2019                            remove(shoppingCategory);
2020                    }
2021            }
2022    
2023            /**
2024             * Returns the number of shopping categories where groupId = &#63;.
2025             *
2026             * @param groupId the group ID
2027             * @return the number of matching shopping categories
2028             * @throws SystemException if a system exception occurred
2029             */
2030            public int countByGroupId(long groupId) throws SystemException {
2031                    Object[] finderArgs = new Object[] { groupId };
2032    
2033                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2034                                    finderArgs, this);
2035    
2036                    if (count == null) {
2037                            StringBundler query = new StringBundler(2);
2038    
2039                            query.append(_SQL_COUNT_SHOPPINGCATEGORY_WHERE);
2040    
2041                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2042    
2043                            String sql = query.toString();
2044    
2045                            Session session = null;
2046    
2047                            try {
2048                                    session = openSession();
2049    
2050                                    Query q = session.createQuery(sql);
2051    
2052                                    QueryPos qPos = QueryPos.getInstance(q);
2053    
2054                                    qPos.add(groupId);
2055    
2056                                    count = (Long)q.uniqueResult();
2057                            }
2058                            catch (Exception e) {
2059                                    throw processException(e);
2060                            }
2061                            finally {
2062                                    if (count == null) {
2063                                            count = Long.valueOf(0);
2064                                    }
2065    
2066                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2067                                            finderArgs, count);
2068    
2069                                    closeSession(session);
2070                            }
2071                    }
2072    
2073                    return count.intValue();
2074            }
2075    
2076            /**
2077             * Returns the number of shopping categories that the user has permission to view where groupId = &#63;.
2078             *
2079             * @param groupId the group ID
2080             * @return the number of matching shopping categories that the user has permission to view
2081             * @throws SystemException if a system exception occurred
2082             */
2083            public int filterCountByGroupId(long groupId) throws SystemException {
2084                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2085                            return countByGroupId(groupId);
2086                    }
2087    
2088                    StringBundler query = new StringBundler(2);
2089    
2090                    query.append(_FILTER_SQL_COUNT_SHOPPINGCATEGORY_WHERE);
2091    
2092                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2093    
2094                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2095                                    ShoppingCategory.class.getName(),
2096                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2097    
2098                    Session session = null;
2099    
2100                    try {
2101                            session = openSession();
2102    
2103                            SQLQuery q = session.createSQLQuery(sql);
2104    
2105                            q.addScalar(COUNT_COLUMN_NAME,
2106                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2107    
2108                            QueryPos qPos = QueryPos.getInstance(q);
2109    
2110                            qPos.add(groupId);
2111    
2112                            Long count = (Long)q.uniqueResult();
2113    
2114                            return count.intValue();
2115                    }
2116                    catch (Exception e) {
2117                            throw processException(e);
2118                    }
2119                    finally {
2120                            closeSession(session);
2121                    }
2122            }
2123    
2124            /**
2125             * Returns the number of shopping categories where groupId = &#63; and parentCategoryId = &#63;.
2126             *
2127             * @param groupId the group ID
2128             * @param parentCategoryId the parent category ID
2129             * @return the number of matching shopping categories
2130             * @throws SystemException if a system exception occurred
2131             */
2132            public int countByG_P(long groupId, long parentCategoryId)
2133                    throws SystemException {
2134                    Object[] finderArgs = new Object[] { groupId, parentCategoryId };
2135    
2136                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2137                                    finderArgs, this);
2138    
2139                    if (count == null) {
2140                            StringBundler query = new StringBundler(3);
2141    
2142                            query.append(_SQL_COUNT_SHOPPINGCATEGORY_WHERE);
2143    
2144                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2145    
2146                            query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
2147    
2148                            String sql = query.toString();
2149    
2150                            Session session = null;
2151    
2152                            try {
2153                                    session = openSession();
2154    
2155                                    Query q = session.createQuery(sql);
2156    
2157                                    QueryPos qPos = QueryPos.getInstance(q);
2158    
2159                                    qPos.add(groupId);
2160    
2161                                    qPos.add(parentCategoryId);
2162    
2163                                    count = (Long)q.uniqueResult();
2164                            }
2165                            catch (Exception e) {
2166                                    throw processException(e);
2167                            }
2168                            finally {
2169                                    if (count == null) {
2170                                            count = Long.valueOf(0);
2171                                    }
2172    
2173                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2174                                            count);
2175    
2176                                    closeSession(session);
2177                            }
2178                    }
2179    
2180                    return count.intValue();
2181            }
2182    
2183            /**
2184             * Returns the number of shopping categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63;.
2185             *
2186             * @param groupId the group ID
2187             * @param parentCategoryId the parent category ID
2188             * @return the number of matching shopping categories that the user has permission to view
2189             * @throws SystemException if a system exception occurred
2190             */
2191            public int filterCountByG_P(long groupId, long parentCategoryId)
2192                    throws SystemException {
2193                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2194                            return countByG_P(groupId, parentCategoryId);
2195                    }
2196    
2197                    StringBundler query = new StringBundler(3);
2198    
2199                    query.append(_FILTER_SQL_COUNT_SHOPPINGCATEGORY_WHERE);
2200    
2201                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2202    
2203                    query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
2204    
2205                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2206                                    ShoppingCategory.class.getName(),
2207                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2208    
2209                    Session session = null;
2210    
2211                    try {
2212                            session = openSession();
2213    
2214                            SQLQuery q = session.createSQLQuery(sql);
2215    
2216                            q.addScalar(COUNT_COLUMN_NAME,
2217                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2218    
2219                            QueryPos qPos = QueryPos.getInstance(q);
2220    
2221                            qPos.add(groupId);
2222    
2223                            qPos.add(parentCategoryId);
2224    
2225                            Long count = (Long)q.uniqueResult();
2226    
2227                            return count.intValue();
2228                    }
2229                    catch (Exception e) {
2230                            throw processException(e);
2231                    }
2232                    finally {
2233                            closeSession(session);
2234                    }
2235            }
2236    
2237            /**
2238             * Returns the number of shopping categories.
2239             *
2240             * @return the number of shopping categories
2241             * @throws SystemException if a system exception occurred
2242             */
2243            public int countAll() throws SystemException {
2244                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2245                                    FINDER_ARGS_EMPTY, this);
2246    
2247                    if (count == null) {
2248                            Session session = null;
2249    
2250                            try {
2251                                    session = openSession();
2252    
2253                                    Query q = session.createQuery(_SQL_COUNT_SHOPPINGCATEGORY);
2254    
2255                                    count = (Long)q.uniqueResult();
2256                            }
2257                            catch (Exception e) {
2258                                    throw processException(e);
2259                            }
2260                            finally {
2261                                    if (count == null) {
2262                                            count = Long.valueOf(0);
2263                                    }
2264    
2265                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2266                                            FINDER_ARGS_EMPTY, count);
2267    
2268                                    closeSession(session);
2269                            }
2270                    }
2271    
2272                    return count.intValue();
2273            }
2274    
2275            /**
2276             * Initializes the shopping category persistence.
2277             */
2278            public void afterPropertiesSet() {
2279                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2280                                            com.liferay.portal.util.PropsUtil.get(
2281                                                    "value.object.listener.com.liferay.portlet.shopping.model.ShoppingCategory")));
2282    
2283                    if (listenerClassNames.length > 0) {
2284                            try {
2285                                    List<ModelListener<ShoppingCategory>> listenersList = new ArrayList<ModelListener<ShoppingCategory>>();
2286    
2287                                    for (String listenerClassName : listenerClassNames) {
2288                                            listenersList.add((ModelListener<ShoppingCategory>)InstanceFactory.newInstance(
2289                                                            listenerClassName));
2290                                    }
2291    
2292                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2293                            }
2294                            catch (Exception e) {
2295                                    _log.error(e);
2296                            }
2297                    }
2298            }
2299    
2300            public void destroy() {
2301                    EntityCacheUtil.removeCache(ShoppingCategoryImpl.class.getName());
2302                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2303                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2304            }
2305    
2306            @BeanReference(type = ShoppingCartPersistence.class)
2307            protected ShoppingCartPersistence shoppingCartPersistence;
2308            @BeanReference(type = ShoppingCategoryPersistence.class)
2309            protected ShoppingCategoryPersistence shoppingCategoryPersistence;
2310            @BeanReference(type = ShoppingCouponPersistence.class)
2311            protected ShoppingCouponPersistence shoppingCouponPersistence;
2312            @BeanReference(type = ShoppingItemPersistence.class)
2313            protected ShoppingItemPersistence shoppingItemPersistence;
2314            @BeanReference(type = ShoppingItemFieldPersistence.class)
2315            protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
2316            @BeanReference(type = ShoppingItemPricePersistence.class)
2317            protected ShoppingItemPricePersistence shoppingItemPricePersistence;
2318            @BeanReference(type = ShoppingOrderPersistence.class)
2319            protected ShoppingOrderPersistence shoppingOrderPersistence;
2320            @BeanReference(type = ShoppingOrderItemPersistence.class)
2321            protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
2322            @BeanReference(type = ResourcePersistence.class)
2323            protected ResourcePersistence resourcePersistence;
2324            @BeanReference(type = UserPersistence.class)
2325            protected UserPersistence userPersistence;
2326            private static final String _SQL_SELECT_SHOPPINGCATEGORY = "SELECT shoppingCategory FROM ShoppingCategory shoppingCategory";
2327            private static final String _SQL_SELECT_SHOPPINGCATEGORY_WHERE = "SELECT shoppingCategory FROM ShoppingCategory shoppingCategory WHERE ";
2328            private static final String _SQL_COUNT_SHOPPINGCATEGORY = "SELECT COUNT(shoppingCategory) FROM ShoppingCategory shoppingCategory";
2329            private static final String _SQL_COUNT_SHOPPINGCATEGORY_WHERE = "SELECT COUNT(shoppingCategory) FROM ShoppingCategory shoppingCategory WHERE ";
2330            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "shoppingCategory.groupId = ?";
2331            private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "shoppingCategory.groupId = ? AND ";
2332            private static final String _FINDER_COLUMN_G_P_PARENTCATEGORYID_2 = "shoppingCategory.parentCategoryId = ?";
2333            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "shoppingCategory.categoryId";
2334            private static final String _FILTER_SQL_SELECT_SHOPPINGCATEGORY_WHERE = "SELECT DISTINCT {shoppingCategory.*} FROM ShoppingCategory shoppingCategory WHERE ";
2335            private static final String _FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
2336                    "SELECT {ShoppingCategory.*} FROM (SELECT DISTINCT shoppingCategory.categoryId FROM ShoppingCategory shoppingCategory WHERE ";
2337            private static final String _FILTER_SQL_SELECT_SHOPPINGCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
2338                    ") TEMP_TABLE INNER JOIN ShoppingCategory ON TEMP_TABLE.categoryId = ShoppingCategory.categoryId";
2339            private static final String _FILTER_SQL_COUNT_SHOPPINGCATEGORY_WHERE = "SELECT COUNT(DISTINCT shoppingCategory.categoryId) AS COUNT_VALUE FROM ShoppingCategory shoppingCategory WHERE ";
2340            private static final String _FILTER_ENTITY_ALIAS = "shoppingCategory";
2341            private static final String _FILTER_ENTITY_TABLE = "ShoppingCategory";
2342            private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingCategory.";
2343            private static final String _ORDER_BY_ENTITY_TABLE = "ShoppingCategory.";
2344            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingCategory exists with the primary key ";
2345            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingCategory exists with the key {";
2346            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2347            private static Log _log = LogFactoryUtil.getLog(ShoppingCategoryPersistenceImpl.class);
2348            private static ShoppingCategory _nullShoppingCategory = new ShoppingCategoryImpl() {
2349                            @Override
2350                            public Object clone() {
2351                                    return this;
2352                            }
2353    
2354                            @Override
2355                            public CacheModel<ShoppingCategory> toCacheModel() {
2356                                    return _nullShoppingCategoryCacheModel;
2357                            }
2358                    };
2359    
2360            private static CacheModel<ShoppingCategory> _nullShoppingCategoryCacheModel = new CacheModel<ShoppingCategory>() {
2361                            public ShoppingCategory toEntityModel() {
2362                                    return _nullShoppingCategory;
2363                            }
2364                    };
2365    }