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