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.LayoutPersistence;
044    import com.liferay.portal.service.persistence.LayoutSetPersistence;
045    import com.liferay.portal.service.persistence.ResourcePersistence;
046    import com.liferay.portal.service.persistence.UserPersistence;
047    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048    
049    import com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException;
050    import com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance;
051    import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleGroupInstanceImpl;
052    import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleGroupInstanceModelImpl;
053    
054    import java.io.Serializable;
055    
056    import java.util.ArrayList;
057    import java.util.Collections;
058    import java.util.List;
059    
060    /**
061     * The persistence implementation for the m d r rule group instance service.
062     *
063     * <p>
064     * Caching information and settings can be found in <code>portal.properties</code>
065     * </p>
066     *
067     * @author Edward C. Han
068     * @see MDRRuleGroupInstancePersistence
069     * @see MDRRuleGroupInstanceUtil
070     * @generated
071     */
072    public class MDRRuleGroupInstancePersistenceImpl extends BasePersistenceImpl<MDRRuleGroupInstance>
073            implements MDRRuleGroupInstancePersistence {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * Never modify or reference this class directly. Always use {@link MDRRuleGroupInstanceUtil} to access the m d r rule group instance persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
078             */
079            public static final String FINDER_CLASS_NAME_ENTITY = MDRRuleGroupInstanceImpl.class.getName();
080            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List1";
082            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List2";
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
085                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
086                            MDRRuleGroupInstanceImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
088                            new String[] {
089                                    String.class.getName(),
090                                    
091                            "java.lang.Integer", "java.lang.Integer",
092                                    "com.liferay.portal.kernel.util.OrderByComparator"
093                            });
094            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
095                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
096                            MDRRuleGroupInstanceImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
098                            new String[] { String.class.getName() },
099                            MDRRuleGroupInstanceModelImpl.UUID_COLUMN_BITMASK);
100            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
101                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
103                            new String[] { String.class.getName() });
104            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
105                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
106                            MDRRuleGroupInstanceImpl.class, FINDER_CLASS_NAME_ENTITY,
107                            "fetchByUUID_G",
108                            new String[] { String.class.getName(), Long.class.getName() },
109                            MDRRuleGroupInstanceModelImpl.UUID_COLUMN_BITMASK |
110                            MDRRuleGroupInstanceModelImpl.GROUPID_COLUMN_BITMASK);
111            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
112                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
113                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
114                            new String[] { String.class.getName(), Long.class.getName() });
115            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
116                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
117                            MDRRuleGroupInstanceImpl.class,
118                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
119                            new String[] {
120                                    Long.class.getName(),
121                                    
122                            "java.lang.Integer", "java.lang.Integer",
123                                    "com.liferay.portal.kernel.util.OrderByComparator"
124                            });
125            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
126                    new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
127                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
128                            MDRRuleGroupInstanceImpl.class,
129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
130                            new String[] { Long.class.getName() },
131                            MDRRuleGroupInstanceModelImpl.GROUPID_COLUMN_BITMASK);
132            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
133                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
134                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
135                            new String[] { Long.class.getName() });
136            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPID =
137                    new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
138                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
139                            MDRRuleGroupInstanceImpl.class,
140                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRuleGroupId",
141                            new String[] {
142                                    Long.class.getName(),
143                                    
144                            "java.lang.Integer", "java.lang.Integer",
145                                    "com.liferay.portal.kernel.util.OrderByComparator"
146                            });
147            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID =
148                    new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
149                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
150                            MDRRuleGroupInstanceImpl.class,
151                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRuleGroupId",
152                            new String[] { Long.class.getName() },
153                            MDRRuleGroupInstanceModelImpl.RULEGROUPID_COLUMN_BITMASK);
154            public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
155                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
156                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRuleGroupId",
157                            new String[] { Long.class.getName() });
158            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
159                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
160                            MDRRuleGroupInstanceImpl.class,
161                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
162                            new String[] {
163                                    Long.class.getName(), Long.class.getName(),
164                                    
165                            "java.lang.Integer", "java.lang.Integer",
166                                    "com.liferay.portal.kernel.util.OrderByComparator"
167                            });
168            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
169                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
170                            MDRRuleGroupInstanceImpl.class,
171                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
172                            new String[] { Long.class.getName(), Long.class.getName() },
173                            MDRRuleGroupInstanceModelImpl.CLASSNAMEID_COLUMN_BITMASK |
174                            MDRRuleGroupInstanceModelImpl.CLASSPK_COLUMN_BITMASK);
175            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
176                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
177                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
178                            new String[] { Long.class.getName(), Long.class.getName() });
179            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
180                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
181                            MDRRuleGroupInstanceImpl.class,
182                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_C",
183                            new String[] {
184                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
185                                    
186                            "java.lang.Integer", "java.lang.Integer",
187                                    "com.liferay.portal.kernel.util.OrderByComparator"
188                            });
189            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
190                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
191                            MDRRuleGroupInstanceImpl.class,
192                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
193                            new String[] {
194                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
195                            },
196                            MDRRuleGroupInstanceModelImpl.GROUPID_COLUMN_BITMASK |
197                            MDRRuleGroupInstanceModelImpl.CLASSNAMEID_COLUMN_BITMASK |
198                            MDRRuleGroupInstanceModelImpl.CLASSPK_COLUMN_BITMASK);
199            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
200                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
201                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
202                            new String[] {
203                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
204                            });
205            public static final FinderPath FINDER_PATH_FETCH_BY_C_C_R = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
206                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
207                            MDRRuleGroupInstanceImpl.class, FINDER_CLASS_NAME_ENTITY,
208                            "fetchByC_C_R",
209                            new String[] {
210                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
211                            },
212                            MDRRuleGroupInstanceModelImpl.CLASSNAMEID_COLUMN_BITMASK |
213                            MDRRuleGroupInstanceModelImpl.CLASSPK_COLUMN_BITMASK |
214                            MDRRuleGroupInstanceModelImpl.RULEGROUPID_COLUMN_BITMASK);
215            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_R = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
216                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
217                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_R",
218                            new String[] {
219                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
220                            });
221            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
222                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
223                            MDRRuleGroupInstanceImpl.class,
224                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
225            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
226                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
227                            MDRRuleGroupInstanceImpl.class,
228                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
229            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
230                            MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
231                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
232    
233            /**
234             * Caches the m d r rule group instance in the entity cache if it is enabled.
235             *
236             * @param mdrRuleGroupInstance the m d r rule group instance
237             */
238            public void cacheResult(MDRRuleGroupInstance mdrRuleGroupInstance) {
239                    EntityCacheUtil.putResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
240                            MDRRuleGroupInstanceImpl.class,
241                            mdrRuleGroupInstance.getPrimaryKey(), mdrRuleGroupInstance);
242    
243                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
244                            new Object[] {
245                                    mdrRuleGroupInstance.getUuid(),
246                                    Long.valueOf(mdrRuleGroupInstance.getGroupId())
247                            }, mdrRuleGroupInstance);
248    
249                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
250                            new Object[] {
251                                    Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
252                                    Long.valueOf(mdrRuleGroupInstance.getClassPK()),
253                                    Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
254                            }, mdrRuleGroupInstance);
255    
256                    mdrRuleGroupInstance.resetOriginalValues();
257            }
258    
259            /**
260             * Caches the m d r rule group instances in the entity cache if it is enabled.
261             *
262             * @param mdrRuleGroupInstances the m d r rule group instances
263             */
264            public void cacheResult(List<MDRRuleGroupInstance> mdrRuleGroupInstances) {
265                    for (MDRRuleGroupInstance mdrRuleGroupInstance : mdrRuleGroupInstances) {
266                            if (EntityCacheUtil.getResult(
267                                                    MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
268                                                    MDRRuleGroupInstanceImpl.class,
269                                                    mdrRuleGroupInstance.getPrimaryKey()) == null) {
270                                    cacheResult(mdrRuleGroupInstance);
271                            }
272                            else {
273                                    mdrRuleGroupInstance.resetOriginalValues();
274                            }
275                    }
276            }
277    
278            /**
279             * Clears the cache for all m d r rule group instances.
280             *
281             * <p>
282             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
283             * </p>
284             */
285            @Override
286            public void clearCache() {
287                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
288                            CacheRegistryUtil.clear(MDRRuleGroupInstanceImpl.class.getName());
289                    }
290    
291                    EntityCacheUtil.clearCache(MDRRuleGroupInstanceImpl.class.getName());
292    
293                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
294                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
295                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
296            }
297    
298            /**
299             * Clears the cache for the m d r rule group instance.
300             *
301             * <p>
302             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
303             * </p>
304             */
305            @Override
306            public void clearCache(MDRRuleGroupInstance mdrRuleGroupInstance) {
307                    EntityCacheUtil.removeResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
308                            MDRRuleGroupInstanceImpl.class, mdrRuleGroupInstance.getPrimaryKey());
309    
310                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
311                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
312    
313                    clearUniqueFindersCache(mdrRuleGroupInstance);
314            }
315    
316            @Override
317            public void clearCache(List<MDRRuleGroupInstance> mdrRuleGroupInstances) {
318                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
319                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
320    
321                    for (MDRRuleGroupInstance mdrRuleGroupInstance : mdrRuleGroupInstances) {
322                            EntityCacheUtil.removeResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
323                                    MDRRuleGroupInstanceImpl.class,
324                                    mdrRuleGroupInstance.getPrimaryKey());
325    
326                            clearUniqueFindersCache(mdrRuleGroupInstance);
327                    }
328            }
329    
330            protected void cacheUniqueFindersCache(
331                    MDRRuleGroupInstance mdrRuleGroupInstance) {
332                    if (mdrRuleGroupInstance.isNew()) {
333                            Object[] args = new Object[] {
334                                            mdrRuleGroupInstance.getUuid(),
335                                            Long.valueOf(mdrRuleGroupInstance.getGroupId())
336                                    };
337    
338                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
339                                    Long.valueOf(1));
340                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
341                                    mdrRuleGroupInstance);
342    
343                            args = new Object[] {
344                                            Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
345                                            Long.valueOf(mdrRuleGroupInstance.getClassPK()),
346                                            Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
347                                    };
348    
349                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_R, args,
350                                    Long.valueOf(1));
351                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R, args,
352                                    mdrRuleGroupInstance);
353                    }
354                    else {
355                            MDRRuleGroupInstanceModelImpl mdrRuleGroupInstanceModelImpl = (MDRRuleGroupInstanceModelImpl)mdrRuleGroupInstance;
356    
357                            if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
358                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
359                                    Object[] args = new Object[] {
360                                                    mdrRuleGroupInstance.getUuid(),
361                                                    Long.valueOf(mdrRuleGroupInstance.getGroupId())
362                                            };
363    
364                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
365                                            Long.valueOf(1));
366                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
367                                            mdrRuleGroupInstance);
368                            }
369    
370                            if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
371                                            FINDER_PATH_FETCH_BY_C_C_R.getColumnBitmask()) != 0) {
372                                    Object[] args = new Object[] {
373                                                    Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
374                                                    Long.valueOf(mdrRuleGroupInstance.getClassPK()),
375                                                    Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
376                                            };
377    
378                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_R, args,
379                                            Long.valueOf(1));
380                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R, args,
381                                            mdrRuleGroupInstance);
382                            }
383                    }
384            }
385    
386            protected void clearUniqueFindersCache(
387                    MDRRuleGroupInstance mdrRuleGroupInstance) {
388                    MDRRuleGroupInstanceModelImpl mdrRuleGroupInstanceModelImpl = (MDRRuleGroupInstanceModelImpl)mdrRuleGroupInstance;
389    
390                    Object[] args = new Object[] {
391                                    mdrRuleGroupInstance.getUuid(),
392                                    Long.valueOf(mdrRuleGroupInstance.getGroupId())
393                            };
394    
395                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
396                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
397    
398                    if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
399                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
400                            args = new Object[] {
401                                            mdrRuleGroupInstanceModelImpl.getOriginalUuid(),
402                                            Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalGroupId())
403                                    };
404    
405                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
406                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
407                    }
408    
409                    args = new Object[] {
410                                    Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
411                                    Long.valueOf(mdrRuleGroupInstance.getClassPK()),
412                                    Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
413                            };
414    
415                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_R, args);
416                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_R, args);
417    
418                    if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
419                                    FINDER_PATH_FETCH_BY_C_C_R.getColumnBitmask()) != 0) {
420                            args = new Object[] {
421                                            Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassNameId()),
422                                            Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassPK()),
423                                            Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalRuleGroupId())
424                                    };
425    
426                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_R, args);
427                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_R, args);
428                    }
429            }
430    
431            /**
432             * Creates a new m d r rule group instance with the primary key. Does not add the m d r rule group instance to the database.
433             *
434             * @param ruleGroupInstanceId the primary key for the new m d r rule group instance
435             * @return the new m d r rule group instance
436             */
437            public MDRRuleGroupInstance create(long ruleGroupInstanceId) {
438                    MDRRuleGroupInstance mdrRuleGroupInstance = new MDRRuleGroupInstanceImpl();
439    
440                    mdrRuleGroupInstance.setNew(true);
441                    mdrRuleGroupInstance.setPrimaryKey(ruleGroupInstanceId);
442    
443                    String uuid = PortalUUIDUtil.generate();
444    
445                    mdrRuleGroupInstance.setUuid(uuid);
446    
447                    return mdrRuleGroupInstance;
448            }
449    
450            /**
451             * Removes the m d r rule group instance with the primary key from the database. Also notifies the appropriate model listeners.
452             *
453             * @param ruleGroupInstanceId the primary key of the m d r rule group instance
454             * @return the m d r rule group instance that was removed
455             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
456             * @throws SystemException if a system exception occurred
457             */
458            public MDRRuleGroupInstance remove(long ruleGroupInstanceId)
459                    throws NoSuchRuleGroupInstanceException, SystemException {
460                    return remove(Long.valueOf(ruleGroupInstanceId));
461            }
462    
463            /**
464             * Removes the m d r rule group instance with the primary key from the database. Also notifies the appropriate model listeners.
465             *
466             * @param primaryKey the primary key of the m d r rule group instance
467             * @return the m d r rule group instance that was removed
468             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
469             * @throws SystemException if a system exception occurred
470             */
471            @Override
472            public MDRRuleGroupInstance remove(Serializable primaryKey)
473                    throws NoSuchRuleGroupInstanceException, SystemException {
474                    Session session = null;
475    
476                    try {
477                            session = openSession();
478    
479                            MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)session.get(MDRRuleGroupInstanceImpl.class,
480                                            primaryKey);
481    
482                            if (mdrRuleGroupInstance == null) {
483                                    if (_log.isWarnEnabled()) {
484                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
485                                    }
486    
487                                    throw new NoSuchRuleGroupInstanceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
488                                            primaryKey);
489                            }
490    
491                            return remove(mdrRuleGroupInstance);
492                    }
493                    catch (NoSuchRuleGroupInstanceException nsee) {
494                            throw nsee;
495                    }
496                    catch (Exception e) {
497                            throw processException(e);
498                    }
499                    finally {
500                            closeSession(session);
501                    }
502            }
503    
504            @Override
505            protected MDRRuleGroupInstance removeImpl(
506                    MDRRuleGroupInstance mdrRuleGroupInstance) throws SystemException {
507                    mdrRuleGroupInstance = toUnwrappedModel(mdrRuleGroupInstance);
508    
509                    Session session = null;
510    
511                    try {
512                            session = openSession();
513    
514                            BatchSessionUtil.delete(session, mdrRuleGroupInstance);
515                    }
516                    catch (Exception e) {
517                            throw processException(e);
518                    }
519                    finally {
520                            closeSession(session);
521                    }
522    
523                    clearCache(mdrRuleGroupInstance);
524    
525                    return mdrRuleGroupInstance;
526            }
527    
528            @Override
529            public MDRRuleGroupInstance updateImpl(
530                    com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance mdrRuleGroupInstance,
531                    boolean merge) throws SystemException {
532                    mdrRuleGroupInstance = toUnwrappedModel(mdrRuleGroupInstance);
533    
534                    boolean isNew = mdrRuleGroupInstance.isNew();
535    
536                    MDRRuleGroupInstanceModelImpl mdrRuleGroupInstanceModelImpl = (MDRRuleGroupInstanceModelImpl)mdrRuleGroupInstance;
537    
538                    if (Validator.isNull(mdrRuleGroupInstance.getUuid())) {
539                            String uuid = PortalUUIDUtil.generate();
540    
541                            mdrRuleGroupInstance.setUuid(uuid);
542                    }
543    
544                    Session session = null;
545    
546                    try {
547                            session = openSession();
548    
549                            BatchSessionUtil.update(session, mdrRuleGroupInstance, merge);
550    
551                            mdrRuleGroupInstance.setNew(false);
552                    }
553                    catch (Exception e) {
554                            throw processException(e);
555                    }
556                    finally {
557                            closeSession(session);
558                    }
559    
560                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
561    
562                    if (isNew || !MDRRuleGroupInstanceModelImpl.COLUMN_BITMASK_ENABLED) {
563                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
564                    }
565    
566                    else {
567                            if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
568                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
569                                    Object[] args = new Object[] {
570                                                    mdrRuleGroupInstanceModelImpl.getOriginalUuid()
571                                            };
572    
573                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
574                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
575                                            args);
576    
577                                    args = new Object[] { mdrRuleGroupInstanceModelImpl.getUuid() };
578    
579                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
580                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
581                                            args);
582                            }
583    
584                            if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
585                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
586                                    Object[] args = new Object[] {
587                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalGroupId())
588                                            };
589    
590                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
591                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
592                                            args);
593    
594                                    args = new Object[] {
595                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getGroupId())
596                                            };
597    
598                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
599                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
600                                            args);
601                            }
602    
603                            if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
604                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID.getColumnBitmask()) != 0) {
605                                    Object[] args = new Object[] {
606                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalRuleGroupId())
607                                            };
608    
609                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
610                                            args);
611                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID,
612                                            args);
613    
614                                    args = new Object[] {
615                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getRuleGroupId())
616                                            };
617    
618                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
619                                            args);
620                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID,
621                                            args);
622                            }
623    
624                            if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
625                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
626                                    Object[] args = new Object[] {
627                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassNameId()),
628                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassPK())
629                                            };
630    
631                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
632                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
633                                            args);
634    
635                                    args = new Object[] {
636                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassNameId()),
637                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassPK())
638                                            };
639    
640                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
641                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
642                                            args);
643                            }
644    
645                            if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
646                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
647                                    Object[] args = new Object[] {
648                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalGroupId()),
649                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassNameId()),
650                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassPK())
651                                            };
652    
653                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
654                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
655                                            args);
656    
657                                    args = new Object[] {
658                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getGroupId()),
659                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassNameId()),
660                                                    Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassPK())
661                                            };
662    
663                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
664                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
665                                            args);
666                            }
667                    }
668    
669                    EntityCacheUtil.putResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
670                            MDRRuleGroupInstanceImpl.class,
671                            mdrRuleGroupInstance.getPrimaryKey(), mdrRuleGroupInstance);
672    
673                    clearUniqueFindersCache(mdrRuleGroupInstance);
674                    cacheUniqueFindersCache(mdrRuleGroupInstance);
675    
676                    return mdrRuleGroupInstance;
677            }
678    
679            protected MDRRuleGroupInstance toUnwrappedModel(
680                    MDRRuleGroupInstance mdrRuleGroupInstance) {
681                    if (mdrRuleGroupInstance instanceof MDRRuleGroupInstanceImpl) {
682                            return mdrRuleGroupInstance;
683                    }
684    
685                    MDRRuleGroupInstanceImpl mdrRuleGroupInstanceImpl = new MDRRuleGroupInstanceImpl();
686    
687                    mdrRuleGroupInstanceImpl.setNew(mdrRuleGroupInstance.isNew());
688                    mdrRuleGroupInstanceImpl.setPrimaryKey(mdrRuleGroupInstance.getPrimaryKey());
689    
690                    mdrRuleGroupInstanceImpl.setUuid(mdrRuleGroupInstance.getUuid());
691                    mdrRuleGroupInstanceImpl.setRuleGroupInstanceId(mdrRuleGroupInstance.getRuleGroupInstanceId());
692                    mdrRuleGroupInstanceImpl.setGroupId(mdrRuleGroupInstance.getGroupId());
693                    mdrRuleGroupInstanceImpl.setCompanyId(mdrRuleGroupInstance.getCompanyId());
694                    mdrRuleGroupInstanceImpl.setUserId(mdrRuleGroupInstance.getUserId());
695                    mdrRuleGroupInstanceImpl.setUserName(mdrRuleGroupInstance.getUserName());
696                    mdrRuleGroupInstanceImpl.setCreateDate(mdrRuleGroupInstance.getCreateDate());
697                    mdrRuleGroupInstanceImpl.setModifiedDate(mdrRuleGroupInstance.getModifiedDate());
698                    mdrRuleGroupInstanceImpl.setClassNameId(mdrRuleGroupInstance.getClassNameId());
699                    mdrRuleGroupInstanceImpl.setClassPK(mdrRuleGroupInstance.getClassPK());
700                    mdrRuleGroupInstanceImpl.setRuleGroupId(mdrRuleGroupInstance.getRuleGroupId());
701                    mdrRuleGroupInstanceImpl.setPriority(mdrRuleGroupInstance.getPriority());
702    
703                    return mdrRuleGroupInstanceImpl;
704            }
705    
706            /**
707             * Returns the m d r rule group instance with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
708             *
709             * @param primaryKey the primary key of the m d r rule group instance
710             * @return the m d r rule group instance
711             * @throws com.liferay.portal.NoSuchModelException if a m d r rule group instance with the primary key could not be found
712             * @throws SystemException if a system exception occurred
713             */
714            @Override
715            public MDRRuleGroupInstance findByPrimaryKey(Serializable primaryKey)
716                    throws NoSuchModelException, SystemException {
717                    return findByPrimaryKey(((Long)primaryKey).longValue());
718            }
719    
720            /**
721             * Returns the m d r rule group instance with the primary key or throws a {@link com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException} if it could not be found.
722             *
723             * @param ruleGroupInstanceId the primary key of the m d r rule group instance
724             * @return the m d r rule group instance
725             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
726             * @throws SystemException if a system exception occurred
727             */
728            public MDRRuleGroupInstance findByPrimaryKey(long ruleGroupInstanceId)
729                    throws NoSuchRuleGroupInstanceException, SystemException {
730                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByPrimaryKey(ruleGroupInstanceId);
731    
732                    if (mdrRuleGroupInstance == null) {
733                            if (_log.isWarnEnabled()) {
734                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
735                                            ruleGroupInstanceId);
736                            }
737    
738                            throw new NoSuchRuleGroupInstanceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
739                                    ruleGroupInstanceId);
740                    }
741    
742                    return mdrRuleGroupInstance;
743            }
744    
745            /**
746             * Returns the m d r rule group instance with the primary key or returns <code>null</code> if it could not be found.
747             *
748             * @param primaryKey the primary key of the m d r rule group instance
749             * @return the m d r rule group instance, or <code>null</code> if a m d r rule group instance with the primary key could not be found
750             * @throws SystemException if a system exception occurred
751             */
752            @Override
753            public MDRRuleGroupInstance fetchByPrimaryKey(Serializable primaryKey)
754                    throws SystemException {
755                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
756            }
757    
758            /**
759             * Returns the m d r rule group instance with the primary key or returns <code>null</code> if it could not be found.
760             *
761             * @param ruleGroupInstanceId the primary key of the m d r rule group instance
762             * @return the m d r rule group instance, or <code>null</code> if a m d r rule group instance with the primary key could not be found
763             * @throws SystemException if a system exception occurred
764             */
765            public MDRRuleGroupInstance fetchByPrimaryKey(long ruleGroupInstanceId)
766                    throws SystemException {
767                    MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)EntityCacheUtil.getResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
768                                    MDRRuleGroupInstanceImpl.class, ruleGroupInstanceId);
769    
770                    if (mdrRuleGroupInstance == _nullMDRRuleGroupInstance) {
771                            return null;
772                    }
773    
774                    if (mdrRuleGroupInstance == null) {
775                            Session session = null;
776    
777                            boolean hasException = false;
778    
779                            try {
780                                    session = openSession();
781    
782                                    mdrRuleGroupInstance = (MDRRuleGroupInstance)session.get(MDRRuleGroupInstanceImpl.class,
783                                                    Long.valueOf(ruleGroupInstanceId));
784                            }
785                            catch (Exception e) {
786                                    hasException = true;
787    
788                                    throw processException(e);
789                            }
790                            finally {
791                                    if (mdrRuleGroupInstance != null) {
792                                            cacheResult(mdrRuleGroupInstance);
793                                    }
794                                    else if (!hasException) {
795                                            EntityCacheUtil.putResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
796                                                    MDRRuleGroupInstanceImpl.class, ruleGroupInstanceId,
797                                                    _nullMDRRuleGroupInstance);
798                                    }
799    
800                                    closeSession(session);
801                            }
802                    }
803    
804                    return mdrRuleGroupInstance;
805            }
806    
807            /**
808             * Returns all the m d r rule group instances where uuid = &#63;.
809             *
810             * @param uuid the uuid
811             * @return the matching m d r rule group instances
812             * @throws SystemException if a system exception occurred
813             */
814            public List<MDRRuleGroupInstance> findByUuid(String uuid)
815                    throws SystemException {
816                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
817            }
818    
819            /**
820             * Returns a range of all the m d r rule group instances where uuid = &#63;.
821             *
822             * <p>
823             * 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.
824             * </p>
825             *
826             * @param uuid the uuid
827             * @param start the lower bound of the range of m d r rule group instances
828             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
829             * @return the range of matching m d r rule group instances
830             * @throws SystemException if a system exception occurred
831             */
832            public List<MDRRuleGroupInstance> findByUuid(String uuid, int start, int end)
833                    throws SystemException {
834                    return findByUuid(uuid, start, end, null);
835            }
836    
837            /**
838             * Returns an ordered range of all the m d r rule group instances where uuid = &#63;.
839             *
840             * <p>
841             * 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.
842             * </p>
843             *
844             * @param uuid the uuid
845             * @param start the lower bound of the range of m d r rule group instances
846             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
847             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
848             * @return the ordered range of matching m d r rule group instances
849             * @throws SystemException if a system exception occurred
850             */
851            public List<MDRRuleGroupInstance> findByUuid(String uuid, int start,
852                    int end, OrderByComparator orderByComparator) throws SystemException {
853                    FinderPath finderPath = null;
854                    Object[] finderArgs = null;
855    
856                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
857                                    (orderByComparator == null)) {
858                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
859                            finderArgs = new Object[] { uuid };
860                    }
861                    else {
862                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
863                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
864                    }
865    
866                    List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
867                                    finderArgs, this);
868    
869                    if ((list != null) && !list.isEmpty()) {
870                            for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
871                                    if (!Validator.equals(uuid, mdrRuleGroupInstance.getUuid())) {
872                                            list = null;
873    
874                                            break;
875                                    }
876                            }
877                    }
878    
879                    if (list == null) {
880                            StringBundler query = null;
881    
882                            if (orderByComparator != null) {
883                                    query = new StringBundler(3 +
884                                                    (orderByComparator.getOrderByFields().length * 3));
885                            }
886                            else {
887                                    query = new StringBundler(2);
888                            }
889    
890                            query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
891    
892                            if (uuid == null) {
893                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
894                            }
895                            else {
896                                    if (uuid.equals(StringPool.BLANK)) {
897                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
898                                    }
899                                    else {
900                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
901                                    }
902                            }
903    
904                            if (orderByComparator != null) {
905                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
906                                            orderByComparator);
907                            }
908    
909                            String sql = query.toString();
910    
911                            Session session = null;
912    
913                            try {
914                                    session = openSession();
915    
916                                    Query q = session.createQuery(sql);
917    
918                                    QueryPos qPos = QueryPos.getInstance(q);
919    
920                                    if (uuid != null) {
921                                            qPos.add(uuid);
922                                    }
923    
924                                    list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
925                                                    getDialect(), start, end);
926                            }
927                            catch (Exception e) {
928                                    throw processException(e);
929                            }
930                            finally {
931                                    if (list == null) {
932                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
933                                    }
934                                    else {
935                                            cacheResult(list);
936    
937                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
938                                    }
939    
940                                    closeSession(session);
941                            }
942                    }
943    
944                    return list;
945            }
946    
947            /**
948             * Returns the first m d r rule group instance in the ordered set where uuid = &#63;.
949             *
950             * @param uuid the uuid
951             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
952             * @return the first matching m d r rule group instance
953             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
954             * @throws SystemException if a system exception occurred
955             */
956            public MDRRuleGroupInstance findByUuid_First(String uuid,
957                    OrderByComparator orderByComparator)
958                    throws NoSuchRuleGroupInstanceException, SystemException {
959                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByUuid_First(uuid,
960                                    orderByComparator);
961    
962                    if (mdrRuleGroupInstance != null) {
963                            return mdrRuleGroupInstance;
964                    }
965    
966                    StringBundler msg = new StringBundler(4);
967    
968                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
969    
970                    msg.append("uuid=");
971                    msg.append(uuid);
972    
973                    msg.append(StringPool.CLOSE_CURLY_BRACE);
974    
975                    throw new NoSuchRuleGroupInstanceException(msg.toString());
976            }
977    
978            /**
979             * Returns the first m d r rule group instance in the ordered set where uuid = &#63;.
980             *
981             * @param uuid the uuid
982             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
983             * @return the first matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
984             * @throws SystemException if a system exception occurred
985             */
986            public MDRRuleGroupInstance fetchByUuid_First(String uuid,
987                    OrderByComparator orderByComparator) throws SystemException {
988                    List<MDRRuleGroupInstance> list = findByUuid(uuid, 0, 1,
989                                    orderByComparator);
990    
991                    if (!list.isEmpty()) {
992                            return list.get(0);
993                    }
994    
995                    return null;
996            }
997    
998            /**
999             * Returns the last m d r rule group instance in the ordered set where uuid = &#63;.
1000             *
1001             * @param uuid the uuid
1002             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1003             * @return the last matching m d r rule group instance
1004             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
1005             * @throws SystemException if a system exception occurred
1006             */
1007            public MDRRuleGroupInstance findByUuid_Last(String uuid,
1008                    OrderByComparator orderByComparator)
1009                    throws NoSuchRuleGroupInstanceException, SystemException {
1010                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByUuid_Last(uuid,
1011                                    orderByComparator);
1012    
1013                    if (mdrRuleGroupInstance != null) {
1014                            return mdrRuleGroupInstance;
1015                    }
1016    
1017                    StringBundler msg = new StringBundler(4);
1018    
1019                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1020    
1021                    msg.append("uuid=");
1022                    msg.append(uuid);
1023    
1024                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1025    
1026                    throw new NoSuchRuleGroupInstanceException(msg.toString());
1027            }
1028    
1029            /**
1030             * Returns the last m d r rule group instance in the ordered set where uuid = &#63;.
1031             *
1032             * @param uuid the uuid
1033             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1034             * @return the last matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
1035             * @throws SystemException if a system exception occurred
1036             */
1037            public MDRRuleGroupInstance fetchByUuid_Last(String uuid,
1038                    OrderByComparator orderByComparator) throws SystemException {
1039                    int count = countByUuid(uuid);
1040    
1041                    List<MDRRuleGroupInstance> list = findByUuid(uuid, count - 1, count,
1042                                    orderByComparator);
1043    
1044                    if (!list.isEmpty()) {
1045                            return list.get(0);
1046                    }
1047    
1048                    return null;
1049            }
1050    
1051            /**
1052             * Returns the m d r rule group instances before and after the current m d r rule group instance in the ordered set where uuid = &#63;.
1053             *
1054             * @param ruleGroupInstanceId the primary key of the current m d r rule group instance
1055             * @param uuid the uuid
1056             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1057             * @return the previous, current, and next m d r rule group instance
1058             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
1059             * @throws SystemException if a system exception occurred
1060             */
1061            public MDRRuleGroupInstance[] findByUuid_PrevAndNext(
1062                    long ruleGroupInstanceId, String uuid,
1063                    OrderByComparator orderByComparator)
1064                    throws NoSuchRuleGroupInstanceException, SystemException {
1065                    MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
1066    
1067                    Session session = null;
1068    
1069                    try {
1070                            session = openSession();
1071    
1072                            MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
1073    
1074                            array[0] = getByUuid_PrevAndNext(session, mdrRuleGroupInstance,
1075                                            uuid, orderByComparator, true);
1076    
1077                            array[1] = mdrRuleGroupInstance;
1078    
1079                            array[2] = getByUuid_PrevAndNext(session, mdrRuleGroupInstance,
1080                                            uuid, orderByComparator, false);
1081    
1082                            return array;
1083                    }
1084                    catch (Exception e) {
1085                            throw processException(e);
1086                    }
1087                    finally {
1088                            closeSession(session);
1089                    }
1090            }
1091    
1092            protected MDRRuleGroupInstance getByUuid_PrevAndNext(Session session,
1093                    MDRRuleGroupInstance mdrRuleGroupInstance, String uuid,
1094                    OrderByComparator orderByComparator, boolean previous) {
1095                    StringBundler query = null;
1096    
1097                    if (orderByComparator != null) {
1098                            query = new StringBundler(6 +
1099                                            (orderByComparator.getOrderByFields().length * 6));
1100                    }
1101                    else {
1102                            query = new StringBundler(3);
1103                    }
1104    
1105                    query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1106    
1107                    if (uuid == null) {
1108                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1109                    }
1110                    else {
1111                            if (uuid.equals(StringPool.BLANK)) {
1112                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1113                            }
1114                            else {
1115                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1116                            }
1117                    }
1118    
1119                    if (orderByComparator != null) {
1120                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1121    
1122                            if (orderByConditionFields.length > 0) {
1123                                    query.append(WHERE_AND);
1124                            }
1125    
1126                            for (int i = 0; i < orderByConditionFields.length; i++) {
1127                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1128                                    query.append(orderByConditionFields[i]);
1129    
1130                                    if ((i + 1) < orderByConditionFields.length) {
1131                                            if (orderByComparator.isAscending() ^ previous) {
1132                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1133                                            }
1134                                            else {
1135                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1136                                            }
1137                                    }
1138                                    else {
1139                                            if (orderByComparator.isAscending() ^ previous) {
1140                                                    query.append(WHERE_GREATER_THAN);
1141                                            }
1142                                            else {
1143                                                    query.append(WHERE_LESSER_THAN);
1144                                            }
1145                                    }
1146                            }
1147    
1148                            query.append(ORDER_BY_CLAUSE);
1149    
1150                            String[] orderByFields = orderByComparator.getOrderByFields();
1151    
1152                            for (int i = 0; i < orderByFields.length; i++) {
1153                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1154                                    query.append(orderByFields[i]);
1155    
1156                                    if ((i + 1) < orderByFields.length) {
1157                                            if (orderByComparator.isAscending() ^ previous) {
1158                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1159                                            }
1160                                            else {
1161                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1162                                            }
1163                                    }
1164                                    else {
1165                                            if (orderByComparator.isAscending() ^ previous) {
1166                                                    query.append(ORDER_BY_ASC);
1167                                            }
1168                                            else {
1169                                                    query.append(ORDER_BY_DESC);
1170                                            }
1171                                    }
1172                            }
1173                    }
1174    
1175                    String sql = query.toString();
1176    
1177                    Query q = session.createQuery(sql);
1178    
1179                    q.setFirstResult(0);
1180                    q.setMaxResults(2);
1181    
1182                    QueryPos qPos = QueryPos.getInstance(q);
1183    
1184                    if (uuid != null) {
1185                            qPos.add(uuid);
1186                    }
1187    
1188                    if (orderByComparator != null) {
1189                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
1190    
1191                            for (Object value : values) {
1192                                    qPos.add(value);
1193                            }
1194                    }
1195    
1196                    List<MDRRuleGroupInstance> list = q.list();
1197    
1198                    if (list.size() == 2) {
1199                            return list.get(1);
1200                    }
1201                    else {
1202                            return null;
1203                    }
1204            }
1205    
1206            /**
1207             * Returns the m d r rule group instance where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException} if it could not be found.
1208             *
1209             * @param uuid the uuid
1210             * @param groupId the group ID
1211             * @return the matching m d r rule group instance
1212             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
1213             * @throws SystemException if a system exception occurred
1214             */
1215            public MDRRuleGroupInstance findByUUID_G(String uuid, long groupId)
1216                    throws NoSuchRuleGroupInstanceException, SystemException {
1217                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByUUID_G(uuid, groupId);
1218    
1219                    if (mdrRuleGroupInstance == null) {
1220                            StringBundler msg = new StringBundler(6);
1221    
1222                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1223    
1224                            msg.append("uuid=");
1225                            msg.append(uuid);
1226    
1227                            msg.append(", groupId=");
1228                            msg.append(groupId);
1229    
1230                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1231    
1232                            if (_log.isWarnEnabled()) {
1233                                    _log.warn(msg.toString());
1234                            }
1235    
1236                            throw new NoSuchRuleGroupInstanceException(msg.toString());
1237                    }
1238    
1239                    return mdrRuleGroupInstance;
1240            }
1241    
1242            /**
1243             * Returns the m d r rule group instance where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1244             *
1245             * @param uuid the uuid
1246             * @param groupId the group ID
1247             * @return the matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
1248             * @throws SystemException if a system exception occurred
1249             */
1250            public MDRRuleGroupInstance fetchByUUID_G(String uuid, long groupId)
1251                    throws SystemException {
1252                    return fetchByUUID_G(uuid, groupId, true);
1253            }
1254    
1255            /**
1256             * Returns the m d r rule group instance where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1257             *
1258             * @param uuid the uuid
1259             * @param groupId the group ID
1260             * @param retrieveFromCache whether to use the finder cache
1261             * @return the matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
1262             * @throws SystemException if a system exception occurred
1263             */
1264            public MDRRuleGroupInstance fetchByUUID_G(String uuid, long groupId,
1265                    boolean retrieveFromCache) throws SystemException {
1266                    Object[] finderArgs = new Object[] { uuid, groupId };
1267    
1268                    Object result = null;
1269    
1270                    if (retrieveFromCache) {
1271                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1272                                            finderArgs, this);
1273                    }
1274    
1275                    if (result instanceof MDRRuleGroupInstance) {
1276                            MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)result;
1277    
1278                            if (!Validator.equals(uuid, mdrRuleGroupInstance.getUuid()) ||
1279                                            (groupId != mdrRuleGroupInstance.getGroupId())) {
1280                                    result = null;
1281                            }
1282                    }
1283    
1284                    if (result == null) {
1285                            StringBundler query = new StringBundler(3);
1286    
1287                            query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1288    
1289                            if (uuid == null) {
1290                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1291                            }
1292                            else {
1293                                    if (uuid.equals(StringPool.BLANK)) {
1294                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1295                                    }
1296                                    else {
1297                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1298                                    }
1299                            }
1300    
1301                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1302    
1303                            String sql = query.toString();
1304    
1305                            Session session = null;
1306    
1307                            try {
1308                                    session = openSession();
1309    
1310                                    Query q = session.createQuery(sql);
1311    
1312                                    QueryPos qPos = QueryPos.getInstance(q);
1313    
1314                                    if (uuid != null) {
1315                                            qPos.add(uuid);
1316                                    }
1317    
1318                                    qPos.add(groupId);
1319    
1320                                    List<MDRRuleGroupInstance> list = q.list();
1321    
1322                                    result = list;
1323    
1324                                    MDRRuleGroupInstance mdrRuleGroupInstance = null;
1325    
1326                                    if (list.isEmpty()) {
1327                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1328                                                    finderArgs, list);
1329                                    }
1330                                    else {
1331                                            mdrRuleGroupInstance = list.get(0);
1332    
1333                                            cacheResult(mdrRuleGroupInstance);
1334    
1335                                            if ((mdrRuleGroupInstance.getUuid() == null) ||
1336                                                            !mdrRuleGroupInstance.getUuid().equals(uuid) ||
1337                                                            (mdrRuleGroupInstance.getGroupId() != groupId)) {
1338                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1339                                                            finderArgs, mdrRuleGroupInstance);
1340                                            }
1341                                    }
1342    
1343                                    return mdrRuleGroupInstance;
1344                            }
1345                            catch (Exception e) {
1346                                    throw processException(e);
1347                            }
1348                            finally {
1349                                    if (result == null) {
1350                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1351                                                    finderArgs);
1352                                    }
1353    
1354                                    closeSession(session);
1355                            }
1356                    }
1357                    else {
1358                            if (result instanceof List<?>) {
1359                                    return null;
1360                            }
1361                            else {
1362                                    return (MDRRuleGroupInstance)result;
1363                            }
1364                    }
1365            }
1366    
1367            /**
1368             * Returns all the m d r rule group instances where groupId = &#63;.
1369             *
1370             * @param groupId the group ID
1371             * @return the matching m d r rule group instances
1372             * @throws SystemException if a system exception occurred
1373             */
1374            public List<MDRRuleGroupInstance> findByGroupId(long groupId)
1375                    throws SystemException {
1376                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1377            }
1378    
1379            /**
1380             * Returns a range of all the m d r rule group instances where groupId = &#63;.
1381             *
1382             * <p>
1383             * 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.
1384             * </p>
1385             *
1386             * @param groupId the group ID
1387             * @param start the lower bound of the range of m d r rule group instances
1388             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
1389             * @return the range of matching m d r rule group instances
1390             * @throws SystemException if a system exception occurred
1391             */
1392            public List<MDRRuleGroupInstance> findByGroupId(long groupId, int start,
1393                    int end) throws SystemException {
1394                    return findByGroupId(groupId, start, end, null);
1395            }
1396    
1397            /**
1398             * Returns an ordered range of all the m d r rule group instances where groupId = &#63;.
1399             *
1400             * <p>
1401             * 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.
1402             * </p>
1403             *
1404             * @param groupId the group ID
1405             * @param start the lower bound of the range of m d r rule group instances
1406             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
1407             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1408             * @return the ordered range of matching m d r rule group instances
1409             * @throws SystemException if a system exception occurred
1410             */
1411            public List<MDRRuleGroupInstance> findByGroupId(long groupId, int start,
1412                    int end, OrderByComparator orderByComparator) throws SystemException {
1413                    FinderPath finderPath = null;
1414                    Object[] finderArgs = null;
1415    
1416                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1417                                    (orderByComparator == null)) {
1418                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1419                            finderArgs = new Object[] { groupId };
1420                    }
1421                    else {
1422                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1423                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1424                    }
1425    
1426                    List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
1427                                    finderArgs, this);
1428    
1429                    if ((list != null) && !list.isEmpty()) {
1430                            for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
1431                                    if ((groupId != mdrRuleGroupInstance.getGroupId())) {
1432                                            list = null;
1433    
1434                                            break;
1435                                    }
1436                            }
1437                    }
1438    
1439                    if (list == null) {
1440                            StringBundler query = null;
1441    
1442                            if (orderByComparator != null) {
1443                                    query = new StringBundler(3 +
1444                                                    (orderByComparator.getOrderByFields().length * 3));
1445                            }
1446                            else {
1447                                    query = new StringBundler(2);
1448                            }
1449    
1450                            query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1451    
1452                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1453    
1454                            if (orderByComparator != null) {
1455                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1456                                            orderByComparator);
1457                            }
1458    
1459                            String sql = query.toString();
1460    
1461                            Session session = null;
1462    
1463                            try {
1464                                    session = openSession();
1465    
1466                                    Query q = session.createQuery(sql);
1467    
1468                                    QueryPos qPos = QueryPos.getInstance(q);
1469    
1470                                    qPos.add(groupId);
1471    
1472                                    list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
1473                                                    getDialect(), start, end);
1474                            }
1475                            catch (Exception e) {
1476                                    throw processException(e);
1477                            }
1478                            finally {
1479                                    if (list == null) {
1480                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1481                                    }
1482                                    else {
1483                                            cacheResult(list);
1484    
1485                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1486                                    }
1487    
1488                                    closeSession(session);
1489                            }
1490                    }
1491    
1492                    return list;
1493            }
1494    
1495            /**
1496             * Returns the first m d r rule group instance in the ordered set where groupId = &#63;.
1497             *
1498             * @param groupId the group ID
1499             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1500             * @return the first matching m d r rule group instance
1501             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
1502             * @throws SystemException if a system exception occurred
1503             */
1504            public MDRRuleGroupInstance findByGroupId_First(long groupId,
1505                    OrderByComparator orderByComparator)
1506                    throws NoSuchRuleGroupInstanceException, SystemException {
1507                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByGroupId_First(groupId,
1508                                    orderByComparator);
1509    
1510                    if (mdrRuleGroupInstance != null) {
1511                            return mdrRuleGroupInstance;
1512                    }
1513    
1514                    StringBundler msg = new StringBundler(4);
1515    
1516                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1517    
1518                    msg.append("groupId=");
1519                    msg.append(groupId);
1520    
1521                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1522    
1523                    throw new NoSuchRuleGroupInstanceException(msg.toString());
1524            }
1525    
1526            /**
1527             * Returns the first m d r rule group instance in the ordered set where groupId = &#63;.
1528             *
1529             * @param groupId the group ID
1530             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1531             * @return the first matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
1532             * @throws SystemException if a system exception occurred
1533             */
1534            public MDRRuleGroupInstance fetchByGroupId_First(long groupId,
1535                    OrderByComparator orderByComparator) throws SystemException {
1536                    List<MDRRuleGroupInstance> list = findByGroupId(groupId, 0, 1,
1537                                    orderByComparator);
1538    
1539                    if (!list.isEmpty()) {
1540                            return list.get(0);
1541                    }
1542    
1543                    return null;
1544            }
1545    
1546            /**
1547             * Returns the last m d r rule group instance in the ordered set where groupId = &#63;.
1548             *
1549             * @param groupId the group ID
1550             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1551             * @return the last matching m d r rule group instance
1552             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
1553             * @throws SystemException if a system exception occurred
1554             */
1555            public MDRRuleGroupInstance findByGroupId_Last(long groupId,
1556                    OrderByComparator orderByComparator)
1557                    throws NoSuchRuleGroupInstanceException, SystemException {
1558                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByGroupId_Last(groupId,
1559                                    orderByComparator);
1560    
1561                    if (mdrRuleGroupInstance != null) {
1562                            return mdrRuleGroupInstance;
1563                    }
1564    
1565                    StringBundler msg = new StringBundler(4);
1566    
1567                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1568    
1569                    msg.append("groupId=");
1570                    msg.append(groupId);
1571    
1572                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1573    
1574                    throw new NoSuchRuleGroupInstanceException(msg.toString());
1575            }
1576    
1577            /**
1578             * Returns the last m d r rule group instance in the ordered set where groupId = &#63;.
1579             *
1580             * @param groupId the group ID
1581             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1582             * @return the last matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
1583             * @throws SystemException if a system exception occurred
1584             */
1585            public MDRRuleGroupInstance fetchByGroupId_Last(long groupId,
1586                    OrderByComparator orderByComparator) throws SystemException {
1587                    int count = countByGroupId(groupId);
1588    
1589                    List<MDRRuleGroupInstance> list = findByGroupId(groupId, count - 1,
1590                                    count, orderByComparator);
1591    
1592                    if (!list.isEmpty()) {
1593                            return list.get(0);
1594                    }
1595    
1596                    return null;
1597            }
1598    
1599            /**
1600             * Returns the m d r rule group instances before and after the current m d r rule group instance in the ordered set where groupId = &#63;.
1601             *
1602             * @param ruleGroupInstanceId the primary key of the current m d r rule group instance
1603             * @param groupId the group ID
1604             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1605             * @return the previous, current, and next m d r rule group instance
1606             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
1607             * @throws SystemException if a system exception occurred
1608             */
1609            public MDRRuleGroupInstance[] findByGroupId_PrevAndNext(
1610                    long ruleGroupInstanceId, long groupId,
1611                    OrderByComparator orderByComparator)
1612                    throws NoSuchRuleGroupInstanceException, SystemException {
1613                    MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
1614    
1615                    Session session = null;
1616    
1617                    try {
1618                            session = openSession();
1619    
1620                            MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
1621    
1622                            array[0] = getByGroupId_PrevAndNext(session, mdrRuleGroupInstance,
1623                                            groupId, orderByComparator, true);
1624    
1625                            array[1] = mdrRuleGroupInstance;
1626    
1627                            array[2] = getByGroupId_PrevAndNext(session, mdrRuleGroupInstance,
1628                                            groupId, orderByComparator, false);
1629    
1630                            return array;
1631                    }
1632                    catch (Exception e) {
1633                            throw processException(e);
1634                    }
1635                    finally {
1636                            closeSession(session);
1637                    }
1638            }
1639    
1640            protected MDRRuleGroupInstance getByGroupId_PrevAndNext(Session session,
1641                    MDRRuleGroupInstance mdrRuleGroupInstance, long groupId,
1642                    OrderByComparator orderByComparator, boolean previous) {
1643                    StringBundler query = null;
1644    
1645                    if (orderByComparator != null) {
1646                            query = new StringBundler(6 +
1647                                            (orderByComparator.getOrderByFields().length * 6));
1648                    }
1649                    else {
1650                            query = new StringBundler(3);
1651                    }
1652    
1653                    query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1654    
1655                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1656    
1657                    if (orderByComparator != null) {
1658                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1659    
1660                            if (orderByConditionFields.length > 0) {
1661                                    query.append(WHERE_AND);
1662                            }
1663    
1664                            for (int i = 0; i < orderByConditionFields.length; i++) {
1665                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1666                                    query.append(orderByConditionFields[i]);
1667    
1668                                    if ((i + 1) < orderByConditionFields.length) {
1669                                            if (orderByComparator.isAscending() ^ previous) {
1670                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1671                                            }
1672                                            else {
1673                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1674                                            }
1675                                    }
1676                                    else {
1677                                            if (orderByComparator.isAscending() ^ previous) {
1678                                                    query.append(WHERE_GREATER_THAN);
1679                                            }
1680                                            else {
1681                                                    query.append(WHERE_LESSER_THAN);
1682                                            }
1683                                    }
1684                            }
1685    
1686                            query.append(ORDER_BY_CLAUSE);
1687    
1688                            String[] orderByFields = orderByComparator.getOrderByFields();
1689    
1690                            for (int i = 0; i < orderByFields.length; i++) {
1691                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1692                                    query.append(orderByFields[i]);
1693    
1694                                    if ((i + 1) < orderByFields.length) {
1695                                            if (orderByComparator.isAscending() ^ previous) {
1696                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1697                                            }
1698                                            else {
1699                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1700                                            }
1701                                    }
1702                                    else {
1703                                            if (orderByComparator.isAscending() ^ previous) {
1704                                                    query.append(ORDER_BY_ASC);
1705                                            }
1706                                            else {
1707                                                    query.append(ORDER_BY_DESC);
1708                                            }
1709                                    }
1710                            }
1711                    }
1712    
1713                    String sql = query.toString();
1714    
1715                    Query q = session.createQuery(sql);
1716    
1717                    q.setFirstResult(0);
1718                    q.setMaxResults(2);
1719    
1720                    QueryPos qPos = QueryPos.getInstance(q);
1721    
1722                    qPos.add(groupId);
1723    
1724                    if (orderByComparator != null) {
1725                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
1726    
1727                            for (Object value : values) {
1728                                    qPos.add(value);
1729                            }
1730                    }
1731    
1732                    List<MDRRuleGroupInstance> list = q.list();
1733    
1734                    if (list.size() == 2) {
1735                            return list.get(1);
1736                    }
1737                    else {
1738                            return null;
1739                    }
1740            }
1741    
1742            /**
1743             * Returns all the m d r rule group instances that the user has permission to view where groupId = &#63;.
1744             *
1745             * @param groupId the group ID
1746             * @return the matching m d r rule group instances that the user has permission to view
1747             * @throws SystemException if a system exception occurred
1748             */
1749            public List<MDRRuleGroupInstance> filterFindByGroupId(long groupId)
1750                    throws SystemException {
1751                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1752                            QueryUtil.ALL_POS, null);
1753            }
1754    
1755            /**
1756             * Returns a range of all the m d r rule group instances that the user has permission to view where groupId = &#63;.
1757             *
1758             * <p>
1759             * 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.
1760             * </p>
1761             *
1762             * @param groupId the group ID
1763             * @param start the lower bound of the range of m d r rule group instances
1764             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
1765             * @return the range of matching m d r rule group instances that the user has permission to view
1766             * @throws SystemException if a system exception occurred
1767             */
1768            public List<MDRRuleGroupInstance> filterFindByGroupId(long groupId,
1769                    int start, int end) throws SystemException {
1770                    return filterFindByGroupId(groupId, start, end, null);
1771            }
1772    
1773            /**
1774             * Returns an ordered range of all the m d r rule group instances that the user has permissions to view where groupId = &#63;.
1775             *
1776             * <p>
1777             * 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.
1778             * </p>
1779             *
1780             * @param groupId the group ID
1781             * @param start the lower bound of the range of m d r rule group instances
1782             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
1783             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1784             * @return the ordered range of matching m d r rule group instances that the user has permission to view
1785             * @throws SystemException if a system exception occurred
1786             */
1787            public List<MDRRuleGroupInstance> filterFindByGroupId(long groupId,
1788                    int start, int end, OrderByComparator orderByComparator)
1789                    throws SystemException {
1790                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1791                            return findByGroupId(groupId, start, end, orderByComparator);
1792                    }
1793    
1794                    StringBundler query = null;
1795    
1796                    if (orderByComparator != null) {
1797                            query = new StringBundler(3 +
1798                                            (orderByComparator.getOrderByFields().length * 3));
1799                    }
1800                    else {
1801                            query = new StringBundler(2);
1802                    }
1803    
1804                    if (getDB().isSupportsInlineDistinct()) {
1805                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1806                    }
1807                    else {
1808                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
1809                    }
1810    
1811                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1812    
1813                    if (!getDB().isSupportsInlineDistinct()) {
1814                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
1815                    }
1816    
1817                    if (orderByComparator != null) {
1818                            if (getDB().isSupportsInlineDistinct()) {
1819                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1820                                            orderByComparator);
1821                            }
1822                            else {
1823                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1824                                            orderByComparator);
1825                            }
1826                    }
1827    
1828                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1829                                    MDRRuleGroupInstance.class.getName(),
1830                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1831    
1832                    Session session = null;
1833    
1834                    try {
1835                            session = openSession();
1836    
1837                            SQLQuery q = session.createSQLQuery(sql);
1838    
1839                            if (getDB().isSupportsInlineDistinct()) {
1840                                    q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
1841                            }
1842                            else {
1843                                    q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
1844                            }
1845    
1846                            QueryPos qPos = QueryPos.getInstance(q);
1847    
1848                            qPos.add(groupId);
1849    
1850                            return (List<MDRRuleGroupInstance>)QueryUtil.list(q, getDialect(),
1851                                    start, end);
1852                    }
1853                    catch (Exception e) {
1854                            throw processException(e);
1855                    }
1856                    finally {
1857                            closeSession(session);
1858                    }
1859            }
1860    
1861            /**
1862             * Returns the m d r rule group instances before and after the current m d r rule group instance in the ordered set of m d r rule group instances that the user has permission to view where groupId = &#63;.
1863             *
1864             * @param ruleGroupInstanceId the primary key of the current m d r rule group instance
1865             * @param groupId the group ID
1866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1867             * @return the previous, current, and next m d r rule group instance
1868             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
1869             * @throws SystemException if a system exception occurred
1870             */
1871            public MDRRuleGroupInstance[] filterFindByGroupId_PrevAndNext(
1872                    long ruleGroupInstanceId, long groupId,
1873                    OrderByComparator orderByComparator)
1874                    throws NoSuchRuleGroupInstanceException, SystemException {
1875                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1876                            return findByGroupId_PrevAndNext(ruleGroupInstanceId, groupId,
1877                                    orderByComparator);
1878                    }
1879    
1880                    MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
1881    
1882                    Session session = null;
1883    
1884                    try {
1885                            session = openSession();
1886    
1887                            MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
1888    
1889                            array[0] = filterGetByGroupId_PrevAndNext(session,
1890                                            mdrRuleGroupInstance, groupId, orderByComparator, true);
1891    
1892                            array[1] = mdrRuleGroupInstance;
1893    
1894                            array[2] = filterGetByGroupId_PrevAndNext(session,
1895                                            mdrRuleGroupInstance, groupId, orderByComparator, false);
1896    
1897                            return array;
1898                    }
1899                    catch (Exception e) {
1900                            throw processException(e);
1901                    }
1902                    finally {
1903                            closeSession(session);
1904                    }
1905            }
1906    
1907            protected MDRRuleGroupInstance filterGetByGroupId_PrevAndNext(
1908                    Session session, MDRRuleGroupInstance mdrRuleGroupInstance,
1909                    long groupId, OrderByComparator orderByComparator, boolean previous) {
1910                    StringBundler query = null;
1911    
1912                    if (orderByComparator != null) {
1913                            query = new StringBundler(6 +
1914                                            (orderByComparator.getOrderByFields().length * 6));
1915                    }
1916                    else {
1917                            query = new StringBundler(3);
1918                    }
1919    
1920                    if (getDB().isSupportsInlineDistinct()) {
1921                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1922                    }
1923                    else {
1924                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
1925                    }
1926    
1927                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1928    
1929                    if (!getDB().isSupportsInlineDistinct()) {
1930                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
1931                    }
1932    
1933                    if (orderByComparator != null) {
1934                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1935    
1936                            if (orderByConditionFields.length > 0) {
1937                                    query.append(WHERE_AND);
1938                            }
1939    
1940                            for (int i = 0; i < orderByConditionFields.length; i++) {
1941                                    if (getDB().isSupportsInlineDistinct()) {
1942                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1943                                    }
1944                                    else {
1945                                            query.append(_ORDER_BY_ENTITY_TABLE);
1946                                    }
1947    
1948                                    query.append(orderByConditionFields[i]);
1949    
1950                                    if ((i + 1) < orderByConditionFields.length) {
1951                                            if (orderByComparator.isAscending() ^ previous) {
1952                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1953                                            }
1954                                            else {
1955                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1956                                            }
1957                                    }
1958                                    else {
1959                                            if (orderByComparator.isAscending() ^ previous) {
1960                                                    query.append(WHERE_GREATER_THAN);
1961                                            }
1962                                            else {
1963                                                    query.append(WHERE_LESSER_THAN);
1964                                            }
1965                                    }
1966                            }
1967    
1968                            query.append(ORDER_BY_CLAUSE);
1969    
1970                            String[] orderByFields = orderByComparator.getOrderByFields();
1971    
1972                            for (int i = 0; i < orderByFields.length; i++) {
1973                                    if (getDB().isSupportsInlineDistinct()) {
1974                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1975                                    }
1976                                    else {
1977                                            query.append(_ORDER_BY_ENTITY_TABLE);
1978                                    }
1979    
1980                                    query.append(orderByFields[i]);
1981    
1982                                    if ((i + 1) < orderByFields.length) {
1983                                            if (orderByComparator.isAscending() ^ previous) {
1984                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1985                                            }
1986                                            else {
1987                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1988                                            }
1989                                    }
1990                                    else {
1991                                            if (orderByComparator.isAscending() ^ previous) {
1992                                                    query.append(ORDER_BY_ASC);
1993                                            }
1994                                            else {
1995                                                    query.append(ORDER_BY_DESC);
1996                                            }
1997                                    }
1998                            }
1999                    }
2000    
2001                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2002                                    MDRRuleGroupInstance.class.getName(),
2003                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2004    
2005                    SQLQuery q = session.createSQLQuery(sql);
2006    
2007                    q.setFirstResult(0);
2008                    q.setMaxResults(2);
2009    
2010                    if (getDB().isSupportsInlineDistinct()) {
2011                            q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
2012                    }
2013                    else {
2014                            q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
2015                    }
2016    
2017                    QueryPos qPos = QueryPos.getInstance(q);
2018    
2019                    qPos.add(groupId);
2020    
2021                    if (orderByComparator != null) {
2022                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
2023    
2024                            for (Object value : values) {
2025                                    qPos.add(value);
2026                            }
2027                    }
2028    
2029                    List<MDRRuleGroupInstance> list = q.list();
2030    
2031                    if (list.size() == 2) {
2032                            return list.get(1);
2033                    }
2034                    else {
2035                            return null;
2036                    }
2037            }
2038    
2039            /**
2040             * Returns all the m d r rule group instances where ruleGroupId = &#63;.
2041             *
2042             * @param ruleGroupId the rule group ID
2043             * @return the matching m d r rule group instances
2044             * @throws SystemException if a system exception occurred
2045             */
2046            public List<MDRRuleGroupInstance> findByRuleGroupId(long ruleGroupId)
2047                    throws SystemException {
2048                    return findByRuleGroupId(ruleGroupId, QueryUtil.ALL_POS,
2049                            QueryUtil.ALL_POS, null);
2050            }
2051    
2052            /**
2053             * Returns a range of all the m d r rule group instances where ruleGroupId = &#63;.
2054             *
2055             * <p>
2056             * 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.
2057             * </p>
2058             *
2059             * @param ruleGroupId the rule group ID
2060             * @param start the lower bound of the range of m d r rule group instances
2061             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
2062             * @return the range of matching m d r rule group instances
2063             * @throws SystemException if a system exception occurred
2064             */
2065            public List<MDRRuleGroupInstance> findByRuleGroupId(long ruleGroupId,
2066                    int start, int end) throws SystemException {
2067                    return findByRuleGroupId(ruleGroupId, start, end, null);
2068            }
2069    
2070            /**
2071             * Returns an ordered range of all the m d r rule group instances where ruleGroupId = &#63;.
2072             *
2073             * <p>
2074             * 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.
2075             * </p>
2076             *
2077             * @param ruleGroupId the rule group ID
2078             * @param start the lower bound of the range of m d r rule group instances
2079             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
2080             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2081             * @return the ordered range of matching m d r rule group instances
2082             * @throws SystemException if a system exception occurred
2083             */
2084            public List<MDRRuleGroupInstance> findByRuleGroupId(long ruleGroupId,
2085                    int start, int end, OrderByComparator orderByComparator)
2086                    throws SystemException {
2087                    FinderPath finderPath = null;
2088                    Object[] finderArgs = null;
2089    
2090                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2091                                    (orderByComparator == null)) {
2092                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID;
2093                            finderArgs = new Object[] { ruleGroupId };
2094                    }
2095                    else {
2096                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPID;
2097                            finderArgs = new Object[] { ruleGroupId, start, end, orderByComparator };
2098                    }
2099    
2100                    List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
2101                                    finderArgs, this);
2102    
2103                    if ((list != null) && !list.isEmpty()) {
2104                            for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
2105                                    if ((ruleGroupId != mdrRuleGroupInstance.getRuleGroupId())) {
2106                                            list = null;
2107    
2108                                            break;
2109                                    }
2110                            }
2111                    }
2112    
2113                    if (list == null) {
2114                            StringBundler query = null;
2115    
2116                            if (orderByComparator != null) {
2117                                    query = new StringBundler(3 +
2118                                                    (orderByComparator.getOrderByFields().length * 3));
2119                            }
2120                            else {
2121                                    query = new StringBundler(2);
2122                            }
2123    
2124                            query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2125    
2126                            query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
2127    
2128                            if (orderByComparator != null) {
2129                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2130                                            orderByComparator);
2131                            }
2132    
2133                            String sql = query.toString();
2134    
2135                            Session session = null;
2136    
2137                            try {
2138                                    session = openSession();
2139    
2140                                    Query q = session.createQuery(sql);
2141    
2142                                    QueryPos qPos = QueryPos.getInstance(q);
2143    
2144                                    qPos.add(ruleGroupId);
2145    
2146                                    list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
2147                                                    getDialect(), start, end);
2148                            }
2149                            catch (Exception e) {
2150                                    throw processException(e);
2151                            }
2152                            finally {
2153                                    if (list == null) {
2154                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2155                                    }
2156                                    else {
2157                                            cacheResult(list);
2158    
2159                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2160                                    }
2161    
2162                                    closeSession(session);
2163                            }
2164                    }
2165    
2166                    return list;
2167            }
2168    
2169            /**
2170             * Returns the first m d r rule group instance in the ordered set where ruleGroupId = &#63;.
2171             *
2172             * @param ruleGroupId the rule group ID
2173             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2174             * @return the first matching m d r rule group instance
2175             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
2176             * @throws SystemException if a system exception occurred
2177             */
2178            public MDRRuleGroupInstance findByRuleGroupId_First(long ruleGroupId,
2179                    OrderByComparator orderByComparator)
2180                    throws NoSuchRuleGroupInstanceException, SystemException {
2181                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByRuleGroupId_First(ruleGroupId,
2182                                    orderByComparator);
2183    
2184                    if (mdrRuleGroupInstance != null) {
2185                            return mdrRuleGroupInstance;
2186                    }
2187    
2188                    StringBundler msg = new StringBundler(4);
2189    
2190                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2191    
2192                    msg.append("ruleGroupId=");
2193                    msg.append(ruleGroupId);
2194    
2195                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2196    
2197                    throw new NoSuchRuleGroupInstanceException(msg.toString());
2198            }
2199    
2200            /**
2201             * Returns the first m d r rule group instance in the ordered set where ruleGroupId = &#63;.
2202             *
2203             * @param ruleGroupId the rule group ID
2204             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2205             * @return the first matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
2206             * @throws SystemException if a system exception occurred
2207             */
2208            public MDRRuleGroupInstance fetchByRuleGroupId_First(long ruleGroupId,
2209                    OrderByComparator orderByComparator) throws SystemException {
2210                    List<MDRRuleGroupInstance> list = findByRuleGroupId(ruleGroupId, 0, 1,
2211                                    orderByComparator);
2212    
2213                    if (!list.isEmpty()) {
2214                            return list.get(0);
2215                    }
2216    
2217                    return null;
2218            }
2219    
2220            /**
2221             * Returns the last m d r rule group instance in the ordered set where ruleGroupId = &#63;.
2222             *
2223             * @param ruleGroupId the rule group ID
2224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2225             * @return the last matching m d r rule group instance
2226             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
2227             * @throws SystemException if a system exception occurred
2228             */
2229            public MDRRuleGroupInstance findByRuleGroupId_Last(long ruleGroupId,
2230                    OrderByComparator orderByComparator)
2231                    throws NoSuchRuleGroupInstanceException, SystemException {
2232                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByRuleGroupId_Last(ruleGroupId,
2233                                    orderByComparator);
2234    
2235                    if (mdrRuleGroupInstance != null) {
2236                            return mdrRuleGroupInstance;
2237                    }
2238    
2239                    StringBundler msg = new StringBundler(4);
2240    
2241                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2242    
2243                    msg.append("ruleGroupId=");
2244                    msg.append(ruleGroupId);
2245    
2246                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2247    
2248                    throw new NoSuchRuleGroupInstanceException(msg.toString());
2249            }
2250    
2251            /**
2252             * Returns the last m d r rule group instance in the ordered set where ruleGroupId = &#63;.
2253             *
2254             * @param ruleGroupId the rule group ID
2255             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2256             * @return the last matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
2257             * @throws SystemException if a system exception occurred
2258             */
2259            public MDRRuleGroupInstance fetchByRuleGroupId_Last(long ruleGroupId,
2260                    OrderByComparator orderByComparator) throws SystemException {
2261                    int count = countByRuleGroupId(ruleGroupId);
2262    
2263                    List<MDRRuleGroupInstance> list = findByRuleGroupId(ruleGroupId,
2264                                    count - 1, count, orderByComparator);
2265    
2266                    if (!list.isEmpty()) {
2267                            return list.get(0);
2268                    }
2269    
2270                    return null;
2271            }
2272    
2273            /**
2274             * Returns the m d r rule group instances before and after the current m d r rule group instance in the ordered set where ruleGroupId = &#63;.
2275             *
2276             * @param ruleGroupInstanceId the primary key of the current m d r rule group instance
2277             * @param ruleGroupId the rule group ID
2278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2279             * @return the previous, current, and next m d r rule group instance
2280             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
2281             * @throws SystemException if a system exception occurred
2282             */
2283            public MDRRuleGroupInstance[] findByRuleGroupId_PrevAndNext(
2284                    long ruleGroupInstanceId, long ruleGroupId,
2285                    OrderByComparator orderByComparator)
2286                    throws NoSuchRuleGroupInstanceException, SystemException {
2287                    MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
2288    
2289                    Session session = null;
2290    
2291                    try {
2292                            session = openSession();
2293    
2294                            MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
2295    
2296                            array[0] = getByRuleGroupId_PrevAndNext(session,
2297                                            mdrRuleGroupInstance, ruleGroupId, orderByComparator, true);
2298    
2299                            array[1] = mdrRuleGroupInstance;
2300    
2301                            array[2] = getByRuleGroupId_PrevAndNext(session,
2302                                            mdrRuleGroupInstance, ruleGroupId, orderByComparator, false);
2303    
2304                            return array;
2305                    }
2306                    catch (Exception e) {
2307                            throw processException(e);
2308                    }
2309                    finally {
2310                            closeSession(session);
2311                    }
2312            }
2313    
2314            protected MDRRuleGroupInstance getByRuleGroupId_PrevAndNext(
2315                    Session session, MDRRuleGroupInstance mdrRuleGroupInstance,
2316                    long ruleGroupId, OrderByComparator orderByComparator, boolean previous) {
2317                    StringBundler query = null;
2318    
2319                    if (orderByComparator != null) {
2320                            query = new StringBundler(6 +
2321                                            (orderByComparator.getOrderByFields().length * 6));
2322                    }
2323                    else {
2324                            query = new StringBundler(3);
2325                    }
2326    
2327                    query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2328    
2329                    query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
2330    
2331                    if (orderByComparator != null) {
2332                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2333    
2334                            if (orderByConditionFields.length > 0) {
2335                                    query.append(WHERE_AND);
2336                            }
2337    
2338                            for (int i = 0; i < orderByConditionFields.length; i++) {
2339                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2340                                    query.append(orderByConditionFields[i]);
2341    
2342                                    if ((i + 1) < orderByConditionFields.length) {
2343                                            if (orderByComparator.isAscending() ^ previous) {
2344                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2345                                            }
2346                                            else {
2347                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2348                                            }
2349                                    }
2350                                    else {
2351                                            if (orderByComparator.isAscending() ^ previous) {
2352                                                    query.append(WHERE_GREATER_THAN);
2353                                            }
2354                                            else {
2355                                                    query.append(WHERE_LESSER_THAN);
2356                                            }
2357                                    }
2358                            }
2359    
2360                            query.append(ORDER_BY_CLAUSE);
2361    
2362                            String[] orderByFields = orderByComparator.getOrderByFields();
2363    
2364                            for (int i = 0; i < orderByFields.length; i++) {
2365                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2366                                    query.append(orderByFields[i]);
2367    
2368                                    if ((i + 1) < orderByFields.length) {
2369                                            if (orderByComparator.isAscending() ^ previous) {
2370                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2371                                            }
2372                                            else {
2373                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2374                                            }
2375                                    }
2376                                    else {
2377                                            if (orderByComparator.isAscending() ^ previous) {
2378                                                    query.append(ORDER_BY_ASC);
2379                                            }
2380                                            else {
2381                                                    query.append(ORDER_BY_DESC);
2382                                            }
2383                                    }
2384                            }
2385                    }
2386    
2387                    String sql = query.toString();
2388    
2389                    Query q = session.createQuery(sql);
2390    
2391                    q.setFirstResult(0);
2392                    q.setMaxResults(2);
2393    
2394                    QueryPos qPos = QueryPos.getInstance(q);
2395    
2396                    qPos.add(ruleGroupId);
2397    
2398                    if (orderByComparator != null) {
2399                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
2400    
2401                            for (Object value : values) {
2402                                    qPos.add(value);
2403                            }
2404                    }
2405    
2406                    List<MDRRuleGroupInstance> list = q.list();
2407    
2408                    if (list.size() == 2) {
2409                            return list.get(1);
2410                    }
2411                    else {
2412                            return null;
2413                    }
2414            }
2415    
2416            /**
2417             * Returns all the m d r rule group instances where classNameId = &#63; and classPK = &#63;.
2418             *
2419             * @param classNameId the class name ID
2420             * @param classPK the class p k
2421             * @return the matching m d r rule group instances
2422             * @throws SystemException if a system exception occurred
2423             */
2424            public List<MDRRuleGroupInstance> findByC_C(long classNameId, long classPK)
2425                    throws SystemException {
2426                    return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
2427                            QueryUtil.ALL_POS, null);
2428            }
2429    
2430            /**
2431             * Returns a range of all the m d r rule group instances where classNameId = &#63; and classPK = &#63;.
2432             *
2433             * <p>
2434             * 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.
2435             * </p>
2436             *
2437             * @param classNameId the class name ID
2438             * @param classPK the class p k
2439             * @param start the lower bound of the range of m d r rule group instances
2440             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
2441             * @return the range of matching m d r rule group instances
2442             * @throws SystemException if a system exception occurred
2443             */
2444            public List<MDRRuleGroupInstance> findByC_C(long classNameId, long classPK,
2445                    int start, int end) throws SystemException {
2446                    return findByC_C(classNameId, classPK, start, end, null);
2447            }
2448    
2449            /**
2450             * Returns an ordered range of all the m d r rule group instances where classNameId = &#63; and classPK = &#63;.
2451             *
2452             * <p>
2453             * 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.
2454             * </p>
2455             *
2456             * @param classNameId the class name ID
2457             * @param classPK the class p k
2458             * @param start the lower bound of the range of m d r rule group instances
2459             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
2460             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2461             * @return the ordered range of matching m d r rule group instances
2462             * @throws SystemException if a system exception occurred
2463             */
2464            public List<MDRRuleGroupInstance> findByC_C(long classNameId, long classPK,
2465                    int start, int end, OrderByComparator orderByComparator)
2466                    throws SystemException {
2467                    FinderPath finderPath = null;
2468                    Object[] finderArgs = null;
2469    
2470                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2471                                    (orderByComparator == null)) {
2472                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2473                            finderArgs = new Object[] { classNameId, classPK };
2474                    }
2475                    else {
2476                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2477                            finderArgs = new Object[] {
2478                                            classNameId, classPK,
2479                                            
2480                                            start, end, orderByComparator
2481                                    };
2482                    }
2483    
2484                    List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
2485                                    finderArgs, this);
2486    
2487                    if ((list != null) && !list.isEmpty()) {
2488                            for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
2489                                    if ((classNameId != mdrRuleGroupInstance.getClassNameId()) ||
2490                                                    (classPK != mdrRuleGroupInstance.getClassPK())) {
2491                                            list = null;
2492    
2493                                            break;
2494                                    }
2495                            }
2496                    }
2497    
2498                    if (list == null) {
2499                            StringBundler query = null;
2500    
2501                            if (orderByComparator != null) {
2502                                    query = new StringBundler(4 +
2503                                                    (orderByComparator.getOrderByFields().length * 3));
2504                            }
2505                            else {
2506                                    query = new StringBundler(3);
2507                            }
2508    
2509                            query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2510    
2511                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2512    
2513                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2514    
2515                            if (orderByComparator != null) {
2516                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2517                                            orderByComparator);
2518                            }
2519    
2520                            String sql = query.toString();
2521    
2522                            Session session = null;
2523    
2524                            try {
2525                                    session = openSession();
2526    
2527                                    Query q = session.createQuery(sql);
2528    
2529                                    QueryPos qPos = QueryPos.getInstance(q);
2530    
2531                                    qPos.add(classNameId);
2532    
2533                                    qPos.add(classPK);
2534    
2535                                    list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
2536                                                    getDialect(), start, end);
2537                            }
2538                            catch (Exception e) {
2539                                    throw processException(e);
2540                            }
2541                            finally {
2542                                    if (list == null) {
2543                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2544                                    }
2545                                    else {
2546                                            cacheResult(list);
2547    
2548                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2549                                    }
2550    
2551                                    closeSession(session);
2552                            }
2553                    }
2554    
2555                    return list;
2556            }
2557    
2558            /**
2559             * Returns the first m d r rule group instance in the ordered set where classNameId = &#63; and classPK = &#63;.
2560             *
2561             * @param classNameId the class name ID
2562             * @param classPK the class p k
2563             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2564             * @return the first matching m d r rule group instance
2565             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
2566             * @throws SystemException if a system exception occurred
2567             */
2568            public MDRRuleGroupInstance findByC_C_First(long classNameId, long classPK,
2569                    OrderByComparator orderByComparator)
2570                    throws NoSuchRuleGroupInstanceException, SystemException {
2571                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByC_C_First(classNameId,
2572                                    classPK, orderByComparator);
2573    
2574                    if (mdrRuleGroupInstance != null) {
2575                            return mdrRuleGroupInstance;
2576                    }
2577    
2578                    StringBundler msg = new StringBundler(6);
2579    
2580                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2581    
2582                    msg.append("classNameId=");
2583                    msg.append(classNameId);
2584    
2585                    msg.append(", classPK=");
2586                    msg.append(classPK);
2587    
2588                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2589    
2590                    throw new NoSuchRuleGroupInstanceException(msg.toString());
2591            }
2592    
2593            /**
2594             * Returns the first m d r rule group instance in the ordered set where classNameId = &#63; and classPK = &#63;.
2595             *
2596             * @param classNameId the class name ID
2597             * @param classPK the class p k
2598             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2599             * @return the first matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
2600             * @throws SystemException if a system exception occurred
2601             */
2602            public MDRRuleGroupInstance fetchByC_C_First(long classNameId,
2603                    long classPK, OrderByComparator orderByComparator)
2604                    throws SystemException {
2605                    List<MDRRuleGroupInstance> list = findByC_C(classNameId, classPK, 0, 1,
2606                                    orderByComparator);
2607    
2608                    if (!list.isEmpty()) {
2609                            return list.get(0);
2610                    }
2611    
2612                    return null;
2613            }
2614    
2615            /**
2616             * Returns the last m d r rule group instance in the ordered set where classNameId = &#63; and classPK = &#63;.
2617             *
2618             * @param classNameId the class name ID
2619             * @param classPK the class p k
2620             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2621             * @return the last matching m d r rule group instance
2622             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
2623             * @throws SystemException if a system exception occurred
2624             */
2625            public MDRRuleGroupInstance findByC_C_Last(long classNameId, long classPK,
2626                    OrderByComparator orderByComparator)
2627                    throws NoSuchRuleGroupInstanceException, SystemException {
2628                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByC_C_Last(classNameId,
2629                                    classPK, orderByComparator);
2630    
2631                    if (mdrRuleGroupInstance != null) {
2632                            return mdrRuleGroupInstance;
2633                    }
2634    
2635                    StringBundler msg = new StringBundler(6);
2636    
2637                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2638    
2639                    msg.append("classNameId=");
2640                    msg.append(classNameId);
2641    
2642                    msg.append(", classPK=");
2643                    msg.append(classPK);
2644    
2645                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2646    
2647                    throw new NoSuchRuleGroupInstanceException(msg.toString());
2648            }
2649    
2650            /**
2651             * Returns the last m d r rule group instance in the ordered set where classNameId = &#63; and classPK = &#63;.
2652             *
2653             * @param classNameId the class name ID
2654             * @param classPK the class p k
2655             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2656             * @return the last matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
2657             * @throws SystemException if a system exception occurred
2658             */
2659            public MDRRuleGroupInstance fetchByC_C_Last(long classNameId, long classPK,
2660                    OrderByComparator orderByComparator) throws SystemException {
2661                    int count = countByC_C(classNameId, classPK);
2662    
2663                    List<MDRRuleGroupInstance> list = findByC_C(classNameId, classPK,
2664                                    count - 1, count, orderByComparator);
2665    
2666                    if (!list.isEmpty()) {
2667                            return list.get(0);
2668                    }
2669    
2670                    return null;
2671            }
2672    
2673            /**
2674             * Returns the m d r rule group instances before and after the current m d r rule group instance in the ordered set where classNameId = &#63; and classPK = &#63;.
2675             *
2676             * @param ruleGroupInstanceId the primary key of the current m d r rule group instance
2677             * @param classNameId the class name ID
2678             * @param classPK the class p k
2679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2680             * @return the previous, current, and next m d r rule group instance
2681             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
2682             * @throws SystemException if a system exception occurred
2683             */
2684            public MDRRuleGroupInstance[] findByC_C_PrevAndNext(
2685                    long ruleGroupInstanceId, long classNameId, long classPK,
2686                    OrderByComparator orderByComparator)
2687                    throws NoSuchRuleGroupInstanceException, SystemException {
2688                    MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
2689    
2690                    Session session = null;
2691    
2692                    try {
2693                            session = openSession();
2694    
2695                            MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
2696    
2697                            array[0] = getByC_C_PrevAndNext(session, mdrRuleGroupInstance,
2698                                            classNameId, classPK, orderByComparator, true);
2699    
2700                            array[1] = mdrRuleGroupInstance;
2701    
2702                            array[2] = getByC_C_PrevAndNext(session, mdrRuleGroupInstance,
2703                                            classNameId, classPK, orderByComparator, false);
2704    
2705                            return array;
2706                    }
2707                    catch (Exception e) {
2708                            throw processException(e);
2709                    }
2710                    finally {
2711                            closeSession(session);
2712                    }
2713            }
2714    
2715            protected MDRRuleGroupInstance getByC_C_PrevAndNext(Session session,
2716                    MDRRuleGroupInstance mdrRuleGroupInstance, long classNameId,
2717                    long classPK, OrderByComparator orderByComparator, boolean previous) {
2718                    StringBundler query = null;
2719    
2720                    if (orderByComparator != null) {
2721                            query = new StringBundler(6 +
2722                                            (orderByComparator.getOrderByFields().length * 6));
2723                    }
2724                    else {
2725                            query = new StringBundler(3);
2726                    }
2727    
2728                    query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2729    
2730                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2731    
2732                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2733    
2734                    if (orderByComparator != null) {
2735                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2736    
2737                            if (orderByConditionFields.length > 0) {
2738                                    query.append(WHERE_AND);
2739                            }
2740    
2741                            for (int i = 0; i < orderByConditionFields.length; i++) {
2742                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2743                                    query.append(orderByConditionFields[i]);
2744    
2745                                    if ((i + 1) < orderByConditionFields.length) {
2746                                            if (orderByComparator.isAscending() ^ previous) {
2747                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2748                                            }
2749                                            else {
2750                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2751                                            }
2752                                    }
2753                                    else {
2754                                            if (orderByComparator.isAscending() ^ previous) {
2755                                                    query.append(WHERE_GREATER_THAN);
2756                                            }
2757                                            else {
2758                                                    query.append(WHERE_LESSER_THAN);
2759                                            }
2760                                    }
2761                            }
2762    
2763                            query.append(ORDER_BY_CLAUSE);
2764    
2765                            String[] orderByFields = orderByComparator.getOrderByFields();
2766    
2767                            for (int i = 0; i < orderByFields.length; i++) {
2768                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2769                                    query.append(orderByFields[i]);
2770    
2771                                    if ((i + 1) < orderByFields.length) {
2772                                            if (orderByComparator.isAscending() ^ previous) {
2773                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2774                                            }
2775                                            else {
2776                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2777                                            }
2778                                    }
2779                                    else {
2780                                            if (orderByComparator.isAscending() ^ previous) {
2781                                                    query.append(ORDER_BY_ASC);
2782                                            }
2783                                            else {
2784                                                    query.append(ORDER_BY_DESC);
2785                                            }
2786                                    }
2787                            }
2788                    }
2789    
2790                    String sql = query.toString();
2791    
2792                    Query q = session.createQuery(sql);
2793    
2794                    q.setFirstResult(0);
2795                    q.setMaxResults(2);
2796    
2797                    QueryPos qPos = QueryPos.getInstance(q);
2798    
2799                    qPos.add(classNameId);
2800    
2801                    qPos.add(classPK);
2802    
2803                    if (orderByComparator != null) {
2804                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
2805    
2806                            for (Object value : values) {
2807                                    qPos.add(value);
2808                            }
2809                    }
2810    
2811                    List<MDRRuleGroupInstance> list = q.list();
2812    
2813                    if (list.size() == 2) {
2814                            return list.get(1);
2815                    }
2816                    else {
2817                            return null;
2818                    }
2819            }
2820    
2821            /**
2822             * Returns all the m d r rule group instances where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
2823             *
2824             * @param groupId the group ID
2825             * @param classNameId the class name ID
2826             * @param classPK the class p k
2827             * @return the matching m d r rule group instances
2828             * @throws SystemException if a system exception occurred
2829             */
2830            public List<MDRRuleGroupInstance> findByG_C_C(long groupId,
2831                    long classNameId, long classPK) throws SystemException {
2832                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
2833                            QueryUtil.ALL_POS, null);
2834            }
2835    
2836            /**
2837             * Returns a range of all the m d r rule group instances where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
2838             *
2839             * <p>
2840             * 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.
2841             * </p>
2842             *
2843             * @param groupId the group ID
2844             * @param classNameId the class name ID
2845             * @param classPK the class p k
2846             * @param start the lower bound of the range of m d r rule group instances
2847             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
2848             * @return the range of matching m d r rule group instances
2849             * @throws SystemException if a system exception occurred
2850             */
2851            public List<MDRRuleGroupInstance> findByG_C_C(long groupId,
2852                    long classNameId, long classPK, int start, int end)
2853                    throws SystemException {
2854                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
2855            }
2856    
2857            /**
2858             * Returns an ordered range of all the m d r rule group instances where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
2859             *
2860             * <p>
2861             * 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.
2862             * </p>
2863             *
2864             * @param groupId the group ID
2865             * @param classNameId the class name ID
2866             * @param classPK the class p k
2867             * @param start the lower bound of the range of m d r rule group instances
2868             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
2869             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2870             * @return the ordered range of matching m d r rule group instances
2871             * @throws SystemException if a system exception occurred
2872             */
2873            public List<MDRRuleGroupInstance> findByG_C_C(long groupId,
2874                    long classNameId, long classPK, int start, int end,
2875                    OrderByComparator orderByComparator) throws SystemException {
2876                    FinderPath finderPath = null;
2877                    Object[] finderArgs = null;
2878    
2879                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2880                                    (orderByComparator == null)) {
2881                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
2882                            finderArgs = new Object[] { groupId, classNameId, classPK };
2883                    }
2884                    else {
2885                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
2886                            finderArgs = new Object[] {
2887                                            groupId, classNameId, classPK,
2888                                            
2889                                            start, end, orderByComparator
2890                                    };
2891                    }
2892    
2893                    List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
2894                                    finderArgs, this);
2895    
2896                    if ((list != null) && !list.isEmpty()) {
2897                            for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
2898                                    if ((groupId != mdrRuleGroupInstance.getGroupId()) ||
2899                                                    (classNameId != mdrRuleGroupInstance.getClassNameId()) ||
2900                                                    (classPK != mdrRuleGroupInstance.getClassPK())) {
2901                                            list = null;
2902    
2903                                            break;
2904                                    }
2905                            }
2906                    }
2907    
2908                    if (list == null) {
2909                            StringBundler query = null;
2910    
2911                            if (orderByComparator != null) {
2912                                    query = new StringBundler(5 +
2913                                                    (orderByComparator.getOrderByFields().length * 3));
2914                            }
2915                            else {
2916                                    query = new StringBundler(4);
2917                            }
2918    
2919                            query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2920    
2921                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
2922    
2923                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
2924    
2925                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
2926    
2927                            if (orderByComparator != null) {
2928                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2929                                            orderByComparator);
2930                            }
2931    
2932                            String sql = query.toString();
2933    
2934                            Session session = null;
2935    
2936                            try {
2937                                    session = openSession();
2938    
2939                                    Query q = session.createQuery(sql);
2940    
2941                                    QueryPos qPos = QueryPos.getInstance(q);
2942    
2943                                    qPos.add(groupId);
2944    
2945                                    qPos.add(classNameId);
2946    
2947                                    qPos.add(classPK);
2948    
2949                                    list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
2950                                                    getDialect(), start, end);
2951                            }
2952                            catch (Exception e) {
2953                                    throw processException(e);
2954                            }
2955                            finally {
2956                                    if (list == null) {
2957                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2958                                    }
2959                                    else {
2960                                            cacheResult(list);
2961    
2962                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2963                                    }
2964    
2965                                    closeSession(session);
2966                            }
2967                    }
2968    
2969                    return list;
2970            }
2971    
2972            /**
2973             * Returns the first m d r rule group instance in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
2974             *
2975             * @param groupId the group ID
2976             * @param classNameId the class name ID
2977             * @param classPK the class p k
2978             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2979             * @return the first matching m d r rule group instance
2980             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
2981             * @throws SystemException if a system exception occurred
2982             */
2983            public MDRRuleGroupInstance findByG_C_C_First(long groupId,
2984                    long classNameId, long classPK, OrderByComparator orderByComparator)
2985                    throws NoSuchRuleGroupInstanceException, SystemException {
2986                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByG_C_C_First(groupId,
2987                                    classNameId, classPK, orderByComparator);
2988    
2989                    if (mdrRuleGroupInstance != null) {
2990                            return mdrRuleGroupInstance;
2991                    }
2992    
2993                    StringBundler msg = new StringBundler(8);
2994    
2995                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2996    
2997                    msg.append("groupId=");
2998                    msg.append(groupId);
2999    
3000                    msg.append(", classNameId=");
3001                    msg.append(classNameId);
3002    
3003                    msg.append(", classPK=");
3004                    msg.append(classPK);
3005    
3006                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3007    
3008                    throw new NoSuchRuleGroupInstanceException(msg.toString());
3009            }
3010    
3011            /**
3012             * Returns the first m d r rule group instance in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
3013             *
3014             * @param groupId the group ID
3015             * @param classNameId the class name ID
3016             * @param classPK the class p k
3017             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3018             * @return the first matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
3019             * @throws SystemException if a system exception occurred
3020             */
3021            public MDRRuleGroupInstance fetchByG_C_C_First(long groupId,
3022                    long classNameId, long classPK, OrderByComparator orderByComparator)
3023                    throws SystemException {
3024                    List<MDRRuleGroupInstance> list = findByG_C_C(groupId, classNameId,
3025                                    classPK, 0, 1, orderByComparator);
3026    
3027                    if (!list.isEmpty()) {
3028                            return list.get(0);
3029                    }
3030    
3031                    return null;
3032            }
3033    
3034            /**
3035             * Returns the last m d r rule group instance in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
3036             *
3037             * @param groupId the group ID
3038             * @param classNameId the class name ID
3039             * @param classPK the class p k
3040             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3041             * @return the last matching m d r rule group instance
3042             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
3043             * @throws SystemException if a system exception occurred
3044             */
3045            public MDRRuleGroupInstance findByG_C_C_Last(long groupId,
3046                    long classNameId, long classPK, OrderByComparator orderByComparator)
3047                    throws NoSuchRuleGroupInstanceException, SystemException {
3048                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByG_C_C_Last(groupId,
3049                                    classNameId, classPK, orderByComparator);
3050    
3051                    if (mdrRuleGroupInstance != null) {
3052                            return mdrRuleGroupInstance;
3053                    }
3054    
3055                    StringBundler msg = new StringBundler(8);
3056    
3057                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3058    
3059                    msg.append("groupId=");
3060                    msg.append(groupId);
3061    
3062                    msg.append(", classNameId=");
3063                    msg.append(classNameId);
3064    
3065                    msg.append(", classPK=");
3066                    msg.append(classPK);
3067    
3068                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3069    
3070                    throw new NoSuchRuleGroupInstanceException(msg.toString());
3071            }
3072    
3073            /**
3074             * Returns the last m d r rule group instance in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
3075             *
3076             * @param groupId the group ID
3077             * @param classNameId the class name ID
3078             * @param classPK the class p k
3079             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3080             * @return the last matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
3081             * @throws SystemException if a system exception occurred
3082             */
3083            public MDRRuleGroupInstance fetchByG_C_C_Last(long groupId,
3084                    long classNameId, long classPK, OrderByComparator orderByComparator)
3085                    throws SystemException {
3086                    int count = countByG_C_C(groupId, classNameId, classPK);
3087    
3088                    List<MDRRuleGroupInstance> list = findByG_C_C(groupId, classNameId,
3089                                    classPK, count - 1, count, orderByComparator);
3090    
3091                    if (!list.isEmpty()) {
3092                            return list.get(0);
3093                    }
3094    
3095                    return null;
3096            }
3097    
3098            /**
3099             * Returns the m d r rule group instances before and after the current m d r rule group instance in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
3100             *
3101             * @param ruleGroupInstanceId the primary key of the current m d r rule group instance
3102             * @param groupId the group ID
3103             * @param classNameId the class name ID
3104             * @param classPK the class p k
3105             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3106             * @return the previous, current, and next m d r rule group instance
3107             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
3108             * @throws SystemException if a system exception occurred
3109             */
3110            public MDRRuleGroupInstance[] findByG_C_C_PrevAndNext(
3111                    long ruleGroupInstanceId, long groupId, long classNameId, long classPK,
3112                    OrderByComparator orderByComparator)
3113                    throws NoSuchRuleGroupInstanceException, SystemException {
3114                    MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
3115    
3116                    Session session = null;
3117    
3118                    try {
3119                            session = openSession();
3120    
3121                            MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
3122    
3123                            array[0] = getByG_C_C_PrevAndNext(session, mdrRuleGroupInstance,
3124                                            groupId, classNameId, classPK, orderByComparator, true);
3125    
3126                            array[1] = mdrRuleGroupInstance;
3127    
3128                            array[2] = getByG_C_C_PrevAndNext(session, mdrRuleGroupInstance,
3129                                            groupId, classNameId, classPK, orderByComparator, false);
3130    
3131                            return array;
3132                    }
3133                    catch (Exception e) {
3134                            throw processException(e);
3135                    }
3136                    finally {
3137                            closeSession(session);
3138                    }
3139            }
3140    
3141            protected MDRRuleGroupInstance getByG_C_C_PrevAndNext(Session session,
3142                    MDRRuleGroupInstance mdrRuleGroupInstance, long groupId,
3143                    long classNameId, long classPK, OrderByComparator orderByComparator,
3144                    boolean previous) {
3145                    StringBundler query = null;
3146    
3147                    if (orderByComparator != null) {
3148                            query = new StringBundler(6 +
3149                                            (orderByComparator.getOrderByFields().length * 6));
3150                    }
3151                    else {
3152                            query = new StringBundler(3);
3153                    }
3154    
3155                    query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
3156    
3157                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
3158    
3159                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
3160    
3161                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
3162    
3163                    if (orderByComparator != null) {
3164                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3165    
3166                            if (orderByConditionFields.length > 0) {
3167                                    query.append(WHERE_AND);
3168                            }
3169    
3170                            for (int i = 0; i < orderByConditionFields.length; i++) {
3171                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3172                                    query.append(orderByConditionFields[i]);
3173    
3174                                    if ((i + 1) < orderByConditionFields.length) {
3175                                            if (orderByComparator.isAscending() ^ previous) {
3176                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3177                                            }
3178                                            else {
3179                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3180                                            }
3181                                    }
3182                                    else {
3183                                            if (orderByComparator.isAscending() ^ previous) {
3184                                                    query.append(WHERE_GREATER_THAN);
3185                                            }
3186                                            else {
3187                                                    query.append(WHERE_LESSER_THAN);
3188                                            }
3189                                    }
3190                            }
3191    
3192                            query.append(ORDER_BY_CLAUSE);
3193    
3194                            String[] orderByFields = orderByComparator.getOrderByFields();
3195    
3196                            for (int i = 0; i < orderByFields.length; i++) {
3197                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3198                                    query.append(orderByFields[i]);
3199    
3200                                    if ((i + 1) < orderByFields.length) {
3201                                            if (orderByComparator.isAscending() ^ previous) {
3202                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3203                                            }
3204                                            else {
3205                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3206                                            }
3207                                    }
3208                                    else {
3209                                            if (orderByComparator.isAscending() ^ previous) {
3210                                                    query.append(ORDER_BY_ASC);
3211                                            }
3212                                            else {
3213                                                    query.append(ORDER_BY_DESC);
3214                                            }
3215                                    }
3216                            }
3217                    }
3218    
3219                    String sql = query.toString();
3220    
3221                    Query q = session.createQuery(sql);
3222    
3223                    q.setFirstResult(0);
3224                    q.setMaxResults(2);
3225    
3226                    QueryPos qPos = QueryPos.getInstance(q);
3227    
3228                    qPos.add(groupId);
3229    
3230                    qPos.add(classNameId);
3231    
3232                    qPos.add(classPK);
3233    
3234                    if (orderByComparator != null) {
3235                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
3236    
3237                            for (Object value : values) {
3238                                    qPos.add(value);
3239                            }
3240                    }
3241    
3242                    List<MDRRuleGroupInstance> list = q.list();
3243    
3244                    if (list.size() == 2) {
3245                            return list.get(1);
3246                    }
3247                    else {
3248                            return null;
3249                    }
3250            }
3251    
3252            /**
3253             * Returns all the m d r rule group instances that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
3254             *
3255             * @param groupId the group ID
3256             * @param classNameId the class name ID
3257             * @param classPK the class p k
3258             * @return the matching m d r rule group instances that the user has permission to view
3259             * @throws SystemException if a system exception occurred
3260             */
3261            public List<MDRRuleGroupInstance> filterFindByG_C_C(long groupId,
3262                    long classNameId, long classPK) throws SystemException {
3263                    return filterFindByG_C_C(groupId, classNameId, classPK,
3264                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3265            }
3266    
3267            /**
3268             * Returns a range of all the m d r rule group instances that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
3269             *
3270             * <p>
3271             * 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.
3272             * </p>
3273             *
3274             * @param groupId the group ID
3275             * @param classNameId the class name ID
3276             * @param classPK the class p k
3277             * @param start the lower bound of the range of m d r rule group instances
3278             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
3279             * @return the range of matching m d r rule group instances that the user has permission to view
3280             * @throws SystemException if a system exception occurred
3281             */
3282            public List<MDRRuleGroupInstance> filterFindByG_C_C(long groupId,
3283                    long classNameId, long classPK, int start, int end)
3284                    throws SystemException {
3285                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
3286            }
3287    
3288            /**
3289             * Returns an ordered range of all the m d r rule group instances that the user has permissions to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
3290             *
3291             * <p>
3292             * 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.
3293             * </p>
3294             *
3295             * @param groupId the group ID
3296             * @param classNameId the class name ID
3297             * @param classPK the class p k
3298             * @param start the lower bound of the range of m d r rule group instances
3299             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
3300             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3301             * @return the ordered range of matching m d r rule group instances that the user has permission to view
3302             * @throws SystemException if a system exception occurred
3303             */
3304            public List<MDRRuleGroupInstance> filterFindByG_C_C(long groupId,
3305                    long classNameId, long classPK, int start, int end,
3306                    OrderByComparator orderByComparator) throws SystemException {
3307                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3308                            return findByG_C_C(groupId, classNameId, classPK, start, end,
3309                                    orderByComparator);
3310                    }
3311    
3312                    StringBundler query = null;
3313    
3314                    if (orderByComparator != null) {
3315                            query = new StringBundler(5 +
3316                                            (orderByComparator.getOrderByFields().length * 3));
3317                    }
3318                    else {
3319                            query = new StringBundler(4);
3320                    }
3321    
3322                    if (getDB().isSupportsInlineDistinct()) {
3323                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
3324                    }
3325                    else {
3326                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
3327                    }
3328    
3329                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
3330    
3331                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
3332    
3333                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
3334    
3335                    if (!getDB().isSupportsInlineDistinct()) {
3336                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
3337                    }
3338    
3339                    if (orderByComparator != null) {
3340                            if (getDB().isSupportsInlineDistinct()) {
3341                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3342                                            orderByComparator);
3343                            }
3344                            else {
3345                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3346                                            orderByComparator);
3347                            }
3348                    }
3349    
3350                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3351                                    MDRRuleGroupInstance.class.getName(),
3352                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3353    
3354                    Session session = null;
3355    
3356                    try {
3357                            session = openSession();
3358    
3359                            SQLQuery q = session.createSQLQuery(sql);
3360    
3361                            if (getDB().isSupportsInlineDistinct()) {
3362                                    q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
3363                            }
3364                            else {
3365                                    q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
3366                            }
3367    
3368                            QueryPos qPos = QueryPos.getInstance(q);
3369    
3370                            qPos.add(groupId);
3371    
3372                            qPos.add(classNameId);
3373    
3374                            qPos.add(classPK);
3375    
3376                            return (List<MDRRuleGroupInstance>)QueryUtil.list(q, getDialect(),
3377                                    start, end);
3378                    }
3379                    catch (Exception e) {
3380                            throw processException(e);
3381                    }
3382                    finally {
3383                            closeSession(session);
3384                    }
3385            }
3386    
3387            /**
3388             * Returns the m d r rule group instances before and after the current m d r rule group instance in the ordered set of m d r rule group instances that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
3389             *
3390             * @param ruleGroupInstanceId the primary key of the current m d r rule group instance
3391             * @param groupId the group ID
3392             * @param classNameId the class name ID
3393             * @param classPK the class p k
3394             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3395             * @return the previous, current, and next m d r rule group instance
3396             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a m d r rule group instance with the primary key could not be found
3397             * @throws SystemException if a system exception occurred
3398             */
3399            public MDRRuleGroupInstance[] filterFindByG_C_C_PrevAndNext(
3400                    long ruleGroupInstanceId, long groupId, long classNameId, long classPK,
3401                    OrderByComparator orderByComparator)
3402                    throws NoSuchRuleGroupInstanceException, SystemException {
3403                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3404                            return findByG_C_C_PrevAndNext(ruleGroupInstanceId, groupId,
3405                                    classNameId, classPK, orderByComparator);
3406                    }
3407    
3408                    MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
3409    
3410                    Session session = null;
3411    
3412                    try {
3413                            session = openSession();
3414    
3415                            MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
3416    
3417                            array[0] = filterGetByG_C_C_PrevAndNext(session,
3418                                            mdrRuleGroupInstance, groupId, classNameId, classPK,
3419                                            orderByComparator, true);
3420    
3421                            array[1] = mdrRuleGroupInstance;
3422    
3423                            array[2] = filterGetByG_C_C_PrevAndNext(session,
3424                                            mdrRuleGroupInstance, groupId, classNameId, classPK,
3425                                            orderByComparator, false);
3426    
3427                            return array;
3428                    }
3429                    catch (Exception e) {
3430                            throw processException(e);
3431                    }
3432                    finally {
3433                            closeSession(session);
3434                    }
3435            }
3436    
3437            protected MDRRuleGroupInstance filterGetByG_C_C_PrevAndNext(
3438                    Session session, MDRRuleGroupInstance mdrRuleGroupInstance,
3439                    long groupId, long classNameId, long classPK,
3440                    OrderByComparator orderByComparator, boolean previous) {
3441                    StringBundler query = null;
3442    
3443                    if (orderByComparator != null) {
3444                            query = new StringBundler(6 +
3445                                            (orderByComparator.getOrderByFields().length * 6));
3446                    }
3447                    else {
3448                            query = new StringBundler(3);
3449                    }
3450    
3451                    if (getDB().isSupportsInlineDistinct()) {
3452                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
3453                    }
3454                    else {
3455                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
3456                    }
3457    
3458                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
3459    
3460                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
3461    
3462                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
3463    
3464                    if (!getDB().isSupportsInlineDistinct()) {
3465                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
3466                    }
3467    
3468                    if (orderByComparator != null) {
3469                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3470    
3471                            if (orderByConditionFields.length > 0) {
3472                                    query.append(WHERE_AND);
3473                            }
3474    
3475                            for (int i = 0; i < orderByConditionFields.length; i++) {
3476                                    if (getDB().isSupportsInlineDistinct()) {
3477                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3478                                    }
3479                                    else {
3480                                            query.append(_ORDER_BY_ENTITY_TABLE);
3481                                    }
3482    
3483                                    query.append(orderByConditionFields[i]);
3484    
3485                                    if ((i + 1) < orderByConditionFields.length) {
3486                                            if (orderByComparator.isAscending() ^ previous) {
3487                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3488                                            }
3489                                            else {
3490                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3491                                            }
3492                                    }
3493                                    else {
3494                                            if (orderByComparator.isAscending() ^ previous) {
3495                                                    query.append(WHERE_GREATER_THAN);
3496                                            }
3497                                            else {
3498                                                    query.append(WHERE_LESSER_THAN);
3499                                            }
3500                                    }
3501                            }
3502    
3503                            query.append(ORDER_BY_CLAUSE);
3504    
3505                            String[] orderByFields = orderByComparator.getOrderByFields();
3506    
3507                            for (int i = 0; i < orderByFields.length; i++) {
3508                                    if (getDB().isSupportsInlineDistinct()) {
3509                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3510                                    }
3511                                    else {
3512                                            query.append(_ORDER_BY_ENTITY_TABLE);
3513                                    }
3514    
3515                                    query.append(orderByFields[i]);
3516    
3517                                    if ((i + 1) < orderByFields.length) {
3518                                            if (orderByComparator.isAscending() ^ previous) {
3519                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3520                                            }
3521                                            else {
3522                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3523                                            }
3524                                    }
3525                                    else {
3526                                            if (orderByComparator.isAscending() ^ previous) {
3527                                                    query.append(ORDER_BY_ASC);
3528                                            }
3529                                            else {
3530                                                    query.append(ORDER_BY_DESC);
3531                                            }
3532                                    }
3533                            }
3534                    }
3535    
3536                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3537                                    MDRRuleGroupInstance.class.getName(),
3538                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3539    
3540                    SQLQuery q = session.createSQLQuery(sql);
3541    
3542                    q.setFirstResult(0);
3543                    q.setMaxResults(2);
3544    
3545                    if (getDB().isSupportsInlineDistinct()) {
3546                            q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
3547                    }
3548                    else {
3549                            q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
3550                    }
3551    
3552                    QueryPos qPos = QueryPos.getInstance(q);
3553    
3554                    qPos.add(groupId);
3555    
3556                    qPos.add(classNameId);
3557    
3558                    qPos.add(classPK);
3559    
3560                    if (orderByComparator != null) {
3561                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
3562    
3563                            for (Object value : values) {
3564                                    qPos.add(value);
3565                            }
3566                    }
3567    
3568                    List<MDRRuleGroupInstance> list = q.list();
3569    
3570                    if (list.size() == 2) {
3571                            return list.get(1);
3572                    }
3573                    else {
3574                            return null;
3575                    }
3576            }
3577    
3578            /**
3579             * Returns the m d r rule group instance where classNameId = &#63; and classPK = &#63; and ruleGroupId = &#63; or throws a {@link com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException} if it could not be found.
3580             *
3581             * @param classNameId the class name ID
3582             * @param classPK the class p k
3583             * @param ruleGroupId the rule group ID
3584             * @return the matching m d r rule group instance
3585             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException if a matching m d r rule group instance could not be found
3586             * @throws SystemException if a system exception occurred
3587             */
3588            public MDRRuleGroupInstance findByC_C_R(long classNameId, long classPK,
3589                    long ruleGroupId)
3590                    throws NoSuchRuleGroupInstanceException, SystemException {
3591                    MDRRuleGroupInstance mdrRuleGroupInstance = fetchByC_C_R(classNameId,
3592                                    classPK, ruleGroupId);
3593    
3594                    if (mdrRuleGroupInstance == null) {
3595                            StringBundler msg = new StringBundler(8);
3596    
3597                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3598    
3599                            msg.append("classNameId=");
3600                            msg.append(classNameId);
3601    
3602                            msg.append(", classPK=");
3603                            msg.append(classPK);
3604    
3605                            msg.append(", ruleGroupId=");
3606                            msg.append(ruleGroupId);
3607    
3608                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3609    
3610                            if (_log.isWarnEnabled()) {
3611                                    _log.warn(msg.toString());
3612                            }
3613    
3614                            throw new NoSuchRuleGroupInstanceException(msg.toString());
3615                    }
3616    
3617                    return mdrRuleGroupInstance;
3618            }
3619    
3620            /**
3621             * Returns the m d r rule group instance where classNameId = &#63; and classPK = &#63; and ruleGroupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3622             *
3623             * @param classNameId the class name ID
3624             * @param classPK the class p k
3625             * @param ruleGroupId the rule group ID
3626             * @return the matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
3627             * @throws SystemException if a system exception occurred
3628             */
3629            public MDRRuleGroupInstance fetchByC_C_R(long classNameId, long classPK,
3630                    long ruleGroupId) throws SystemException {
3631                    return fetchByC_C_R(classNameId, classPK, ruleGroupId, true);
3632            }
3633    
3634            /**
3635             * Returns the m d r rule group instance where classNameId = &#63; and classPK = &#63; and ruleGroupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
3636             *
3637             * @param classNameId the class name ID
3638             * @param classPK the class p k
3639             * @param ruleGroupId the rule group ID
3640             * @param retrieveFromCache whether to use the finder cache
3641             * @return the matching m d r rule group instance, or <code>null</code> if a matching m d r rule group instance could not be found
3642             * @throws SystemException if a system exception occurred
3643             */
3644            public MDRRuleGroupInstance fetchByC_C_R(long classNameId, long classPK,
3645                    long ruleGroupId, boolean retrieveFromCache) throws SystemException {
3646                    Object[] finderArgs = new Object[] { classNameId, classPK, ruleGroupId };
3647    
3648                    Object result = null;
3649    
3650                    if (retrieveFromCache) {
3651                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_R,
3652                                            finderArgs, this);
3653                    }
3654    
3655                    if (result instanceof MDRRuleGroupInstance) {
3656                            MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)result;
3657    
3658                            if ((classNameId != mdrRuleGroupInstance.getClassNameId()) ||
3659                                            (classPK != mdrRuleGroupInstance.getClassPK()) ||
3660                                            (ruleGroupId != mdrRuleGroupInstance.getRuleGroupId())) {
3661                                    result = null;
3662                            }
3663                    }
3664    
3665                    if (result == null) {
3666                            StringBundler query = new StringBundler(4);
3667    
3668                            query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
3669    
3670                            query.append(_FINDER_COLUMN_C_C_R_CLASSNAMEID_2);
3671    
3672                            query.append(_FINDER_COLUMN_C_C_R_CLASSPK_2);
3673    
3674                            query.append(_FINDER_COLUMN_C_C_R_RULEGROUPID_2);
3675    
3676                            String sql = query.toString();
3677    
3678                            Session session = null;
3679    
3680                            try {
3681                                    session = openSession();
3682    
3683                                    Query q = session.createQuery(sql);
3684    
3685                                    QueryPos qPos = QueryPos.getInstance(q);
3686    
3687                                    qPos.add(classNameId);
3688    
3689                                    qPos.add(classPK);
3690    
3691                                    qPos.add(ruleGroupId);
3692    
3693                                    List<MDRRuleGroupInstance> list = q.list();
3694    
3695                                    result = list;
3696    
3697                                    MDRRuleGroupInstance mdrRuleGroupInstance = null;
3698    
3699                                    if (list.isEmpty()) {
3700                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
3701                                                    finderArgs, list);
3702                                    }
3703                                    else {
3704                                            mdrRuleGroupInstance = list.get(0);
3705    
3706                                            cacheResult(mdrRuleGroupInstance);
3707    
3708                                            if ((mdrRuleGroupInstance.getClassNameId() != classNameId) ||
3709                                                            (mdrRuleGroupInstance.getClassPK() != classPK) ||
3710                                                            (mdrRuleGroupInstance.getRuleGroupId() != ruleGroupId)) {
3711                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
3712                                                            finderArgs, mdrRuleGroupInstance);
3713                                            }
3714                                    }
3715    
3716                                    return mdrRuleGroupInstance;
3717                            }
3718                            catch (Exception e) {
3719                                    throw processException(e);
3720                            }
3721                            finally {
3722                                    if (result == null) {
3723                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_R,
3724                                                    finderArgs);
3725                                    }
3726    
3727                                    closeSession(session);
3728                            }
3729                    }
3730                    else {
3731                            if (result instanceof List<?>) {
3732                                    return null;
3733                            }
3734                            else {
3735                                    return (MDRRuleGroupInstance)result;
3736                            }
3737                    }
3738            }
3739    
3740            /**
3741             * Returns all the m d r rule group instances.
3742             *
3743             * @return the m d r rule group instances
3744             * @throws SystemException if a system exception occurred
3745             */
3746            public List<MDRRuleGroupInstance> findAll() throws SystemException {
3747                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3748            }
3749    
3750            /**
3751             * Returns a range of all the m d r rule group instances.
3752             *
3753             * <p>
3754             * 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.
3755             * </p>
3756             *
3757             * @param start the lower bound of the range of m d r rule group instances
3758             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
3759             * @return the range of m d r rule group instances
3760             * @throws SystemException if a system exception occurred
3761             */
3762            public List<MDRRuleGroupInstance> findAll(int start, int end)
3763                    throws SystemException {
3764                    return findAll(start, end, null);
3765            }
3766    
3767            /**
3768             * Returns an ordered range of all the m d r rule group instances.
3769             *
3770             * <p>
3771             * 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.
3772             * </p>
3773             *
3774             * @param start the lower bound of the range of m d r rule group instances
3775             * @param end the upper bound of the range of m d r rule group instances (not inclusive)
3776             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3777             * @return the ordered range of m d r rule group instances
3778             * @throws SystemException if a system exception occurred
3779             */
3780            public List<MDRRuleGroupInstance> findAll(int start, int end,
3781                    OrderByComparator orderByComparator) throws SystemException {
3782                    FinderPath finderPath = null;
3783                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
3784    
3785                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3786                                    (orderByComparator == null)) {
3787                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3788                            finderArgs = FINDER_ARGS_EMPTY;
3789                    }
3790                    else {
3791                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3792                            finderArgs = new Object[] { start, end, orderByComparator };
3793                    }
3794    
3795                    List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
3796                                    finderArgs, this);
3797    
3798                    if (list == null) {
3799                            StringBundler query = null;
3800                            String sql = null;
3801    
3802                            if (orderByComparator != null) {
3803                                    query = new StringBundler(2 +
3804                                                    (orderByComparator.getOrderByFields().length * 3));
3805    
3806                                    query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE);
3807    
3808                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3809                                            orderByComparator);
3810    
3811                                    sql = query.toString();
3812                            }
3813                            else {
3814                                    sql = _SQL_SELECT_MDRRULEGROUPINSTANCE;
3815                            }
3816    
3817                            Session session = null;
3818    
3819                            try {
3820                                    session = openSession();
3821    
3822                                    Query q = session.createQuery(sql);
3823    
3824                                    if (orderByComparator == null) {
3825                                            list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
3826                                                            getDialect(), start, end, false);
3827    
3828                                            Collections.sort(list);
3829                                    }
3830                                    else {
3831                                            list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
3832                                                            getDialect(), start, end);
3833                                    }
3834                            }
3835                            catch (Exception e) {
3836                                    throw processException(e);
3837                            }
3838                            finally {
3839                                    if (list == null) {
3840                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3841                                    }
3842                                    else {
3843                                            cacheResult(list);
3844    
3845                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3846                                    }
3847    
3848                                    closeSession(session);
3849                            }
3850                    }
3851    
3852                    return list;
3853            }
3854    
3855            /**
3856             * Removes all the m d r rule group instances where uuid = &#63; from the database.
3857             *
3858             * @param uuid the uuid
3859             * @throws SystemException if a system exception occurred
3860             */
3861            public void removeByUuid(String uuid) throws SystemException {
3862                    for (MDRRuleGroupInstance mdrRuleGroupInstance : findByUuid(uuid)) {
3863                            remove(mdrRuleGroupInstance);
3864                    }
3865            }
3866    
3867            /**
3868             * Removes the m d r rule group instance where uuid = &#63; and groupId = &#63; from the database.
3869             *
3870             * @param uuid the uuid
3871             * @param groupId the group ID
3872             * @return the m d r rule group instance that was removed
3873             * @throws SystemException if a system exception occurred
3874             */
3875            public MDRRuleGroupInstance removeByUUID_G(String uuid, long groupId)
3876                    throws NoSuchRuleGroupInstanceException, SystemException {
3877                    MDRRuleGroupInstance mdrRuleGroupInstance = findByUUID_G(uuid, groupId);
3878    
3879                    return remove(mdrRuleGroupInstance);
3880            }
3881    
3882            /**
3883             * Removes all the m d r rule group instances where groupId = &#63; from the database.
3884             *
3885             * @param groupId the group ID
3886             * @throws SystemException if a system exception occurred
3887             */
3888            public void removeByGroupId(long groupId) throws SystemException {
3889                    for (MDRRuleGroupInstance mdrRuleGroupInstance : findByGroupId(groupId)) {
3890                            remove(mdrRuleGroupInstance);
3891                    }
3892            }
3893    
3894            /**
3895             * Removes all the m d r rule group instances where ruleGroupId = &#63; from the database.
3896             *
3897             * @param ruleGroupId the rule group ID
3898             * @throws SystemException if a system exception occurred
3899             */
3900            public void removeByRuleGroupId(long ruleGroupId) throws SystemException {
3901                    for (MDRRuleGroupInstance mdrRuleGroupInstance : findByRuleGroupId(
3902                                    ruleGroupId)) {
3903                            remove(mdrRuleGroupInstance);
3904                    }
3905            }
3906    
3907            /**
3908             * Removes all the m d r rule group instances where classNameId = &#63; and classPK = &#63; from the database.
3909             *
3910             * @param classNameId the class name ID
3911             * @param classPK the class p k
3912             * @throws SystemException if a system exception occurred
3913             */
3914            public void removeByC_C(long classNameId, long classPK)
3915                    throws SystemException {
3916                    for (MDRRuleGroupInstance mdrRuleGroupInstance : findByC_C(
3917                                    classNameId, classPK)) {
3918                            remove(mdrRuleGroupInstance);
3919                    }
3920            }
3921    
3922            /**
3923             * Removes all the m d r rule group instances where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
3924             *
3925             * @param groupId the group ID
3926             * @param classNameId the class name ID
3927             * @param classPK the class p k
3928             * @throws SystemException if a system exception occurred
3929             */
3930            public void removeByG_C_C(long groupId, long classNameId, long classPK)
3931                    throws SystemException {
3932                    for (MDRRuleGroupInstance mdrRuleGroupInstance : findByG_C_C(groupId,
3933                                    classNameId, classPK)) {
3934                            remove(mdrRuleGroupInstance);
3935                    }
3936            }
3937    
3938            /**
3939             * Removes the m d r rule group instance where classNameId = &#63; and classPK = &#63; and ruleGroupId = &#63; from the database.
3940             *
3941             * @param classNameId the class name ID
3942             * @param classPK the class p k
3943             * @param ruleGroupId the rule group ID
3944             * @return the m d r rule group instance that was removed
3945             * @throws SystemException if a system exception occurred
3946             */
3947            public MDRRuleGroupInstance removeByC_C_R(long classNameId, long classPK,
3948                    long ruleGroupId)
3949                    throws NoSuchRuleGroupInstanceException, SystemException {
3950                    MDRRuleGroupInstance mdrRuleGroupInstance = findByC_C_R(classNameId,
3951                                    classPK, ruleGroupId);
3952    
3953                    return remove(mdrRuleGroupInstance);
3954            }
3955    
3956            /**
3957             * Removes all the m d r rule group instances from the database.
3958             *
3959             * @throws SystemException if a system exception occurred
3960             */
3961            public void removeAll() throws SystemException {
3962                    for (MDRRuleGroupInstance mdrRuleGroupInstance : findAll()) {
3963                            remove(mdrRuleGroupInstance);
3964                    }
3965            }
3966    
3967            /**
3968             * Returns the number of m d r rule group instances where uuid = &#63;.
3969             *
3970             * @param uuid the uuid
3971             * @return the number of matching m d r rule group instances
3972             * @throws SystemException if a system exception occurred
3973             */
3974            public int countByUuid(String uuid) throws SystemException {
3975                    Object[] finderArgs = new Object[] { uuid };
3976    
3977                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3978                                    finderArgs, this);
3979    
3980                    if (count == null) {
3981                            StringBundler query = new StringBundler(2);
3982    
3983                            query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
3984    
3985                            if (uuid == null) {
3986                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
3987                            }
3988                            else {
3989                                    if (uuid.equals(StringPool.BLANK)) {
3990                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
3991                                    }
3992                                    else {
3993                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
3994                                    }
3995                            }
3996    
3997                            String sql = query.toString();
3998    
3999                            Session session = null;
4000    
4001                            try {
4002                                    session = openSession();
4003    
4004                                    Query q = session.createQuery(sql);
4005    
4006                                    QueryPos qPos = QueryPos.getInstance(q);
4007    
4008                                    if (uuid != null) {
4009                                            qPos.add(uuid);
4010                                    }
4011    
4012                                    count = (Long)q.uniqueResult();
4013                            }
4014                            catch (Exception e) {
4015                                    throw processException(e);
4016                            }
4017                            finally {
4018                                    if (count == null) {
4019                                            count = Long.valueOf(0);
4020                                    }
4021    
4022                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4023                                            finderArgs, count);
4024    
4025                                    closeSession(session);
4026                            }
4027                    }
4028    
4029                    return count.intValue();
4030            }
4031    
4032            /**
4033             * Returns the number of m d r rule group instances where uuid = &#63; and groupId = &#63;.
4034             *
4035             * @param uuid the uuid
4036             * @param groupId the group ID
4037             * @return the number of matching m d r rule group instances
4038             * @throws SystemException if a system exception occurred
4039             */
4040            public int countByUUID_G(String uuid, long groupId)
4041                    throws SystemException {
4042                    Object[] finderArgs = new Object[] { uuid, groupId };
4043    
4044                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4045                                    finderArgs, this);
4046    
4047                    if (count == null) {
4048                            StringBundler query = new StringBundler(3);
4049    
4050                            query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4051    
4052                            if (uuid == null) {
4053                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4054                            }
4055                            else {
4056                                    if (uuid.equals(StringPool.BLANK)) {
4057                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4058                                    }
4059                                    else {
4060                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4061                                    }
4062                            }
4063    
4064                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4065    
4066                            String sql = query.toString();
4067    
4068                            Session session = null;
4069    
4070                            try {
4071                                    session = openSession();
4072    
4073                                    Query q = session.createQuery(sql);
4074    
4075                                    QueryPos qPos = QueryPos.getInstance(q);
4076    
4077                                    if (uuid != null) {
4078                                            qPos.add(uuid);
4079                                    }
4080    
4081                                    qPos.add(groupId);
4082    
4083                                    count = (Long)q.uniqueResult();
4084                            }
4085                            catch (Exception e) {
4086                                    throw processException(e);
4087                            }
4088                            finally {
4089                                    if (count == null) {
4090                                            count = Long.valueOf(0);
4091                                    }
4092    
4093                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4094                                            finderArgs, count);
4095    
4096                                    closeSession(session);
4097                            }
4098                    }
4099    
4100                    return count.intValue();
4101            }
4102    
4103            /**
4104             * Returns the number of m d r rule group instances where groupId = &#63;.
4105             *
4106             * @param groupId the group ID
4107             * @return the number of matching m d r rule group instances
4108             * @throws SystemException if a system exception occurred
4109             */
4110            public int countByGroupId(long groupId) throws SystemException {
4111                    Object[] finderArgs = new Object[] { groupId };
4112    
4113                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4114                                    finderArgs, this);
4115    
4116                    if (count == null) {
4117                            StringBundler query = new StringBundler(2);
4118    
4119                            query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4120    
4121                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4122    
4123                            String sql = query.toString();
4124    
4125                            Session session = null;
4126    
4127                            try {
4128                                    session = openSession();
4129    
4130                                    Query q = session.createQuery(sql);
4131    
4132                                    QueryPos qPos = QueryPos.getInstance(q);
4133    
4134                                    qPos.add(groupId);
4135    
4136                                    count = (Long)q.uniqueResult();
4137                            }
4138                            catch (Exception e) {
4139                                    throw processException(e);
4140                            }
4141                            finally {
4142                                    if (count == null) {
4143                                            count = Long.valueOf(0);
4144                                    }
4145    
4146                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4147                                            finderArgs, count);
4148    
4149                                    closeSession(session);
4150                            }
4151                    }
4152    
4153                    return count.intValue();
4154            }
4155    
4156            /**
4157             * Returns the number of m d r rule group instances that the user has permission to view where groupId = &#63;.
4158             *
4159             * @param groupId the group ID
4160             * @return the number of matching m d r rule group instances that the user has permission to view
4161             * @throws SystemException if a system exception occurred
4162             */
4163            public int filterCountByGroupId(long groupId) throws SystemException {
4164                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4165                            return countByGroupId(groupId);
4166                    }
4167    
4168                    StringBundler query = new StringBundler(2);
4169    
4170                    query.append(_FILTER_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4171    
4172                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4173    
4174                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4175                                    MDRRuleGroupInstance.class.getName(),
4176                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4177    
4178                    Session session = null;
4179    
4180                    try {
4181                            session = openSession();
4182    
4183                            SQLQuery q = session.createSQLQuery(sql);
4184    
4185                            q.addScalar(COUNT_COLUMN_NAME,
4186                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4187    
4188                            QueryPos qPos = QueryPos.getInstance(q);
4189    
4190                            qPos.add(groupId);
4191    
4192                            Long count = (Long)q.uniqueResult();
4193    
4194                            return count.intValue();
4195                    }
4196                    catch (Exception e) {
4197                            throw processException(e);
4198                    }
4199                    finally {
4200                            closeSession(session);
4201                    }
4202            }
4203    
4204            /**
4205             * Returns the number of m d r rule group instances where ruleGroupId = &#63;.
4206             *
4207             * @param ruleGroupId the rule group ID
4208             * @return the number of matching m d r rule group instances
4209             * @throws SystemException if a system exception occurred
4210             */
4211            public int countByRuleGroupId(long ruleGroupId) throws SystemException {
4212                    Object[] finderArgs = new Object[] { ruleGroupId };
4213    
4214                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
4215                                    finderArgs, this);
4216    
4217                    if (count == null) {
4218                            StringBundler query = new StringBundler(2);
4219    
4220                            query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4221    
4222                            query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
4223    
4224                            String sql = query.toString();
4225    
4226                            Session session = null;
4227    
4228                            try {
4229                                    session = openSession();
4230    
4231                                    Query q = session.createQuery(sql);
4232    
4233                                    QueryPos qPos = QueryPos.getInstance(q);
4234    
4235                                    qPos.add(ruleGroupId);
4236    
4237                                    count = (Long)q.uniqueResult();
4238                            }
4239                            catch (Exception e) {
4240                                    throw processException(e);
4241                            }
4242                            finally {
4243                                    if (count == null) {
4244                                            count = Long.valueOf(0);
4245                                    }
4246    
4247                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
4248                                            finderArgs, count);
4249    
4250                                    closeSession(session);
4251                            }
4252                    }
4253    
4254                    return count.intValue();
4255            }
4256    
4257            /**
4258             * Returns the number of m d r rule group instances where classNameId = &#63; and classPK = &#63;.
4259             *
4260             * @param classNameId the class name ID
4261             * @param classPK the class p k
4262             * @return the number of matching m d r rule group instances
4263             * @throws SystemException if a system exception occurred
4264             */
4265            public int countByC_C(long classNameId, long classPK)
4266                    throws SystemException {
4267                    Object[] finderArgs = new Object[] { classNameId, classPK };
4268    
4269                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
4270                                    finderArgs, this);
4271    
4272                    if (count == null) {
4273                            StringBundler query = new StringBundler(3);
4274    
4275                            query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4276    
4277                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
4278    
4279                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
4280    
4281                            String sql = query.toString();
4282    
4283                            Session session = null;
4284    
4285                            try {
4286                                    session = openSession();
4287    
4288                                    Query q = session.createQuery(sql);
4289    
4290                                    QueryPos qPos = QueryPos.getInstance(q);
4291    
4292                                    qPos.add(classNameId);
4293    
4294                                    qPos.add(classPK);
4295    
4296                                    count = (Long)q.uniqueResult();
4297                            }
4298                            catch (Exception e) {
4299                                    throw processException(e);
4300                            }
4301                            finally {
4302                                    if (count == null) {
4303                                            count = Long.valueOf(0);
4304                                    }
4305    
4306                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
4307                                            count);
4308    
4309                                    closeSession(session);
4310                            }
4311                    }
4312    
4313                    return count.intValue();
4314            }
4315    
4316            /**
4317             * Returns the number of m d r rule group instances where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
4318             *
4319             * @param groupId the group ID
4320             * @param classNameId the class name ID
4321             * @param classPK the class p k
4322             * @return the number of matching m d r rule group instances
4323             * @throws SystemException if a system exception occurred
4324             */
4325            public int countByG_C_C(long groupId, long classNameId, long classPK)
4326                    throws SystemException {
4327                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
4328    
4329                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
4330                                    finderArgs, this);
4331    
4332                    if (count == null) {
4333                            StringBundler query = new StringBundler(4);
4334    
4335                            query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4336    
4337                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
4338    
4339                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
4340    
4341                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
4342    
4343                            String sql = query.toString();
4344    
4345                            Session session = null;
4346    
4347                            try {
4348                                    session = openSession();
4349    
4350                                    Query q = session.createQuery(sql);
4351    
4352                                    QueryPos qPos = QueryPos.getInstance(q);
4353    
4354                                    qPos.add(groupId);
4355    
4356                                    qPos.add(classNameId);
4357    
4358                                    qPos.add(classPK);
4359    
4360                                    count = (Long)q.uniqueResult();
4361                            }
4362                            catch (Exception e) {
4363                                    throw processException(e);
4364                            }
4365                            finally {
4366                                    if (count == null) {
4367                                            count = Long.valueOf(0);
4368                                    }
4369    
4370                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
4371                                            finderArgs, count);
4372    
4373                                    closeSession(session);
4374                            }
4375                    }
4376    
4377                    return count.intValue();
4378            }
4379    
4380            /**
4381             * Returns the number of m d r rule group instances that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
4382             *
4383             * @param groupId the group ID
4384             * @param classNameId the class name ID
4385             * @param classPK the class p k
4386             * @return the number of matching m d r rule group instances that the user has permission to view
4387             * @throws SystemException if a system exception occurred
4388             */
4389            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
4390                    throws SystemException {
4391                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4392                            return countByG_C_C(groupId, classNameId, classPK);
4393                    }
4394    
4395                    StringBundler query = new StringBundler(4);
4396    
4397                    query.append(_FILTER_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4398    
4399                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
4400    
4401                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
4402    
4403                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
4404    
4405                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4406                                    MDRRuleGroupInstance.class.getName(),
4407                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4408    
4409                    Session session = null;
4410    
4411                    try {
4412                            session = openSession();
4413    
4414                            SQLQuery q = session.createSQLQuery(sql);
4415    
4416                            q.addScalar(COUNT_COLUMN_NAME,
4417                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4418    
4419                            QueryPos qPos = QueryPos.getInstance(q);
4420    
4421                            qPos.add(groupId);
4422    
4423                            qPos.add(classNameId);
4424    
4425                            qPos.add(classPK);
4426    
4427                            Long count = (Long)q.uniqueResult();
4428    
4429                            return count.intValue();
4430                    }
4431                    catch (Exception e) {
4432                            throw processException(e);
4433                    }
4434                    finally {
4435                            closeSession(session);
4436                    }
4437            }
4438    
4439            /**
4440             * Returns the number of m d r rule group instances where classNameId = &#63; and classPK = &#63; and ruleGroupId = &#63;.
4441             *
4442             * @param classNameId the class name ID
4443             * @param classPK the class p k
4444             * @param ruleGroupId the rule group ID
4445             * @return the number of matching m d r rule group instances
4446             * @throws SystemException if a system exception occurred
4447             */
4448            public int countByC_C_R(long classNameId, long classPK, long ruleGroupId)
4449                    throws SystemException {
4450                    Object[] finderArgs = new Object[] { classNameId, classPK, ruleGroupId };
4451    
4452                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_R,
4453                                    finderArgs, this);
4454    
4455                    if (count == null) {
4456                            StringBundler query = new StringBundler(4);
4457    
4458                            query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4459    
4460                            query.append(_FINDER_COLUMN_C_C_R_CLASSNAMEID_2);
4461    
4462                            query.append(_FINDER_COLUMN_C_C_R_CLASSPK_2);
4463    
4464                            query.append(_FINDER_COLUMN_C_C_R_RULEGROUPID_2);
4465    
4466                            String sql = query.toString();
4467    
4468                            Session session = null;
4469    
4470                            try {
4471                                    session = openSession();
4472    
4473                                    Query q = session.createQuery(sql);
4474    
4475                                    QueryPos qPos = QueryPos.getInstance(q);
4476    
4477                                    qPos.add(classNameId);
4478    
4479                                    qPos.add(classPK);
4480    
4481                                    qPos.add(ruleGroupId);
4482    
4483                                    count = (Long)q.uniqueResult();
4484                            }
4485                            catch (Exception e) {
4486                                    throw processException(e);
4487                            }
4488                            finally {
4489                                    if (count == null) {
4490                                            count = Long.valueOf(0);
4491                                    }
4492    
4493                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_R,
4494                                            finderArgs, count);
4495    
4496                                    closeSession(session);
4497                            }
4498                    }
4499    
4500                    return count.intValue();
4501            }
4502    
4503            /**
4504             * Returns the number of m d r rule group instances.
4505             *
4506             * @return the number of m d r rule group instances
4507             * @throws SystemException if a system exception occurred
4508             */
4509            public int countAll() throws SystemException {
4510                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4511                                    FINDER_ARGS_EMPTY, this);
4512    
4513                    if (count == null) {
4514                            Session session = null;
4515    
4516                            try {
4517                                    session = openSession();
4518    
4519                                    Query q = session.createQuery(_SQL_COUNT_MDRRULEGROUPINSTANCE);
4520    
4521                                    count = (Long)q.uniqueResult();
4522                            }
4523                            catch (Exception e) {
4524                                    throw processException(e);
4525                            }
4526                            finally {
4527                                    if (count == null) {
4528                                            count = Long.valueOf(0);
4529                                    }
4530    
4531                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4532                                            FINDER_ARGS_EMPTY, count);
4533    
4534                                    closeSession(session);
4535                            }
4536                    }
4537    
4538                    return count.intValue();
4539            }
4540    
4541            /**
4542             * Initializes the m d r rule group instance persistence.
4543             */
4544            public void afterPropertiesSet() {
4545                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4546                                            com.liferay.portal.util.PropsUtil.get(
4547                                                    "value.object.listener.com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance")));
4548    
4549                    if (listenerClassNames.length > 0) {
4550                            try {
4551                                    List<ModelListener<MDRRuleGroupInstance>> listenersList = new ArrayList<ModelListener<MDRRuleGroupInstance>>();
4552    
4553                                    for (String listenerClassName : listenerClassNames) {
4554                                            Class<?> clazz = getClass();
4555    
4556                                            listenersList.add((ModelListener<MDRRuleGroupInstance>)InstanceFactory.newInstance(
4557                                                            clazz.getClassLoader(), listenerClassName));
4558                                    }
4559    
4560                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4561                            }
4562                            catch (Exception e) {
4563                                    _log.error(e);
4564                            }
4565                    }
4566            }
4567    
4568            public void destroy() {
4569                    EntityCacheUtil.removeCache(MDRRuleGroupInstanceImpl.class.getName());
4570                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4571                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4572            }
4573    
4574            @BeanReference(type = MDRActionPersistence.class)
4575            protected MDRActionPersistence mdrActionPersistence;
4576            @BeanReference(type = MDRRulePersistence.class)
4577            protected MDRRulePersistence mdrRulePersistence;
4578            @BeanReference(type = MDRRuleGroupPersistence.class)
4579            protected MDRRuleGroupPersistence mdrRuleGroupPersistence;
4580            @BeanReference(type = MDRRuleGroupInstancePersistence.class)
4581            protected MDRRuleGroupInstancePersistence mdrRuleGroupInstancePersistence;
4582            @BeanReference(type = LayoutPersistence.class)
4583            protected LayoutPersistence layoutPersistence;
4584            @BeanReference(type = LayoutSetPersistence.class)
4585            protected LayoutSetPersistence layoutSetPersistence;
4586            @BeanReference(type = ResourcePersistence.class)
4587            protected ResourcePersistence resourcePersistence;
4588            @BeanReference(type = UserPersistence.class)
4589            protected UserPersistence userPersistence;
4590            private static final String _SQL_SELECT_MDRRULEGROUPINSTANCE = "SELECT mdrRuleGroupInstance FROM MDRRuleGroupInstance mdrRuleGroupInstance";
4591            private static final String _SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE = "SELECT mdrRuleGroupInstance FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
4592            private static final String _SQL_COUNT_MDRRULEGROUPINSTANCE = "SELECT COUNT(mdrRuleGroupInstance) FROM MDRRuleGroupInstance mdrRuleGroupInstance";
4593            private static final String _SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE = "SELECT COUNT(mdrRuleGroupInstance) FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
4594            private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrRuleGroupInstance.uuid IS NULL";
4595            private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrRuleGroupInstance.uuid = ?";
4596            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrRuleGroupInstance.uuid IS NULL OR mdrRuleGroupInstance.uuid = ?)";
4597            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrRuleGroupInstance.uuid IS NULL AND ";
4598            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrRuleGroupInstance.uuid = ? AND ";
4599            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrRuleGroupInstance.uuid IS NULL OR mdrRuleGroupInstance.uuid = ?) AND ";
4600            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrRuleGroupInstance.groupId = ?";
4601            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mdrRuleGroupInstance.groupId = ?";
4602            private static final String _FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2 = "mdrRuleGroupInstance.ruleGroupId = ?";
4603            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "mdrRuleGroupInstance.classNameId = ? AND ";
4604            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "mdrRuleGroupInstance.classPK = ?";
4605            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "mdrRuleGroupInstance.groupId = ? AND ";
4606            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "mdrRuleGroupInstance.classNameId = ? AND ";
4607            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "mdrRuleGroupInstance.classPK = ?";
4608            private static final String _FINDER_COLUMN_C_C_R_CLASSNAMEID_2 = "mdrRuleGroupInstance.classNameId = ? AND ";
4609            private static final String _FINDER_COLUMN_C_C_R_CLASSPK_2 = "mdrRuleGroupInstance.classPK = ? AND ";
4610            private static final String _FINDER_COLUMN_C_C_R_RULEGROUPID_2 = "mdrRuleGroupInstance.ruleGroupId = ?";
4611            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mdrRuleGroupInstance.ruleGroupInstanceId";
4612            private static final String _FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE = "SELECT DISTINCT {mdrRuleGroupInstance.*} FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
4613            private static final String _FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1 =
4614                    "SELECT {MDRRuleGroupInstance.*} FROM (SELECT DISTINCT mdrRuleGroupInstance.ruleGroupInstanceId FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
4615            private static final String _FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2 =
4616                    ") TEMP_TABLE INNER JOIN MDRRuleGroupInstance ON TEMP_TABLE.ruleGroupInstanceId = MDRRuleGroupInstance.ruleGroupInstanceId";
4617            private static final String _FILTER_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE = "SELECT COUNT(DISTINCT mdrRuleGroupInstance.ruleGroupInstanceId) AS COUNT_VALUE FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
4618            private static final String _FILTER_ENTITY_ALIAS = "mdrRuleGroupInstance";
4619            private static final String _FILTER_ENTITY_TABLE = "MDRRuleGroupInstance";
4620            private static final String _ORDER_BY_ENTITY_ALIAS = "mdrRuleGroupInstance.";
4621            private static final String _ORDER_BY_ENTITY_TABLE = "MDRRuleGroupInstance.";
4622            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRRuleGroupInstance exists with the primary key ";
4623            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRRuleGroupInstance exists with the key {";
4624            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4625            private static Log _log = LogFactoryUtil.getLog(MDRRuleGroupInstancePersistenceImpl.class);
4626            private static MDRRuleGroupInstance _nullMDRRuleGroupInstance = new MDRRuleGroupInstanceImpl() {
4627                            @Override
4628                            public Object clone() {
4629                                    return this;
4630                            }
4631    
4632                            @Override
4633                            public CacheModel<MDRRuleGroupInstance> toCacheModel() {
4634                                    return _nullMDRRuleGroupInstanceCacheModel;
4635                            }
4636                    };
4637    
4638            private static CacheModel<MDRRuleGroupInstance> _nullMDRRuleGroupInstanceCacheModel =
4639                    new CacheModel<MDRRuleGroupInstance>() {
4640                            public MDRRuleGroupInstance toEntityModel() {
4641                                    return _nullMDRRuleGroupInstance;
4642                            }
4643                    };
4644    }