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