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